@vibeframe/cli 0.27.0 → 0.29.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/dist/agent/adapters/index.d.ts +1 -0
- package/dist/agent/adapters/index.d.ts.map +1 -1
- package/dist/agent/adapters/index.js +5 -0
- package/dist/agent/adapters/index.js.map +1 -1
- package/dist/agent/adapters/openrouter.d.ts +16 -0
- package/dist/agent/adapters/openrouter.d.ts.map +1 -0
- package/dist/agent/adapters/openrouter.js +100 -0
- package/dist/agent/adapters/openrouter.js.map +1 -0
- package/dist/agent/types.d.ts +1 -1
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/commands/agent.d.ts.map +1 -1
- package/dist/commands/agent.js +3 -1
- package/dist/commands/agent.js.map +1 -1
- package/dist/commands/setup.js +5 -2
- package/dist/commands/setup.js.map +1 -1
- package/dist/config/schema.d.ts +2 -1
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/schema.js +2 -0
- package/dist/config/schema.js.map +1 -1
- package/dist/index.js +0 -0
- package/package.json +16 -12
- package/.turbo/turbo-build.log +0 -4
- package/.turbo/turbo-lint.log +0 -21
- package/.turbo/turbo-test.log +0 -689
- package/src/agent/adapters/claude.ts +0 -143
- package/src/agent/adapters/gemini.ts +0 -159
- package/src/agent/adapters/index.ts +0 -61
- package/src/agent/adapters/ollama.ts +0 -231
- package/src/agent/adapters/openai.ts +0 -116
- package/src/agent/adapters/xai.ts +0 -119
- package/src/agent/index.ts +0 -251
- package/src/agent/memory/index.ts +0 -151
- package/src/agent/prompts/system.ts +0 -106
- package/src/agent/tools/ai-editing.ts +0 -845
- package/src/agent/tools/ai-generation.ts +0 -1073
- package/src/agent/tools/ai-pipeline.ts +0 -1055
- package/src/agent/tools/ai.ts +0 -21
- package/src/agent/tools/batch.ts +0 -429
- package/src/agent/tools/e2e.test.ts +0 -545
- package/src/agent/tools/export.ts +0 -184
- package/src/agent/tools/filesystem.ts +0 -237
- package/src/agent/tools/index.ts +0 -150
- package/src/agent/tools/integration.test.ts +0 -775
- package/src/agent/tools/media.ts +0 -697
- package/src/agent/tools/project.ts +0 -313
- package/src/agent/tools/timeline.ts +0 -951
- package/src/agent/types.ts +0 -68
- package/src/commands/agent.ts +0 -340
- package/src/commands/ai-analyze.ts +0 -429
- package/src/commands/ai-animated-caption.ts +0 -390
- package/src/commands/ai-audio.ts +0 -941
- package/src/commands/ai-broll.ts +0 -490
- package/src/commands/ai-edit-cli.ts +0 -658
- package/src/commands/ai-edit.ts +0 -1542
- package/src/commands/ai-fill-gaps.ts +0 -566
- package/src/commands/ai-helpers.ts +0 -65
- package/src/commands/ai-highlights.ts +0 -1303
- package/src/commands/ai-image.ts +0 -761
- package/src/commands/ai-motion.ts +0 -347
- package/src/commands/ai-narrate.ts +0 -451
- package/src/commands/ai-review.ts +0 -309
- package/src/commands/ai-script-pipeline-cli.ts +0 -1710
- package/src/commands/ai-script-pipeline.ts +0 -1365
- package/src/commands/ai-suggest-edit.ts +0 -264
- package/src/commands/ai-video-fx.ts +0 -445
- package/src/commands/ai-video.ts +0 -915
- package/src/commands/ai-viral.ts +0 -595
- package/src/commands/ai-visual-fx.ts +0 -601
- package/src/commands/ai.test.ts +0 -627
- package/src/commands/ai.ts +0 -307
- package/src/commands/analyze.ts +0 -282
- package/src/commands/audio.ts +0 -644
- package/src/commands/batch.test.ts +0 -279
- package/src/commands/batch.ts +0 -440
- package/src/commands/detect.ts +0 -329
- package/src/commands/doctor.ts +0 -237
- package/src/commands/edit-cmd.ts +0 -1014
- package/src/commands/export.ts +0 -918
- package/src/commands/generate.ts +0 -2146
- package/src/commands/media.ts +0 -177
- package/src/commands/output.ts +0 -142
- package/src/commands/pipeline.ts +0 -398
- package/src/commands/project.test.ts +0 -127
- package/src/commands/project.ts +0 -149
- package/src/commands/sanitize.ts +0 -60
- package/src/commands/schema.ts +0 -130
- package/src/commands/setup.ts +0 -509
- package/src/commands/timeline.test.ts +0 -499
- package/src/commands/timeline.ts +0 -529
- package/src/commands/validate.ts +0 -77
- package/src/config/config.test.ts +0 -197
- package/src/config/index.ts +0 -125
- package/src/config/schema.ts +0 -82
- package/src/engine/index.ts +0 -2
- package/src/engine/project.test.ts +0 -702
- package/src/engine/project.ts +0 -439
- package/src/index.ts +0 -146
- package/src/utils/api-key.test.ts +0 -41
- package/src/utils/api-key.ts +0 -247
- package/src/utils/audio.ts +0 -83
- package/src/utils/exec-safe.ts +0 -75
- package/src/utils/first-run.ts +0 -52
- package/src/utils/provider-resolver.ts +0 -56
- package/src/utils/remotion.ts +0 -951
- package/src/utils/subtitle.test.ts +0 -227
- package/src/utils/subtitle.ts +0 -169
- package/src/utils/tty.ts +0 -196
- package/tsconfig.json +0 -20
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Export Tools - Export projects to video, audio, or subtitles
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { resolve, basename } from "node:path";
|
|
6
|
-
import type { ToolRegistry, ToolHandler } from "./index.js";
|
|
7
|
-
import type { ToolDefinition, ToolResult } from "../types.js";
|
|
8
|
-
import { runExport } from "../../commands/export.js";
|
|
9
|
-
|
|
10
|
-
// Tool Definitions
|
|
11
|
-
const exportVideoDef: ToolDefinition = {
|
|
12
|
-
name: "export_video",
|
|
13
|
-
description: "Export a project to a video file",
|
|
14
|
-
parameters: {
|
|
15
|
-
type: "object",
|
|
16
|
-
properties: {
|
|
17
|
-
project: {
|
|
18
|
-
type: "string",
|
|
19
|
-
description: "Project file path",
|
|
20
|
-
},
|
|
21
|
-
output: {
|
|
22
|
-
type: "string",
|
|
23
|
-
description: "Output video file path",
|
|
24
|
-
},
|
|
25
|
-
format: {
|
|
26
|
-
type: "string",
|
|
27
|
-
description: "Output format (mp4, webm, mov)",
|
|
28
|
-
enum: ["mp4", "webm", "mov"],
|
|
29
|
-
},
|
|
30
|
-
preset: {
|
|
31
|
-
type: "string",
|
|
32
|
-
description: "Quality preset (draft, standard, high, ultra)",
|
|
33
|
-
enum: ["draft", "standard", "high", "ultra"],
|
|
34
|
-
},
|
|
35
|
-
overwrite: {
|
|
36
|
-
type: "boolean",
|
|
37
|
-
description: "Overwrite existing file",
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
required: ["project"],
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const exportAudioDef: ToolDefinition = {
|
|
45
|
-
name: "export_audio",
|
|
46
|
-
description: "Export audio track from a project",
|
|
47
|
-
parameters: {
|
|
48
|
-
type: "object",
|
|
49
|
-
properties: {
|
|
50
|
-
project: {
|
|
51
|
-
type: "string",
|
|
52
|
-
description: "Project file path",
|
|
53
|
-
},
|
|
54
|
-
output: {
|
|
55
|
-
type: "string",
|
|
56
|
-
description: "Output audio file path",
|
|
57
|
-
},
|
|
58
|
-
format: {
|
|
59
|
-
type: "string",
|
|
60
|
-
description: "Output format (mp3, wav, aac)",
|
|
61
|
-
enum: ["mp3", "wav", "aac"],
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
required: ["project"],
|
|
65
|
-
},
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
const exportSubtitlesDef: ToolDefinition = {
|
|
69
|
-
name: "export_subtitles",
|
|
70
|
-
description: "Export subtitles from transcription",
|
|
71
|
-
parameters: {
|
|
72
|
-
type: "object",
|
|
73
|
-
properties: {
|
|
74
|
-
project: {
|
|
75
|
-
type: "string",
|
|
76
|
-
description: "Project file path",
|
|
77
|
-
},
|
|
78
|
-
output: {
|
|
79
|
-
type: "string",
|
|
80
|
-
description: "Output subtitle file path",
|
|
81
|
-
},
|
|
82
|
-
format: {
|
|
83
|
-
type: "string",
|
|
84
|
-
description: "Subtitle format (srt, vtt)",
|
|
85
|
-
enum: ["srt", "vtt"],
|
|
86
|
-
},
|
|
87
|
-
},
|
|
88
|
-
required: ["project"],
|
|
89
|
-
},
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
// Tool Handlers
|
|
93
|
-
const exportVideo: ToolHandler = async (args, context): Promise<ToolResult> => {
|
|
94
|
-
const projectPath = args.project as string;
|
|
95
|
-
const format = (args.format as string) || "mp4";
|
|
96
|
-
const preset = (args.preset as "draft" | "standard" | "high" | "ultra") || "standard";
|
|
97
|
-
const overwrite = (args.overwrite as boolean) || false;
|
|
98
|
-
|
|
99
|
-
// Determine output path
|
|
100
|
-
const output = (args.output as string) ||
|
|
101
|
-
`${basename(projectPath, ".vibe.json")}.${format}`;
|
|
102
|
-
|
|
103
|
-
const absProjectPath = resolve(context.workingDirectory, projectPath);
|
|
104
|
-
const absOutputPath = resolve(context.workingDirectory, output);
|
|
105
|
-
|
|
106
|
-
try {
|
|
107
|
-
const result = await runExport(absProjectPath, absOutputPath, {
|
|
108
|
-
format: format as "mp4" | "webm" | "mov",
|
|
109
|
-
preset,
|
|
110
|
-
overwrite,
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
if (!result.success) {
|
|
114
|
-
return {
|
|
115
|
-
toolCallId: "",
|
|
116
|
-
success: false,
|
|
117
|
-
output: "",
|
|
118
|
-
error: result.message,
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
return {
|
|
123
|
-
toolCallId: "",
|
|
124
|
-
success: true,
|
|
125
|
-
output: `Video exported: ${output}\nFormat: ${format}\nPreset: ${preset}`,
|
|
126
|
-
};
|
|
127
|
-
} catch (error) {
|
|
128
|
-
return {
|
|
129
|
-
toolCallId: "",
|
|
130
|
-
success: false,
|
|
131
|
-
output: "",
|
|
132
|
-
error: `Failed to export video: ${error instanceof Error ? error.message : String(error)}`,
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
const exportAudio: ToolHandler = async (_args, _context): Promise<ToolResult> => {
|
|
138
|
-
|
|
139
|
-
try {
|
|
140
|
-
// Audio export would be implemented similarly to video export
|
|
141
|
-
// For now, provide a helpful message
|
|
142
|
-
return {
|
|
143
|
-
toolCallId: "",
|
|
144
|
-
success: false,
|
|
145
|
-
output: "",
|
|
146
|
-
error: "Audio-only export not yet implemented. Use export_video and extract audio with FFmpeg: ffmpeg -i video.mp4 -vn -acodec mp3 audio.mp3",
|
|
147
|
-
};
|
|
148
|
-
} catch (error) {
|
|
149
|
-
return {
|
|
150
|
-
toolCallId: "",
|
|
151
|
-
success: false,
|
|
152
|
-
output: "",
|
|
153
|
-
error: `Failed to export audio: ${error instanceof Error ? error.message : String(error)}`,
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
const exportSubtitles: ToolHandler = async (_args, _context): Promise<ToolResult> => {
|
|
159
|
-
|
|
160
|
-
try {
|
|
161
|
-
// Subtitle export would extract transcription data from project
|
|
162
|
-
// For now, provide a helpful message
|
|
163
|
-
return {
|
|
164
|
-
toolCallId: "",
|
|
165
|
-
success: false,
|
|
166
|
-
output: "",
|
|
167
|
-
error: "Subtitle export not yet implemented. Use ai_transcribe to generate subtitles from audio: ai_transcribe audio.mp3 --output subtitles.srt",
|
|
168
|
-
};
|
|
169
|
-
} catch (error) {
|
|
170
|
-
return {
|
|
171
|
-
toolCallId: "",
|
|
172
|
-
success: false,
|
|
173
|
-
output: "",
|
|
174
|
-
error: `Failed to export subtitles: ${error instanceof Error ? error.message : String(error)}`,
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
// Registration function
|
|
180
|
-
export function registerExportTools(registry: ToolRegistry): void {
|
|
181
|
-
registry.register(exportVideoDef, exportVideo);
|
|
182
|
-
registry.register(exportAudioDef, exportAudio);
|
|
183
|
-
registry.register(exportSubtitlesDef, exportSubtitles);
|
|
184
|
-
}
|
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Filesystem Tools - List, read, write, and check files
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { readFile, writeFile, readdir, stat, access } from "node:fs/promises";
|
|
6
|
-
import { resolve, join } from "node:path";
|
|
7
|
-
import type { ToolRegistry, ToolHandler } from "./index.js";
|
|
8
|
-
import type { ToolDefinition, ToolResult } from "../types.js";
|
|
9
|
-
|
|
10
|
-
// Tool Definitions
|
|
11
|
-
const listDef: ToolDefinition = {
|
|
12
|
-
name: "fs_list",
|
|
13
|
-
description: "List files and directories in a path",
|
|
14
|
-
parameters: {
|
|
15
|
-
type: "object",
|
|
16
|
-
properties: {
|
|
17
|
-
path: {
|
|
18
|
-
type: "string",
|
|
19
|
-
description: "Directory path (default: current directory)",
|
|
20
|
-
},
|
|
21
|
-
pattern: {
|
|
22
|
-
type: "string",
|
|
23
|
-
description: "Filter pattern (e.g., *.mp4, *.json)",
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
required: [],
|
|
27
|
-
},
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const readDef: ToolDefinition = {
|
|
31
|
-
name: "fs_read",
|
|
32
|
-
description: "Read contents of a text file",
|
|
33
|
-
parameters: {
|
|
34
|
-
type: "object",
|
|
35
|
-
properties: {
|
|
36
|
-
path: {
|
|
37
|
-
type: "string",
|
|
38
|
-
description: "File path to read",
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
required: ["path"],
|
|
42
|
-
},
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
const writeDef: ToolDefinition = {
|
|
46
|
-
name: "fs_write",
|
|
47
|
-
description: "Write content to a file",
|
|
48
|
-
parameters: {
|
|
49
|
-
type: "object",
|
|
50
|
-
properties: {
|
|
51
|
-
path: {
|
|
52
|
-
type: "string",
|
|
53
|
-
description: "File path to write",
|
|
54
|
-
},
|
|
55
|
-
content: {
|
|
56
|
-
type: "string",
|
|
57
|
-
description: "Content to write",
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
required: ["path", "content"],
|
|
61
|
-
},
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
const existsDef: ToolDefinition = {
|
|
65
|
-
name: "fs_exists",
|
|
66
|
-
description: "Check if a file or directory exists",
|
|
67
|
-
parameters: {
|
|
68
|
-
type: "object",
|
|
69
|
-
properties: {
|
|
70
|
-
path: {
|
|
71
|
-
type: "string",
|
|
72
|
-
description: "Path to check",
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
required: ["path"],
|
|
76
|
-
},
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
// Helper to match glob pattern
|
|
80
|
-
function matchPattern(filename: string, pattern: string): boolean {
|
|
81
|
-
// Simple glob matching (* = any characters)
|
|
82
|
-
const regex = new RegExp(
|
|
83
|
-
"^" +
|
|
84
|
-
pattern
|
|
85
|
-
.replace(/\./g, "\\.")
|
|
86
|
-
.replace(/\*/g, ".*")
|
|
87
|
-
.replace(/\?/g, ".") +
|
|
88
|
-
"$",
|
|
89
|
-
"i"
|
|
90
|
-
);
|
|
91
|
-
return regex.test(filename);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
// Format file size
|
|
95
|
-
function formatSize(bytes: number): string {
|
|
96
|
-
const units = ["B", "KB", "MB", "GB"];
|
|
97
|
-
let size = bytes;
|
|
98
|
-
let unit = 0;
|
|
99
|
-
while (size >= 1024 && unit < units.length - 1) {
|
|
100
|
-
size /= 1024;
|
|
101
|
-
unit++;
|
|
102
|
-
}
|
|
103
|
-
return `${size.toFixed(1)}${units[unit]}`;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// Tool Handlers
|
|
107
|
-
const list: ToolHandler = async (args, context): Promise<ToolResult> => {
|
|
108
|
-
const dirPath = (args.path as string) || ".";
|
|
109
|
-
const pattern = args.pattern as string | undefined;
|
|
110
|
-
|
|
111
|
-
try {
|
|
112
|
-
const absPath = resolve(context.workingDirectory, dirPath);
|
|
113
|
-
const entries = await readdir(absPath, { withFileTypes: true });
|
|
114
|
-
|
|
115
|
-
const results: string[] = [];
|
|
116
|
-
for (const entry of entries) {
|
|
117
|
-
// Filter by pattern if provided
|
|
118
|
-
if (pattern && !matchPattern(entry.name, pattern)) {
|
|
119
|
-
continue;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
const fullPath = join(absPath, entry.name);
|
|
123
|
-
const stats = await stat(fullPath);
|
|
124
|
-
|
|
125
|
-
if (entry.isDirectory()) {
|
|
126
|
-
results.push(`[DIR] ${entry.name}/`);
|
|
127
|
-
} else {
|
|
128
|
-
results.push(`[FILE] ${entry.name} (${formatSize(stats.size)})`);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
if (results.length === 0) {
|
|
133
|
-
return {
|
|
134
|
-
toolCallId: "",
|
|
135
|
-
success: true,
|
|
136
|
-
output: pattern ? `No files matching "${pattern}" in ${dirPath}` : `Directory is empty: ${dirPath}`,
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
return {
|
|
141
|
-
toolCallId: "",
|
|
142
|
-
success: true,
|
|
143
|
-
output: `Contents of ${dirPath}:\n${results.join("\n")}`,
|
|
144
|
-
};
|
|
145
|
-
} catch (error) {
|
|
146
|
-
return {
|
|
147
|
-
toolCallId: "",
|
|
148
|
-
success: false,
|
|
149
|
-
output: "",
|
|
150
|
-
error: `Failed to list directory: ${error instanceof Error ? error.message : String(error)}`,
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
const read: ToolHandler = async (args, context): Promise<ToolResult> => {
|
|
156
|
-
const filePath = args.path as string;
|
|
157
|
-
|
|
158
|
-
try {
|
|
159
|
-
const absPath = resolve(context.workingDirectory, filePath);
|
|
160
|
-
const content = await readFile(absPath, "utf-8");
|
|
161
|
-
|
|
162
|
-
// Truncate if too long
|
|
163
|
-
const maxLength = 4000;
|
|
164
|
-
const truncated = content.length > maxLength;
|
|
165
|
-
const output = truncated
|
|
166
|
-
? content.substring(0, maxLength) + "\n... (truncated)"
|
|
167
|
-
: content;
|
|
168
|
-
|
|
169
|
-
return {
|
|
170
|
-
toolCallId: "",
|
|
171
|
-
success: true,
|
|
172
|
-
output: `Contents of ${filePath}:\n${output}`,
|
|
173
|
-
};
|
|
174
|
-
} catch (error) {
|
|
175
|
-
return {
|
|
176
|
-
toolCallId: "",
|
|
177
|
-
success: false,
|
|
178
|
-
output: "",
|
|
179
|
-
error: `Failed to read file: ${error instanceof Error ? error.message : String(error)}`,
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
const write: ToolHandler = async (args, context): Promise<ToolResult> => {
|
|
185
|
-
const filePath = args.path as string;
|
|
186
|
-
const content = args.content as string;
|
|
187
|
-
|
|
188
|
-
try {
|
|
189
|
-
const absPath = resolve(context.workingDirectory, filePath);
|
|
190
|
-
await writeFile(absPath, content, "utf-8");
|
|
191
|
-
|
|
192
|
-
return {
|
|
193
|
-
toolCallId: "",
|
|
194
|
-
success: true,
|
|
195
|
-
output: `File written: ${filePath} (${formatSize(content.length)})`,
|
|
196
|
-
};
|
|
197
|
-
} catch (error) {
|
|
198
|
-
return {
|
|
199
|
-
toolCallId: "",
|
|
200
|
-
success: false,
|
|
201
|
-
output: "",
|
|
202
|
-
error: `Failed to write file: ${error instanceof Error ? error.message : String(error)}`,
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
};
|
|
206
|
-
|
|
207
|
-
const exists: ToolHandler = async (args, context): Promise<ToolResult> => {
|
|
208
|
-
const filePath = args.path as string;
|
|
209
|
-
|
|
210
|
-
try {
|
|
211
|
-
const absPath = resolve(context.workingDirectory, filePath);
|
|
212
|
-
await access(absPath);
|
|
213
|
-
|
|
214
|
-
const stats = await stat(absPath);
|
|
215
|
-
const type = stats.isDirectory() ? "directory" : "file";
|
|
216
|
-
|
|
217
|
-
return {
|
|
218
|
-
toolCallId: "",
|
|
219
|
-
success: true,
|
|
220
|
-
output: `${type} exists: ${filePath}`,
|
|
221
|
-
};
|
|
222
|
-
} catch {
|
|
223
|
-
return {
|
|
224
|
-
toolCallId: "",
|
|
225
|
-
success: true,
|
|
226
|
-
output: `Does not exist: ${filePath}`,
|
|
227
|
-
};
|
|
228
|
-
}
|
|
229
|
-
};
|
|
230
|
-
|
|
231
|
-
// Registration function
|
|
232
|
-
export function registerFilesystemTools(registry: ToolRegistry): void {
|
|
233
|
-
registry.register(listDef, list);
|
|
234
|
-
registry.register(readDef, read);
|
|
235
|
-
registry.register(writeDef, write);
|
|
236
|
-
registry.register(existsDef, exists);
|
|
237
|
-
}
|
package/src/agent/tools/index.ts
DELETED
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tool Registry - Central registry for all agent tools
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import type { ToolDefinition, ToolResult, AgentContext } from "../types.js";
|
|
6
|
-
|
|
7
|
-
export type ToolHandler = (
|
|
8
|
-
args: Record<string, unknown>,
|
|
9
|
-
context: AgentContext
|
|
10
|
-
) => Promise<ToolResult>;
|
|
11
|
-
|
|
12
|
-
interface RegisteredTool {
|
|
13
|
-
definition: ToolDefinition;
|
|
14
|
-
handler: ToolHandler;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Tool Registry class
|
|
19
|
-
* Manages tool definitions and execution
|
|
20
|
-
*/
|
|
21
|
-
export class ToolRegistry {
|
|
22
|
-
private tools: Map<string, RegisteredTool> = new Map();
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Register a tool
|
|
26
|
-
*/
|
|
27
|
-
register(definition: ToolDefinition, handler: ToolHandler): void {
|
|
28
|
-
this.tools.set(definition.name, { definition, handler });
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Get all tool definitions
|
|
33
|
-
*/
|
|
34
|
-
getDefinitions(): ToolDefinition[] {
|
|
35
|
-
return Array.from(this.tools.values()).map((t) => t.definition);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Get a specific tool definition
|
|
40
|
-
*/
|
|
41
|
-
getDefinition(name: string): ToolDefinition | undefined {
|
|
42
|
-
return this.tools.get(name)?.definition;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Get a specific tool definition (alias for getDefinition)
|
|
47
|
-
*/
|
|
48
|
-
get(name: string): ToolDefinition | undefined {
|
|
49
|
-
return this.getDefinition(name);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Get all tool definitions (alias for getDefinitions)
|
|
54
|
-
*/
|
|
55
|
-
getAll(): ToolDefinition[] {
|
|
56
|
-
return this.getDefinitions();
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Get a tool handler by name
|
|
61
|
-
*/
|
|
62
|
-
getHandler(name: string): ToolHandler | undefined {
|
|
63
|
-
return this.tools.get(name)?.handler;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Execute a tool
|
|
68
|
-
*/
|
|
69
|
-
async execute(
|
|
70
|
-
name: string,
|
|
71
|
-
args: Record<string, unknown>,
|
|
72
|
-
context: AgentContext
|
|
73
|
-
): Promise<ToolResult> {
|
|
74
|
-
const tool = this.tools.get(name);
|
|
75
|
-
if (!tool) {
|
|
76
|
-
return {
|
|
77
|
-
toolCallId: "",
|
|
78
|
-
success: false,
|
|
79
|
-
output: "",
|
|
80
|
-
error: `Unknown tool: ${name}`,
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
try {
|
|
85
|
-
return await tool.handler(args, context);
|
|
86
|
-
} catch (error) {
|
|
87
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
88
|
-
return {
|
|
89
|
-
toolCallId: "",
|
|
90
|
-
success: false,
|
|
91
|
-
output: "",
|
|
92
|
-
error: errorMessage,
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Check if a tool exists
|
|
99
|
-
*/
|
|
100
|
-
has(name: string): boolean {
|
|
101
|
-
return this.tools.has(name);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Get tool count
|
|
106
|
-
*/
|
|
107
|
-
get size(): number {
|
|
108
|
-
return this.tools.size;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* List all tool names
|
|
113
|
-
*/
|
|
114
|
-
list(): string[] {
|
|
115
|
-
return Array.from(this.tools.keys());
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
// Global registry instance
|
|
120
|
-
export const toolRegistry = new ToolRegistry();
|
|
121
|
-
|
|
122
|
-
// Re-export tool modules
|
|
123
|
-
export { registerProjectTools } from "./project.js";
|
|
124
|
-
export { registerTimelineTools } from "./timeline.js";
|
|
125
|
-
export { registerFilesystemTools } from "./filesystem.js";
|
|
126
|
-
export { registerMediaTools } from "./media.js";
|
|
127
|
-
export { registerAITools } from "./ai.js";
|
|
128
|
-
export { registerExportTools } from "./export.js";
|
|
129
|
-
export { registerBatchTools } from "./batch.js";
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Register all tools
|
|
133
|
-
*/
|
|
134
|
-
export async function registerAllTools(registry: ToolRegistry): Promise<void> {
|
|
135
|
-
const { registerProjectTools } = await import("./project.js");
|
|
136
|
-
const { registerTimelineTools } = await import("./timeline.js");
|
|
137
|
-
const { registerFilesystemTools } = await import("./filesystem.js");
|
|
138
|
-
const { registerMediaTools } = await import("./media.js");
|
|
139
|
-
const { registerAITools } = await import("./ai.js");
|
|
140
|
-
const { registerExportTools } = await import("./export.js");
|
|
141
|
-
const { registerBatchTools } = await import("./batch.js");
|
|
142
|
-
|
|
143
|
-
registerProjectTools(registry);
|
|
144
|
-
registerTimelineTools(registry);
|
|
145
|
-
registerFilesystemTools(registry);
|
|
146
|
-
registerMediaTools(registry);
|
|
147
|
-
registerAITools(registry);
|
|
148
|
-
registerExportTools(registry);
|
|
149
|
-
registerBatchTools(registry);
|
|
150
|
-
}
|