@ariacode/cli 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/LICENSE +21 -0
- package/README.md +404 -0
- package/dist/actions.d.ts +271 -0
- package/dist/actions.js +1809 -0
- package/dist/actions.js.map +1 -0
- package/dist/agent.d.ts +26 -0
- package/dist/agent.js +182 -0
- package/dist/agent.js.map +1 -0
- package/dist/app.d.ts +14 -0
- package/dist/app.js +83 -0
- package/dist/app.js.map +1 -0
- package/dist/cli.d.ts +12 -0
- package/dist/cli.js +157 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +170 -0
- package/dist/config.js +291 -0
- package/dist/config.js.map +1 -0
- package/dist/context.d.ts +58 -0
- package/dist/context.js +44 -0
- package/dist/context.js.map +1 -0
- package/dist/parser.d.ts +39 -0
- package/dist/parser.js +323 -0
- package/dist/parser.js.map +1 -0
- package/dist/prompts/ask.md +20 -0
- package/dist/prompts/explore.md +38 -0
- package/dist/prompts/patch.md +27 -0
- package/dist/prompts/plan.md +41 -0
- package/dist/prompts/prompts/ask.md +20 -0
- package/dist/prompts/prompts/explore.md +38 -0
- package/dist/prompts/prompts/patch.md +27 -0
- package/dist/prompts/prompts/plan.md +41 -0
- package/dist/prompts/prompts/review.md +33 -0
- package/dist/prompts/review.md +33 -0
- package/dist/provider.d.ts +148 -0
- package/dist/provider.js +486 -0
- package/dist/provider.js.map +1 -0
- package/dist/repo.d.ts +22 -0
- package/dist/repo.js +154 -0
- package/dist/repo.js.map +1 -0
- package/dist/safety.d.ts +48 -0
- package/dist/safety.js +140 -0
- package/dist/safety.js.map +1 -0
- package/dist/storage.d.ts +133 -0
- package/dist/storage.js +300 -0
- package/dist/storage.js.map +1 -0
- package/dist/tools.d.ts +70 -0
- package/dist/tools.js +654 -0
- package/dist/tools.js.map +1 -0
- package/dist/ui.d.ts +203 -0
- package/dist/ui.js +410 -0
- package/dist/ui.js.map +1 -0
- package/package.json +73 -0
package/dist/storage.js
ADDED
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
import Database from "better-sqlite3";
|
|
2
|
+
import * as fs from "node:fs";
|
|
3
|
+
import * as path from "node:path";
|
|
4
|
+
import * as os from "node:os";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
// Schema definitions
|
|
7
|
+
export const SessionStatusSchema = z.enum([
|
|
8
|
+
"running",
|
|
9
|
+
"completed",
|
|
10
|
+
"failed",
|
|
11
|
+
"cancelled",
|
|
12
|
+
]);
|
|
13
|
+
export const MessageRoleSchema = z.enum(["user", "assistant", "system"]);
|
|
14
|
+
export const RiskLevelSchema = z.enum(["low", "medium", "high"]);
|
|
15
|
+
// Database connection manager
|
|
16
|
+
let dbInstance = null;
|
|
17
|
+
/**
|
|
18
|
+
* Get or create database connection to ~/.aria/history.db
|
|
19
|
+
* Sets file permissions to 600 (user-only read/write)
|
|
20
|
+
*/
|
|
21
|
+
export function getDatabase() {
|
|
22
|
+
if (dbInstance) {
|
|
23
|
+
return dbInstance;
|
|
24
|
+
}
|
|
25
|
+
const ariaDir = path.join(os.homedir(), ".aria");
|
|
26
|
+
const dbPath = path.join(ariaDir, "history.db");
|
|
27
|
+
// Ensure ~/.aria directory exists
|
|
28
|
+
if (!fs.existsSync(ariaDir)) {
|
|
29
|
+
fs.mkdirSync(ariaDir, { recursive: true, mode: 0o700 });
|
|
30
|
+
}
|
|
31
|
+
// Create database connection
|
|
32
|
+
dbInstance = new Database(dbPath);
|
|
33
|
+
// Set file permissions to 600 (user-only read/write)
|
|
34
|
+
try {
|
|
35
|
+
fs.chmodSync(dbPath, 0o600);
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
console.warn("Warning: Could not set database file permissions:", error);
|
|
39
|
+
}
|
|
40
|
+
// Enable foreign keys
|
|
41
|
+
dbInstance.pragma("foreign_keys = ON");
|
|
42
|
+
return dbInstance;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Close database connection
|
|
46
|
+
*/
|
|
47
|
+
export function closeDatabase() {
|
|
48
|
+
if (dbInstance) {
|
|
49
|
+
dbInstance.close();
|
|
50
|
+
dbInstance = null;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
// Ensure database is closed on process exit
|
|
54
|
+
process.on("exit", closeDatabase);
|
|
55
|
+
process.on("SIGINT", () => { closeDatabase(); process.exit(130); });
|
|
56
|
+
process.on("SIGTERM", () => { closeDatabase(); process.exit(0); });
|
|
57
|
+
// Schema versioning
|
|
58
|
+
const CURRENT_SCHEMA_VERSION = 1;
|
|
59
|
+
/**
|
|
60
|
+
* Get current schema version from database
|
|
61
|
+
* Returns 0 if schema_versions table doesn't exist
|
|
62
|
+
*/
|
|
63
|
+
export function getCurrentSchemaVersion(db) {
|
|
64
|
+
try {
|
|
65
|
+
const result = db
|
|
66
|
+
.prepare(`SELECT name FROM sqlite_master WHERE type='table' AND name='schema_versions'`)
|
|
67
|
+
.get();
|
|
68
|
+
if (!result) {
|
|
69
|
+
return 0;
|
|
70
|
+
}
|
|
71
|
+
const versionResult = db
|
|
72
|
+
.prepare(`SELECT MAX(version) as version FROM schema_versions`)
|
|
73
|
+
.get();
|
|
74
|
+
return versionResult.version ?? 0;
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
return 0;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Run database migrations sequentially
|
|
82
|
+
*/
|
|
83
|
+
export function runMigrations(db) {
|
|
84
|
+
const currentVersion = getCurrentSchemaVersion(db);
|
|
85
|
+
if (currentVersion >= CURRENT_SCHEMA_VERSION) {
|
|
86
|
+
return; // Already up to date
|
|
87
|
+
}
|
|
88
|
+
// Create schema_versions table if it doesn't exist
|
|
89
|
+
if (currentVersion === 0) {
|
|
90
|
+
db.exec(`
|
|
91
|
+
CREATE TABLE IF NOT EXISTS schema_versions (
|
|
92
|
+
version INTEGER PRIMARY KEY,
|
|
93
|
+
applied_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
|
94
|
+
)
|
|
95
|
+
`);
|
|
96
|
+
}
|
|
97
|
+
// Get all migrations that need to be applied
|
|
98
|
+
const migrationsToRun = migrations.filter((m) => m.version > currentVersion && m.version <= CURRENT_SCHEMA_VERSION);
|
|
99
|
+
// Sort by version to ensure sequential execution
|
|
100
|
+
migrationsToRun.sort((a, b) => a.version - b.version);
|
|
101
|
+
// Run each migration in a transaction
|
|
102
|
+
for (const migration of migrationsToRun) {
|
|
103
|
+
const transaction = db.transaction(() => {
|
|
104
|
+
migration.up(db);
|
|
105
|
+
db.prepare(`INSERT INTO schema_versions (version) VALUES (?)`).run(migration.version);
|
|
106
|
+
});
|
|
107
|
+
try {
|
|
108
|
+
transaction();
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
throw new Error(`Migration to version ${migration.version} failed: ${error}`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Initialize database with schema
|
|
117
|
+
*/
|
|
118
|
+
export function initializeDatabase() {
|
|
119
|
+
const db = getDatabase();
|
|
120
|
+
runMigrations(db);
|
|
121
|
+
return db;
|
|
122
|
+
}
|
|
123
|
+
// Migrations array
|
|
124
|
+
const migrations = [
|
|
125
|
+
{
|
|
126
|
+
version: 1,
|
|
127
|
+
up: (db) => {
|
|
128
|
+
// Create sessions table
|
|
129
|
+
db.exec(`
|
|
130
|
+
CREATE TABLE sessions (
|
|
131
|
+
id TEXT PRIMARY KEY,
|
|
132
|
+
command TEXT NOT NULL,
|
|
133
|
+
project_root TEXT NOT NULL,
|
|
134
|
+
provider TEXT NOT NULL,
|
|
135
|
+
model TEXT NOT NULL,
|
|
136
|
+
status TEXT NOT NULL CHECK(status IN ('running', 'completed', 'failed', 'cancelled')),
|
|
137
|
+
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
138
|
+
completed_at TIMESTAMP,
|
|
139
|
+
error TEXT
|
|
140
|
+
)
|
|
141
|
+
`);
|
|
142
|
+
// Create indexes on sessions table
|
|
143
|
+
db.exec(`
|
|
144
|
+
CREATE INDEX idx_sessions_created_at ON sessions(created_at);
|
|
145
|
+
CREATE INDEX idx_sessions_status ON sessions(status);
|
|
146
|
+
`);
|
|
147
|
+
// Create messages table
|
|
148
|
+
db.exec(`
|
|
149
|
+
CREATE TABLE messages (
|
|
150
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
151
|
+
session_id TEXT NOT NULL,
|
|
152
|
+
role TEXT NOT NULL CHECK(role IN ('user', 'assistant', 'system')),
|
|
153
|
+
content TEXT NOT NULL,
|
|
154
|
+
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
155
|
+
FOREIGN KEY (session_id) REFERENCES sessions(id) ON DELETE CASCADE
|
|
156
|
+
)
|
|
157
|
+
`);
|
|
158
|
+
// Create index on messages table
|
|
159
|
+
db.exec(`
|
|
160
|
+
CREATE INDEX idx_messages_session_id ON messages(session_id);
|
|
161
|
+
`);
|
|
162
|
+
// Create tool_executions table
|
|
163
|
+
db.exec(`
|
|
164
|
+
CREATE TABLE tool_executions (
|
|
165
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
166
|
+
session_id TEXT NOT NULL,
|
|
167
|
+
tool_name TEXT NOT NULL,
|
|
168
|
+
input TEXT NOT NULL,
|
|
169
|
+
output TEXT,
|
|
170
|
+
error TEXT,
|
|
171
|
+
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
172
|
+
FOREIGN KEY (session_id) REFERENCES sessions(id) ON DELETE CASCADE
|
|
173
|
+
)
|
|
174
|
+
`);
|
|
175
|
+
// Create index on tool_executions table
|
|
176
|
+
db.exec(`
|
|
177
|
+
CREATE INDEX idx_tool_executions_session_id ON tool_executions(session_id);
|
|
178
|
+
`);
|
|
179
|
+
// Create mutations table
|
|
180
|
+
db.exec(`
|
|
181
|
+
CREATE TABLE mutations (
|
|
182
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
183
|
+
session_id TEXT NOT NULL,
|
|
184
|
+
action TEXT NOT NULL,
|
|
185
|
+
affected_files TEXT NOT NULL,
|
|
186
|
+
risk_level TEXT NOT NULL CHECK(risk_level IN ('low', 'medium', 'high')),
|
|
187
|
+
reversible BOOLEAN NOT NULL,
|
|
188
|
+
rollback_hints TEXT,
|
|
189
|
+
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
190
|
+
FOREIGN KEY (session_id) REFERENCES sessions(id) ON DELETE CASCADE
|
|
191
|
+
)
|
|
192
|
+
`);
|
|
193
|
+
// Create index on mutations table
|
|
194
|
+
db.exec(`
|
|
195
|
+
CREATE INDEX idx_mutations_session_id ON mutations(session_id);
|
|
196
|
+
`);
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
];
|
|
200
|
+
// Session CRUD operations
|
|
201
|
+
/**
|
|
202
|
+
* Create a new session
|
|
203
|
+
*/
|
|
204
|
+
export function createSession(db, session) {
|
|
205
|
+
const stmt = db.prepare(`
|
|
206
|
+
INSERT INTO sessions (id, command, project_root, provider, model, status)
|
|
207
|
+
VALUES (?, ?, ?, ?, ?, 'running')
|
|
208
|
+
`);
|
|
209
|
+
stmt.run(session.id, session.command, session.projectRoot, session.provider, session.model);
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Update session status
|
|
213
|
+
*/
|
|
214
|
+
export function updateSessionStatus(db, sessionId, status, error) {
|
|
215
|
+
const stmt = db.prepare(`
|
|
216
|
+
UPDATE sessions
|
|
217
|
+
SET status = ?,
|
|
218
|
+
completed_at = CURRENT_TIMESTAMP,
|
|
219
|
+
error = ?
|
|
220
|
+
WHERE id = ?
|
|
221
|
+
`);
|
|
222
|
+
stmt.run(status, error ?? null, sessionId);
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Get a single session by ID
|
|
226
|
+
*/
|
|
227
|
+
export function getSession(db, sessionId) {
|
|
228
|
+
const stmt = db.prepare(`
|
|
229
|
+
SELECT id, command, project_root as projectRoot, provider, model,
|
|
230
|
+
status, created_at as createdAt, completed_at as completedAt, error
|
|
231
|
+
FROM sessions
|
|
232
|
+
WHERE id = ?
|
|
233
|
+
`);
|
|
234
|
+
return stmt.get(sessionId) ?? null;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* List sessions with pagination
|
|
238
|
+
*/
|
|
239
|
+
export function listSessions(db, options = {}) {
|
|
240
|
+
const { limit = 50, offset = 0, status } = options;
|
|
241
|
+
let query = `
|
|
242
|
+
SELECT id, command, project_root as projectRoot, provider, model,
|
|
243
|
+
status, created_at as createdAt, completed_at as completedAt, error
|
|
244
|
+
FROM sessions
|
|
245
|
+
`;
|
|
246
|
+
const params = [];
|
|
247
|
+
if (status) {
|
|
248
|
+
query += ` WHERE status = ?`;
|
|
249
|
+
params.push(status);
|
|
250
|
+
}
|
|
251
|
+
query += ` ORDER BY created_at DESC LIMIT ? OFFSET ?`;
|
|
252
|
+
params.push(limit, offset);
|
|
253
|
+
const stmt = db.prepare(query);
|
|
254
|
+
return stmt.all(...params);
|
|
255
|
+
}
|
|
256
|
+
// Logging functions
|
|
257
|
+
/**
|
|
258
|
+
* Log a message to the database
|
|
259
|
+
*/
|
|
260
|
+
export function logMessage(db, sessionId, role, content) {
|
|
261
|
+
const stmt = db.prepare(`
|
|
262
|
+
INSERT INTO messages (session_id, role, content)
|
|
263
|
+
VALUES (?, ?, ?)
|
|
264
|
+
`);
|
|
265
|
+
stmt.run(sessionId, role, content);
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Log a tool execution to the database
|
|
269
|
+
*/
|
|
270
|
+
export function logToolExecution(db, sessionId, toolName, input, result) {
|
|
271
|
+
const stmt = db.prepare(`
|
|
272
|
+
INSERT INTO tool_executions (session_id, tool_name, input, output, error)
|
|
273
|
+
VALUES (?, ?, ?, ?, ?)
|
|
274
|
+
`);
|
|
275
|
+
stmt.run(sessionId, toolName, JSON.stringify(input), result.success ? JSON.stringify(result.data) : null, result.error ?? null);
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Log a mutation to the database
|
|
279
|
+
*/
|
|
280
|
+
export function logMutation(db, sessionId, mutation) {
|
|
281
|
+
const stmt = db.prepare(`
|
|
282
|
+
INSERT INTO mutations (session_id, action, affected_files, risk_level, reversible, rollback_hints)
|
|
283
|
+
VALUES (?, ?, ?, ?, ?, ?)
|
|
284
|
+
`);
|
|
285
|
+
stmt.run(sessionId, mutation.action, JSON.stringify(mutation.affectedFiles), mutation.riskLevel, mutation.reversible ? 1 : 0, mutation.rollbackHints ? JSON.stringify(mutation.rollbackHints) : null);
|
|
286
|
+
}
|
|
287
|
+
// Session cleanup
|
|
288
|
+
/**
|
|
289
|
+
* Delete sessions older than retainDays
|
|
290
|
+
* Cascading deletes will remove associated messages, tool_executions, and mutations
|
|
291
|
+
*/
|
|
292
|
+
export function deleteOldSessions(db, retainDays) {
|
|
293
|
+
const stmt = db.prepare(`
|
|
294
|
+
DELETE FROM sessions
|
|
295
|
+
WHERE created_at < datetime('now', '-' || ? || ' days')
|
|
296
|
+
`);
|
|
297
|
+
const result = stmt.run(retainDays);
|
|
298
|
+
return result.changes;
|
|
299
|
+
}
|
|
300
|
+
//# sourceMappingURL=storage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AACtC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,qBAAqB;AACrB,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,IAAI,CAAC;IACxC,SAAS;IACT,WAAW;IACX,QAAQ;IACR,WAAW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AAC,CAAC,CAAC,IAAI,EACnD,MAAM,CAAC,KAAK,IAAI,IAAI,CACrB,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,WAAW,CACzB,EAAqB,EACrB,SAAiB,EACjB,QAMC;IAED,MAAM,IAAI,GAAG,EAAE,CAAC,OAAO,CAAC;;;GAGvB,CAAC,CAAC;IAEH,IAAI,CAAC,GAAG,CACN,SAAS,EACT,QAAQ,CAAC,MAAM,EACf,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,aAAa,CAAC,EACtC,QAAQ,CAAC,SAAS,EAClB,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAC3B,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,IAAI,CACvE,CAAC;AACJ,CAAC;AAED,kBAAkB;AAElB;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAC/B,EAAqB,EACrB,UAAkB;IAElB,MAAM,IAAI,GAAG,EAAE,CAAC,OAAO,CAAC;;;GAGvB,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IACpC,OAAO,MAAM,CAAC,OAAO,CAAC;AACxB,CAAC"}
|
package/dist/tools.d.ts
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { ExecutionContext } from "./context.js";
|
|
3
|
+
import type { Config } from "./config.js";
|
|
4
|
+
/**
|
|
5
|
+
* Tool result interface
|
|
6
|
+
* All tools must return this structure
|
|
7
|
+
*/
|
|
8
|
+
export interface ToolResult {
|
|
9
|
+
success: boolean;
|
|
10
|
+
data?: unknown;
|
|
11
|
+
error?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Tool interface
|
|
15
|
+
* Defines the contract for all tools (read-only and mutation)
|
|
16
|
+
*/
|
|
17
|
+
export interface Tool {
|
|
18
|
+
name: string;
|
|
19
|
+
description: string;
|
|
20
|
+
isMutation: boolean;
|
|
21
|
+
inputSchema: z.ZodSchema;
|
|
22
|
+
execute(input: unknown, ctx: ExecutionContext, config: Config): Promise<ToolResult>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* read_file tool
|
|
26
|
+
* Reads file content by path with safety validation
|
|
27
|
+
* Requirements: 8.1, 8.7, 8.8
|
|
28
|
+
*/
|
|
29
|
+
export declare const readFileTool: Tool;
|
|
30
|
+
/**
|
|
31
|
+
* list_directory tool
|
|
32
|
+
* Lists directory contents with optional recursion
|
|
33
|
+
* Requirements: 8.2, 8.6, 23.2, 23.3
|
|
34
|
+
*/
|
|
35
|
+
export declare const listDirectoryTool: Tool;
|
|
36
|
+
/**
|
|
37
|
+
* search_code tool
|
|
38
|
+
* Searches code using ripgrep with gitignore support
|
|
39
|
+
* Requirements: 8.3, 22.3
|
|
40
|
+
*/
|
|
41
|
+
export declare const searchCodeTool: Tool;
|
|
42
|
+
/**
|
|
43
|
+
* read_package_json tool
|
|
44
|
+
* Reads and parses package.json from project root
|
|
45
|
+
* Requirements: 8.4
|
|
46
|
+
*/
|
|
47
|
+
export declare const readPackageJsonTool: Tool;
|
|
48
|
+
/**
|
|
49
|
+
* read_prisma_schema tool
|
|
50
|
+
* Reads prisma/schema.prisma if Prisma is detected
|
|
51
|
+
* Requirements: 8.5
|
|
52
|
+
*/
|
|
53
|
+
export declare const readPrismaSchemaTool: Tool;
|
|
54
|
+
/**
|
|
55
|
+
* propose_diff tool
|
|
56
|
+
* Generates a unified diff without applying changes
|
|
57
|
+
* Requirements: 11.4, 11.5
|
|
58
|
+
*/
|
|
59
|
+
export declare const proposeDiffTool: Tool;
|
|
60
|
+
/**
|
|
61
|
+
* apply_diff tool
|
|
62
|
+
* Applies a previously proposed diff atomically
|
|
63
|
+
* Requirements: 11.10, 11.11, 11.12, 11.13
|
|
64
|
+
*/
|
|
65
|
+
export declare const applyDiffTool: Tool;
|
|
66
|
+
/**
|
|
67
|
+
* Tool registry
|
|
68
|
+
* All available tools for the agent
|
|
69
|
+
*/
|
|
70
|
+
export declare const allTools: Tool[];
|