@crewx/sdk 0.8.0-rc.58
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 +201 -0
- package/README.md +1022 -0
- package/dist/adapters/MastraToolAdapter.d.ts +9 -0
- package/dist/adapters/MastraToolAdapter.js +66 -0
- package/dist/adapters/MastraToolAdapter.js.map +1 -0
- package/dist/api/index.d.ts +2 -0
- package/dist/api/index.js +8 -0
- package/dist/api/index.js.map +1 -0
- package/dist/boxing/box-storage.interface.d.ts +13 -0
- package/dist/boxing/box-storage.interface.js +3 -0
- package/dist/boxing/box-storage.interface.js.map +1 -0
- package/dist/boxing/box.service.d.ts +15 -0
- package/dist/boxing/box.service.js +70 -0
- package/dist/boxing/box.service.js.map +1 -0
- package/dist/boxing/box.types.d.ts +86 -0
- package/dist/boxing/box.types.js +3 -0
- package/dist/boxing/box.types.js.map +1 -0
- package/dist/boxing/context-builder.d.ts +8 -0
- package/dist/boxing/context-builder.js +76 -0
- package/dist/boxing/context-builder.js.map +1 -0
- package/dist/boxing/index.d.ts +6 -0
- package/dist/boxing/index.js +11 -0
- package/dist/boxing/index.js.map +1 -0
- package/dist/boxing/tokenizer.d.ts +3 -0
- package/dist/boxing/tokenizer.js +11 -0
- package/dist/boxing/tokenizer.js.map +1 -0
- package/dist/config/api-provider-parser.d.ts +58 -0
- package/dist/config/api-provider-parser.js +212 -0
- package/dist/config/api-provider-parser.js.map +1 -0
- package/dist/config/index.d.ts +3 -0
- package/dist/config/index.js +20 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/log.config.d.ts +7 -0
- package/dist/config/log.config.js +20 -0
- package/dist/config/log.config.js.map +1 -0
- package/dist/config/pricing.d.ts +10 -0
- package/dist/config/pricing.js +44 -0
- package/dist/config/pricing.js.map +1 -0
- package/dist/config/timeout.config.d.ts +14 -0
- package/dist/config/timeout.config.js +34 -0
- package/dist/config/timeout.config.js.map +1 -0
- package/dist/config/yaml-loader.d.ts +8 -0
- package/dist/config/yaml-loader.js +155 -0
- package/dist/config/yaml-loader.js.map +1 -0
- package/dist/constants/index.d.ts +4 -0
- package/dist/constants/index.js +8 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +18 -0
- package/dist/constants.js.map +1 -0
- package/dist/conversation/conversation-config.d.ts +9 -0
- package/dist/conversation/conversation-config.js +22 -0
- package/dist/conversation/conversation-config.js.map +1 -0
- package/dist/conversation/conversation-history.interface.d.ts +36 -0
- package/dist/conversation/conversation-history.interface.js +3 -0
- package/dist/conversation/conversation-history.interface.js.map +1 -0
- package/dist/conversation/conversation-storage.service.d.ts +16 -0
- package/dist/conversation/conversation-storage.service.js +213 -0
- package/dist/conversation/conversation-storage.service.js.map +1 -0
- package/dist/conversation/index.d.ts +3 -0
- package/dist/conversation/index.js +20 -0
- package/dist/conversation/index.js.map +1 -0
- package/dist/core/agent/agent-factory.d.ts +37 -0
- package/dist/core/agent/agent-factory.js +68 -0
- package/dist/core/agent/agent-factory.js.map +1 -0
- package/dist/core/agent/agent-runtime.d.ts +52 -0
- package/dist/core/agent/agent-runtime.js +206 -0
- package/dist/core/agent/agent-runtime.js.map +1 -0
- package/dist/core/agent/event-bus.d.ts +44 -0
- package/dist/core/agent/event-bus.js +43 -0
- package/dist/core/agent/event-bus.js.map +1 -0
- package/dist/core/agent/index.d.ts +3 -0
- package/dist/core/agent/index.js +13 -0
- package/dist/core/agent/index.js.map +1 -0
- package/dist/core/env-defaults.d.ts +1 -0
- package/dist/core/env-defaults.js +7 -0
- package/dist/core/env-defaults.js.map +1 -0
- package/dist/core/parallel/helpers.d.ts +27 -0
- package/dist/core/parallel/helpers.js +252 -0
- package/dist/core/parallel/helpers.js.map +1 -0
- package/dist/core/parallel/index.d.ts +4 -0
- package/dist/core/parallel/index.js +11 -0
- package/dist/core/parallel/index.js.map +1 -0
- package/dist/core/parallel/parallel-runner.d.ts +16 -0
- package/dist/core/parallel/parallel-runner.js +230 -0
- package/dist/core/parallel/parallel-runner.js.map +1 -0
- package/dist/core/parallel/types.d.ts +41 -0
- package/dist/core/parallel/types.js +3 -0
- package/dist/core/parallel/types.js.map +1 -0
- package/dist/core/providers/MastraAPIProvider.d.ts +31 -0
- package/dist/core/providers/MastraAPIProvider.js +365 -0
- package/dist/core/providers/MastraAPIProvider.js.map +1 -0
- package/dist/core/providers/ai-provider.interface.d.ts +78 -0
- package/dist/core/providers/ai-provider.interface.js +23 -0
- package/dist/core/providers/ai-provider.interface.js.map +1 -0
- package/dist/core/providers/base-ai.provider.d.ts +80 -0
- package/dist/core/providers/base-ai.provider.js +1183 -0
- package/dist/core/providers/base-ai.provider.js.map +1 -0
- package/dist/core/providers/base-ai.types.d.ts +26 -0
- package/dist/core/providers/base-ai.types.js +3 -0
- package/dist/core/providers/base-ai.types.js.map +1 -0
- package/dist/core/providers/claude.provider.d.ts +19 -0
- package/dist/core/providers/claude.provider.js +170 -0
- package/dist/core/providers/claude.provider.js.map +1 -0
- package/dist/core/providers/codex.provider.d.ts +21 -0
- package/dist/core/providers/codex.provider.js +134 -0
- package/dist/core/providers/codex.provider.js.map +1 -0
- package/dist/core/providers/copilot.provider.d.ts +24 -0
- package/dist/core/providers/copilot.provider.js +146 -0
- package/dist/core/providers/copilot.provider.js.map +1 -0
- package/dist/core/providers/dynamic-provider.factory.d.ts +74 -0
- package/dist/core/providers/dynamic-provider.factory.js +643 -0
- package/dist/core/providers/dynamic-provider.factory.js.map +1 -0
- package/dist/core/providers/gemini.provider.d.ts +16 -0
- package/dist/core/providers/gemini.provider.js +101 -0
- package/dist/core/providers/gemini.provider.js.map +1 -0
- package/dist/core/providers/index.d.ts +8 -0
- package/dist/core/providers/index.js +20 -0
- package/dist/core/providers/index.js.map +1 -0
- package/dist/core/providers/mock.provider.d.ts +13 -0
- package/dist/core/providers/mock.provider.js +55 -0
- package/dist/core/providers/mock.provider.js.map +1 -0
- package/dist/core/providers/provider-factory.d.ts +3 -0
- package/dist/core/providers/provider-factory.js +65 -0
- package/dist/core/providers/provider-factory.js.map +1 -0
- package/dist/core/providers/tool-call.types.d.ts +39 -0
- package/dist/core/providers/tool-call.types.js +3 -0
- package/dist/core/providers/tool-call.types.js.map +1 -0
- package/dist/core/remote/index.d.ts +3 -0
- package/dist/core/remote/index.js +20 -0
- package/dist/core/remote/index.js.map +1 -0
- package/dist/core/remote/remote-agent-manager.d.ts +24 -0
- package/dist/core/remote/remote-agent-manager.js +195 -0
- package/dist/core/remote/remote-agent-manager.js.map +1 -0
- package/dist/core/remote/remote-transport.d.ts +15 -0
- package/dist/core/remote/remote-transport.js +70 -0
- package/dist/core/remote/remote-transport.js.map +1 -0
- package/dist/core/remote/types.d.ts +79 -0
- package/dist/core/remote/types.js +3 -0
- package/dist/core/remote/types.js.map +1 -0
- package/dist/index.d.ts +56 -0
- package/dist/index.js +133 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/index.d.ts +1 -0
- package/dist/internal/index.js +6 -0
- package/dist/internal/index.js.map +1 -0
- package/dist/knowledge/DocumentManager.d.ts +4 -0
- package/dist/knowledge/DocumentManager.js +119 -0
- package/dist/knowledge/DocumentManager.js.map +1 -0
- package/dist/knowledge/index.d.ts +1 -0
- package/dist/knowledge/index.js +18 -0
- package/dist/knowledge/index.js.map +1 -0
- package/dist/parsers/agent-call.util.d.ts +3 -0
- package/dist/parsers/agent-call.util.js +17 -0
- package/dist/parsers/agent-call.util.js.map +1 -0
- package/dist/parsers/claude.parser.d.ts +2 -0
- package/dist/parsers/claude.parser.js +46 -0
- package/dist/parsers/claude.parser.js.map +1 -0
- package/dist/parsers/codex.parser.d.ts +2 -0
- package/dist/parsers/codex.parser.js +89 -0
- package/dist/parsers/codex.parser.js.map +1 -0
- package/dist/parsers/copilot.parser.d.ts +2 -0
- package/dist/parsers/copilot.parser.js +58 -0
- package/dist/parsers/copilot.parser.js.map +1 -0
- package/dist/parsers/gemini.parser.d.ts +2 -0
- package/dist/parsers/gemini.parser.js +36 -0
- package/dist/parsers/gemini.parser.js.map +1 -0
- package/dist/parsers/index.d.ts +7 -0
- package/dist/parsers/index.js +45 -0
- package/dist/parsers/index.js.map +1 -0
- package/dist/schema/skills-parser.d.ts +8 -0
- package/dist/schema/skills-parser.js +438 -0
- package/dist/schema/skills-parser.js.map +1 -0
- package/dist/schema/skills.types.d.ts +158 -0
- package/dist/schema/skills.types.js +41 -0
- package/dist/schema/skills.types.js.map +1 -0
- package/dist/schemas/api-provider.schema.d.ts +432 -0
- package/dist/schemas/api-provider.schema.js +50 -0
- package/dist/schemas/api-provider.schema.js.map +1 -0
- package/dist/services/index.d.ts +2 -0
- package/dist/services/index.js +19 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/layout-loader.service.d.ts +18 -0
- package/dist/services/layout-loader.service.js +271 -0
- package/dist/services/layout-loader.service.js.map +1 -0
- package/dist/services/layout-renderer.service.d.ts +34 -0
- package/dist/services/layout-renderer.service.js +325 -0
- package/dist/services/layout-renderer.service.js.map +1 -0
- package/dist/services/props-validator.service.d.ts +29 -0
- package/dist/services/props-validator.service.js +332 -0
- package/dist/services/props-validator.service.js.map +1 -0
- package/dist/skills/adapter/claude-skill-adapter.d.ts +11 -0
- package/dist/skills/adapter/claude-skill-adapter.js +222 -0
- package/dist/skills/adapter/claude-skill-adapter.js.map +1 -0
- package/dist/skills/index.d.ts +6 -0
- package/dist/skills/index.js +31 -0
- package/dist/skills/index.js.map +1 -0
- package/dist/skills/runtime/progressive-loader.d.ts +27 -0
- package/dist/skills/runtime/progressive-loader.js +186 -0
- package/dist/skills/runtime/progressive-loader.js.map +1 -0
- package/dist/skills/runtime/runtime-requirements-validator.d.ts +23 -0
- package/dist/skills/runtime/runtime-requirements-validator.js +248 -0
- package/dist/skills/runtime/runtime-requirements-validator.js.map +1 -0
- package/dist/skills/runtime/skill-runtime.service.d.ts +42 -0
- package/dist/skills/runtime/skill-runtime.service.js +434 -0
- package/dist/skills/runtime/skill-runtime.service.js.map +1 -0
- package/dist/tools/file-system.service.d.ts +10 -0
- package/dist/tools/file-system.service.js +33 -0
- package/dist/tools/file-system.service.js.map +1 -0
- package/dist/tools/find.tool.d.ts +85 -0
- package/dist/tools/find.tool.js +139 -0
- package/dist/tools/find.tool.js.map +1 -0
- package/dist/tools/glob.tool.d.ts +100 -0
- package/dist/tools/glob.tool.js +153 -0
- package/dist/tools/glob.tool.js.map +1 -0
- package/dist/tools/grep.tool.d.ts +30 -0
- package/dist/tools/grep.tool.js +137 -0
- package/dist/tools/grep.tool.js.map +1 -0
- package/dist/tools/index.d.ts +12 -0
- package/dist/tools/index.js +40 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/ls.tool.d.ts +24 -0
- package/dist/tools/ls.tool.js +94 -0
- package/dist/tools/ls.tool.js.map +1 -0
- package/dist/tools/read-file.tool.d.ts +30 -0
- package/dist/tools/read-file.tool.js +69 -0
- package/dist/tools/read-file.tool.js.map +1 -0
- package/dist/tools/replace.tool.d.ts +36 -0
- package/dist/tools/replace.tool.js +68 -0
- package/dist/tools/replace.tool.js.map +1 -0
- package/dist/tools/run-shell-command.tool.d.ts +24 -0
- package/dist/tools/run-shell-command.tool.js +64 -0
- package/dist/tools/run-shell-command.tool.js.map +1 -0
- package/dist/tools/tree.tool.d.ts +24 -0
- package/dist/tools/tree.tool.js +109 -0
- package/dist/tools/tree.tool.js.map +1 -0
- package/dist/tools/types.d.ts +42 -0
- package/dist/tools/types.js +13 -0
- package/dist/tools/types.js.map +1 -0
- package/dist/tools/utils/file-utils.d.ts +5 -0
- package/dist/tools/utils/file-utils.js +221 -0
- package/dist/tools/utils/file-utils.js.map +1 -0
- package/dist/tools/write-file.tool.d.ts +24 -0
- package/dist/tools/write-file.tool.js +55 -0
- package/dist/tools/write-file.tool.js.map +1 -0
- package/dist/types/agent.types.d.ts +134 -0
- package/dist/types/agent.types.js +16 -0
- package/dist/types/agent.types.js.map +1 -0
- package/dist/types/api-provider.types.d.ts +85 -0
- package/dist/types/api-provider.types.js +65 -0
- package/dist/types/api-provider.types.js.map +1 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.js +23 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/layout.types.d.ts +115 -0
- package/dist/types/layout.types.js +22 -0
- package/dist/types/layout.types.js.map +1 -0
- package/dist/types/provider.types.d.ts +12 -0
- package/dist/types/provider.types.js +3 -0
- package/dist/types/provider.types.js.map +1 -0
- package/dist/types/skill-runtime.types.d.ts +244 -0
- package/dist/types/skill-runtime.types.js +44 -0
- package/dist/types/skill-runtime.types.js.map +1 -0
- package/dist/types/structured-payload.types.d.ts +46 -0
- package/dist/types/structured-payload.types.js +65 -0
- package/dist/types/structured-payload.types.js.map +1 -0
- package/dist/types/task-log.types.d.ts +14 -0
- package/dist/types/task-log.types.js +3 -0
- package/dist/types/task-log.types.js.map +1 -0
- package/dist/types/template.types.d.ts +38 -0
- package/dist/types/template.types.js +3 -0
- package/dist/types/template.types.js.map +1 -0
- package/dist/types.d.ts +1 -0
- package/dist/types.js +18 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/api-provider-normalizer.d.ts +16 -0
- package/dist/utils/api-provider-normalizer.js +135 -0
- package/dist/utils/api-provider-normalizer.js.map +1 -0
- package/dist/utils/base-message-formatter.d.ts +32 -0
- package/dist/utils/base-message-formatter.js +170 -0
- package/dist/utils/base-message-formatter.js.map +1 -0
- package/dist/utils/error-utils.d.ts +3 -0
- package/dist/utils/error-utils.js +27 -0
- package/dist/utils/error-utils.js.map +1 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.js +21 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/math-utils.d.ts +3 -0
- package/dist/utils/math-utils.js +10 -0
- package/dist/utils/math-utils.js.map +1 -0
- package/dist/utils/mention-parser.d.ts +18 -0
- package/dist/utils/mention-parser.js +136 -0
- package/dist/utils/mention-parser.js.map +1 -0
- package/dist/utils/string-utils.d.ts +1 -0
- package/dist/utils/string-utils.js +10 -0
- package/dist/utils/string-utils.js.map +1 -0
- package/dist/utils.d.ts +3 -0
- package/dist/utils.js +20 -0
- package/dist/utils.js.map +1 -0
- package/package.json +134 -0
- package/schema/api-provider-config.json +138 -0
- package/schema/crewx-config.json +224 -0
- package/schema/skills-config.json +306 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const lsTool: import("@mastra/core/tools").Tool<z.ZodObject<{
|
|
3
|
+
path: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
4
|
+
recursive: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
5
|
+
}, "strip", z.ZodTypeAny, {
|
|
6
|
+
path: string;
|
|
7
|
+
recursive: boolean;
|
|
8
|
+
}, {
|
|
9
|
+
path?: string | undefined;
|
|
10
|
+
recursive?: boolean | undefined;
|
|
11
|
+
}>, z.ZodString, any, any, any> & {
|
|
12
|
+
inputSchema: z.ZodObject<{
|
|
13
|
+
path: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
14
|
+
recursive: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
15
|
+
}, "strip", z.ZodTypeAny, {
|
|
16
|
+
path: string;
|
|
17
|
+
recursive: boolean;
|
|
18
|
+
}, {
|
|
19
|
+
path?: string | undefined;
|
|
20
|
+
recursive?: boolean | undefined;
|
|
21
|
+
}>;
|
|
22
|
+
outputSchema: z.ZodString;
|
|
23
|
+
execute: (context: any, options: import("@mastra/core/tools").MastraToolInvocationOptions) => Promise<any>;
|
|
24
|
+
};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.lsTool = void 0;
|
|
7
|
+
const tools_1 = require("@mastra/core/tools");
|
|
8
|
+
const zod_1 = require("zod");
|
|
9
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
10
|
+
const promises_1 = __importDefault(require("node:fs/promises"));
|
|
11
|
+
async function listRecursive(dirPath, basePath, maxDepth = 5, currentDepth = 0) {
|
|
12
|
+
if (currentDepth >= maxDepth) {
|
|
13
|
+
return [`${dirPath}/ (max depth reached)`];
|
|
14
|
+
}
|
|
15
|
+
const results = [];
|
|
16
|
+
const entries = await promises_1.default.readdir(dirPath, { withFileTypes: true });
|
|
17
|
+
for (const entry of entries) {
|
|
18
|
+
const fullPath = node_path_1.default.join(dirPath, entry.name);
|
|
19
|
+
const relativePath = node_path_1.default.relative(basePath, fullPath);
|
|
20
|
+
if (entry.isDirectory()) {
|
|
21
|
+
results.push(`${relativePath}/`);
|
|
22
|
+
try {
|
|
23
|
+
const subResults = await listRecursive(fullPath, basePath, maxDepth, currentDepth + 1);
|
|
24
|
+
results.push(...subResults);
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
results.push(`${relativePath}/ (permission denied)`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
const stats = await promises_1.default.stat(fullPath);
|
|
32
|
+
results.push(`${relativePath} (${stats.size} bytes)`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return results;
|
|
36
|
+
}
|
|
37
|
+
exports.lsTool = (0, tools_1.createTool)({
|
|
38
|
+
id: 'ls',
|
|
39
|
+
description: `Lists contents of a directory. Can list recursively with the 'recursive' flag. Shows file sizes and distinguishes directories with trailing slashes.`,
|
|
40
|
+
inputSchema: zod_1.z.object({
|
|
41
|
+
path: zod_1.z
|
|
42
|
+
.string()
|
|
43
|
+
.optional()
|
|
44
|
+
.default('.')
|
|
45
|
+
.describe('The directory path to list (default: current directory).'),
|
|
46
|
+
recursive: zod_1.z
|
|
47
|
+
.boolean()
|
|
48
|
+
.optional()
|
|
49
|
+
.default(false)
|
|
50
|
+
.describe('Optional: List contents recursively (default: false).'),
|
|
51
|
+
}),
|
|
52
|
+
outputSchema: zod_1.z.string().describe('Directory listing or error message'),
|
|
53
|
+
execute: async ({ context }) => {
|
|
54
|
+
const { path: dirPath = '.', recursive = false } = context;
|
|
55
|
+
const resolvedPath = node_path_1.default.resolve(dirPath);
|
|
56
|
+
try {
|
|
57
|
+
const stats = await promises_1.default.stat(resolvedPath);
|
|
58
|
+
if (!stats.isDirectory()) {
|
|
59
|
+
throw new Error(`Path is not a directory: ${dirPath}`);
|
|
60
|
+
}
|
|
61
|
+
let output = `Directory listing: ${dirPath}\n\n`;
|
|
62
|
+
if (recursive) {
|
|
63
|
+
const entries = await listRecursive(resolvedPath, resolvedPath);
|
|
64
|
+
output += entries.join('\n');
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
const entries = await promises_1.default.readdir(resolvedPath, { withFileTypes: true });
|
|
68
|
+
const lines = [];
|
|
69
|
+
for (const entry of entries) {
|
|
70
|
+
const fullPath = node_path_1.default.join(resolvedPath, entry.name);
|
|
71
|
+
if (entry.isDirectory()) {
|
|
72
|
+
lines.push(`${entry.name}/`);
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
const stats = await promises_1.default.stat(fullPath);
|
|
76
|
+
lines.push(`${entry.name} (${stats.size} bytes)`);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
output += lines.join('\n');
|
|
80
|
+
}
|
|
81
|
+
return output || 'Directory is empty';
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
if (error.code === 'ENOENT') {
|
|
85
|
+
throw new Error(`Directory not found: ${dirPath}`);
|
|
86
|
+
}
|
|
87
|
+
if (error.code === 'EACCES') {
|
|
88
|
+
throw new Error(`Permission denied: ${dirPath}`);
|
|
89
|
+
}
|
|
90
|
+
throw error;
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
//# sourceMappingURL=ls.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ls.tool.js","sourceR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tool<z.ZodObject<{
|
|
3
|
+
file_path: z.ZodString;
|
|
4
|
+
offset: z.ZodOptional<z.ZodNumber>;
|
|
5
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
6
|
+
}, "strip", z.ZodTypeAny, {
|
|
7
|
+
file_path: string;
|
|
8
|
+
offset?: number | undefined;
|
|
9
|
+
limit?: number | undefined;
|
|
10
|
+
}, {
|
|
11
|
+
file_path: string;
|
|
12
|
+
offset?: number | undefined;
|
|
13
|
+
limit?: number | undefined;
|
|
14
|
+
}>, z.ZodString, any, any, any> & {
|
|
15
|
+
inputSchema: z.ZodObject<{
|
|
16
|
+
file_path: z.ZodString;
|
|
17
|
+
offset: z.ZodOptional<z.ZodNumber>;
|
|
18
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
19
|
+
}, "strip", z.ZodTypeAny, {
|
|
20
|
+
file_path: string;
|
|
21
|
+
offset?: number | undefined;
|
|
22
|
+
limit?: number | undefined;
|
|
23
|
+
}, {
|
|
24
|
+
file_path: string;
|
|
25
|
+
offset?: number | undefined;
|
|
26
|
+
limit?: number | undefined;
|
|
27
|
+
}>;
|
|
28
|
+
outputSchema: z.ZodString;
|
|
29
|
+
execute: (context: any, options: import("@mastra/core/tools").MastraToolInvocationOptions) => Promise<any>;
|
|
30
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.readFileTool = void 0;
|
|
7
|
+
const tools_1 = require("@mastra/core/tools");
|
|
8
|
+
const zod_1 = require("zod");
|
|
9
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
10
|
+
const file_utils_js_1 = require("./utils/file-utils.js");
|
|
11
|
+
const file_system_service_js_1 = require("./file-system.service.js");
|
|
12
|
+
exports.readFileTool = (0, tools_1.createTool)({
|
|
13
|
+
id: 'read_file',
|
|
14
|
+
description: `Reads and returns the content of a specified file. If the file is large, the content will be truncated. The tool's response will clearly indicate if truncation has occurred and will provide details on how to read more of the file using the 'offset' and 'limit' parameters. Handles text, images (PNG, JPG, GIF, WEBP, SVG, BMP), and PDF files. For text files, it can read specific line ranges.`,
|
|
15
|
+
inputSchema: zod_1.z.object({
|
|
16
|
+
file_path: zod_1.z
|
|
17
|
+
.string()
|
|
18
|
+
.describe('The path to the file to read.'),
|
|
19
|
+
offset: zod_1.z
|
|
20
|
+
.number()
|
|
21
|
+
.int()
|
|
22
|
+
.nonnegative()
|
|
23
|
+
.optional()
|
|
24
|
+
.describe("Optional: For text files, the 0-based line number to start reading from. Use for paginating through large files."),
|
|
25
|
+
limit: zod_1.z
|
|
26
|
+
.number()
|
|
27
|
+
.int()
|
|
28
|
+
.positive()
|
|
29
|
+
.optional()
|
|
30
|
+
.describe("Optional: For text files, maximum number of lines to read. Use with 'offset' to paginate through large files."),
|
|
31
|
+
}),
|
|
32
|
+
outputSchema: zod_1.z.string().describe('The file content or error message'),
|
|
33
|
+
execute: async ({ context }) => {
|
|
34
|
+
const { file_path, offset, limit } = context;
|
|
35
|
+
if (file_path.trim() === '') {
|
|
36
|
+
throw new Error("The 'file_path' parameter must be non-empty.");
|
|
37
|
+
}
|
|
38
|
+
const targetDir = process.cwd();
|
|
39
|
+
const resolvedPath = node_path_1.default.resolve(file_path);
|
|
40
|
+
const fileSystemService = new file_system_service_js_1.StandardFileSystemService();
|
|
41
|
+
const result = await (0, file_utils_js_1.processSingleFileContent)(resolvedPath, targetDir, fileSystemService, offset, limit);
|
|
42
|
+
if (result.error) {
|
|
43
|
+
throw new Error(result.error);
|
|
44
|
+
}
|
|
45
|
+
if (typeof result.llmContent === 'string') {
|
|
46
|
+
if (result.isTruncated) {
|
|
47
|
+
const [start, end] = result.linesShown;
|
|
48
|
+
const total = result.originalLineCount;
|
|
49
|
+
const nextOffset = offset ? offset + end - start + 1 : end;
|
|
50
|
+
return `IMPORTANT: The file content has been truncated.
|
|
51
|
+
Status: Showing lines ${start}-${end} of ${total} total lines.
|
|
52
|
+
Action: To read more of the file, you can use the 'offset' and 'limit' parameters in a subsequent 'read_file' call. For example, to read the next section of the file, use offset: ${nextOffset}.
|
|
53
|
+
|
|
54
|
+
--- FILE CONTENT (truncated) ---
|
|
55
|
+
${result.llmContent}`;
|
|
56
|
+
}
|
|
57
|
+
return result.llmContent;
|
|
58
|
+
}
|
|
59
|
+
const relativePath2 = (0, file_utils_js_1.makeRelative)(resolvedPath, targetDir);
|
|
60
|
+
const inlineData = result.llmContent.inlineData;
|
|
61
|
+
return `File read successfully: ${(0, file_utils_js_1.shortenPath)(relativePath2)}
|
|
62
|
+
Type: ${inlineData.mimeType}
|
|
63
|
+
Size: ${Buffer.from(inlineData.data, 'base64').length} bytes
|
|
64
|
+
|
|
65
|
+
Note: Binary content (image/PDF) has been loaded. The agent can work with this file.
|
|
66
|
+
Base64 data: ${inlineData.data.substring(0, 100)}...`;
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
//# sourceMappingURL=read-file.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-file.tool.js","sourceRoot":"","sources":["../../src/tools/read-file.tool.ts"],"names":[],"mappings":";;;;;;AAKA,8CAAgD;AAChD,6BAAwB;AACxB,0DAA6B;AAE7B,yDAI+B;AAC/B,qEAAqE;AAQxD,QAAA,YAAY,GAAG,IAAA,kBAAU,EAAC;IACrC,EAAE,EAAE,WAAW;IACf,WAAW,EAAE,yYAAyY;IAEtZ,WAAW,EAAE,OAAC,CAAC,MAAM,CAAC;QACpB,SAAS,EAAE,OAAC;aACT,MAAM,EAAE;aACR,QAAQ,CAAC,+BAA+B,CAAC;QAC5C,MAAM,EAAE,OAAC;aACN,MAAM,EAAE;aACR,GAAG,EAAE;aACL,WAAW,EAAE;aACb,QAAQ,EAAE;aACV,QAAQ,CACP,kHAAkH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CAAC;gBAE3D,OAAO;wBACS,KAAK,IAAI,GAAG,OAAO,KAAK;qLACqI,UAAU;;;EAG7L,MAAM,CAAC,UAAU,EAAE,CAAC;YAChB,CAAC;YAED,OAAO,MAAM,CAAC,UAAU,CAAC;QAC3B,CAAC;QAGD,MAAM,aAAa,GAAG,IAAA,4BAAY,EAAC,YAAY,EAAE,SAAS,CAAC,CAAC;QAC5D,MAAM,UAAU,GAAI,MAAM,CAAC,UAAkB,CAAC,UAAU,CAAC;QAEzD,OAAO,2BAA2B,IAAA,2BAAW,EAAC,aAAa,CAAC;QACxD,UAAU,CAAC,QAAQ;QACnB,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,MAAM;;;eAGtC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,GAAG,CAAC,KAAK,CAAC;IACpD,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const replaceTool: import("@mastra/core/tools").Tool<z.ZodObject<{
|
|
3
|
+
file_path: z.ZodString;
|
|
4
|
+
start_line: z.ZodNumber;
|
|
5
|
+
end_line: z.ZodNumber;
|
|
6
|
+
new_text: z.ZodString;
|
|
7
|
+
}, "strip", z.ZodTypeAny, {
|
|
8
|
+
file_path: string;
|
|
9
|
+
start_line: number;
|
|
10
|
+
end_line: number;
|
|
11
|
+
new_text: string;
|
|
12
|
+
}, {
|
|
13
|
+
file_path: string;
|
|
14
|
+
start_line: number;
|
|
15
|
+
end_line: number;
|
|
16
|
+
new_text: string;
|
|
17
|
+
}>, z.ZodString, any, any, any> & {
|
|
18
|
+
inputSchema: z.ZodObject<{
|
|
19
|
+
file_path: z.ZodString;
|
|
20
|
+
start_line: z.ZodNumber;
|
|
21
|
+
end_line: z.ZodNumber;
|
|
22
|
+
new_text: z.ZodString;
|
|
23
|
+
}, "strip", z.ZodTypeAny, {
|
|
24
|
+
file_path: string;
|
|
25
|
+
start_line: number;
|
|
26
|
+
end_line: number;
|
|
27
|
+
new_text: string;
|
|
28
|
+
}, {
|
|
29
|
+
file_path: string;
|
|
30
|
+
start_line: number;
|
|
31
|
+
end_line: number;
|
|
32
|
+
new_text: string;
|
|
33
|
+
}>;
|
|
34
|
+
outputSchema: z.ZodString;
|
|
35
|
+
execute: (context: any, options: import("@mastra/core/tools").MastraToolInvocationOptions) => Promise<any>;
|
|
36
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.replaceTool = void 0;
|
|
7
|
+
const tools_1 = require("@mastra/core/tools");
|
|
8
|
+
const zod_1 = require("zod");
|
|
9
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
10
|
+
const promises_1 = __importDefault(require("node:fs/promises"));
|
|
11
|
+
exports.replaceTool = (0, tools_1.createTool)({
|
|
12
|
+
id: 'replace',
|
|
13
|
+
description: `Replaces a range of lines in a file with new text. Useful for editing existing files. Requires start_line, end_line, and new_text parameters. Line numbers are 1-based.`,
|
|
14
|
+
inputSchema: zod_1.z.object({
|
|
15
|
+
file_path: zod_1.z
|
|
16
|
+
.string()
|
|
17
|
+
.describe('The path to the file to modify.'),
|
|
18
|
+
start_line: zod_1.z
|
|
19
|
+
.number()
|
|
20
|
+
.int()
|
|
21
|
+
.positive()
|
|
22
|
+
.describe('The starting line number to replace (1-based, inclusive).'),
|
|
23
|
+
end_line: zod_1.z
|
|
24
|
+
.number()
|
|
25
|
+
.int()
|
|
26
|
+
.positive()
|
|
27
|
+
.describe('The ending line number to replace (1-based, inclusive).'),
|
|
28
|
+
new_text: zod_1.z
|
|
29
|
+
.string()
|
|
30
|
+
.describe('The new text to insert in place of the specified lines.'),
|
|
31
|
+
}),
|
|
32
|
+
outputSchema: zod_1.z.string().describe('Success message or error'),
|
|
33
|
+
execute: async ({ context }) => {
|
|
34
|
+
const { file_path, start_line, end_line, new_text } = context;
|
|
35
|
+
if (file_path.trim() === '') {
|
|
36
|
+
throw new Error("The 'file_path' parameter must be non-empty.");
|
|
37
|
+
}
|
|
38
|
+
if (start_line > end_line) {
|
|
39
|
+
throw new Error(`Invalid line range: start_line (${start_line}) must be <= end_line (${end_line}).`);
|
|
40
|
+
}
|
|
41
|
+
const resolvedPath = node_path_1.default.resolve(file_path);
|
|
42
|
+
try {
|
|
43
|
+
await promises_1.default.access(resolvedPath);
|
|
44
|
+
const content = await promises_1.default.readFile(resolvedPath, 'utf-8');
|
|
45
|
+
const lines = content.split('\n');
|
|
46
|
+
if (start_line < 1 || start_line > lines.length) {
|
|
47
|
+
throw new Error(`start_line (${start_line}) is out of range. File has ${lines.length} lines.`);
|
|
48
|
+
}
|
|
49
|
+
if (end_line > lines.length) {
|
|
50
|
+
throw new Error(`end_line (${end_line}) is out of range. File has ${lines.length} lines.`);
|
|
51
|
+
}
|
|
52
|
+
const newLines = new_text.split('\n');
|
|
53
|
+
lines.splice(start_line - 1, end_line - start_line + 1, ...newLines);
|
|
54
|
+
await promises_1.default.writeFile(resolvedPath, lines.join('\n'), 'utf-8');
|
|
55
|
+
return `Successfully replaced lines ${start_line}-${end_line} in ${file_path}`;
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
if (error.code === 'ENOENT') {
|
|
59
|
+
throw new Error(`File not found: ${file_path}`);
|
|
60
|
+
}
|
|
61
|
+
if (error.code === 'EACCES') {
|
|
62
|
+
throw new Error(`Permission denied: ${file_path}`);
|
|
63
|
+
}
|
|
64
|
+
throw error;
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
//# sourceMappingURL=replace.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replace.tool.js","sourceRoot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"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const runShellCommandTool: import("@mastra/core/tools").Tool<z.ZodObject<{
|
|
3
|
+
command: z.ZodString;
|
|
4
|
+
timeout_seconds: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
5
|
+
}, "strip", z.ZodTypeAny, {
|
|
6
|
+
command: string;
|
|
7
|
+
timeout_seconds: number;
|
|
8
|
+
}, {
|
|
9
|
+
command: string;
|
|
10
|
+
timeout_seconds?: number | undefined;
|
|
11
|
+
}>, z.ZodString, any, any, any> & {
|
|
12
|
+
inputSchema: z.ZodObject<{
|
|
13
|
+
command: z.ZodString;
|
|
14
|
+
timeout_seconds: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
15
|
+
}, "strip", z.ZodTypeAny, {
|
|
16
|
+
command: string;
|
|
17
|
+
timeout_seconds: number;
|
|
18
|
+
}, {
|
|
19
|
+
command: string;
|
|
20
|
+
timeout_seconds?: number | undefined;
|
|
21
|
+
}>;
|
|
22
|
+
outputSchema: z.ZodString;
|
|
23
|
+
execute: (context: any, options: import("@mastra/core/tools").MastraToolInvocationOptions) => Promise<any>;
|
|
24
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runShellCommandTool = void 0;
|
|
4
|
+
const tools_1 = require("@mastra/core/tools");
|
|
5
|
+
const zod_1 = require("zod");
|
|
6
|
+
const node_child_process_1 = require("node:child_process");
|
|
7
|
+
const node_util_1 = require("node:util");
|
|
8
|
+
const execAsync = (0, node_util_1.promisify)(node_child_process_1.exec);
|
|
9
|
+
exports.runShellCommandTool = (0, tools_1.createTool)({
|
|
10
|
+
id: 'run_shell_command',
|
|
11
|
+
description: `Executes a shell command and returns its output (stdout and stderr). Supports optional timeout in seconds. Use with caution as this can execute any shell command.`,
|
|
12
|
+
inputSchema: zod_1.z.object({
|
|
13
|
+
command: zod_1.z
|
|
14
|
+
.string()
|
|
15
|
+
.describe('The shell command to execute.'),
|
|
16
|
+
timeout_seconds: zod_1.z
|
|
17
|
+
.number()
|
|
18
|
+
.int()
|
|
19
|
+
.positive()
|
|
20
|
+
.optional()
|
|
21
|
+
.default(30)
|
|
22
|
+
.describe('Optional: Maximum execution time in seconds (default: 30).'),
|
|
23
|
+
}),
|
|
24
|
+
outputSchema: zod_1.z.string().describe('Command output or error message'),
|
|
25
|
+
execute: async ({ context }) => {
|
|
26
|
+
const { command, timeout_seconds = 30 } = context;
|
|
27
|
+
if (command.trim() === '') {
|
|
28
|
+
throw new Error("The 'command' parameter must be non-empty.");
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
const { stdout, stderr } = await execAsync(command, {
|
|
32
|
+
timeout: timeout_seconds * 1000,
|
|
33
|
+
maxBuffer: 10 * 1024 * 1024,
|
|
34
|
+
cwd: process.cwd(),
|
|
35
|
+
});
|
|
36
|
+
let output = '';
|
|
37
|
+
if (stdout) {
|
|
38
|
+
output += `STDOUT:\n${stdout}`;
|
|
39
|
+
}
|
|
40
|
+
if (stderr) {
|
|
41
|
+
output += stdout ? '\n\n' : '';
|
|
42
|
+
output += `STDERR:\n${stderr}`;
|
|
43
|
+
}
|
|
44
|
+
return output || 'Command executed successfully (no output)';
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
if (error.killed && error.signal === 'SIGTERM') {
|
|
48
|
+
throw new Error(`Command timed out after ${timeout_seconds} seconds`);
|
|
49
|
+
}
|
|
50
|
+
let errorMsg = `Command failed: ${command}\n`;
|
|
51
|
+
if (error.stdout) {
|
|
52
|
+
errorMsg += `\nSTDOUT:\n${error.stdout}`;
|
|
53
|
+
}
|
|
54
|
+
if (error.stderr) {
|
|
55
|
+
errorMsg += `\nSTDERR:\n${error.stderr}`;
|
|
56
|
+
}
|
|
57
|
+
if (error.code !== undefined) {
|
|
58
|
+
errorMsg += `\nExit code: ${error.code}`;
|
|
59
|
+
}
|
|
60
|
+
throw new Error(errorMsg);
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
//# sourceMappingURL=run-shell-command.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-shell-command.tool.js","sourceRoot":"","sources":["../../src/tools/run-shell-command.tool.ts"],"names":[],"mappings":";;;AAKA,8CAAgD;AAChD,6BAAwB;AACxB,2DAA0C;AAC1C,yCAAsC;AAEtC,MAAM,SAAS,GAAG,IAAA,qBAAS,EAAC,yBAAI,CAAC,CAAC;AAOrB,QAAA,mBAAmB,GAAG,IAAA,kBAAU,EAAC;IAC5C,EAAE,EAAE,mBAAmB;IACvB,WAAW,EAAE,oKAAoK;IAEjL,WAAW,EAAE,OAAC,CAAC,MAAM,CAAC;QACpB,OAAO,EAAE,OAAC;aACP,MAAM,EAAE;aACR,QAAQ,CAAC,+BAA+B,CAAC;QAC5C,eAAe,EAAE,OAAC;aACf,MAAM,EAAE;aACR,GAAG,EAAE;aACL,QAAQ,EAAE;aACV,QAAQ,EAAE;aACV,OAAO,CAAC,EAAE,CAAC;aACX,QAAQ,CAAC,4DAA4D,CAAC;KAC1E,CAAC;IAEF,YAAY,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,iCAAiC,CAAC;IAEpE,OAAO,EAAE,KAAK,EAAE,EAAE,OAAO,EAAO,EAAE,EAAE;QAClC,MAAM,EAAE,OAAO,EAAE,eAAe,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC;QAGlD,IAAI,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YAC1B,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;QAChE,CAAC;QAED,IAAI,CAAC;YACH,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,SAAS,CAAC,OAAO,EAAE;gBAClD,OAAO,EAAE,eAAe,GAAG,IAAI;g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|
3
|
+
path: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
4
|
+
max_depth: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
5
|
+
}, "strip", z.ZodTypeAny, {
|
|
6
|
+
path: string;
|
|
7
|
+
max_depth: number;
|
|
8
|
+
}, {
|
|
9
|
+
path?: string | undefined;
|
|
10
|
+
max_depth?: number | undefined;
|
|
11
|
+
}>, z.ZodString, any, any, any> & {
|
|
12
|
+
inputSchema: z.ZodObject<{
|
|
13
|
+
path: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
14
|
+
max_depth: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
15
|
+
}, "strip", z.ZodTypeAny, {
|
|
16
|
+
path: string;
|
|
17
|
+
max_depth: number;
|
|
18
|
+
}, {
|
|
19
|
+
path?: string | undefined;
|
|
20
|
+
max_depth?: number | undefined;
|
|
21
|
+
}>;
|
|
22
|
+
outputSchema: z.ZodString;
|
|
23
|
+
execute: (context: any, options: import("@mastra/core/tools").MastraToolInvocationOptions) => Promise<any>;
|
|
24
|
+
};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.treeTool = void 0;
|
|
7
|
+
const tools_1 = require("@mastra/core/tools");
|
|
8
|
+
const zod_1 = require("zod");
|
|
9
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
10
|
+
const promises_1 = __importDefault(require("node:fs/promises"));
|
|
11
|
+
const INDENT_UNIT = ' ';
|
|
12
|
+
async function buildTreeLines(dirPath, options) {
|
|
13
|
+
const { currentDepth, maxDepth } = options;
|
|
14
|
+
let entries;
|
|
15
|
+
try {
|
|
16
|
+
entries = await promises_1.default.readdir(dirPath, { withFileTypes: true });
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
const indent = INDENT_UNIT.repeat(currentDepth);
|
|
20
|
+
const reason = error?.code === 'EACCES' ? 'permission denied' : error?.message || 'unknown error';
|
|
21
|
+
return [`${indent}(error reading directory: ${reason})`];
|
|
22
|
+
}
|
|
23
|
+
if (entries.length === 0) {
|
|
24
|
+
return [`${INDENT_UNIT.repeat(currentDepth)}(empty)`];
|
|
25
|
+
}
|
|
26
|
+
entries.sort((a, b) => {
|
|
27
|
+
if (a.isDirectory() && !b.isDirectory())
|
|
28
|
+
return -1;
|
|
29
|
+
if (!a.isDirectory() && b.isDirectory())
|
|
30
|
+
return 1;
|
|
31
|
+
return a.name.localeCompare(b.name);
|
|
32
|
+
});
|
|
33
|
+
const lines = [];
|
|
34
|
+
for (const entry of entries) {
|
|
35
|
+
const indent = INDENT_UNIT.repeat(currentDepth);
|
|
36
|
+
const fullPath = node_path_1.default.join(dirPath, entry.name);
|
|
37
|
+
if (entry.isDirectory()) {
|
|
38
|
+
lines.push(`${indent}[DIR] ${entry.name}/`);
|
|
39
|
+
if (currentDepth < maxDepth) {
|
|
40
|
+
const childLines = await buildTreeLines(fullPath, {
|
|
41
|
+
currentDepth: currentDepth + 1,
|
|
42
|
+
maxDepth,
|
|
43
|
+
});
|
|
44
|
+
lines.push(...childLines);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
lines.push(`${INDENT_UNIT.repeat(currentDepth + 1)}(max depth reached)`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
try {
|
|
52
|
+
const stats = await promises_1.default.stat(fullPath);
|
|
53
|
+
lines.push(`${indent}[FILE] ${entry.name} (${stats.size} bytes)`);
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
lines.push(`${indent}[FILE] ${entry.name} (error: ${error?.code || 'stat failed'})`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return lines;
|
|
61
|
+
}
|
|
62
|
+
exports.treeTool = (0, tools_1.createTool)({
|
|
63
|
+
id: 'tree',
|
|
64
|
+
description: `Displays a directory tree similar to the Unix 'tree' command. Shows nested directories up to 'max_depth' levels with [DIR]/[FILE] labels and indentation to represent hierarchy.`,
|
|
65
|
+
inputSchema: zod_1.z.object({
|
|
66
|
+
path: zod_1.z
|
|
67
|
+
.string()
|
|
68
|
+
.optional()
|
|
69
|
+
.default('.')
|
|
70
|
+
.describe('Path of the directory to inspect (default: current working directory).'),
|
|
71
|
+
max_depth: zod_1.z
|
|
72
|
+
.number()
|
|
73
|
+
.int()
|
|
74
|
+
.min(1)
|
|
75
|
+
.optional()
|
|
76
|
+
.default(3)
|
|
77
|
+
.describe('Maximum depth to traverse relative to the root directory (default: 3).'),
|
|
78
|
+
}),
|
|
79
|
+
outputSchema: zod_1.z.string().describe('Formatted tree output or an error message'),
|
|
80
|
+
execute: async ({ context }) => {
|
|
81
|
+
const { path: targetPath = '.', max_depth = 3 } = context;
|
|
82
|
+
const resolvedPath = node_path_1.default.resolve(targetPath);
|
|
83
|
+
try {
|
|
84
|
+
const stats = await promises_1.default.stat(resolvedPath);
|
|
85
|
+
if (!stats.isDirectory()) {
|
|
86
|
+
throw new Error(`Path is not a directory: ${targetPath}`);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
if (error?.code === 'ENOENT') {
|
|
91
|
+
throw new Error(`Directory not found: ${targetPath}`);
|
|
92
|
+
}
|
|
93
|
+
if (error?.code === 'EACCES') {
|
|
94
|
+
throw new Error(`Permission denied: ${targetPath}`);
|
|
95
|
+
}
|
|
96
|
+
throw error;
|
|
97
|
+
}
|
|
98
|
+
const relativeRoot = node_path_1.default.relative(process.cwd(), resolvedPath);
|
|
99
|
+
const rootLabel = relativeRoot === '' ? '.' : relativeRoot;
|
|
100
|
+
const lines = [`Tree for ${rootLabel} (max depth: ${max_depth})`, `[DIR] ${rootLabel}/`];
|
|
101
|
+
const treeLines = await buildTreeLines(resolvedPath, {
|
|
102
|
+
currentDepth: 1,
|
|
103
|
+
maxDepth: max_depth,
|
|
104
|
+
});
|
|
105
|
+
lines.push(...treeLines);
|
|
106
|
+
return lines.join('\n');
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
//# sourceMappingURL=tree.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tree.tool.js","sourceRoot":"","sources":["../../src/tools/tree.tool.ts"],"names":[],"mappings":";;;;;;AAKA,8CAAgD;AAChD,6BAAwB;AACxB,0DAA6B;AAC7B,gEAAkC;AAGlC,MAAM,WAAW,GAAG,IAAI,CAAC;AAUzB,KAAK,UAAU,cAAc,CAAC,OAAe,EAAE,OAA6B;IAC1E,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IAE3C,IAAI,OAAiB,CAAC;IACtB,IAAI,CAAC;QACH,OAAO,GAAG,MAAM,kBAAE,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;IAC/D,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;QAChD,MAAM,MAAM,GAAG,KAAK,EAAE,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,KAAK,EAAE,OAAO,IAAI,eAAe,CAAC;QAClG,OAAO,CAAC,GAAG,MAAM,6BAA6B,MAAM,GAAG,CAAC,CAAC;IAC3D,CAAC;IAED,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,CAAC,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;IACxD,CAAC;IAED,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QACpB,IAAI,CAAC,CAAC,WAA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,KAAU,EAAE,CAAC;YACpB,IAAI,KAAK,EAAE,IAAI,KAAK,QAAQ,EAAE,CAAC;gBAC7B,MAAM,IAAI,KAAK,CAAC,wBAAwB,UAAU,EAAE,CAAC,CAAC;YACxD,CAAC;YACD,IAAI,KAAK,EAAE,IAAI,KAAK,QAAQ,EAAE,CAAC;gBAC7B,MAAM,IAAI,KAAK,CAAC,sBAAsB,UAAU,EAAE,CAAC,CAAC;YACtD,CAAC;YACD,MAAM,KAAK,CAAC;QACd,CAAC;QAED,MAAM,YAAY,GAAG,mBAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,YAAY,CAAC,CAAC;QAChE,MAAM,SAAS,GAAG,YAAY,KAAK,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,YAAY,CAAC;QAE3D,MAAM,KAAK,GAAG,CAAC,YAAY,SAAS,gBAAgB,SAAS,GAAG,EAAE,SAAS,SAAS,GAAG,CAAC,CAAC;QACzF,MAAM,SAAS,GAAG,MAAM,cAAc,CAAC,YAAY,EAAE;YACnD,YAAY,EAAE,CAAC;YACf,QAAQ,EAAE,SAAS;SACpB,CAAC,CAAC;QAEH,KAAK,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC,CAAC;QAEzB,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export interface ToolExecutionContext {
|
|
2
|
+
workingDirectory: string;
|
|
3
|
+
isPathWithinWorkspace(path: string): boolean;
|
|
4
|
+
fileSystemService: FileSystemService;
|
|
5
|
+
shouldIgnoreFile(path: string): boolean;
|
|
6
|
+
agentId: string;
|
|
7
|
+
provider: string;
|
|
8
|
+
model: string;
|
|
9
|
+
env: Record<string, string | undefined>;
|
|
10
|
+
vars: Record<string, any>;
|
|
11
|
+
}
|
|
12
|
+
export interface FileSystemService {
|
|
13
|
+
readFile(path: string): Promise<Buffer>;
|
|
14
|
+
exists(path: string): Promise<boolean>;
|
|
15
|
+
stat(path: string): Promise<{
|
|
16
|
+
size: number;
|
|
17
|
+
isDirectory: boolean;
|
|
18
|
+
}>;
|
|
19
|
+
readdir(path: string): Promise<string[]>;
|
|
20
|
+
}
|
|
21
|
+
export interface ProcessedFileReadResult {
|
|
22
|
+
llmContent: string | {
|
|
23
|
+
inlineData: {
|
|
24
|
+
data: string;
|
|
25
|
+
mimeType: string;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
returnDisplay: string;
|
|
29
|
+
error?: string;
|
|
30
|
+
errorType?: ToolErrorType;
|
|
31
|
+
isTruncated?: boolean;
|
|
32
|
+
originalLineCount?: number;
|
|
33
|
+
linesShown?: [number, number];
|
|
34
|
+
}
|
|
35
|
+
export declare enum ToolErrorType {
|
|
36
|
+
FILE_NOT_FOUND = "FILE_NOT_FOUND",
|
|
37
|
+
PATH_IS_DIRECTORY = "PATH_IS_DIRECTORY",
|
|
38
|
+
FILE_TOO_LARGE = "FILE_TOO_LARGE",
|
|
39
|
+
BINARY_FILE = "BINARY_FILE",
|
|
40
|
+
PERMISSION_DENIED = "PERMISSION_DENIED",
|
|
41
|
+
UNKNOWN = "UNKNOWN"
|
|
42
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ToolErrorType = void 0;
|
|
4
|
+
var ToolErrorType;
|
|
5
|
+
(function (ToolErrorType) {
|
|
6
|
+
ToolErrorType["FILE_NOT_FOUND"] = "FILE_NOT_FOUND";
|
|
7
|
+
ToolErrorType["PATH_IS_DIRECTORY"] = "PATH_IS_DIRECTORY";
|
|
8
|
+
ToolErrorType["FILE_TOO_LARGE"] = "FILE_TOO_LARGE";
|
|
9
|
+
ToolErrorType["BINARY_FILE"] = "BINARY_FILE";
|
|
10
|
+
ToolErrorType["PERMISSION_DENIED"] = "PERMISSION_DENIED";
|
|
11
|
+
ToolErrorType["UNKNOWN"] = "UNKNOWN";
|
|
12
|
+
})(ToolErrorType || (exports.ToolErrorType = ToolErrorType = {}));
|
|
13
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/tools/types.ts"],"names":[],"mappings":";;;AAkDA,IAAY,aAOX;AAPD,WAAY,aAAa;IACvB,kDAAiC,CAAA;IACjC,wDAAuC,CAAA;IACvC,kDAAiC,CAAA;IACjC,4CAA2B,CAAA;IAC3B,wDAAuC,CAAA;IACvC,oCAAmB,CAAA;AACrB,CAAC,EAPW,aAAa,6BAAb,aAAa,QAOxB"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { FileSystemService, ProcessedFileReadResult } from '../types.js';
|
|
2
|
+
export declare function getSpecificMimeType(filePath: string): string;
|
|
3
|
+
export declare function processSingleFileContent(filePath: string, rootDirectory: string, fileSystemService: FileSystemService, offset?: number, limit?: number): Promise<ProcessedFileReadResult>;
|
|
4
|
+
export declare function makeRelative(absolutePath: string, rootDir: string): string;
|
|
5
|
+
export declare function shortenPath(filePath: string, maxLength?: number): string;
|