vigthoria-cli 1.8.12 → 1.8.13
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/utils/tools.d.ts +1 -0
- package/dist/utils/tools.js +83 -0
- package/package.json +1 -1
package/dist/utils/tools.d.ts
CHANGED
package/dist/utils/tools.js
CHANGED
|
@@ -399,6 +399,19 @@ class AgenticTools {
|
|
|
399
399
|
riskLevel: 'low',
|
|
400
400
|
category: 'read',
|
|
401
401
|
},
|
|
402
|
+
{
|
|
403
|
+
name: 'browser',
|
|
404
|
+
description: 'Drive a real headless Chromium via the Vigthoria DevTools Bridge. Use to capture a page (screenshot+HTML+metrics), collect console/page errors, or run a quick smoke test on a URL. Cross-platform.',
|
|
405
|
+
parameters: [
|
|
406
|
+
{ name: 'mode', description: "One of: 'capture' (screenshot + html + metrics), 'errors' (console + page errors), 'test' (quick smoke test)", required: true },
|
|
407
|
+
{ name: 'url', description: 'Target URL (must start with http:// or https://)', required: true },
|
|
408
|
+
{ name: 'include_screenshot', description: "For mode=capture: 'true' to include base64 screenshot (default true), 'false' to skip", required: false },
|
|
409
|
+
],
|
|
410
|
+
requiresPermission: true,
|
|
411
|
+
dangerous: false,
|
|
412
|
+
riskLevel: 'low',
|
|
413
|
+
category: 'read',
|
|
414
|
+
},
|
|
402
415
|
{
|
|
403
416
|
name: 'ssh_exec',
|
|
404
417
|
description: 'Execute a command on a remote server via SSH (useful for Unix commands from Windows)',
|
|
@@ -602,6 +615,8 @@ class AgenticTools {
|
|
|
602
615
|
return this.repo(call.args);
|
|
603
616
|
case 'fetch_url':
|
|
604
617
|
return this.fetchUrl(call.args);
|
|
618
|
+
case 'browser':
|
|
619
|
+
return this.browserTool(call.args);
|
|
605
620
|
case 'ssh_exec':
|
|
606
621
|
return this.sshExec(call.args);
|
|
607
622
|
case 'task':
|
|
@@ -1857,6 +1872,74 @@ class AgenticTools {
|
|
|
1857
1872
|
return this.createErrorResult(ToolErrorType.NETWORK_ERROR, error.message, 'Check your internet connection and ensure the URL is correct.');
|
|
1858
1873
|
}
|
|
1859
1874
|
}
|
|
1875
|
+
async browserTool(args) {
|
|
1876
|
+
const mode = (args.mode || '').toLowerCase();
|
|
1877
|
+
const url = args.url;
|
|
1878
|
+
if (!['capture', 'errors', 'test'].includes(mode)) {
|
|
1879
|
+
return this.createErrorResult(ToolErrorType.INVALID_ARGS, `Invalid mode: ${args.mode}`, "mode must be one of: 'capture', 'errors', 'test'");
|
|
1880
|
+
}
|
|
1881
|
+
if (!url || (!url.startsWith('http://') && !url.startsWith('https://'))) {
|
|
1882
|
+
return this.createErrorResult(ToolErrorType.INVALID_ARGS, 'URL must start with http:// or https://', 'Provide a valid URL, e.g., https://example.com');
|
|
1883
|
+
}
|
|
1884
|
+
const host = process.env.VIGTHORIA_DEVTOOLS_BRIDGE_HOST || '127.0.0.1';
|
|
1885
|
+
const port = process.env.VIGTHORIA_DEVTOOLS_BRIDGE_PORT || '4016';
|
|
1886
|
+
const base = `http://${host}:${port}`;
|
|
1887
|
+
const toolName = mode === 'capture' ? 'capture_state' :
|
|
1888
|
+
mode === 'errors' ? 'get_page_errors' :
|
|
1889
|
+
'run_test';
|
|
1890
|
+
const params = { url };
|
|
1891
|
+
if (mode === 'capture' && (args.include_screenshot || '').toLowerCase() === 'false') {
|
|
1892
|
+
params.includeScreenshot = false;
|
|
1893
|
+
}
|
|
1894
|
+
if (mode === 'test') {
|
|
1895
|
+
params.testType = 'quick';
|
|
1896
|
+
}
|
|
1897
|
+
const controller = new AbortController();
|
|
1898
|
+
const timeoutMs = mode === 'test' ? 60000 : 45000;
|
|
1899
|
+
const timeout = setTimeout(() => controller.abort(), timeoutMs);
|
|
1900
|
+
try {
|
|
1901
|
+
const res = await fetch(`${base}/api/mcp/tools`, {
|
|
1902
|
+
method: 'POST',
|
|
1903
|
+
headers: { 'Content-Type': 'application/json', 'User-Agent': 'Vigthoria-CLI-Browser/1.0' },
|
|
1904
|
+
body: JSON.stringify({ tool: toolName, params }),
|
|
1905
|
+
signal: controller.signal,
|
|
1906
|
+
});
|
|
1907
|
+
clearTimeout(timeout);
|
|
1908
|
+
if (!res.ok) {
|
|
1909
|
+
return this.createErrorResult(ToolErrorType.NETWORK_ERROR, `DevTools Bridge HTTP ${res.status}`, 'Ensure the bridge is running (vigthoria bridge status). On a developer workstation it must be installed and started locally.');
|
|
1910
|
+
}
|
|
1911
|
+
const data = await res.json();
|
|
1912
|
+
if (!data.success) {
|
|
1913
|
+
return this.createErrorResult(ToolErrorType.NETWORK_ERROR, data.error || 'DevTools Bridge returned unsuccessful response', 'Check the bridge logs.');
|
|
1914
|
+
}
|
|
1915
|
+
let payload;
|
|
1916
|
+
if (mode === 'capture' && data.result && typeof data.result === 'object') {
|
|
1917
|
+
const r = data.result;
|
|
1918
|
+
const trimmed = {
|
|
1919
|
+
url: r.url,
|
|
1920
|
+
timestamp: r.timestamp,
|
|
1921
|
+
metrics: r.metrics,
|
|
1922
|
+
performance: r.performance,
|
|
1923
|
+
html_excerpt: typeof r.html === 'string' ? r.html.slice(0, 4000) : undefined,
|
|
1924
|
+
screenshot_data_url_length: typeof r.screenshot === 'string' ? r.screenshot.length : 0,
|
|
1925
|
+
};
|
|
1926
|
+
payload = JSON.stringify(trimmed, null, 2);
|
|
1927
|
+
}
|
|
1928
|
+
else {
|
|
1929
|
+
payload = JSON.stringify(data.result, null, 2).slice(0, 8000);
|
|
1930
|
+
}
|
|
1931
|
+
return {
|
|
1932
|
+
success: true,
|
|
1933
|
+
output: payload,
|
|
1934
|
+
metadata: { tool: 'browser', mode, url },
|
|
1935
|
+
};
|
|
1936
|
+
}
|
|
1937
|
+
catch (e) {
|
|
1938
|
+
clearTimeout(timeout);
|
|
1939
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
1940
|
+
return this.createErrorResult(ToolErrorType.NETWORK_ERROR, `Browser tool failed: ${msg}`, "Verify the DevTools Bridge is reachable on host:port (defaults 127.0.0.1:4016).");
|
|
1941
|
+
}
|
|
1942
|
+
}
|
|
1860
1943
|
/**
|
|
1861
1944
|
* Execute command via SSH on remote server
|
|
1862
1945
|
* Useful for running Unix commands from Windows
|