@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,502 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* OpenAI Agent Executor
|
|
4
|
+
*
|
|
5
|
+
* Executes code implementation using OpenAI's function calling API.
|
|
6
|
+
* Provides similar capabilities to Claude Agent SDK but using GPT models.
|
|
7
|
+
*/
|
|
8
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
}) : (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
}));
|
|
19
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
20
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
21
|
+
}) : function(o, v) {
|
|
22
|
+
o["default"] = v;
|
|
23
|
+
});
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.planWithOpenAI = planWithOpenAI;
|
|
43
|
+
exports.executeWithOpenAI = executeWithOpenAI;
|
|
44
|
+
const fs = __importStar(require("fs/promises"));
|
|
45
|
+
const path = __importStar(require("path"));
|
|
46
|
+
const child_process_1 = require("child_process");
|
|
47
|
+
const glob_1 = require("glob");
|
|
48
|
+
const agent_config_js_1 = require("../utils/agent-config.js");
|
|
49
|
+
// ============================================================================
|
|
50
|
+
// TOOL DEFINITIONS
|
|
51
|
+
// ============================================================================
|
|
52
|
+
const TOOLS = [
|
|
53
|
+
{
|
|
54
|
+
type: 'function',
|
|
55
|
+
function: {
|
|
56
|
+
name: 'read_file',
|
|
57
|
+
description: 'Read the contents of a file',
|
|
58
|
+
parameters: {
|
|
59
|
+
type: 'object',
|
|
60
|
+
properties: {
|
|
61
|
+
file_path: { type: 'string', description: 'Path to the file relative to repository root' }
|
|
62
|
+
},
|
|
63
|
+
required: ['file_path']
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
type: 'function',
|
|
69
|
+
function: {
|
|
70
|
+
name: 'write_file',
|
|
71
|
+
description: 'Write content to a file (creates or overwrites)',
|
|
72
|
+
parameters: {
|
|
73
|
+
type: 'object',
|
|
74
|
+
properties: {
|
|
75
|
+
file_path: { type: 'string', description: 'Path to the file' },
|
|
76
|
+
content: { type: 'string', description: 'Content to write' }
|
|
77
|
+
},
|
|
78
|
+
required: ['file_path', 'content']
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
type: 'function',
|
|
84
|
+
function: {
|
|
85
|
+
name: 'edit_file',
|
|
86
|
+
description: 'Edit a file by replacing old_string with new_string',
|
|
87
|
+
parameters: {
|
|
88
|
+
type: 'object',
|
|
89
|
+
properties: {
|
|
90
|
+
file_path: { type: 'string', description: 'Path to the file' },
|
|
91
|
+
old_string: { type: 'string', description: 'String to find and replace' },
|
|
92
|
+
new_string: { type: 'string', description: 'Replacement string' }
|
|
93
|
+
},
|
|
94
|
+
required: ['file_path', 'old_string', 'new_string']
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
type: 'function',
|
|
100
|
+
function: {
|
|
101
|
+
name: 'run_bash',
|
|
102
|
+
description: 'Run a bash command in the repository',
|
|
103
|
+
parameters: {
|
|
104
|
+
type: 'object',
|
|
105
|
+
properties: {
|
|
106
|
+
command: { type: 'string', description: 'The bash command to run' }
|
|
107
|
+
},
|
|
108
|
+
required: ['command']
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
type: 'function',
|
|
114
|
+
function: {
|
|
115
|
+
name: 'glob_files',
|
|
116
|
+
description: 'Find files matching a glob pattern',
|
|
117
|
+
parameters: {
|
|
118
|
+
type: 'object',
|
|
119
|
+
properties: {
|
|
120
|
+
pattern: { type: 'string', description: 'Glob pattern (e.g., "**/*.ts")' }
|
|
121
|
+
},
|
|
122
|
+
required: ['pattern']
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
type: 'function',
|
|
128
|
+
function: {
|
|
129
|
+
name: 'grep_search',
|
|
130
|
+
description: 'Search for a pattern in files',
|
|
131
|
+
parameters: {
|
|
132
|
+
type: 'object',
|
|
133
|
+
properties: {
|
|
134
|
+
pattern: { type: 'string', description: 'Search pattern' },
|
|
135
|
+
file_pattern: { type: 'string', description: 'Optional glob pattern to limit search' }
|
|
136
|
+
},
|
|
137
|
+
required: ['pattern']
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
type: 'function',
|
|
143
|
+
function: {
|
|
144
|
+
name: 'task_complete',
|
|
145
|
+
description: 'Signal that the task is complete',
|
|
146
|
+
parameters: {
|
|
147
|
+
type: 'object',
|
|
148
|
+
properties: {
|
|
149
|
+
commit_message: { type: 'string', description: 'Git commit message' },
|
|
150
|
+
pr_title: { type: 'string', description: 'Pull request title' },
|
|
151
|
+
pr_description: { type: 'string', description: 'Pull request description' }
|
|
152
|
+
},
|
|
153
|
+
required: ['commit_message', 'pr_title', 'pr_description']
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
];
|
|
158
|
+
async function executeTool(name, args, repoPath) {
|
|
159
|
+
try {
|
|
160
|
+
switch (name) {
|
|
161
|
+
case 'read_file': {
|
|
162
|
+
const filePath = path.join(repoPath, args.file_path);
|
|
163
|
+
const content = await fs.readFile(filePath, 'utf-8');
|
|
164
|
+
return { success: true, result: content };
|
|
165
|
+
}
|
|
166
|
+
case 'write_file': {
|
|
167
|
+
const filePath = path.join(repoPath, args.file_path);
|
|
168
|
+
const content = args.content;
|
|
169
|
+
let action = 'create';
|
|
170
|
+
try {
|
|
171
|
+
await fs.access(filePath);
|
|
172
|
+
action = 'modify';
|
|
173
|
+
}
|
|
174
|
+
catch {
|
|
175
|
+
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
|
176
|
+
}
|
|
177
|
+
await fs.writeFile(filePath, content, 'utf-8');
|
|
178
|
+
return {
|
|
179
|
+
success: true,
|
|
180
|
+
result: `File ${action === 'create' ? 'created' : 'updated'}: ${args.file_path}`,
|
|
181
|
+
fileChange: { path: args.file_path, content, action }
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
case 'edit_file': {
|
|
185
|
+
const filePath = path.join(repoPath, args.file_path);
|
|
186
|
+
const oldContent = await fs.readFile(filePath, 'utf-8');
|
|
187
|
+
const oldString = args.old_string;
|
|
188
|
+
const newString = args.new_string;
|
|
189
|
+
if (!oldContent.includes(oldString)) {
|
|
190
|
+
return { success: false, result: `Error: Could not find string in file` };
|
|
191
|
+
}
|
|
192
|
+
const newContent = oldContent.replace(oldString, newString);
|
|
193
|
+
await fs.writeFile(filePath, newContent, 'utf-8');
|
|
194
|
+
return {
|
|
195
|
+
success: true,
|
|
196
|
+
result: `File edited: ${args.file_path}`,
|
|
197
|
+
fileChange: { path: args.file_path, content: newContent, action: 'modify' }
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
case 'run_bash': {
|
|
201
|
+
const command = args.command;
|
|
202
|
+
const dangerous = ['rm -rf /', 'sudo', '> /dev/', 'mkfs', 'dd if='];
|
|
203
|
+
if (dangerous.some(d => command.includes(d))) {
|
|
204
|
+
return { success: false, result: 'Error: Dangerous command blocked' };
|
|
205
|
+
}
|
|
206
|
+
try {
|
|
207
|
+
const output = (0, child_process_1.execSync)(command, {
|
|
208
|
+
cwd: repoPath,
|
|
209
|
+
encoding: 'utf-8',
|
|
210
|
+
timeout: 60000,
|
|
211
|
+
maxBuffer: 1024 * 1024
|
|
212
|
+
});
|
|
213
|
+
return { success: true, result: output || '(no output)' };
|
|
214
|
+
}
|
|
215
|
+
catch (error) {
|
|
216
|
+
const err = error;
|
|
217
|
+
return { success: false, result: `Error: ${err.stderr || err.message}` };
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
case 'glob_files': {
|
|
221
|
+
const pattern = args.pattern;
|
|
222
|
+
const files = await (0, glob_1.glob)(pattern, { cwd: repoPath, nodir: true });
|
|
223
|
+
return { success: true, result: files.slice(0, 100).join('\n') || '(no matches)' };
|
|
224
|
+
}
|
|
225
|
+
case 'grep_search': {
|
|
226
|
+
const pattern = args.pattern;
|
|
227
|
+
const filePattern = args.file_pattern || '.';
|
|
228
|
+
try {
|
|
229
|
+
const output = (0, child_process_1.execSync)(`grep -rn "${pattern.replace(/"/g, '\\"')}" ${filePattern} | head -50`, { cwd: repoPath, encoding: 'utf-8', timeout: 30000 });
|
|
230
|
+
return { success: true, result: output || '(no matches)' };
|
|
231
|
+
}
|
|
232
|
+
catch {
|
|
233
|
+
return { success: true, result: '(no matches)' };
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
case 'task_complete':
|
|
237
|
+
return { success: true, result: 'Task marked complete' };
|
|
238
|
+
default:
|
|
239
|
+
return { success: false, result: `Unknown tool: ${name}` };
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
catch (error) {
|
|
243
|
+
return { success: false, result: `Error: ${error instanceof Error ? error.message : String(error)}` };
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
async function callOpenAI(messages, apiKey, model) {
|
|
247
|
+
const response = await fetch('https://api.openai.com/v1/chat/completions', {
|
|
248
|
+
method: 'POST',
|
|
249
|
+
headers: {
|
|
250
|
+
'Content-Type': 'application/json',
|
|
251
|
+
'Authorization': `Bearer ${apiKey}`
|
|
252
|
+
},
|
|
253
|
+
body: JSON.stringify({
|
|
254
|
+
model,
|
|
255
|
+
messages,
|
|
256
|
+
tools: TOOLS,
|
|
257
|
+
tool_choice: 'auto',
|
|
258
|
+
max_tokens: 4096
|
|
259
|
+
})
|
|
260
|
+
});
|
|
261
|
+
if (!response.ok) {
|
|
262
|
+
const error = await response.text();
|
|
263
|
+
throw new Error(`OpenAI API error: ${error}`);
|
|
264
|
+
}
|
|
265
|
+
return response.json();
|
|
266
|
+
}
|
|
267
|
+
async function loadAstridMd(repoPath) {
|
|
268
|
+
try {
|
|
269
|
+
const content = await fs.readFile(path.join(repoPath, 'ASTRID.md'), 'utf-8');
|
|
270
|
+
return content.length > 8000 ? content.substring(0, 8000) + '\n\n[truncated...]' : content;
|
|
271
|
+
}
|
|
272
|
+
catch {
|
|
273
|
+
return null;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
// ============================================================================
|
|
277
|
+
// PLANNING
|
|
278
|
+
// ============================================================================
|
|
279
|
+
async function planWithOpenAI(taskTitle, taskDescription, config) {
|
|
280
|
+
const log = config.logger || (() => { });
|
|
281
|
+
const onProgress = config.onProgress || (() => { });
|
|
282
|
+
const model = config.model || agent_config_js_1.DEFAULT_MODELS.openai;
|
|
283
|
+
log('info', 'Starting OpenAI planning', { repoPath: config.repoPath, taskTitle });
|
|
284
|
+
onProgress('Initializing OpenAI for planning...');
|
|
285
|
+
const astridMd = await loadAstridMd(config.repoPath);
|
|
286
|
+
const systemPrompt = `You are an AI coding assistant analyzing a codebase to create an implementation plan.
|
|
287
|
+
|
|
288
|
+
${astridMd ? `## Project Context\n${astridMd}\n` : ''}
|
|
289
|
+
|
|
290
|
+
## Your Task
|
|
291
|
+
Analyze the codebase and create an implementation plan for: "${taskTitle}"
|
|
292
|
+
${taskDescription ? `\nDetails: ${taskDescription}` : ''}
|
|
293
|
+
|
|
294
|
+
## Instructions
|
|
295
|
+
1. Use glob_files and grep_search to explore the codebase
|
|
296
|
+
2. Use read_file to examine relevant files
|
|
297
|
+
3. Create a focused implementation plan
|
|
298
|
+
|
|
299
|
+
When ready, respond with ONLY a JSON block:
|
|
300
|
+
\`\`\`json
|
|
301
|
+
{
|
|
302
|
+
"summary": "Brief summary",
|
|
303
|
+
"approach": "High-level approach",
|
|
304
|
+
"files": [{"path": "path/to/file.ts", "purpose": "Why", "changes": "What"}],
|
|
305
|
+
"estimatedComplexity": "simple|medium|complex",
|
|
306
|
+
"considerations": ["Note 1"]
|
|
307
|
+
}
|
|
308
|
+
\`\`\`
|
|
309
|
+
|
|
310
|
+
RULES: Maximum 5 files, be SURGICAL.`;
|
|
311
|
+
const messages = [
|
|
312
|
+
{ role: 'system', content: systemPrompt },
|
|
313
|
+
{ role: 'user', content: `Please analyze the codebase and create an implementation plan for: ${taskTitle}` }
|
|
314
|
+
];
|
|
315
|
+
let totalInputTokens = 0;
|
|
316
|
+
let totalOutputTokens = 0;
|
|
317
|
+
const maxIterations = config.maxIterations || 20;
|
|
318
|
+
try {
|
|
319
|
+
for (let i = 0; i < maxIterations; i++) {
|
|
320
|
+
onProgress(`Planning iteration ${i + 1}...`);
|
|
321
|
+
const response = await callOpenAI(messages, config.apiKey, model);
|
|
322
|
+
totalInputTokens += response.usage.prompt_tokens;
|
|
323
|
+
totalOutputTokens += response.usage.completion_tokens;
|
|
324
|
+
const choice = response.choices[0];
|
|
325
|
+
const assistantMessage = choice.message;
|
|
326
|
+
messages.push({
|
|
327
|
+
role: 'assistant',
|
|
328
|
+
content: assistantMessage.content,
|
|
329
|
+
tool_calls: assistantMessage.tool_calls
|
|
330
|
+
});
|
|
331
|
+
if (assistantMessage.tool_calls && assistantMessage.tool_calls.length > 0) {
|
|
332
|
+
for (const toolCall of assistantMessage.tool_calls) {
|
|
333
|
+
const args = JSON.parse(toolCall.function.arguments);
|
|
334
|
+
onProgress(`Using tool: ${toolCall.function.name}`);
|
|
335
|
+
const result = await executeTool(toolCall.function.name, args, config.repoPath);
|
|
336
|
+
messages.push({
|
|
337
|
+
role: 'tool',
|
|
338
|
+
content: result.result.substring(0, 10000),
|
|
339
|
+
tool_call_id: toolCall.id
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
continue;
|
|
343
|
+
}
|
|
344
|
+
if (assistantMessage.content) {
|
|
345
|
+
const jsonMatch = assistantMessage.content.match(/```json\s*([\s\S]*?)\s*```/);
|
|
346
|
+
if (jsonMatch) {
|
|
347
|
+
try {
|
|
348
|
+
const plan = JSON.parse(jsonMatch[1]);
|
|
349
|
+
return {
|
|
350
|
+
success: true,
|
|
351
|
+
plan,
|
|
352
|
+
usage: {
|
|
353
|
+
inputTokens: totalInputTokens,
|
|
354
|
+
outputTokens: totalOutputTokens,
|
|
355
|
+
costUSD: (totalInputTokens * 0.0025 + totalOutputTokens * 0.01) / 1000
|
|
356
|
+
}
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
catch {
|
|
360
|
+
log('warn', 'Failed to parse plan JSON', {});
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
if (choice.finish_reason === 'stop') {
|
|
365
|
+
messages.push({ role: 'user', content: 'Please provide the implementation plan as a JSON block.' });
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
return { success: false, error: 'Max iterations reached without producing a plan' };
|
|
369
|
+
}
|
|
370
|
+
catch (error) {
|
|
371
|
+
return { success: false, error: error instanceof Error ? error.message : String(error) };
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
// ============================================================================
|
|
375
|
+
// EXECUTION
|
|
376
|
+
// ============================================================================
|
|
377
|
+
async function executeWithOpenAI(plan, taskTitle, taskDescription, config) {
|
|
378
|
+
const log = config.logger || (() => { });
|
|
379
|
+
const onProgress = config.onProgress || (() => { });
|
|
380
|
+
const model = config.model || agent_config_js_1.DEFAULT_MODELS.openai;
|
|
381
|
+
log('info', 'Starting OpenAI execution', { repoPath: config.repoPath, filesInPlan: plan.files.length });
|
|
382
|
+
onProgress('Initializing OpenAI agent...');
|
|
383
|
+
const astridMd = await loadAstridMd(config.repoPath);
|
|
384
|
+
const systemPrompt = `You are an AI coding assistant implementing changes to a codebase.
|
|
385
|
+
|
|
386
|
+
${astridMd ? `## Project Context\n${astridMd}\n` : ''}
|
|
387
|
+
|
|
388
|
+
## Task
|
|
389
|
+
Implement: "${taskTitle}"
|
|
390
|
+
${taskDescription ? `\nDetails: ${taskDescription}` : ''}
|
|
391
|
+
|
|
392
|
+
## Implementation Plan
|
|
393
|
+
${JSON.stringify(plan, null, 2)}
|
|
394
|
+
|
|
395
|
+
## Instructions
|
|
396
|
+
1. Read the files mentioned in the plan
|
|
397
|
+
2. Make the necessary changes using edit_file or write_file
|
|
398
|
+
3. Run tests if available
|
|
399
|
+
4. When done, call task_complete with commit message and PR details
|
|
400
|
+
|
|
401
|
+
## Rules
|
|
402
|
+
- Follow the implementation plan
|
|
403
|
+
- Make minimal, surgical changes
|
|
404
|
+
- Test your changes`;
|
|
405
|
+
const messages = [
|
|
406
|
+
{ role: 'system', content: systemPrompt },
|
|
407
|
+
{ role: 'user', content: 'Please implement the changes according to the plan.' }
|
|
408
|
+
];
|
|
409
|
+
const fileChanges = new Map();
|
|
410
|
+
let totalInputTokens = 0;
|
|
411
|
+
let totalOutputTokens = 0;
|
|
412
|
+
const maxIterations = config.maxIterations || 50;
|
|
413
|
+
try {
|
|
414
|
+
for (let i = 0; i < maxIterations; i++) {
|
|
415
|
+
onProgress(`Implementation iteration ${i + 1}...`);
|
|
416
|
+
const response = await callOpenAI(messages, config.apiKey, model);
|
|
417
|
+
totalInputTokens += response.usage.prompt_tokens;
|
|
418
|
+
totalOutputTokens += response.usage.completion_tokens;
|
|
419
|
+
const choice = response.choices[0];
|
|
420
|
+
const assistantMessage = choice.message;
|
|
421
|
+
messages.push({
|
|
422
|
+
role: 'assistant',
|
|
423
|
+
content: assistantMessage.content,
|
|
424
|
+
tool_calls: assistantMessage.tool_calls
|
|
425
|
+
});
|
|
426
|
+
if (assistantMessage.tool_calls && assistantMessage.tool_calls.length > 0) {
|
|
427
|
+
for (const toolCall of assistantMessage.tool_calls) {
|
|
428
|
+
const args = JSON.parse(toolCall.function.arguments);
|
|
429
|
+
const toolName = toolCall.function.name;
|
|
430
|
+
onProgress(`Using tool: ${toolName}`);
|
|
431
|
+
if (toolName === 'task_complete') {
|
|
432
|
+
const files = Array.from(fileChanges.entries()).map(([p, change]) => ({
|
|
433
|
+
path: p,
|
|
434
|
+
content: change.content,
|
|
435
|
+
action: change.action
|
|
436
|
+
}));
|
|
437
|
+
return {
|
|
438
|
+
success: true,
|
|
439
|
+
files,
|
|
440
|
+
commitMessage: args.commit_message,
|
|
441
|
+
prTitle: args.pr_title,
|
|
442
|
+
prDescription: args.pr_description,
|
|
443
|
+
usage: {
|
|
444
|
+
inputTokens: totalInputTokens,
|
|
445
|
+
outputTokens: totalOutputTokens,
|
|
446
|
+
costUSD: (totalInputTokens * 0.0025 + totalOutputTokens * 0.01) / 1000
|
|
447
|
+
}
|
|
448
|
+
};
|
|
449
|
+
}
|
|
450
|
+
const result = await executeTool(toolName, args, config.repoPath);
|
|
451
|
+
if (result.fileChange) {
|
|
452
|
+
fileChanges.set(result.fileChange.path, {
|
|
453
|
+
content: result.fileChange.content,
|
|
454
|
+
action: result.fileChange.action
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
messages.push({
|
|
458
|
+
role: 'tool',
|
|
459
|
+
content: result.result.substring(0, 10000),
|
|
460
|
+
tool_call_id: toolCall.id
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
continue;
|
|
464
|
+
}
|
|
465
|
+
if (choice.finish_reason === 'stop') {
|
|
466
|
+
messages.push({
|
|
467
|
+
role: 'user',
|
|
468
|
+
content: 'Please call task_complete to finalize the implementation.'
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
const files = Array.from(fileChanges.entries()).map(([p, change]) => ({
|
|
473
|
+
path: p,
|
|
474
|
+
content: change.content,
|
|
475
|
+
action: change.action
|
|
476
|
+
}));
|
|
477
|
+
return {
|
|
478
|
+
success: files.length > 0,
|
|
479
|
+
files,
|
|
480
|
+
commitMessage: `feat: ${taskTitle}`,
|
|
481
|
+
prTitle: `feat: ${taskTitle}`,
|
|
482
|
+
prDescription: taskDescription || taskTitle,
|
|
483
|
+
error: 'Max iterations reached',
|
|
484
|
+
usage: {
|
|
485
|
+
inputTokens: totalInputTokens,
|
|
486
|
+
outputTokens: totalOutputTokens,
|
|
487
|
+
costUSD: (totalInputTokens * 0.0025 + totalOutputTokens * 0.01) / 1000
|
|
488
|
+
}
|
|
489
|
+
};
|
|
490
|
+
}
|
|
491
|
+
catch (error) {
|
|
492
|
+
return {
|
|
493
|
+
success: false,
|
|
494
|
+
files: [],
|
|
495
|
+
commitMessage: '',
|
|
496
|
+
prTitle: '',
|
|
497
|
+
prDescription: '',
|
|
498
|
+
error: error instanceof Error ? error.message : String(error)
|
|
499
|
+
};
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
//# sourceMappingURL=openai.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai.js","sourceRoot":"","sources":["../../src/executors/openai.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsUH,wCA6GC;AAMD,8CAkJC;AAzkBD,gDAAiC;AACjC,2CAA4B;AAC5B,iDAAwC;AACxC,+BAA2B;AAQ3B,8DAAyD;AAqBzD,+EAA+E;AAC/E,mBAAmB;AACnB,+EAA+E;AAE/E,MAAM,KAAK,GAAG;IACZ;QACE,IAAI,EAAE,UAAmB;QACzB,QAAQ,EAAE;YACR,IAAI,EAAE,WAAW;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B,GAAG,IAAI,CAAC,GAAG,IAAI;aACvE;SACF,CAAA;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,EAAE;YACT,aAAa,EAAE,EAAE;YACjB,OAAO,EAAE,EAAE;YACX,aAAa,EAAE,EAAE;YACjB,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;SAC9D,CAAA;IACH,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @gracefultools/astrid-sdk
|
|
3
|
+
*
|
|
4
|
+
* AI agent SDK for automated coding tasks with Claude, OpenAI, and Gemini
|
|
5
|
+
*/
|
|
6
|
+
export type { CodeGenerationRequest, GeneratedCode, ImplementationPlan, ExecutionResult, PlanningResult, AIService, AIAgentConfig, LogLevel, Logger, ProgressCallback, AstridTask, AstridList, PreviousTaskContext, RepositoryContextCache, } from './types/index.js';
|
|
7
|
+
export { AI_AGENT_CONFIG, SUGGESTED_MODELS, DEFAULT_MODELS, getAgentConfig, getAgentService, getAgentModel, getAgentContextFile, isRegisteredAgent, getRegisteredAgentEmails, getAllAgentConfigs, } from './utils/agent-config.js';
|
|
8
|
+
export { planWithClaude, executeWithClaude, prepareRepository, type ClaudeExecutorConfig, } from './executors/claude.js';
|
|
9
|
+
export { planWithOpenAI, executeWithOpenAI, type OpenAIExecutorConfig, } from './executors/openai.js';
|
|
10
|
+
export { planWithGemini, executeWithGemini, type GeminiExecutorConfig, } from './executors/gemini.js';
|
|
11
|
+
export { AstridOAuthClient, type AstridOAuthConfig, type APIResponse, type Comment, type CreateTaskData, type UpdateTaskData, } from './adapters/astrid-oauth.js';
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,YAAY,EACV,qBAAqB,EACrB,aAAa,EACb,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,SAAS,EACT,aAAa,EACb,QAAQ,EACR,MAAM,EACN,gBAAgB,EAChB,UAAU,EACV,UAAU,EACV,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,kBAAkB,CAAA;AAGzB,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,eAAe,EACf,aAAa,EACb,mBAAmB,EACnB,iBAAiB,EACjB,wBAAwB,EACxB,kBAAkB,GACnB,MAAM,yBAAyB,CAAA;AAGhC,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,iBAAiB,EACjB,KAAK,oBAAoB,GAC1B,MAAM,uBAAuB,CAAA;AAG9B,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,KAAK,oBAAoB,GAC1B,MAAM,uBAAuB,CAAA;AAG9B,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,KAAK,oBAAoB,GAC1B,MAAM,uBAAuB,CAAA;AAG9B,OAAO,EACL,iBAAiB,EACjB,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,KAAK,cAAc,GACpB,MAAM,4BAA4B,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @gracefultools/astrid-sdk
|
|
4
|
+
*
|
|
5
|
+
* AI agent SDK for automated coding tasks with Claude, OpenAI, and Gemini
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.AstridOAuthClient = exports.executeWithGemini = exports.planWithGemini = exports.executeWithOpenAI = exports.planWithOpenAI = exports.prepareRepository = exports.executeWithClaude = exports.planWithClaude = exports.getAllAgentConfigs = exports.getRegisteredAgentEmails = exports.isRegisteredAgent = exports.getAgentContextFile = exports.getAgentModel = exports.getAgentService = exports.getAgentConfig = exports.DEFAULT_MODELS = exports.SUGGESTED_MODELS = exports.AI_AGENT_CONFIG = void 0;
|
|
9
|
+
// Agent Configuration
|
|
10
|
+
var agent_config_js_1 = require("./utils/agent-config.js");
|
|
11
|
+
Object.defineProperty(exports, "AI_AGENT_CONFIG", { enumerable: true, get: function () { return agent_config_js_1.AI_AGENT_CONFIG; } });
|
|
12
|
+
Object.defineProperty(exports, "SUGGESTED_MODELS", { enumerable: true, get: function () { return agent_config_js_1.SUGGESTED_MODELS; } });
|
|
13
|
+
Object.defineProperty(exports, "DEFAULT_MODELS", { enumerable: true, get: function () { return agent_config_js_1.DEFAULT_MODELS; } });
|
|
14
|
+
Object.defineProperty(exports, "getAgentConfig", { enumerable: true, get: function () { return agent_config_js_1.getAgentConfig; } });
|
|
15
|
+
Object.defineProperty(exports, "getAgentService", { enumerable: true, get: function () { return agent_config_js_1.getAgentService; } });
|
|
16
|
+
Object.defineProperty(exports, "getAgentModel", { enumerable: true, get: function () { return agent_config_js_1.getAgentModel; } });
|
|
17
|
+
Object.defineProperty(exports, "getAgentContextFile", { enumerable: true, get: function () { return agent_config_js_1.getAgentContextFile; } });
|
|
18
|
+
Object.defineProperty(exports, "isRegisteredAgent", { enumerable: true, get: function () { return agent_config_js_1.isRegisteredAgent; } });
|
|
19
|
+
Object.defineProperty(exports, "getRegisteredAgentEmails", { enumerable: true, get: function () { return agent_config_js_1.getRegisteredAgentEmails; } });
|
|
20
|
+
Object.defineProperty(exports, "getAllAgentConfigs", { enumerable: true, get: function () { return agent_config_js_1.getAllAgentConfigs; } });
|
|
21
|
+
// Claude Executor
|
|
22
|
+
var claude_js_1 = require("./executors/claude.js");
|
|
23
|
+
Object.defineProperty(exports, "planWithClaude", { enumerable: true, get: function () { return claude_js_1.planWithClaude; } });
|
|
24
|
+
Object.defineProperty(exports, "executeWithClaude", { enumerable: true, get: function () { return claude_js_1.executeWithClaude; } });
|
|
25
|
+
Object.defineProperty(exports, "prepareRepository", { enumerable: true, get: function () { return claude_js_1.prepareRepository; } });
|
|
26
|
+
// OpenAI Executor
|
|
27
|
+
var openai_js_1 = require("./executors/openai.js");
|
|
28
|
+
Object.defineProperty(exports, "planWithOpenAI", { enumerable: true, get: function () { return openai_js_1.planWithOpenAI; } });
|
|
29
|
+
Object.defineProperty(exports, "executeWithOpenAI", { enumerable: true, get: function () { return openai_js_1.executeWithOpenAI; } });
|
|
30
|
+
// Gemini Executor
|
|
31
|
+
var gemini_js_1 = require("./executors/gemini.js");
|
|
32
|
+
Object.defineProperty(exports, "planWithGemini", { enumerable: true, get: function () { return gemini_js_1.planWithGemini; } });
|
|
33
|
+
Object.defineProperty(exports, "executeWithGemini", { enumerable: true, get: function () { return gemini_js_1.executeWithGemini; } });
|
|
34
|
+
// Astrid OAuth Client
|
|
35
|
+
var astrid_oauth_js_1 = require("./adapters/astrid-oauth.js");
|
|
36
|
+
Object.defineProperty(exports, "AstridOAuthClient", { enumerable: true, get: function () { return astrid_oauth_js_1.AstridOAuthClient; } });
|
|
37
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAoBH,sBAAsB;AACtB,2DAWgC;AAV9B,kHAAA,eAAe,OAAA;AACf,mHAAA,gBAAgB,OAAA;AAChB,iHAAA,cAAc,OAAA;AACd,iHAAA,cAAc,OAAA;AACd,kHAAA,eAAe,OAAA;AACf,gHAAA,aAAa,OAAA;AACb,sHAAA,mBAAmB,OAAA;AACnB,oHAAA,iBAAiB,OAAA;AACjB,2HAAA,wBAAwB,OAAA;AACxB,qHAAA,kBAAkB,OAAA;AAGpB,kBAAkB;AAClB,mDAK8B;AAJ5B,2GAAA,cAAc,OAAA;AACd,8GAAA,iBAAiB,OAAA;AACjB,8GAAA,iBAAiB,OAAA;AAInB,kBAAkB;AAClB,mDAI8B;AAH5B,2GAAA,cAAc,OAAA;AACd,8GAAA,iBAAiB,OAAA;AAInB,kBAAkB;AAClB,mDAI8B;AAH5B,2GAAA,cAAc,OAAA;AACd,8GAAA,iBAAiB,OAAA;AAInB,sBAAsB;AACtB,8DAOmC;AANjC,oHAAA,iBAAiB,OAAA"}
|