Forked from brdcastro/maestro
"use strict";
/**
* @file toolsProvider.ts
* Thin orchestrator — composes tools from sub-modules.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.toolsProvider = void 0;
const config_1 = require("./config");
const stateManager_1 = require("./stateManager");
const gitTools_1 = require("./gitTools");
const fileTools_1 = require("./fileTools");
const codeTools_1 = require("./codeTools");
const webTools_1 = require("./webTools");
const systemTools_1 = require("./systemTools");
const macosTools_1 = require("./macosTools");
const secondaryAgent_1 = require("./secondaryAgent");
const videoTools_1 = require("./videoTools");
const outputLimits_1 = require("./outputLimits");
const toolsProvider = async (ctl) => {
const pluginConfig = ctl.getPluginConfig(config_1.toolsPluginConfig);
// Load state
const fullState = await (0, stateManager_1.getPersistedState)();
const configCwd = pluginConfig.get("defaultWorkingDirectory");
// Shared mutable context — all modules see cwd changes
const initialCwd = configCwd || fullState.currentWorkingDirectory;
const ctx = {
workspaceRoot: initialCwd,
cwd: initialCwd,
fullState,
saveState: () => (0, stateManager_1.savePersistedState)(fullState),
};
// Config flags (simplified — merged toggles)
const allowCode = pluginConfig.get("allowCodeExecution");
const allowMacOS = pluginConfig.get("allowMacOSIntegration");
const searxngUrl = pluginConfig.get("searxngUrl") || "";
const enableSecondary = pluginConfig.get("enableSecondaryAgent");
const enableVideoRender = pluginConfig.get("enableVideoRendering");
// Ensure workspace exists (no-op if already exists, safe to call every time)
await (0, stateManager_1.ensureWorkspaceExists)(ctx.cwd);
// Output budget — configurable truncation limits
const limits = (0, outputLimits_1.getOutputLimits)(pluginConfig.get("toolOutputBudget"));
// Compose tools from modules
const tools = [];
// Git — always enabled
tools.push(...(0, gitTools_1.createGitTools)(ctx, limits));
tools.push(...(0, fileTools_1.createFileTools)(ctx, limits));
const codeResult = (0, codeTools_1.createCodeTools)(ctx, {
allowJavascript: allowCode, allowPython: allowCode,
allowShell: allowCode, allowTerminal: allowCode,
}, limits);
tools.push(...codeResult.tools);
tools.push(...(0, webTools_1.createWebTools)({ enableWikipedia: true, searxngUrl: searxngUrl || undefined }, limits));
// Notifications + Database — always enabled when code execution is on
tools.push(...(0, systemTools_1.createSystemTools)(ctx, { allowNotify: true, allowDb: allowCode }, limits));
tools.push(...(0, macosTools_1.createMacOSTools)({ allowAppleScript: allowMacOS, allowScreenshot: allowMacOS }, limits));
if (enableSecondary) {
tools.push((0, secondaryAgent_1.createSecondaryAgentTool)(ctx, {
pluginConfig,
originalRunJavascript: codeResult.originalRunJavascript,
originalRunPython: codeResult.originalRunPython,
limits,
}));
}
// Video rendering — gated, off by default. The model must use the
// 'video-composition' design reference to produce HF-compatible HTML.
tools.push(...(0, videoTools_1.createVideoTools)(ctx, { enableVideoRendering: enableVideoRender }));
return tools;
};
exports.toolsProvider = toolsProvider;
//# sourceMappingURL=toolsProvider.js.map