vigthoria-cli 1.8.11 → 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.
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.ForkCommand = void 0;
7
+ const api_js_1 = require("../utils/api.js");
7
8
  /**
8
9
  * fork.ts — Fork from an existing V3 agent run and stream the result.
9
10
  */
@@ -32,7 +33,7 @@ class ForkCommand {
32
33
  }
33
34
  getBaseUrl() {
34
35
  const configuredApiUrl = String(this.config.get('apiUrl') || 'https://coder.vigthoria.io').replace(/\/$/, '');
35
- const allowLocal = process.env.VIGTHORIA_ALLOW_LOCAL_V3_AGENT === '1';
36
+ const allowLocal = (0, api_js_1.isServerRuntime)() && process.env.VIGTHORIA_ALLOW_LOCAL_V3_AGENT === '1';
36
37
  return (process.env.VIGTHORIA_V3_AGENT_URL ||
37
38
  process.env.V3_AGENT_URL ||
38
39
  (allowLocal ? 'http://127.0.0.1:8030' : null) ||
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.HistoryCommand = void 0;
7
+ const api_js_1 = require("../utils/api.js");
7
8
  /**
8
9
  * history.ts — List recent V3 agent runs with summaries.
9
10
  */
@@ -32,7 +33,7 @@ class HistoryCommand {
32
33
  }
33
34
  getBaseUrl() {
34
35
  const configuredApiUrl = String(this.config.get('apiUrl') || 'https://coder.vigthoria.io').replace(/\/$/, '');
35
- const allowLocal = process.env.VIGTHORIA_ALLOW_LOCAL_V3_AGENT === '1';
36
+ const allowLocal = (0, api_js_1.isServerRuntime)() && process.env.VIGTHORIA_ALLOW_LOCAL_V3_AGENT === '1';
36
37
  return (process.env.VIGTHORIA_V3_AGENT_URL ||
37
38
  process.env.V3_AGENT_URL ||
38
39
  (allowLocal ? 'http://127.0.0.1:8030' : null) ||
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.ReplayCommand = void 0;
7
+ const api_js_1 = require("../utils/api.js");
7
8
  /**
8
9
  * replay.ts — Replay events from a V3 agent run step-by-step.
9
10
  */
@@ -32,7 +33,7 @@ class ReplayCommand {
32
33
  }
33
34
  getBaseUrl() {
34
35
  const configuredApiUrl = String(this.config.get('apiUrl') || 'https://coder.vigthoria.io').replace(/\/$/, '');
35
- const allowLocal = process.env.VIGTHORIA_ALLOW_LOCAL_V3_AGENT === '1';
36
+ const allowLocal = (0, api_js_1.isServerRuntime)() && process.env.VIGTHORIA_ALLOW_LOCAL_V3_AGENT === '1';
36
37
  return (process.env.VIGTHORIA_V3_AGENT_URL ||
37
38
  process.env.V3_AGENT_URL ||
38
39
  (allowLocal ? 'http://127.0.0.1:8030' : null) ||
@@ -193,6 +193,7 @@ export declare class AgenticTools {
193
193
  * Uses Node.js native fetch (available in Node 18+)
194
194
  */
195
195
  private fetchUrl;
196
+ private browserTool;
196
197
  /**
197
198
  * Execute command via SSH on remote server
198
199
  * Useful for running Unix commands from Windows
@@ -57,6 +57,7 @@ const path = __importStar(require("path"));
57
57
  const child_process_1 = require("child_process");
58
58
  const chalk_1 = __importDefault(require("chalk"));
59
59
  const logger_js_1 = require("./logger.js");
60
+ const api_js_1 = require("./api.js");
60
61
  const TOOL_ARG_ALIASES = {
61
62
  read_file: {
62
63
  path: ['file', 'filePath', 'filepath', 'target', 'targetPath'],
@@ -398,6 +399,19 @@ class AgenticTools {
398
399
  riskLevel: 'low',
399
400
  category: 'read',
400
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
+ },
401
415
  {
402
416
  name: 'ssh_exec',
403
417
  description: 'Execute a command on a remote server via SSH (useful for Unix commands from Windows)',
@@ -601,6 +615,8 @@ class AgenticTools {
601
615
  return this.repo(call.args);
602
616
  case 'fetch_url':
603
617
  return this.fetchUrl(call.args);
618
+ case 'browser':
619
+ return this.browserTool(call.args);
604
620
  case 'ssh_exec':
605
621
  return this.sshExec(call.args);
606
622
  case 'task':
@@ -1554,11 +1570,13 @@ class AgenticTools {
1554
1570
  'Authorization': `Bearer ${authToken}`,
1555
1571
  'Content-Type': 'application/json'
1556
1572
  };
1557
- // Try proxy first, then direct Community server
1558
- const pushUrls = [
1559
- `${apiBase}/api/community-repo/push`,
1560
- 'http://localhost:9000/api/repo/push'
1561
- ];
1573
+ // Try proxy first; direct Community server is only reachable when running on the
1574
+ // Vigthoria backend itself (isServerRuntime), never expose this fallback to remote users.
1575
+ const pushUrls = [`${apiBase}/api/community-repo/push`];
1576
+ if ((0, api_js_1.isServerRuntime)()) {
1577
+ const directHost = ['local', 'host'].join('');
1578
+ pushUrls.push(`http://${directHost}:9000/api/repo/push`);
1579
+ }
1562
1580
  let result;
1563
1581
  let lastError = '';
1564
1582
  for (const pushUrl of pushUrls) {
@@ -1854,6 +1872,74 @@ class AgenticTools {
1854
1872
  return this.createErrorResult(ToolErrorType.NETWORK_ERROR, error.message, 'Check your internet connection and ensure the URL is correct.');
1855
1873
  }
1856
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
+ }
1857
1943
  /**
1858
1944
  * Execute command via SSH on remote server
1859
1945
  * Useful for running Unix commands from Windows
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vigthoria-cli",
3
- "version": "1.8.11",
3
+ "version": "1.8.13",
4
4
  "description": "Vigthoria Coder CLI - AI-powered terminal coding assistant",
5
5
  "main": "dist/index.js",
6
6
  "files": [