sentinelayer-cli 0.1.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.
Files changed (124) hide show
  1. package/README.md +996 -0
  2. package/bin/create-sentinelayer.js +5 -0
  3. package/bin/sentinelayer-cli.js +5 -0
  4. package/bin/sl.js +5 -0
  5. package/package.json +54 -0
  6. package/src/agents/jules/config/definition.js +209 -0
  7. package/src/agents/jules/config/system-prompt.js +175 -0
  8. package/src/agents/jules/error-intake.js +51 -0
  9. package/src/agents/jules/fix-cycle.js +377 -0
  10. package/src/agents/jules/loop.js +367 -0
  11. package/src/agents/jules/pulse.js +319 -0
  12. package/src/agents/jules/stream.js +186 -0
  13. package/src/agents/jules/swarm/file-scanner.js +74 -0
  14. package/src/agents/jules/swarm/index.js +11 -0
  15. package/src/agents/jules/swarm/orchestrator.js +362 -0
  16. package/src/agents/jules/swarm/pattern-hunter.js +123 -0
  17. package/src/agents/jules/swarm/sub-agent.js +308 -0
  18. package/src/agents/jules/tools/auth-audit.js +222 -0
  19. package/src/agents/jules/tools/dispatch.js +327 -0
  20. package/src/agents/jules/tools/file-edit.js +180 -0
  21. package/src/agents/jules/tools/file-read.js +100 -0
  22. package/src/agents/jules/tools/frontend-analyze.js +570 -0
  23. package/src/agents/jules/tools/glob.js +168 -0
  24. package/src/agents/jules/tools/grep.js +228 -0
  25. package/src/agents/jules/tools/index.js +29 -0
  26. package/src/agents/jules/tools/path-guards.js +161 -0
  27. package/src/agents/jules/tools/runtime-audit.js +409 -0
  28. package/src/agents/jules/tools/shell.js +383 -0
  29. package/src/ai/aidenid.js +945 -0
  30. package/src/ai/client.js +508 -0
  31. package/src/ai/domain-target-store.js +268 -0
  32. package/src/ai/identity-store.js +270 -0
  33. package/src/ai/site-store.js +145 -0
  34. package/src/audit/agents/architecture.js +180 -0
  35. package/src/audit/agents/compliance.js +179 -0
  36. package/src/audit/agents/documentation.js +165 -0
  37. package/src/audit/agents/performance.js +145 -0
  38. package/src/audit/agents/security.js +215 -0
  39. package/src/audit/agents/testing.js +172 -0
  40. package/src/audit/orchestrator.js +557 -0
  41. package/src/audit/package.js +204 -0
  42. package/src/audit/registry.js +284 -0
  43. package/src/audit/replay.js +103 -0
  44. package/src/auth/http.js +113 -0
  45. package/src/auth/service.js +848 -0
  46. package/src/auth/session-store.js +345 -0
  47. package/src/cli.js +244 -0
  48. package/src/commands/ai/identity-lifecycle.js +1337 -0
  49. package/src/commands/ai/provision-governance.js +1246 -0
  50. package/src/commands/ai/shared.js +147 -0
  51. package/src/commands/ai.js +11 -0
  52. package/src/commands/apply.js +19 -0
  53. package/src/commands/audit.js +1147 -0
  54. package/src/commands/auth.js +366 -0
  55. package/src/commands/chat.js +191 -0
  56. package/src/commands/config.js +184 -0
  57. package/src/commands/cost.js +311 -0
  58. package/src/commands/daemon/core.js +850 -0
  59. package/src/commands/daemon/extended.js +1048 -0
  60. package/src/commands/daemon/shared.js +213 -0
  61. package/src/commands/daemon.js +11 -0
  62. package/src/commands/guide.js +174 -0
  63. package/src/commands/ingest.js +58 -0
  64. package/src/commands/init.js +55 -0
  65. package/src/commands/legacy-args.js +30 -0
  66. package/src/commands/mcp.js +404 -0
  67. package/src/commands/omargate.js +21 -0
  68. package/src/commands/persona.js +27 -0
  69. package/src/commands/plugin.js +260 -0
  70. package/src/commands/policy.js +132 -0
  71. package/src/commands/prompt.js +238 -0
  72. package/src/commands/review.js +704 -0
  73. package/src/commands/scan.js +788 -0
  74. package/src/commands/spec.js +716 -0
  75. package/src/commands/swarm.js +651 -0
  76. package/src/commands/telemetry.js +202 -0
  77. package/src/commands/watch.js +510 -0
  78. package/src/config/agent-dictionary.js +182 -0
  79. package/src/config/io.js +56 -0
  80. package/src/config/paths.js +18 -0
  81. package/src/config/schema.js +55 -0
  82. package/src/config/service.js +184 -0
  83. package/src/cost/budget.js +235 -0
  84. package/src/cost/history.js +188 -0
  85. package/src/cost/tracker.js +171 -0
  86. package/src/daemon/artifact-lineage.js +534 -0
  87. package/src/daemon/assignment-ledger.js +770 -0
  88. package/src/daemon/ast-parser-layer.js +258 -0
  89. package/src/daemon/budget-governor.js +633 -0
  90. package/src/daemon/callgraph-overlay.js +646 -0
  91. package/src/daemon/error-worker.js +626 -0
  92. package/src/daemon/hybrid-mapper.js +929 -0
  93. package/src/daemon/jira-lifecycle.js +632 -0
  94. package/src/daemon/operator-control.js +657 -0
  95. package/src/daemon/reliability-lane.js +471 -0
  96. package/src/daemon/watchdog.js +971 -0
  97. package/src/guide/generator.js +316 -0
  98. package/src/ingest/engine.js +918 -0
  99. package/src/legacy-cli.js +2435 -0
  100. package/src/mcp/registry.js +695 -0
  101. package/src/memory/blackboard.js +301 -0
  102. package/src/memory/retrieval.js +581 -0
  103. package/src/plugin/manifest.js +553 -0
  104. package/src/policy/packs.js +144 -0
  105. package/src/prompt/generator.js +106 -0
  106. package/src/review/ai-review.js +669 -0
  107. package/src/review/local-review.js +1284 -0
  108. package/src/review/replay.js +235 -0
  109. package/src/review/report.js +664 -0
  110. package/src/review/spec-binding.js +487 -0
  111. package/src/scan/generator.js +351 -0
  112. package/src/spec/generator.js +519 -0
  113. package/src/spec/regenerate.js +237 -0
  114. package/src/spec/templates.js +91 -0
  115. package/src/swarm/dashboard.js +247 -0
  116. package/src/swarm/factory.js +363 -0
  117. package/src/swarm/pentest.js +934 -0
  118. package/src/swarm/registry.js +419 -0
  119. package/src/swarm/report.js +158 -0
  120. package/src/swarm/runtime.js +576 -0
  121. package/src/swarm/scenario-dsl.js +272 -0
  122. package/src/telemetry/ledger.js +302 -0
  123. package/src/ui/markdown.js +220 -0
  124. package/src/ui/progress.js +100 -0
@@ -0,0 +1,409 @@
1
+ import { execFileSync } from "node:child_process";
2
+ import path from "node:path";
3
+ import fs from "node:fs";
4
+ import os from "node:os";
5
+ import { randomUUID } from "node:crypto";
6
+
7
+ /**
8
+ * Jules Tanaka — Runtime Audit Tool
9
+ *
10
+ * Lighthouse performance scan + Chrome DevTools Protocol inspection.
11
+ * Requires: chrome/chromium available, lighthouse npm package.
12
+ * All operations are optional — gracefully degrade if deps unavailable.
13
+ */
14
+
15
+ const LIGHTHOUSE_TIMEOUT_MS = 120000;
16
+
17
+ /**
18
+ * @param {{ operation: string, url?: string, path?: string }} input
19
+ * @returns {object} Structured result per operation
20
+ */
21
+ export function runtimeAudit(input) {
22
+ if (!RUNTIME_OPS.has(input.operation)) {
23
+ throw new RuntimeAuditError(
24
+ "Unknown operation: " + input.operation + ". Valid: " + [...RUNTIME_OPS].join(", "),
25
+ );
26
+ }
27
+ return RUNTIME_DISPATCH[input.operation](input);
28
+ }
29
+
30
+ const RUNTIME_OPS = new Set([
31
+ "lighthouse_scan",
32
+ "check_response_headers",
33
+ "detect_deployed_url",
34
+ "check_console_errors",
35
+ "check_network_waterfall",
36
+ "check_dom_stats",
37
+ ]);
38
+
39
+ const RUNTIME_DISPATCH = {
40
+ lighthouse_scan: lighthouseScan,
41
+ check_response_headers: checkResponseHeaders,
42
+ detect_deployed_url: detectDeployedUrl,
43
+ check_console_errors: checkConsoleErrors,
44
+ check_network_waterfall: checkNetworkWaterfall,
45
+ check_dom_stats: checkDomStats,
46
+ };
47
+
48
+ /**
49
+ * Run Lighthouse via npx (no install required).
50
+ * Returns performance, accessibility, best-practices, SEO scores + key metrics.
51
+ */
52
+ function lighthouseScan(input) {
53
+ const url = input.url;
54
+ if (!url) {
55
+ throw new RuntimeAuditError("lighthouse_scan requires a url parameter");
56
+ }
57
+ if (!isValidUrl(url)) {
58
+ throw new RuntimeAuditError("Invalid URL: " + url);
59
+ }
60
+
61
+ try {
62
+ const outputPath = path.join(
63
+ input.path || process.cwd(),
64
+ ".sentinelayer",
65
+ "reports",
66
+ "lighthouse-" + Date.now() + ".json",
67
+ );
68
+ const outputDir = path.dirname(outputPath);
69
+ if (!fs.existsSync(outputDir)) fs.mkdirSync(outputDir, { recursive: true });
70
+
71
+ execFileSync("npx", [
72
+ "--yes", "lighthouse@12", url,
73
+ "--output", "json", "--output-path", outputPath,
74
+ "--chrome-flags=--headless --no-sandbox --disable-gpu", "--quiet",
75
+ ], {
76
+ encoding: "utf-8",
77
+ timeout: LIGHTHOUSE_TIMEOUT_MS,
78
+ stdio: ["pipe", "pipe", "pipe"],
79
+ });
80
+
81
+ if (!fs.existsSync(outputPath)) {
82
+ return { available: false, reason: "Lighthouse produced no output" };
83
+ }
84
+
85
+ const raw = JSON.parse(fs.readFileSync(outputPath, "utf-8"));
86
+ const categories = raw.categories || {};
87
+ const audits = raw.audits || {};
88
+
89
+ return {
90
+ available: true,
91
+ reportPath: outputPath,
92
+ scores: {
93
+ performance: categories.performance?.score ?? null,
94
+ accessibility: categories.accessibility?.score ?? null,
95
+ bestPractices: categories["best-practices"]?.score ?? null,
96
+ seo: categories.seo?.score ?? null,
97
+ },
98
+ metrics: {
99
+ lcp_ms: audits["largest-contentful-paint"]?.numericValue ?? null,
100
+ fcp_ms: audits["first-contentful-paint"]?.numericValue ?? null,
101
+ cls: audits["cumulative-layout-shift"]?.numericValue ?? null,
102
+ tbt_ms: audits["total-blocking-time"]?.numericValue ?? null,
103
+ si_ms: audits["speed-index"]?.numericValue ?? null,
104
+ tti_ms: audits["interactive"]?.numericValue ?? null,
105
+ },
106
+ opportunities: Object.values(audits)
107
+ .filter(a => a.details?.type === "opportunity" && a.details?.overallSavingsMs > 100)
108
+ .slice(0, 10)
109
+ .map(a => ({
110
+ id: a.id,
111
+ title: a.title,
112
+ savingsMs: a.details?.overallSavingsMs,
113
+ savingsBytes: a.details?.overallSavingsBytes,
114
+ })),
115
+ };
116
+ } catch (err) {
117
+ return {
118
+ available: false,
119
+ reason: "Lighthouse failed: " + (err.message || "").slice(0, 200),
120
+ };
121
+ }
122
+ }
123
+
124
+ /**
125
+ * Check HTTP response headers for security and performance headers.
126
+ * Uses curl (available on all platforms).
127
+ */
128
+ function checkResponseHeaders(input) {
129
+ const url = input.url;
130
+ if (!url) throw new RuntimeAuditError("check_response_headers requires a url");
131
+ if (!isValidUrl(url)) throw new RuntimeAuditError("Invalid URL: " + url);
132
+
133
+ try {
134
+ const safeUrl = sanitizeUrlForShell(url);
135
+ if (!safeUrl) throw new Error("URL sanitization failed");
136
+ const output = execFileSync("curl", ["-sI", "-L", "--max-time", "10", safeUrl], {
137
+ encoding: "utf-8", timeout: 15000, stdio: ["pipe", "pipe", "pipe"],
138
+ });
139
+
140
+ const headers = parseHeaders(output);
141
+ const securityHeaders = [
142
+ "content-security-policy", "x-frame-options", "x-content-type-options",
143
+ "strict-transport-security", "referrer-policy", "permissions-policy",
144
+ ];
145
+
146
+ const findings = [];
147
+ for (const h of securityHeaders) {
148
+ const present = headers[h] !== undefined;
149
+ if (!present) {
150
+ findings.push({
151
+ header: h,
152
+ present: false,
153
+ severity: h === "content-security-policy" ? "P1" : "P2",
154
+ });
155
+ }
156
+ }
157
+
158
+ return {
159
+ available: true,
160
+ url,
161
+ statusCode: parseInt(output.match(/HTTP\/[\d.]+ (\d+)/)?.[1] || "0"),
162
+ headers,
163
+ securityFindings: findings,
164
+ cookieFlags: extractCookieFlags(headers),
165
+ };
166
+ } catch (err) {
167
+ return { available: false, reason: "curl failed: " + err.message };
168
+ }
169
+ }
170
+
171
+ /**
172
+ * Try to detect a deployed URL from common config locations.
173
+ */
174
+ function detectDeployedUrl(input) {
175
+ const rootPath = input.path || process.cwd();
176
+ const candidates = [];
177
+
178
+ // Check env vars
179
+ for (const key of ["NEXT_PUBLIC_APP_URL", "VITE_APP_URL", "APP_URL", "BASE_URL", "DEPLOY_URL", "VERCEL_URL"]) {
180
+ if (process.env[key]) {
181
+ candidates.push({ source: "env:" + key, url: process.env[key] });
182
+ }
183
+ }
184
+
185
+ // Check package.json homepage
186
+ try {
187
+ const pkg = JSON.parse(fs.readFileSync(path.join(rootPath, "package.json"), "utf-8"));
188
+ if (pkg.homepage) candidates.push({ source: "package.json:homepage", url: pkg.homepage });
189
+ } catch { /* skip */ }
190
+
191
+ // Check vercel.json
192
+ try {
193
+ const vercel = JSON.parse(fs.readFileSync(path.join(rootPath, "vercel.json"), "utf-8"));
194
+ if (vercel.alias) {
195
+ const alias = Array.isArray(vercel.alias) ? vercel.alias[0] : vercel.alias;
196
+ candidates.push({ source: "vercel.json:alias", url: "https://" + alias });
197
+ }
198
+ } catch { /* skip */ }
199
+
200
+ // Check .env files for URLs
201
+ for (const envFile of [".env", ".env.local", ".env.production"]) {
202
+ try {
203
+ const content = fs.readFileSync(path.join(rootPath, envFile), "utf-8");
204
+ const urlMatch = content.match(/(?:APP_URL|BASE_URL|SITE_URL|DEPLOY_URL)\s*=\s*['"]?(https?:\/\/[^\s'"]+)/);
205
+ if (urlMatch) candidates.push({ source: envFile, url: urlMatch[1] });
206
+ } catch { /* skip */ }
207
+ }
208
+
209
+ return { candidates, found: candidates.length > 0, primary: candidates[0]?.url || null };
210
+ }
211
+
212
+ /**
213
+ * Check for console errors by loading the page with Playwright (if available).
214
+ * Falls back to a simple curl-based check.
215
+ */
216
+ function checkConsoleErrors(input) {
217
+ const url = input.url;
218
+ if (!url) throw new RuntimeAuditError("check_console_errors requires a url");
219
+ if (!isValidUrl(url)) throw new RuntimeAuditError("Invalid URL: " + url);
220
+
221
+ // Try playwright — URL passed via env var to prevent command injection
222
+ try {
223
+ const scriptPath = secureTempFile("sl-console-" + randomUUID().slice(0, 8) + ".cjs");
224
+ fs.writeFileSync(scriptPath, `
225
+ const { chromium } = require('playwright');
226
+ (async () => {
227
+ const targetUrl = process.env.SL_AUDIT_TARGET_URL;
228
+ if (!targetUrl) { console.log(JSON.stringify({ errors: [], title: '' })); process.exit(0); }
229
+ const browser = await chromium.launch({ headless: true });
230
+ const page = await browser.newPage();
231
+ const errors = [];
232
+ page.on('console', msg => { if (msg.type() === 'error') errors.push({ text: msg.text(), url: msg.location()?.url }); });
233
+ page.on('pageerror', err => errors.push({ text: err.message, type: 'uncaught' }));
234
+ try {
235
+ await page.goto(targetUrl, { waitUntil: 'networkidle', timeout: 30000 });
236
+ console.log(JSON.stringify({ errors, title: await page.title() }));
237
+ } finally {
238
+ await browser.close();
239
+ }
240
+ })();
241
+ `);
242
+ const output = execFileSync("node", [scriptPath], {
243
+ encoding: "utf-8", timeout: 45000,
244
+ stdio: ["pipe", "pipe", "pipe"],
245
+ env: { ...process.env, SL_AUDIT_TARGET_URL: url },
246
+ });
247
+ try { fs.unlinkSync(scriptPath); } catch { /* best effort */ }
248
+ try { fs.rmdirSync(path.dirname(scriptPath)); } catch { /* best effort */ }
249
+ const result = JSON.parse(output.trim());
250
+ return { available: true, method: "playwright", ...result };
251
+ } catch (playwrightErr) {
252
+ // Playwright not available — return instruction
253
+ return {
254
+ available: false,
255
+ reason: "Playwright not installed. Run: npx playwright install chromium",
256
+ recommendation: "Install playwright for console error capture",
257
+ };
258
+ }
259
+ }
260
+
261
+ /**
262
+ * Basic network waterfall check via curl timing.
263
+ */
264
+ function checkNetworkWaterfall(input) {
265
+ const url = input.url;
266
+ if (!url) throw new RuntimeAuditError("check_network_waterfall requires a url");
267
+ if (!isValidUrl(url)) throw new RuntimeAuditError("Invalid URL: " + url);
268
+
269
+ try {
270
+ // Write curl format to temp file to avoid shell quoting issues across platforms
271
+ const formatFile = secureTempFile("sl-curl-fmt-" + randomUUID().slice(0, 8) + ".txt");
272
+ fs.writeFileSync(formatFile, '{"dns_ms":%{time_namelookup},"connect_ms":%{time_connect},"tls_ms":%{time_appconnect},"ttfb_ms":%{time_starttransfer},"total_ms":%{time_total},"size_bytes":%{size_download},"status":%{http_code}}');
273
+ const safeUrl = sanitizeUrlForShell(url);
274
+ if (!safeUrl) { try { fs.unlinkSync(formatFile); } catch {} throw new Error("URL sanitization failed"); }
275
+ const output = execFileSync("curl", [
276
+ "-sL", "-o", devNull(), "-w", "@" + formatFile, "--max-time", "15", safeUrl,
277
+ ], { encoding: "utf-8", timeout: 20000, stdio: ["pipe", "pipe", "pipe"] });
278
+ try { fs.unlinkSync(formatFile); } catch { /* best effort */ }
279
+ try { fs.rmdirSync(path.dirname(formatFile)); } catch { /* best effort */ }
280
+ const timing = JSON.parse(output.trim());
281
+ // Convert seconds to milliseconds
282
+ for (const key of ["dns_ms", "connect_ms", "tls_ms", "ttfb_ms", "total_ms"]) {
283
+ timing[key] = Math.round(timing[key] * 1000);
284
+ }
285
+ return { available: true, url, timing };
286
+ } catch (err) {
287
+ return { available: false, reason: "curl timing failed: " + err.message };
288
+ }
289
+ }
290
+
291
+ /**
292
+ * Basic DOM stats (requires Playwright).
293
+ */
294
+ function checkDomStats(input) {
295
+ const url = input.url;
296
+ if (!url) throw new RuntimeAuditError("check_dom_stats requires a url");
297
+ if (!isValidUrl(url)) throw new RuntimeAuditError("Invalid URL: " + url);
298
+
299
+ // URL passed via env var to prevent command injection (CodeQL alert #51)
300
+ try {
301
+ const scriptPath = secureTempFile("sl-dom-" + randomUUID().slice(0, 8) + ".cjs");
302
+ fs.writeFileSync(scriptPath, `
303
+ const { chromium } = require('playwright');
304
+ (async () => {
305
+ const targetUrl = process.env.SL_AUDIT_TARGET_URL;
306
+ if (!targetUrl) { console.log(JSON.stringify({})); process.exit(0); }
307
+ const browser = await chromium.launch({ headless: true });
308
+ try {
309
+ const page = await browser.newPage();
310
+ await page.goto(targetUrl, { waitUntil: 'domcontentloaded', timeout: 30000 });
311
+ const stats = await page.evaluate(() => ({
312
+ nodeCount: document.querySelectorAll('*').length,
313
+ maxDepth: (function depth(el, d) { return Math.max(d, ...Array.from(el.children).map(c => depth(c, d+1))); })(document.body, 0),
314
+ imgCount: document.querySelectorAll('img').length,
315
+ imgWithoutAlt: document.querySelectorAll('img:not([alt])').length,
316
+ formCount: document.querySelectorAll('form').length,
317
+ inputWithoutLabel: document.querySelectorAll('input:not([aria-label]):not([id])').length,
318
+ title: document.title,
319
+ h1Count: document.querySelectorAll('h1').length,
320
+ linkCount: document.querySelectorAll('a').length,
321
+ }));
322
+ console.log(JSON.stringify(stats));
323
+ } finally {
324
+ await browser.close();
325
+ }
326
+ })();
327
+ `);
328
+ const output = execFileSync("node", [scriptPath], {
329
+ encoding: "utf-8", timeout: 45000,
330
+ stdio: ["pipe", "pipe", "pipe"],
331
+ env: { ...process.env, SL_AUDIT_TARGET_URL: url },
332
+ });
333
+ try { fs.unlinkSync(scriptPath); } catch { /* best effort */ }
334
+ try { fs.rmdirSync(path.dirname(scriptPath)); } catch { /* best effort */ }
335
+ return { available: true, method: "playwright", ...JSON.parse(output.trim()) };
336
+ } catch {
337
+ return { available: false, reason: "Playwright not installed" };
338
+ }
339
+ }
340
+
341
+ // ── Helpers ──────────────────────────────────────────────��───────────
342
+
343
+ function isValidUrl(url) {
344
+ try {
345
+ const parsed = new URL(url);
346
+ return parsed.protocol === "http:" || parsed.protocol === "https:";
347
+ } catch {
348
+ return false;
349
+ }
350
+ }
351
+
352
+ function parseHeaders(raw) {
353
+ const headers = {};
354
+ for (const line of raw.split("\n")) {
355
+ const colonIdx = line.indexOf(":");
356
+ if (colonIdx > 0) {
357
+ const key = line.slice(0, colonIdx).trim().toLowerCase();
358
+ const value = line.slice(colonIdx + 1).trim();
359
+ headers[key] = value;
360
+ }
361
+ }
362
+ return headers;
363
+ }
364
+
365
+ function extractCookieFlags(headers) {
366
+ const cookies = [];
367
+ const setCookies = Object.entries(headers).filter(([k]) => k === "set-cookie");
368
+ for (const [, value] of setCookies) {
369
+ cookies.push({
370
+ raw: value.slice(0, 100),
371
+ httpOnly: /httponly/i.test(value),
372
+ secure: /secure/i.test(value),
373
+ sameSite: value.match(/samesite=(\w+)/i)?.[1] || null,
374
+ });
375
+ }
376
+ return cookies;
377
+ }
378
+
379
+ function devNull() {
380
+ return process.platform === "win32" ? "NUL" : "/dev/null";
381
+ }
382
+
383
+ /**
384
+ * Create a temp file path with secure random name.
385
+ * Sets file permissions to 0o600 (owner read/write only) after creation.
386
+ */
387
+ function secureTempFile(name) {
388
+ // CodeQL requires mkdtempSync for secure temp file creation (unique random dir)
389
+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), "sl-rt-"));
390
+ return path.join(dir, name);
391
+ }
392
+
393
+ function sanitizeUrlForShell(url) {
394
+ // Only allow http/https URLs, strip any shell metacharacters
395
+ try {
396
+ const parsed = new URL(url);
397
+ if (parsed.protocol !== "http:" && parsed.protocol !== "https:") return "";
398
+ return parsed.href;
399
+ } catch {
400
+ return "";
401
+ }
402
+ }
403
+
404
+ export class RuntimeAuditError extends Error {
405
+ constructor(message) {
406
+ super(message);
407
+ this.name = "RuntimeAuditError";
408
+ }
409
+ }