@gracefultools/astrid-sdk 0.7.13 → 0.7.15
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/dist/bin/cli.js +102 -21
- package/dist/bin/cli.js.map +1 -1
- package/dist/executors/shared/index.d.ts +9 -0
- package/dist/executors/shared/index.d.ts.map +1 -0
- package/dist/executors/shared/index.js +21 -0
- package/dist/executors/shared/index.js.map +1 -0
- package/dist/executors/shared/tool-executor.d.ts +52 -0
- package/dist/executors/shared/tool-executor.d.ts.map +1 -0
- package/dist/executors/shared/tool-executor.js +262 -0
- package/dist/executors/shared/tool-executor.js.map +1 -0
- package/dist/executors/shared/tool-schemas.d.ts +61 -0
- package/dist/executors/shared/tool-schemas.d.ts.map +1 -0
- package/dist/executors/shared/tool-schemas.js +135 -0
- package/dist/executors/shared/tool-schemas.js.map +1 -0
- package/dist/executors/terminal-base.d.ts +100 -4
- package/dist/executors/terminal-base.d.ts.map +1 -1
- package/dist/executors/terminal-base.js +406 -0
- package/dist/executors/terminal-base.js.map +1 -1
- package/dist/executors/terminal-claude.d.ts +23 -4
- package/dist/executors/terminal-claude.d.ts.map +1 -1
- package/dist/executors/terminal-claude.js +190 -62
- package/dist/executors/terminal-claude.js.map +1 -1
- package/dist/executors/terminal-executors.test.js +190 -0
- package/dist/executors/terminal-executors.test.js.map +1 -1
- package/dist/executors/terminal-gemini.d.ts +4 -3
- package/dist/executors/terminal-gemini.d.ts.map +1 -1
- package/dist/executors/terminal-gemini.js +87 -191
- package/dist/executors/terminal-gemini.js.map +1 -1
- package/dist/executors/terminal-openai.d.ts +4 -3
- package/dist/executors/terminal-openai.d.ts.map +1 -1
- package/dist/executors/terminal-openai.js +87 -212
- package/dist/executors/terminal-openai.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Shared Tool Executor
|
|
4
|
+
*
|
|
5
|
+
* Common tool execution logic used by all AI executors.
|
|
6
|
+
* Handles file operations, bash commands, and search operations.
|
|
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.isDangerousCommand = isDangerousCommand;
|
|
43
|
+
exports.executeTool = executeTool;
|
|
44
|
+
exports.truncateOutput = truncateOutput;
|
|
45
|
+
exports.getToolNames = getToolNames;
|
|
46
|
+
const fs = __importStar(require("fs/promises"));
|
|
47
|
+
const path = __importStar(require("path"));
|
|
48
|
+
const child_process_1 = require("child_process");
|
|
49
|
+
const glob_1 = require("glob");
|
|
50
|
+
const DEFAULT_CONFIG = {
|
|
51
|
+
bashTimeout: 120000,
|
|
52
|
+
bashMaxBuffer: 1024 * 1024,
|
|
53
|
+
grepTimeout: 30000,
|
|
54
|
+
grepMaxResults: 50,
|
|
55
|
+
globMaxResults: 100,
|
|
56
|
+
maxOutputLength: 10000
|
|
57
|
+
};
|
|
58
|
+
// ============================================================================
|
|
59
|
+
// SECURITY
|
|
60
|
+
// ============================================================================
|
|
61
|
+
/**
|
|
62
|
+
* Dangerous commands that should be blocked for safety
|
|
63
|
+
*/
|
|
64
|
+
const DANGEROUS_COMMANDS = [
|
|
65
|
+
'rm -rf /',
|
|
66
|
+
'rm -rf /*',
|
|
67
|
+
'sudo',
|
|
68
|
+
'> /dev/',
|
|
69
|
+
'mkfs',
|
|
70
|
+
'dd if=',
|
|
71
|
+
':(){:|:&};:', // Fork bomb
|
|
72
|
+
'chmod -R 777 /',
|
|
73
|
+
'chown -R',
|
|
74
|
+
];
|
|
75
|
+
/**
|
|
76
|
+
* Check if a command is potentially dangerous
|
|
77
|
+
*/
|
|
78
|
+
function isDangerousCommand(command) {
|
|
79
|
+
const lowerCommand = command.toLowerCase();
|
|
80
|
+
return DANGEROUS_COMMANDS.some(d => lowerCommand.includes(d.toLowerCase()));
|
|
81
|
+
}
|
|
82
|
+
// ============================================================================
|
|
83
|
+
// TOOL EXECUTION
|
|
84
|
+
// ============================================================================
|
|
85
|
+
/**
|
|
86
|
+
* Execute a tool by name with the given arguments
|
|
87
|
+
*
|
|
88
|
+
* @param name - Tool name (read_file, write_file, etc.)
|
|
89
|
+
* @param args - Tool arguments
|
|
90
|
+
* @param repoPath - Base path for file operations
|
|
91
|
+
* @param config - Optional execution configuration
|
|
92
|
+
* @returns Tool execution result
|
|
93
|
+
*/
|
|
94
|
+
async function executeTool(name, args, repoPath, config = {}) {
|
|
95
|
+
const cfg = { ...DEFAULT_CONFIG, ...config };
|
|
96
|
+
try {
|
|
97
|
+
switch (name) {
|
|
98
|
+
case 'read_file':
|
|
99
|
+
return await executeReadFile(args, repoPath);
|
|
100
|
+
case 'write_file':
|
|
101
|
+
return await executeWriteFile(args, repoPath);
|
|
102
|
+
case 'edit_file':
|
|
103
|
+
return await executeEditFile(args, repoPath);
|
|
104
|
+
case 'run_bash':
|
|
105
|
+
return await executeRunBash(args, repoPath, cfg);
|
|
106
|
+
case 'glob_files':
|
|
107
|
+
return await executeGlobFiles(args, repoPath, cfg);
|
|
108
|
+
case 'grep_search':
|
|
109
|
+
return await executeGrepSearch(args, repoPath, cfg);
|
|
110
|
+
case 'task_complete':
|
|
111
|
+
return { success: true, result: 'Task marked complete' };
|
|
112
|
+
default:
|
|
113
|
+
return { success: false, result: `Unknown tool: ${name}` };
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
catch (error) {
|
|
117
|
+
return {
|
|
118
|
+
success: false,
|
|
119
|
+
result: `Error: ${error instanceof Error ? error.message : String(error)}`
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
// ============================================================================
|
|
124
|
+
// INDIVIDUAL TOOL IMPLEMENTATIONS
|
|
125
|
+
// ============================================================================
|
|
126
|
+
async function executeReadFile(args, repoPath) {
|
|
127
|
+
const filePath = path.join(repoPath, args.file_path);
|
|
128
|
+
const content = await fs.readFile(filePath, 'utf-8');
|
|
129
|
+
return { success: true, result: content };
|
|
130
|
+
}
|
|
131
|
+
async function executeWriteFile(args, repoPath) {
|
|
132
|
+
const filePath = path.join(repoPath, args.file_path);
|
|
133
|
+
const content = args.content;
|
|
134
|
+
// Check if file exists to determine action
|
|
135
|
+
let action = 'create';
|
|
136
|
+
try {
|
|
137
|
+
await fs.access(filePath);
|
|
138
|
+
action = 'modify';
|
|
139
|
+
}
|
|
140
|
+
catch {
|
|
141
|
+
// File doesn't exist, create parent directories
|
|
142
|
+
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
|
143
|
+
}
|
|
144
|
+
await fs.writeFile(filePath, content, 'utf-8');
|
|
145
|
+
return {
|
|
146
|
+
success: true,
|
|
147
|
+
result: `File ${action === 'create' ? 'created' : 'updated'}: ${args.file_path}`,
|
|
148
|
+
fileChange: { path: args.file_path, content, action }
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
async function executeEditFile(args, repoPath) {
|
|
152
|
+
const filePath = path.join(repoPath, args.file_path);
|
|
153
|
+
const oldContent = await fs.readFile(filePath, 'utf-8');
|
|
154
|
+
const oldString = args.old_string;
|
|
155
|
+
const newString = args.new_string;
|
|
156
|
+
if (!oldContent.includes(oldString)) {
|
|
157
|
+
return {
|
|
158
|
+
success: false,
|
|
159
|
+
result: 'Error: Could not find the specified string in file'
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
const newContent = oldContent.replace(oldString, newString);
|
|
163
|
+
await fs.writeFile(filePath, newContent, 'utf-8');
|
|
164
|
+
return {
|
|
165
|
+
success: true,
|
|
166
|
+
result: `File edited: ${args.file_path}`,
|
|
167
|
+
fileChange: { path: args.file_path, content: newContent, action: 'modify' }
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
async function executeRunBash(args, repoPath, config) {
|
|
171
|
+
const command = args.command;
|
|
172
|
+
// Security check
|
|
173
|
+
if (isDangerousCommand(command)) {
|
|
174
|
+
return {
|
|
175
|
+
success: false,
|
|
176
|
+
result: 'Error: Command blocked by safety policy'
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
try {
|
|
180
|
+
const output = (0, child_process_1.execSync)(command, {
|
|
181
|
+
cwd: repoPath,
|
|
182
|
+
encoding: 'utf-8',
|
|
183
|
+
timeout: config.bashTimeout,
|
|
184
|
+
maxBuffer: config.bashMaxBuffer
|
|
185
|
+
});
|
|
186
|
+
return {
|
|
187
|
+
success: true,
|
|
188
|
+
result: output || '(no output)'
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
catch (error) {
|
|
192
|
+
const err = error;
|
|
193
|
+
const errorOutput = err.stderr || err.stdout || err.message || 'Command failed';
|
|
194
|
+
return {
|
|
195
|
+
success: false,
|
|
196
|
+
result: `Error: ${errorOutput}`
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
async function executeGlobFiles(args, repoPath, config) {
|
|
201
|
+
const pattern = args.pattern;
|
|
202
|
+
const files = await (0, glob_1.glob)(pattern, { cwd: repoPath, nodir: true });
|
|
203
|
+
const limitedFiles = files.slice(0, config.globMaxResults);
|
|
204
|
+
const result = limitedFiles.join('\n') || '(no matches)';
|
|
205
|
+
return {
|
|
206
|
+
success: true,
|
|
207
|
+
result: files.length > config.globMaxResults
|
|
208
|
+
? `${result}\n\n[... ${files.length - config.globMaxResults} more files truncated]`
|
|
209
|
+
: result
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
async function executeGrepSearch(args, repoPath, config) {
|
|
213
|
+
const pattern = args.pattern;
|
|
214
|
+
const filePattern = args.file_pattern || '.';
|
|
215
|
+
// Escape double quotes in pattern for shell safety
|
|
216
|
+
const escapedPattern = pattern.replace(/"/g, '\\"');
|
|
217
|
+
try {
|
|
218
|
+
const output = (0, child_process_1.execSync)(`grep -rn "${escapedPattern}" ${filePattern} | head -${config.grepMaxResults}`, {
|
|
219
|
+
cwd: repoPath,
|
|
220
|
+
encoding: 'utf-8',
|
|
221
|
+
timeout: config.grepTimeout
|
|
222
|
+
});
|
|
223
|
+
return {
|
|
224
|
+
success: true,
|
|
225
|
+
result: output || '(no matches)'
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
catch {
|
|
229
|
+
// grep returns exit code 1 when no matches found
|
|
230
|
+
return {
|
|
231
|
+
success: true,
|
|
232
|
+
result: '(no matches)'
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
// ============================================================================
|
|
237
|
+
// UTILITY FUNCTIONS
|
|
238
|
+
// ============================================================================
|
|
239
|
+
/**
|
|
240
|
+
* Truncate output to maximum length
|
|
241
|
+
*/
|
|
242
|
+
function truncateOutput(output, maxLength = 10000) {
|
|
243
|
+
if (output.length <= maxLength) {
|
|
244
|
+
return output;
|
|
245
|
+
}
|
|
246
|
+
return output.slice(0, maxLength) + '\n\n[... output truncated]';
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Extract tool names from results for tracking
|
|
250
|
+
*/
|
|
251
|
+
function getToolNames() {
|
|
252
|
+
return [
|
|
253
|
+
'read_file',
|
|
254
|
+
'write_file',
|
|
255
|
+
'edit_file',
|
|
256
|
+
'run_bash',
|
|
257
|
+
'glob_files',
|
|
258
|
+
'grep_search',
|
|
259
|
+
'task_complete'
|
|
260
|
+
];
|
|
261
|
+
}
|
|
262
|
+
//# sourceMappingURL=tool-executor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-executor.js","sourceRoot":"","sources":["../../../src/executors/shared/tool-executor.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmEH,gDAGC;AAeD,kCAwCC;AAoKD,wCAKC;AAKD,oCAUC;AAnTD,gDAAiC;AACjC,2CAA4B;AAC5B,iDAAwC;AACxC,+BAA2B;AA+B3B,MAAM,cAAc,GAAkC;IACpD,WAAW,EAAE,MAAM;IACnB,aAAa,EAAE,IAAI,GAAG,IAAI;IAC1B,WAAW,EAAE,KAAK;IAClB,cAAc,EAAE,EAAE;IAClB,cAAc,EAAE,GAAG;IACnB,eAAe,EAAE,KAAK;CACvB,CAAA;AAED,+EAA+E;AAC/E,WAAW;AACX,+EAA+E;AAE/E;;GAEG;AACH,MAAM,kBAAkB,GAAG;IACzB,UAAU;IACV,WAAW;IACX,MAAM;IACN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AAClE,CAAC;AAED;;GAEG;AACH,SAAgB,YAAY;IAC1B,OAAO;QACL,WAAW;QACX,YAAY;QACZ,WAAW;QACX,UAAU;QACV,YAAY;QACZ,aAAa;QACb,eAAe;KAChB,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared Tool Schemas
|
|
3
|
+
*
|
|
4
|
+
* Common tool definitions used by all AI executors (OpenAI, Gemini).
|
|
5
|
+
* This eliminates duplication across executor implementations.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Base tool definition (generic format)
|
|
9
|
+
*/
|
|
10
|
+
export interface BaseToolSchema {
|
|
11
|
+
name: string;
|
|
12
|
+
description: string;
|
|
13
|
+
parameters: {
|
|
14
|
+
type: 'object';
|
|
15
|
+
properties: Record<string, {
|
|
16
|
+
type: string;
|
|
17
|
+
description: string;
|
|
18
|
+
}>;
|
|
19
|
+
required: string[];
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Common tools available to all executors
|
|
24
|
+
*/
|
|
25
|
+
export declare const COMMON_TOOLS: BaseToolSchema[];
|
|
26
|
+
/**
|
|
27
|
+
* OpenAI function calling format
|
|
28
|
+
*/
|
|
29
|
+
export interface OpenAITool {
|
|
30
|
+
type: 'function';
|
|
31
|
+
function: {
|
|
32
|
+
name: string;
|
|
33
|
+
description: string;
|
|
34
|
+
parameters: BaseToolSchema['parameters'];
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Convert common tools to OpenAI format
|
|
39
|
+
*/
|
|
40
|
+
export declare function toOpenAIFormat(tools?: BaseToolSchema[]): OpenAITool[];
|
|
41
|
+
/**
|
|
42
|
+
* Gemini function declaration format
|
|
43
|
+
*/
|
|
44
|
+
export interface GeminiToolDeclaration {
|
|
45
|
+
name: string;
|
|
46
|
+
description: string;
|
|
47
|
+
parameters: BaseToolSchema['parameters'];
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Convert common tools to Gemini format
|
|
51
|
+
*/
|
|
52
|
+
export declare function toGeminiFormat(tools?: BaseToolSchema[]): GeminiToolDeclaration[];
|
|
53
|
+
/**
|
|
54
|
+
* OpenAI-formatted tools (cached for performance)
|
|
55
|
+
*/
|
|
56
|
+
export declare const OPENAI_TOOLS: OpenAITool[];
|
|
57
|
+
/**
|
|
58
|
+
* Gemini-formatted tools (cached for performance)
|
|
59
|
+
*/
|
|
60
|
+
export declare const GEMINI_TOOL_DECLARATIONS: GeminiToolDeclaration[];
|
|
61
|
+
//# sourceMappingURL=tool-schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-schemas.d.ts","sourceRoot":"","sources":["../../../src/executors/shared/tool-schemas.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,UAAU,EAAE;QACV,IAAI,EAAE,QAAQ,CAAA;QACd,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,WAAW,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;QACjE,QAAQ,EAAE,MAAM,EAAE,CAAA;KACnB,CAAA;CACF;AAED;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,cAAc,EAqFxC,CAAA;AAMD;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,UAAU,CAAA;IAChB,QAAQ,EAAE;QACR,IAAI,EAAE,MAAM,CAAA;QACZ,WAAW,EAAE,MAAM,CAAA;QACnB,UAAU,EAAE,cAAc,CAAC,YAAY,CAAC,CAAA;KACzC,CAAA;CACF;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,GAAE,cAAc,EAAiB,GAAG,UAAU,EAAE,CASnF;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,UAAU,EAAE,cAAc,CAAC,YAAY,CAAC,CAAA;CACzC;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,GAAE,cAAc,EAAiB,GAAG,qBAAqB,EAAE,CAM9F;AAMD;;GAEG;AACH,eAAO,MAAM,YAAY,cAAmB,CAAA;AAE5C;;GAEG;AACH,eAAO,MAAM,wBAAwB,yBAAmB,CAAA"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Shared Tool Schemas
|
|
4
|
+
*
|
|
5
|
+
* Common tool definitions used by all AI executors (OpenAI, Gemini).
|
|
6
|
+
* This eliminates duplication across executor implementations.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.GEMINI_TOOL_DECLARATIONS = exports.OPENAI_TOOLS = exports.COMMON_TOOLS = void 0;
|
|
10
|
+
exports.toOpenAIFormat = toOpenAIFormat;
|
|
11
|
+
exports.toGeminiFormat = toGeminiFormat;
|
|
12
|
+
/**
|
|
13
|
+
* Common tools available to all executors
|
|
14
|
+
*/
|
|
15
|
+
exports.COMMON_TOOLS = [
|
|
16
|
+
{
|
|
17
|
+
name: 'read_file',
|
|
18
|
+
description: 'Read the contents of a file',
|
|
19
|
+
parameters: {
|
|
20
|
+
type: 'object',
|
|
21
|
+
properties: {
|
|
22
|
+
file_path: { type: 'string', description: 'Path to the file' }
|
|
23
|
+
},
|
|
24
|
+
required: ['file_path']
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
name: 'write_file',
|
|
29
|
+
description: 'Write content to a file (creates or overwrites)',
|
|
30
|
+
parameters: {
|
|
31
|
+
type: 'object',
|
|
32
|
+
properties: {
|
|
33
|
+
file_path: { type: 'string', description: 'Path to the file' },
|
|
34
|
+
content: { type: 'string', description: 'Content to write' }
|
|
35
|
+
},
|
|
36
|
+
required: ['file_path', 'content']
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: 'edit_file',
|
|
41
|
+
description: 'Edit a file by replacing old_string with new_string',
|
|
42
|
+
parameters: {
|
|
43
|
+
type: 'object',
|
|
44
|
+
properties: {
|
|
45
|
+
file_path: { type: 'string', description: 'Path to the file' },
|
|
46
|
+
old_string: { type: 'string', description: 'String to find' },
|
|
47
|
+
new_string: { type: 'string', description: 'Replacement string' }
|
|
48
|
+
},
|
|
49
|
+
required: ['file_path', 'old_string', 'new_string']
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
name: 'run_bash',
|
|
54
|
+
description: 'Run a bash command',
|
|
55
|
+
parameters: {
|
|
56
|
+
type: 'object',
|
|
57
|
+
properties: {
|
|
58
|
+
command: { type: 'string', description: 'The bash command' }
|
|
59
|
+
},
|
|
60
|
+
required: ['command']
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: 'glob_files',
|
|
65
|
+
description: 'Find files matching a glob pattern',
|
|
66
|
+
parameters: {
|
|
67
|
+
type: 'object',
|
|
68
|
+
properties: {
|
|
69
|
+
pattern: { type: 'string', description: 'Glob pattern' }
|
|
70
|
+
},
|
|
71
|
+
required: ['pattern']
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
name: 'grep_search',
|
|
76
|
+
description: 'Search for a pattern in files',
|
|
77
|
+
parameters: {
|
|
78
|
+
type: 'object',
|
|
79
|
+
properties: {
|
|
80
|
+
pattern: { type: 'string', description: 'Search pattern' },
|
|
81
|
+
file_pattern: { type: 'string', description: 'Optional glob pattern to filter files' }
|
|
82
|
+
},
|
|
83
|
+
required: ['pattern']
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
name: 'task_complete',
|
|
88
|
+
description: 'Signal that the task is complete',
|
|
89
|
+
parameters: {
|
|
90
|
+
type: 'object',
|
|
91
|
+
properties: {
|
|
92
|
+
summary: { type: 'string', description: 'Summary of what was done' },
|
|
93
|
+
commit_message: { type: 'string', description: 'Git commit message' },
|
|
94
|
+
pr_title: { type: 'string', description: 'PR title' },
|
|
95
|
+
pr_description: { type: 'string', description: 'PR description' }
|
|
96
|
+
},
|
|
97
|
+
required: ['summary']
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
];
|
|
101
|
+
/**
|
|
102
|
+
* Convert common tools to OpenAI format
|
|
103
|
+
*/
|
|
104
|
+
function toOpenAIFormat(tools = exports.COMMON_TOOLS) {
|
|
105
|
+
return tools.map(tool => ({
|
|
106
|
+
type: 'function',
|
|
107
|
+
function: {
|
|
108
|
+
name: tool.name,
|
|
109
|
+
description: tool.description,
|
|
110
|
+
parameters: tool.parameters
|
|
111
|
+
}
|
|
112
|
+
}));
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Convert common tools to Gemini format
|
|
116
|
+
*/
|
|
117
|
+
function toGeminiFormat(tools = exports.COMMON_TOOLS) {
|
|
118
|
+
return tools.map(tool => ({
|
|
119
|
+
name: tool.name,
|
|
120
|
+
description: tool.description,
|
|
121
|
+
parameters: tool.parameters
|
|
122
|
+
}));
|
|
123
|
+
}
|
|
124
|
+
// ============================================================================
|
|
125
|
+
// PRE-FORMATTED EXPORTS
|
|
126
|
+
// ============================================================================
|
|
127
|
+
/**
|
|
128
|
+
* OpenAI-formatted tools (cached for performance)
|
|
129
|
+
*/
|
|
130
|
+
exports.OPENAI_TOOLS = toOpenAIFormat();
|
|
131
|
+
/**
|
|
132
|
+
* Gemini-formatted tools (cached for performance)
|
|
133
|
+
*/
|
|
134
|
+
exports.GEMINI_TOOL_DECLARATIONS = toGeminiFormat();
|
|
135
|
+
//# sourceMappingURL=tool-schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-schemas.js","sourceRoot":"","sources":["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AY;IACnE,OAAO,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACxB,IAAI,EAAE,UAAmB;QACzB,QAAQ,EAAE;YACR,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,UAAU,EAAE,IAAI,CAAC,UAAU;SAC5B;KACF,CAAC,CAAC,CAAA;AACL,CAAC;AAWD;;GAEG;AACH,SAAgB,cAAc,CAAC,QAA0B,oBAAY;IACnE,OAAO,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACxB,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,UAAU,EAAE,IAAI,CAAC,UAAU;KAC5B,CAAC,CAAC,CAAA;AACL,CAAC;AAED,+EAA+E;AAC/E,wBAAwB;AACxB,+EAA+E;AAE/E;;GAEG;AACU,QAAA,YAAY,GAAG,cAAc,EAAE,CAAA;AAE5C;;GAEG;AACU,QAAA,wBAAwB,GAAG,cAAc,EAAE,CAAA"}
|
|
@@ -42,6 +42,17 @@ export interface ParsedOutput {
|
|
|
42
42
|
* Progress callback function
|
|
43
43
|
*/
|
|
44
44
|
export type TerminalProgressCallback = (message: string) => void;
|
|
45
|
+
/**
|
|
46
|
+
* Comment callback function for posting updates to the task
|
|
47
|
+
*/
|
|
48
|
+
export type TerminalCommentCallback = (content: string) => Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* Options for terminal executor callbacks
|
|
51
|
+
*/
|
|
52
|
+
export interface TerminalExecutorCallbacks {
|
|
53
|
+
onProgress?: TerminalProgressCallback;
|
|
54
|
+
onComment?: TerminalCommentCallback;
|
|
55
|
+
}
|
|
45
56
|
/**
|
|
46
57
|
* Common interface for all terminal executors.
|
|
47
58
|
*
|
|
@@ -61,20 +72,20 @@ export interface TerminalExecutor {
|
|
|
61
72
|
* @param session - The session containing task details
|
|
62
73
|
* @param prompt - Optional custom prompt (uses default if not provided)
|
|
63
74
|
* @param context - Optional context including comments and PR info
|
|
64
|
-
* @param
|
|
75
|
+
* @param callbacks - Optional callbacks for progress updates and comments
|
|
65
76
|
* @returns Execution result with output, modified files, and PR URL
|
|
66
77
|
*/
|
|
67
|
-
startSession(session: Session, prompt?: string, context?: TerminalTaskContext,
|
|
78
|
+
startSession(session: Session, prompt?: string, context?: TerminalTaskContext, callbacks?: TerminalExecutorCallbacks): Promise<TerminalExecutionResult>;
|
|
68
79
|
/**
|
|
69
80
|
* Resume an existing session with new input
|
|
70
81
|
*
|
|
71
82
|
* @param session - The session to resume
|
|
72
83
|
* @param input - New input from user (e.g., follow-up message)
|
|
73
84
|
* @param context - Optional updated context
|
|
74
|
-
* @param
|
|
85
|
+
* @param callbacks - Optional callbacks for progress updates and comments
|
|
75
86
|
* @returns Execution result
|
|
76
87
|
*/
|
|
77
|
-
resumeSession(session: Session, input: string, context?: TerminalTaskContext,
|
|
88
|
+
resumeSession(session: Session, input: string, context?: TerminalTaskContext, callbacks?: TerminalExecutorCallbacks): Promise<TerminalExecutionResult>;
|
|
78
89
|
/**
|
|
79
90
|
* Parse output to extract key information
|
|
80
91
|
*
|
|
@@ -108,4 +119,89 @@ export declare function captureGitChanges(projectPath: string, baseline?: Set<st
|
|
|
108
119
|
* Build default prompt for a task
|
|
109
120
|
*/
|
|
110
121
|
export declare function buildDefaultPrompt(session: Session, context?: TerminalTaskContext): string;
|
|
122
|
+
/**
|
|
123
|
+
* Types of content detected in Claude's output
|
|
124
|
+
*/
|
|
125
|
+
export type OutputContentType = 'plan' | 'question' | 'progress' | 'error' | 'pr_created';
|
|
126
|
+
/**
|
|
127
|
+
* Detected content from parsing output
|
|
128
|
+
*/
|
|
129
|
+
export interface DetectedContent {
|
|
130
|
+
type: OutputContentType;
|
|
131
|
+
content: string;
|
|
132
|
+
raw?: string;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Parser state for accumulating output across chunks
|
|
136
|
+
*/
|
|
137
|
+
export interface OutputParserState {
|
|
138
|
+
buffer: string;
|
|
139
|
+
lastPlanPosted: number;
|
|
140
|
+
lastProgressPosted: number;
|
|
141
|
+
lastQuestionPosted: number;
|
|
142
|
+
postedPlans: Set<string>;
|
|
143
|
+
postedQuestions: Set<string>;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Create a new parser state
|
|
147
|
+
*/
|
|
148
|
+
export declare function createParserState(): OutputParserState;
|
|
149
|
+
/**
|
|
150
|
+
* Parse a chunk of output and detect any plans, questions, or progress updates.
|
|
151
|
+
* Uses the state to track what's been posted to avoid duplicates.
|
|
152
|
+
*
|
|
153
|
+
* @param chunk - New output chunk to parse
|
|
154
|
+
* @param state - Parser state for tracking
|
|
155
|
+
* @returns Array of detected content items
|
|
156
|
+
*/
|
|
157
|
+
export declare function parseOutputChunk(chunk: string, state: OutputParserState): DetectedContent[];
|
|
158
|
+
/**
|
|
159
|
+
* Format detected content as a comment for posting
|
|
160
|
+
*/
|
|
161
|
+
export declare function formatContentAsComment(content: DetectedContent, agentName?: string): string;
|
|
162
|
+
/**
|
|
163
|
+
* Configuration for worktree isolation
|
|
164
|
+
*/
|
|
165
|
+
export interface WorktreeConfig {
|
|
166
|
+
/** Enable worktree isolation (default: true for safety) */
|
|
167
|
+
enabled: boolean;
|
|
168
|
+
/** Base directory for worktrees (default: /tmp/astrid-worktrees) */
|
|
169
|
+
baseDir: string;
|
|
170
|
+
/** Clean up worktrees after completion (default: true) */
|
|
171
|
+
autoCleanup: boolean;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Get worktree configuration from environment variables
|
|
175
|
+
*/
|
|
176
|
+
export declare function getWorktreeConfig(): WorktreeConfig;
|
|
177
|
+
/**
|
|
178
|
+
* Result from creating a worktree
|
|
179
|
+
*/
|
|
180
|
+
export interface WorktreeResult {
|
|
181
|
+
/** Path to the worktree directory */
|
|
182
|
+
worktreePath: string;
|
|
183
|
+
/** Branch name created for this worktree */
|
|
184
|
+
branchName: string;
|
|
185
|
+
/** Cleanup function to remove the worktree */
|
|
186
|
+
cleanup: () => Promise<void>;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Create an isolated git worktree for a task.
|
|
190
|
+
* This allows the agent to work on changes without affecting the main working directory.
|
|
191
|
+
*
|
|
192
|
+
* @param projectPath - Path to the main git repository
|
|
193
|
+
* @param taskId - Task ID for naming the worktree and branch
|
|
194
|
+
* @param branchPrefix - Prefix for the branch name (default: 'task/')
|
|
195
|
+
* @returns WorktreeResult with path and cleanup function
|
|
196
|
+
*/
|
|
197
|
+
export declare function createWorktree(projectPath: string, taskId: string, branchPrefix?: string): Promise<WorktreeResult>;
|
|
198
|
+
/**
|
|
199
|
+
* Check if worktree isolation should be used
|
|
200
|
+
*/
|
|
201
|
+
export declare function shouldUseWorktree(): boolean;
|
|
202
|
+
/**
|
|
203
|
+
* Push changes from worktree and create PR
|
|
204
|
+
* Returns the PR URL if successful
|
|
205
|
+
*/
|
|
206
|
+
export declare function pushWorktreeChanges(worktreePath: string, branchName: string, taskTitle: string): Promise<string | undefined>;
|
|
111
207
|
//# sourceMappingURL=terminal-base.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"terminal-base.d.ts","sourceRoot":"","sources":["../../src/executors/terminal-base.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAA;AAM3D;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAA;IACxB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED;;GAEG;AACH,MAAM,W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