sentinelayer-cli 0.4.4 → 0.6.2

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 (149) hide show
  1. package/README.md +996 -998
  2. package/bin/create-sentinelayer.js +5 -5
  3. package/bin/sentinelayer-cli.js +4 -4
  4. package/bin/sl.js +5 -5
  5. package/package.json +63 -63
  6. package/src/agents/jules/config/definition.js +160 -209
  7. package/src/agents/jules/config/system-prompt.js +182 -175
  8. package/src/agents/jules/error-intake.js +51 -51
  9. package/src/agents/jules/fix-cycle.js +17 -377
  10. package/src/agents/jules/loop.js +450 -367
  11. package/src/agents/jules/pulse.js +10 -327
  12. package/src/agents/jules/stream.js +186 -186
  13. package/src/agents/jules/swarm/file-scanner.js +74 -74
  14. package/src/agents/jules/swarm/index.js +11 -11
  15. package/src/agents/jules/swarm/orchestrator.js +362 -362
  16. package/src/agents/jules/swarm/pattern-hunter.js +123 -123
  17. package/src/agents/jules/swarm/sub-agent.js +309 -308
  18. package/src/agents/jules/tools/aidenid-email.js +189 -0
  19. package/src/agents/jules/tools/auth-audit.js +1691 -557
  20. package/src/agents/jules/tools/dispatch.js +335 -327
  21. package/src/agents/jules/tools/file-edit.js +2 -180
  22. package/src/agents/jules/tools/file-read.js +2 -100
  23. package/src/agents/jules/tools/frontend-analyze.js +570 -570
  24. package/src/agents/jules/tools/glob.js +2 -168
  25. package/src/agents/jules/tools/grep.js +2 -228
  26. package/src/agents/jules/tools/index.js +29 -29
  27. package/src/agents/jules/tools/path-guards.js +2 -161
  28. package/src/agents/jules/tools/runtime-audit.js +507 -503
  29. package/src/agents/jules/tools/shell.js +2 -383
  30. package/src/agents/jules/tools/url-policy.js +100 -100
  31. package/src/agents/persona-visuals.js +61 -0
  32. package/src/agents/shared-tools/dispatch-core.js +315 -0
  33. package/src/agents/shared-tools/file-edit.js +180 -0
  34. package/src/agents/shared-tools/file-read.js +100 -0
  35. package/src/agents/shared-tools/glob.js +168 -0
  36. package/src/agents/shared-tools/grep.js +228 -0
  37. package/src/agents/shared-tools/index.js +46 -0
  38. package/src/agents/shared-tools/path-guards.js +161 -0
  39. package/src/agents/shared-tools/shell.js +383 -0
  40. package/src/ai/aidenid.js +1009 -972
  41. package/src/ai/client.js +553 -508
  42. package/src/ai/domain-target-store.js +268 -268
  43. package/src/ai/identity-store.js +270 -270
  44. package/src/ai/proxy.js +137 -0
  45. package/src/ai/site-store.js +145 -145
  46. package/src/audit/agents/architecture.js +180 -180
  47. package/src/audit/agents/compliance.js +179 -179
  48. package/src/audit/agents/documentation.js +165 -165
  49. package/src/audit/agents/performance.js +145 -145
  50. package/src/audit/agents/security.js +215 -215
  51. package/src/audit/agents/testing.js +172 -172
  52. package/src/audit/orchestrator.js +557 -557
  53. package/src/audit/package.js +204 -204
  54. package/src/audit/registry.js +284 -284
  55. package/src/audit/replay.js +103 -103
  56. package/src/auth/gate.js +371 -126
  57. package/src/auth/http.js +611 -270
  58. package/src/auth/service.js +1106 -891
  59. package/src/auth/session-store.js +813 -359
  60. package/src/cli.js +252 -252
  61. package/src/commands/ai/identity-lifecycle.js +1338 -1338
  62. package/src/commands/ai/provision-governance.js +1272 -1272
  63. package/src/commands/ai/shared.js +147 -147
  64. package/src/commands/ai.js +11 -11
  65. package/src/commands/apply.js +12 -12
  66. package/src/commands/audit.js +1166 -1166
  67. package/src/commands/auth.js +419 -375
  68. package/src/commands/chat.js +191 -191
  69. package/src/commands/config.js +184 -184
  70. package/src/commands/cost.js +311 -311
  71. package/src/commands/daemon/core.js +850 -850
  72. package/src/commands/daemon/extended.js +1048 -1048
  73. package/src/commands/daemon/shared.js +213 -213
  74. package/src/commands/daemon.js +11 -11
  75. package/src/commands/guide.js +174 -174
  76. package/src/commands/ingest.js +58 -58
  77. package/src/commands/init.js +55 -55
  78. package/src/commands/legacy-args.js +10 -10
  79. package/src/commands/mcp.js +461 -461
  80. package/src/commands/omargate.js +29 -21
  81. package/src/commands/persona.js +20 -20
  82. package/src/commands/plugin.js +260 -260
  83. package/src/commands/policy.js +132 -132
  84. package/src/commands/prompt.js +238 -238
  85. package/src/commands/review.js +704 -704
  86. package/src/commands/scan.js +872 -866
  87. package/src/commands/spec.js +716 -716
  88. package/src/commands/swarm.js +651 -651
  89. package/src/commands/telemetry.js +202 -202
  90. package/src/commands/watch.js +511 -510
  91. package/src/config/agent-dictionary.js +182 -182
  92. package/src/config/io.js +56 -56
  93. package/src/config/paths.js +18 -18
  94. package/src/config/schema.js +55 -55
  95. package/src/config/service.js +184 -184
  96. package/src/cost/budget.js +235 -235
  97. package/src/cost/history.js +188 -188
  98. package/src/cost/tracker.js +171 -171
  99. package/src/daemon/artifact-lineage.js +534 -534
  100. package/src/daemon/assignment-ledger.js +770 -770
  101. package/src/daemon/ast-parser-layer.js +258 -258
  102. package/src/daemon/budget-governor.js +633 -633
  103. package/src/daemon/callgraph-overlay.js +646 -646
  104. package/src/daemon/error-worker.js +626 -626
  105. package/src/daemon/fix-cycle.js +377 -0
  106. package/src/daemon/hybrid-mapper.js +929 -929
  107. package/src/daemon/jira-lifecycle.js +632 -632
  108. package/src/daemon/operator-control.js +657 -657
  109. package/src/daemon/pulse.js +327 -0
  110. package/src/daemon/reliability-lane.js +471 -471
  111. package/src/daemon/watchdog.js +971 -971
  112. package/src/guide/generator.js +316 -316
  113. package/src/ingest/engine.js +918 -918
  114. package/src/interactive/index.js +97 -95
  115. package/src/legacy-cli.js +2994 -2592
  116. package/src/mcp/registry.js +695 -695
  117. package/src/memory/blackboard.js +301 -301
  118. package/src/memory/retrieval.js +581 -581
  119. package/src/plugin/manifest.js +553 -553
  120. package/src/policy/packs.js +144 -144
  121. package/src/prompt/generator.js +118 -118
  122. package/src/review/ai-review.js +679 -669
  123. package/src/review/local-review.js +1305 -1295
  124. package/src/review/omargate-interactive.js +68 -0
  125. package/src/review/omargate-orchestrator.js +300 -0
  126. package/src/review/persona-prompts.js +296 -0
  127. package/src/review/replay.js +235 -235
  128. package/src/review/report.js +664 -664
  129. package/src/review/scan-modes.js +42 -0
  130. package/src/review/spec-binding.js +487 -487
  131. package/src/scaffold/generator.js +67 -67
  132. package/src/scaffold/templates.js +150 -150
  133. package/src/scan/generator.js +418 -418
  134. package/src/scan/gh-secrets.js +107 -107
  135. package/src/spec/generator.js +519 -519
  136. package/src/spec/regenerate.js +237 -237
  137. package/src/spec/templates.js +91 -91
  138. package/src/swarm/dashboard.js +247 -247
  139. package/src/swarm/factory.js +363 -363
  140. package/src/swarm/pentest.js +934 -934
  141. package/src/swarm/registry.js +419 -419
  142. package/src/swarm/report.js +158 -158
  143. package/src/swarm/runtime.js +576 -576
  144. package/src/swarm/scenario-dsl.js +272 -272
  145. package/src/telemetry/ledger.js +302 -302
  146. package/src/telemetry/session-tracker.js +234 -118
  147. package/src/telemetry/sync.js +203 -199
  148. package/src/ui/command-hints.js +13 -0
  149. package/src/ui/markdown.js +220 -220
@@ -1,383 +1,2 @@
1
- import { execSync } from "node:child_process";
2
- import path from "node:path";
3
-
4
- const DEFAULT_TIMEOUT_MS = 120_000;
5
- const MAX_OUTPUT_CHARS = 30_000;
6
- const DEFAULT_ALLOWED_FETCH_HOSTS = [
7
- "github.com",
8
- "api.github.com",
9
- "raw.githubusercontent.com",
10
- "*.githubusercontent.com",
11
- "registry.npmjs.org",
12
- "registry.yarnpkg.com",
13
- "pypi.org",
14
- "files.pythonhosted.org",
15
- "rubygems.org",
16
- "crates.io",
17
- "static.crates.io",
18
- ];
19
-
20
- /**
21
- * Patterns that are BLOCKED unconditionally.
22
- * Sourced from review/local-review.js security rules + src bash security patterns.
23
- */
24
- const BLOCKED_PATTERNS = [
25
- { pattern: /rm\s+(-[rR]f?|--recursive)\s+\/($|\s)/, desc: "rm -rf /" },
26
- { pattern: /:\(\)\s*\{[^}]*\}\s*;?\s*:/, desc: "fork bomb" },
27
- { pattern: /\beval\s*\(/, desc: "eval injection" },
28
- { pattern: /curl[^|]*\|\s*(ba)?sh/, desc: "pipe to shell" },
29
- { pattern: /wget[^|]*\|\s*(ba)?sh/, desc: "wget pipe to shell" },
30
- { pattern: />\s*\/dev\/sd[a-z]/, desc: "write to raw device" },
31
- { pattern: /mkfs\./, desc: "filesystem format" },
32
- { pattern: /dd\s+.*of=\/dev\//, desc: "dd to device" },
33
- { pattern: /chmod\s+777\s+\//, desc: "chmod 777 root" },
34
- { pattern: />\s*\/etc\//, desc: "write to /etc" },
35
- { pattern: /rm\s+-rf?\s+~/, desc: "rm home directory" },
36
- { pattern: /git\s+push\s+.*--force\s+.*main/, desc: "force push to main" },
37
- { pattern: /git\s+reset\s+--hard/, desc: "git reset hard" },
38
- { pattern: /DROP\s+TABLE|DROP\s+DATABASE/i, desc: "SQL drop" },
39
- { pattern: /TRUNCATE\s+TABLE/i, desc: "SQL truncate" },
40
- ];
41
-
42
- /**
43
- * Patterns that trigger a WARNING but are allowed.
44
- */
45
- const WARN_PATTERNS = [
46
- { pattern: /npm\s+install|yarn\s+add|pnpm\s+add/, desc: "package install" },
47
- { pattern: /git\s+push/, desc: "git push" },
48
- { pattern: /curl\s|wget\s|fetch\(/, desc: "network request" },
49
- { pattern: /rm\s+-/, desc: "file deletion" },
50
- { pattern: /sudo\s/, desc: "elevated privileges" },
51
- ];
52
-
53
- /**
54
- * Environment variables to strip from child process env.
55
- * Prevents credential leakage to spawned commands.
56
- */
57
- const EXACT_ENV_KEYS_TO_STRIP = new Set([
58
- "ANTHROPIC_API_KEY",
59
- "OPENAI_API_KEY",
60
- "GOOGLE_API_KEY",
61
- "GEMINI_API_KEY",
62
- "SENTINELAYER_TOKEN",
63
- "AIDENID_API_KEY",
64
- "AIDENID_TOKEN",
65
- "AWS_ACCESS_KEY_ID",
66
- "AWS_SECRET_ACCESS_KEY",
67
- "AWS_SESSION_TOKEN",
68
- "AWS_WEB_IDENTITY_TOKEN_FILE",
69
- "AZURE_CLIENT_SECRET",
70
- "GOOGLE_APPLICATION_CREDENTIALS",
71
- "GITHUB_TOKEN",
72
- "GH_TOKEN",
73
- "GITLAB_TOKEN",
74
- "BITBUCKET_TOKEN",
75
- "NPM_TOKEN",
76
- "NODE_AUTH_TOKEN",
77
- "PYPI_API_TOKEN",
78
- "RUBYGEMS_API_KEY",
79
- "CARGO_REGISTRY_TOKEN",
80
- "ACTIONS_ID_TOKEN_REQUEST_TOKEN",
81
- "ACTIONS_RUNTIME_TOKEN",
82
- "CI_JOB_TOKEN",
83
- "CI_JOB_JWT",
84
- "STRIPE_SECRET_KEY",
85
- "SLACK_BOT_TOKEN",
86
- "TELEGRAM_BOT_TOKEN",
87
- "DISCORD_BOT_TOKEN",
88
- "TWILIO_AUTH_TOKEN",
89
- "SENDGRID_API_KEY",
90
- "RESEND_API_KEY",
91
- "DATABASE_URL",
92
- "REDIS_URL",
93
- "MONGODB_URI",
94
- "SSH_SIGNING_KEY",
95
- "SSH_PRIVATE_KEY",
96
- "KUBECONFIG",
97
- "KUBE_CONFIG_DATA",
98
- ]);
99
-
100
- const ENV_KEY_PREFIX_PATTERNS = [
101
- /^AIDENID_/i,
102
- /^SENTINELAYER_/i,
103
- /^OPENAI_/i,
104
- /^ANTHROPIC_/i,
105
- /^GOOGLE_/i,
106
- /^GITHUB_/i,
107
- /^GH_/i,
108
- /^AWS_/i,
109
- /^AZURE_/i,
110
- /^SLACK_/i,
111
- /^STRIPE_/i,
112
- /^TELEGRAM_/i,
113
- /^DISCORD_/i,
114
- /^TWILIO_/i,
115
- /^SENDGRID_/i,
116
- /^RESEND_/i,
117
- ];
118
-
119
- const ENV_KEY_SUFFIX_PATTERNS = [
120
- /_TOKEN$/i,
121
- /_API_KEY$/i,
122
- /_SECRET$/i,
123
- /_SECRET_KEY$/i,
124
- /_PASSWORD$/i,
125
- /_PRIVATE_KEY$/i,
126
- /_ACCESS_KEY$/i,
127
- /_AUTH_TOKEN$/i,
128
- /_SESSION_TOKEN$/i,
129
- ];
130
-
131
- /**
132
- * Execute a shell command with security analysis, timeout, and env scrubbing.
133
- *
134
- * @param {object} input
135
- * @param {string} input.command - The shell command to execute.
136
- * @param {string} [input.cwd] - Working directory (default: process.cwd()).
137
- * @param {number} [input.timeout] - Timeout in ms (default: 120000).
138
- * @returns {{ stdout, stderr, exitCode, durationMs, command, security }}
139
- */
140
- export function shell(input) {
141
- if (!input.command || typeof input.command !== "string") {
142
- throw new ShellError("command is required and must be a non-empty string.");
143
- }
144
-
145
- const command = input.command.trim();
146
- const cwd = input.cwd ? path.resolve(input.cwd) : process.cwd();
147
- const timeout = input.timeout ?? DEFAULT_TIMEOUT_MS;
148
-
149
- // Security analysis
150
- const security = analyzeCommand(command);
151
- if (security.risk === "blocked") {
152
- throw new ShellBlockedError(
153
- `Command blocked: ${security.patterns[0].desc}`,
154
- security,
155
- );
156
- }
157
-
158
- // Build scrubbed environment
159
- const env = buildScrubbedEnv();
160
-
161
- const startMs = Date.now();
162
- let stdout = "";
163
- let stderr = "";
164
- let exitCode = 0;
165
-
166
- try {
167
- stdout = execSync(command, {
168
- cwd,
169
- encoding: "utf-8",
170
- timeout,
171
- env,
172
- maxBuffer: 10 * 1024 * 1024,
173
- stdio: ["pipe", "pipe", "pipe"],
174
- });
175
- } catch (err) {
176
- exitCode = err.status ?? 1;
177
- stdout = err.stdout ?? "";
178
- stderr = err.stderr ?? "";
179
- if (err.killed) {
180
- stderr += `\n[Process killed: timeout after ${timeout}ms]`;
181
- }
182
- }
183
-
184
- const durationMs = Date.now() - startMs;
185
-
186
- // Truncate large outputs
187
- if (stdout.length > MAX_OUTPUT_CHARS) {
188
- stdout = stdout.slice(0, MAX_OUTPUT_CHARS) + "\n[... truncated]";
189
- }
190
- if (stderr.length > MAX_OUTPUT_CHARS) {
191
- stderr = stderr.slice(0, MAX_OUTPUT_CHARS) + "\n[... truncated]";
192
- }
193
-
194
- return { stdout, stderr, exitCode, durationMs, command, security };
195
- }
196
-
197
- /**
198
- * Analyze a command for security risks.
199
- * @param {object} [options]
200
- * @param {Record<string, string|undefined>} [options.env]
201
- * @returns {{ risk: "safe"|"warn"|"blocked", patterns: Array<{desc}>, networkPolicy?: object }}
202
- */
203
- export function analyzeCommand(command, options = {}) {
204
- const networkPolicy = evaluateNetworkPolicy(command, options.env);
205
- if (networkPolicy.blocking) {
206
- return {
207
- risk: "blocked",
208
- patterns: [{ desc: networkPolicy.reason }],
209
- networkPolicy,
210
- };
211
- }
212
-
213
- for (const rule of BLOCKED_PATTERNS) {
214
- if (rule.pattern.test(command)) {
215
- return { risk: "blocked", patterns: [rule], networkPolicy };
216
- }
217
- }
218
-
219
- const warnings = [];
220
- for (const rule of WARN_PATTERNS) {
221
- if (rule.pattern.test(command)) {
222
- warnings.push(rule);
223
- }
224
- }
225
-
226
- if (warnings.length > 0) {
227
- return { risk: "warn", patterns: warnings, networkPolicy };
228
- }
229
-
230
- return { risk: "safe", patterns: [], networkPolicy };
231
- }
232
-
233
- export function buildScrubbedEnv(sourceEnv = process.env) {
234
- const env = { ...sourceEnv };
235
- for (const key of Object.keys(env)) {
236
- if (shouldStripEnvKey(key)) {
237
- delete env[key];
238
- }
239
- }
240
- return env;
241
- }
242
-
243
- function shouldStripEnvKey(key) {
244
- if (!key) {
245
- return false;
246
- }
247
-
248
- const upperKey = String(key).toUpperCase();
249
- if (EXACT_ENV_KEYS_TO_STRIP.has(upperKey)) {
250
- return true;
251
- }
252
-
253
- if (upperKey.startsWith("INPUT_")) {
254
- const baseKey = upperKey.slice("INPUT_".length);
255
- if (EXACT_ENV_KEYS_TO_STRIP.has(baseKey)) {
256
- return true;
257
- }
258
- if (ENV_KEY_PREFIX_PATTERNS.some((pattern) => pattern.test(baseKey))) {
259
- return true;
260
- }
261
- if (ENV_KEY_SUFFIX_PATTERNS.some((pattern) => pattern.test(baseKey))) {
262
- return true;
263
- }
264
- }
265
-
266
- if (ENV_KEY_PREFIX_PATTERNS.some((pattern) => pattern.test(upperKey))) {
267
- return true;
268
- }
269
-
270
- return ENV_KEY_SUFFIX_PATTERNS.some((pattern) => pattern.test(upperKey));
271
- }
272
-
273
- function evaluateNetworkPolicy(command, sourceEnv = process.env) {
274
- if (!/\b(curl|wget)\b/i.test(command)) {
275
- return {
276
- blocking: false,
277
- hosts: [],
278
- deniedHosts: [],
279
- };
280
- }
281
-
282
- const hosts = extractNetworkHosts(command);
283
- if (hosts.length === 0) {
284
- return {
285
- blocking: true,
286
- hosts: [],
287
- deniedHosts: [],
288
- reason: "network command requires explicit URL host",
289
- };
290
- }
291
-
292
- const allowlist = resolveAllowedFetchHosts(sourceEnv);
293
- const deniedHosts = hosts.filter((host) => !isAllowedHost(host, allowlist));
294
- if (deniedHosts.length > 0) {
295
- return {
296
- blocking: true,
297
- hosts,
298
- deniedHosts,
299
- reason: `network host not allowlisted: ${deniedHosts.join(", ")}`,
300
- };
301
- }
302
-
303
- return {
304
- blocking: false,
305
- hosts,
306
- deniedHosts: [],
307
- };
308
- }
309
-
310
- function resolveAllowedFetchHosts(sourceEnv = process.env) {
311
- const configured = String(sourceEnv.SENTINELAYER_ALLOWED_FETCH_HOSTS || "")
312
- .split(",")
313
- .map((item) => normalizeHostPattern(item))
314
- .filter(Boolean);
315
-
316
- const allPatterns = [...DEFAULT_ALLOWED_FETCH_HOSTS, ...configured]
317
- .map((item) => normalizeHostPattern(item))
318
- .filter(Boolean);
319
- return Array.from(new Set(allPatterns));
320
- }
321
-
322
- function extractNetworkHosts(command) {
323
- const matches = command.matchAll(/\bhttps?:\/\/([^\s"'`]+)/gi);
324
- const hosts = new Set();
325
- for (const match of matches) {
326
- const candidate = match?.[0];
327
- if (!candidate) {
328
- continue;
329
- }
330
- try {
331
- const parsed = new URL(candidate);
332
- const host = normalizeHostPattern(parsed.hostname);
333
- if (host) {
334
- hosts.add(host);
335
- }
336
- } catch {
337
- // Skip malformed URL segments.
338
- }
339
- }
340
- return Array.from(hosts);
341
- }
342
-
343
- function isAllowedHost(host, allowlist) {
344
- const normalizedHost = normalizeHostPattern(host);
345
- if (!normalizedHost) {
346
- return false;
347
- }
348
-
349
- return allowlist.some((pattern) => {
350
- if (!pattern) {
351
- return false;
352
- }
353
-
354
- if (pattern.startsWith("*.")) {
355
- const suffix = pattern.slice(2);
356
- return normalizedHost === suffix || normalizedHost.endsWith(`.${suffix}`);
357
- }
358
-
359
- return normalizedHost === pattern;
360
- });
361
- }
362
-
363
- function normalizeHostPattern(value) {
364
- return String(value || "")
365
- .trim()
366
- .toLowerCase()
367
- .replace(/\.$/, "");
368
- }
369
-
370
- export class ShellError extends Error {
371
- constructor(message) {
372
- super(message);
373
- this.name = "ShellError";
374
- }
375
- }
376
-
377
- export class ShellBlockedError extends ShellError {
378
- constructor(message, security) {
379
- super(message);
380
- this.name = "ShellBlockedError";
381
- this.security = security;
382
- }
383
- }
1
+ // Re-export from shared tools. Shell is not Jules-specific.
2
+ export { shell, analyzeCommand, buildScrubbedEnv, ShellError, ShellBlockedError } from "../../shared-tools/shell.js";
@@ -1,100 +1,100 @@
1
- const PRIVATE_HOST_SUFFIXES = [".internal", ".local", ".localhost"];
2
- const BLOCKED_LITERAL_HOSTS = new Set([
3
- "localhost",
4
- "127.0.0.1",
5
- "::1",
6
- "0.0.0.0",
7
- "169.254.169.254",
8
- "metadata.google.internal",
9
- "metadata.google.internal.",
10
- ]);
11
-
12
- function isNumericIpv4(hostname) {
13
- const parts = String(hostname || "").split(".");
14
- if (parts.length !== 4) {
15
- return false;
16
- }
17
- return parts.every((part) => /^[0-9]{1,3}$/.test(part) && Number(part) >= 0 && Number(part) <= 255);
18
- }
19
-
20
- function isPrivateIpv4(hostname) {
21
- if (!isNumericIpv4(hostname)) {
22
- return false;
23
- }
24
- const parts = hostname.split(".").map((part) => Number(part));
25
- const [a, b] = parts;
26
- if (a === 10 || a === 127 || a === 0) return true;
27
- if (a === 169 && b === 254) return true;
28
- if (a === 172 && b >= 16 && b <= 31) return true;
29
- if (a === 192 && b === 168) return true;
30
- if (a === 100 && b >= 64 && b <= 127) return true;
31
- if (a === 198 && (b === 18 || b === 19)) return true;
32
- return false;
33
- }
34
-
35
- function isPrivateIpv6(hostname) {
36
- const normalized = String(hostname || "").toLowerCase().split("%")[0];
37
- if (!normalized.includes(":")) {
38
- return false;
39
- }
40
- if (normalized === "::1" || normalized === "::") {
41
- return true;
42
- }
43
- if (normalized.startsWith("fc") || normalized.startsWith("fd")) {
44
- return true;
45
- }
46
- if (normalized.startsWith("fe8") || normalized.startsWith("fe9") || normalized.startsWith("fea") || normalized.startsWith("feb")) {
47
- return true;
48
- }
49
- return false;
50
- }
51
-
52
- function isPrivateHostname(hostname) {
53
- const normalized = String(hostname || "").toLowerCase();
54
- if (!normalized) {
55
- return true;
56
- }
57
- if (BLOCKED_LITERAL_HOSTS.has(normalized)) {
58
- return true;
59
- }
60
- if (PRIVATE_HOST_SUFFIXES.some((suffix) => normalized.endsWith(suffix))) {
61
- return true;
62
- }
63
- if (isPrivateIpv4(normalized) || isPrivateIpv6(normalized)) {
64
- return true;
65
- }
66
- return false;
67
- }
68
-
69
- function isPrivateTargetBypassEnabled(allowPrivateTargets) {
70
- if (allowPrivateTargets === true) {
71
- return true;
72
- }
73
- if (process.env.SENTINELAYER_ALLOW_PRIVATE_AUDIT_TARGETS === "1") {
74
- return true;
75
- }
76
- if (process.env.NODE_ENV === "test") {
77
- return true;
78
- }
79
- return false;
80
- }
81
-
82
- export function assertPermittedAuditTarget(urlValue, options = {}) {
83
- const { operation = "audit", allowPrivateTargets = false } = options;
84
- let parsed;
85
- try {
86
- parsed = new URL(urlValue);
87
- } catch {
88
- throw new Error("Invalid URL: " + urlValue);
89
- }
90
- if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
91
- throw new Error("Invalid URL: " + parsed.toString());
92
- }
93
- if (!isPrivateTargetBypassEnabled(allowPrivateTargets) && isPrivateHostname(parsed.hostname)) {
94
- throw new Error(
95
- `Blocked private audit target for ${operation}: ${parsed.hostname}. ` +
96
- "Set allowPrivateTargets=true or SENTINELAYER_ALLOW_PRIVATE_AUDIT_TARGETS=1 to override."
97
- );
98
- }
99
- return parsed;
100
- }
1
+ const PRIVATE_HOST_SUFFIXES = [".internal", ".local", ".localhost"];
2
+ const BLOCKED_LITERAL_HOSTS = new Set([
3
+ "localhost",
4
+ "127.0.0.1",
5
+ "::1",
6
+ "0.0.0.0",
7
+ "169.254.169.254",
8
+ "metadata.google.internal",
9
+ "metadata.google.internal.",
10
+ ]);
11
+
12
+ function isNumericIpv4(hostname) {
13
+ const parts = String(hostname || "").split(".");
14
+ if (parts.length !== 4) {
15
+ return false;
16
+ }
17
+ return parts.every((part) => /^[0-9]{1,3}$/.test(part) && Number(part) >= 0 && Number(part) <= 255);
18
+ }
19
+
20
+ function isPrivateIpv4(hostname) {
21
+ if (!isNumericIpv4(hostname)) {
22
+ return false;
23
+ }
24
+ const parts = hostname.split(".").map((part) => Number(part));
25
+ const [a, b] = parts;
26
+ if (a === 10 || a === 127 || a === 0) return true;
27
+ if (a === 169 && b === 254) return true;
28
+ if (a === 172 && b >= 16 && b <= 31) return true;
29
+ if (a === 192 && b === 168) return true;
30
+ if (a === 100 && b >= 64 && b <= 127) return true;
31
+ if (a === 198 && (b === 18 || b === 19)) return true;
32
+ return false;
33
+ }
34
+
35
+ function isPrivateIpv6(hostname) {
36
+ const normalized = String(hostname || "").toLowerCase().split("%")[0];
37
+ if (!normalized.includes(":")) {
38
+ return false;
39
+ }
40
+ if (normalized === "::1" || normalized === "::") {
41
+ return true;
42
+ }
43
+ if (normalized.startsWith("fc") || normalized.startsWith("fd")) {
44
+ return true;
45
+ }
46
+ if (normalized.startsWith("fe8") || normalized.startsWith("fe9") || normalized.startsWith("fea") || normalized.startsWith("feb")) {
47
+ return true;
48
+ }
49
+ return false;
50
+ }
51
+
52
+ function isPrivateHostname(hostname) {
53
+ const normalized = String(hostname || "").toLowerCase();
54
+ if (!normalized) {
55
+ return true;
56
+ }
57
+ if (BLOCKED_LITERAL_HOSTS.has(normalized)) {
58
+ return true;
59
+ }
60
+ if (PRIVATE_HOST_SUFFIXES.some((suffix) => normalized.endsWith(suffix))) {
61
+ return true;
62
+ }
63
+ if (isPrivateIpv4(normalized) || isPrivateIpv6(normalized)) {
64
+ return true;
65
+ }
66
+ return false;
67
+ }
68
+
69
+ function isPrivateTargetBypassEnabled(allowPrivateTargets) {
70
+ if (allowPrivateTargets === true) {
71
+ return true;
72
+ }
73
+ if (process.env.SENTINELAYER_ALLOW_PRIVATE_AUDIT_TARGETS === "1") {
74
+ return true;
75
+ }
76
+ if (process.env.NODE_ENV === "test") {
77
+ return true;
78
+ }
79
+ return false;
80
+ }
81
+
82
+ export function assertPermittedAuditTarget(urlValue, options = {}) {
83
+ const { operation = "audit", allowPrivateTargets = false } = options;
84
+ let parsed;
85
+ try {
86
+ parsed = new URL(urlValue);
87
+ } catch {
88
+ throw new Error("Invalid URL: " + urlValue);
89
+ }
90
+ if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
91
+ throw new Error("Invalid URL: " + parsed.toString());
92
+ }
93
+ if (!isPrivateTargetBypassEnabled(allowPrivateTargets) && isPrivateHostname(parsed.hostname)) {
94
+ throw new Error(
95
+ `Blocked private audit target for ${operation}: ${parsed.hostname}. ` +
96
+ "Set allowPrivateTargets=true or SENTINELAYER_ALLOW_PRIVATE_AUDIT_TARGETS=1 to override."
97
+ );
98
+ }
99
+ return parsed;
100
+ }
@@ -0,0 +1,61 @@
1
+ /**
2
+ * SentinelLayer Persona Visual Identity Registry
3
+ *
4
+ * All 13 personas — visual identity, domain specialty, and bias.
5
+ * Shared across all persona packages, daemon services, and orchestrators.
6
+ * NOT Jules-specific — this is platform infrastructure.
7
+ */
8
+
9
+ export const PERSONA_VISUALS = Object.freeze({
10
+ frontend: { color: "cyan", avatar: "\u{1F3AF}", shortName: "Jules", fullName: "Jules Tanaka", domain: "frontend_runtime", specialty: "React/Next.js/Vue production specialist — hydration safety, render cost, accessibility, bundle weight, mobile responsiveness", bias: "user-perceived performance over vanity optimization" },
11
+ security: { color: "red", avatar: "\u{1F6E1}\uFE0F", shortName: "Nina", fullName: "Nina Patel", domain: "security_overlay", specialty: "AuthZ breaks, secret exposure, injection paths, policy bypass, externally reachable abuse conditions", bias: "assume hostile inputs until proven safe" },
12
+ backend: { color: "blue", avatar: "\u2699\uFE0F", shortName: "Maya", fullName: "Maya Volkov", domain: "backend_runtime", specialty: "Unsafe request handling, runtime crashes, unbounded work, validation gaps, server-side trust boundary failures", bias: "every request is potentially adversarial" },
13
+ testing: { color: "green", avatar: "\u{1F9EA}", shortName: "Priya", fullName: "Priya Raman", domain: "testing_correctness", specialty: "Missing regression coverage, false confidence from shallow tests, broken invariants with no executable proof", bias: "tests that pass but miss real bugs are worse than no tests" },
14
+ release: { color: "yellow", avatar: "\u{1F680}", shortName: "Omar", fullName: "Omar Singh", domain: "release_engineering", specialty: "CI/CD integrity, workflow trust, artifact provenance, bypassable gates, unsafe deployment automation", bias: "every deployment is a security boundary" },
15
+ "code-quality": { color: "purple", avatar: "\u{1F48E}", shortName: "Ethan", fullName: "Ethan Park", domain: "code_quality", specialty: "Complexity hotspots, unsafe shortcuts, brittle structure, maintenance risks that hide future defects", bias: "simplicity is a security feature" },
16
+ infrastructure: { color: "orange", avatar: "\u{1F3D7}\uFE0F", shortName: "Kat", fullName: "Kat Hughes", domain: "infrastructure", specialty: "IAM blast radius, public exposure, network posture, secrets placement, infrastructure policy drift", bias: "least privilege by default, explicit escalation required" },
17
+ data: { color: "pink", avatar: "\u{1F5C4}\uFE0F", shortName: "Linh", fullName: "Linh Tran", domain: "data_layer", specialty: "Query safety, migration drift, integrity failures, tenancy leaks, schema/application mismatches", bias: "data integrity is non-negotiable" },
18
+ observability: { color: "magenta", avatar: "\u{1F4CA}", shortName: "Sofia", fullName: "Sofia Alvarez", domain: "observability", specialty: "Missing telemetry, broken alerting, weak auditability, blind spots that hide failures or attacks", bias: "if you can't observe it, you can't secure it" },
19
+ reliability: { color: "white", avatar: "\u{1F504}", shortName: "Noah", fullName: "Noah Ben-David", domain: "reliability_sre", specialty: "Timeout safety, retry storms, backlog growth, partial failure handling, operational blast radius", bias: "graceful degradation over silent failure" },
20
+ documentation: { color: "gray", avatar: "\u{1F4DD}", shortName: "Samir", fullName: "Samir Okafor", domain: "docs_knowledge", specialty: "Operational drift between docs and code, missing runbook steps, misleading instructions that break operators", bias: "documentation is a contract, not decoration" },
21
+ "supply-chain": { color: "brown", avatar: "\u{1F4E6}", shortName: "Nora", fullName: "Nora Kline", domain: "supply_chain", specialty: "Dependency risk, provenance gaps, pinning drift, artifact trust, compromised build inputs", bias: "every dependency is a trust decision" },
22
+ "ai-governance": { color: "violet", avatar: "\u{1F916}", shortName: "Amina", fullName: "Amina Chen", domain: "ai_pipeline", specialty: "Prompt injection, tool abuse, eval regressions, unsafe model routing, guardrail bypass, policy drift in agentic flows", bias: "AI autonomy requires proportional governance" },
23
+ });
24
+
25
+ /**
26
+ * Resolve persona visual identity by agent ID or persona name.
27
+ */
28
+ export function resolvePersonaVisual(idOrName) {
29
+ if (!idOrName) return null;
30
+ const lower = String(idOrName).toLowerCase();
31
+
32
+ // Direct ID match
33
+ if (PERSONA_VISUALS[lower]) return { id: lower, ...PERSONA_VISUALS[lower] };
34
+
35
+ // Name match (first name or full name)
36
+ for (const [id, visual] of Object.entries(PERSONA_VISUALS)) {
37
+ if (visual.shortName.toLowerCase() === lower || visual.fullName.toLowerCase() === lower) {
38
+ return { id, ...visual };
39
+ }
40
+ }
41
+
42
+ return null;
43
+ }
44
+
45
+ /**
46
+ * List all persona IDs for autocomplete.
47
+ */
48
+ export function listPersonaIds() {
49
+ return Object.keys(PERSONA_VISUALS);
50
+ }
51
+
52
+ /**
53
+ * List all persona names (short + full) for autocomplete.
54
+ */
55
+ export function listPersonaNames() {
56
+ const names = [];
57
+ for (const [id, visual] of Object.entries(PERSONA_VISUALS)) {
58
+ names.push(id, visual.shortName.toLowerCase(), visual.fullName.toLowerCase());
59
+ }
60
+ return names;
61
+ }