@causyne/agent 1.20.31 → 1.20.33

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.
@@ -0,0 +1,413 @@
1
+ import { spawn } from 'node:child_process';
2
+ import { sidebarVisible, sessionMainWidth } from './sessionSidebar.js';
3
+ import { visibleWidth } from './text.js';
4
+ import type { MessageMarker } from './messageInteraction.js';
5
+
6
+ export interface DetectedLink {
7
+ url: string;
8
+ label: string;
9
+ startCol: number;
10
+ endCol: number;
11
+ row: number;
12
+ isOsc8: boolean;
13
+ }
14
+
15
+ export interface SmartLinkSurface {
16
+ width: number;
17
+ out: { rows?: number };
18
+ stage: { height: number; reserved: boolean };
19
+ viewport: { height: number; width: number; scrollTop: number };
20
+ transcript: { flatten(width: number): { rows: string[]; markers: MessageMarker[] } };
21
+ turnRailLayout?: { turns?: unknown[] } | null;
22
+ }
23
+
24
+ const KNOWN_WEB_TLDS = new Set([
25
+ 'com', 'org', 'net', 'io', 'dev', 'app', 'ai', 'co', 'edu', 'gov',
26
+ 'me', 'sh', 'xyz', 'tech', 'cloud', 'gg', 'tv', 'info', 'biz', 'page',
27
+ 'site', 'online', 'link', 'live', 'studio', 'design', 'so', 'to', 'fm',
28
+ 'id', 'uk', 'de', 'fr', 'jp', 'kr', 'au', 'ca', 'us', 'eu', 'in', 'sg'
29
+ ]);
30
+
31
+ const CODE_FILE_EXTENSIONS = new Set([
32
+ 'js', 'ts', 'jsx', 'tsx', 'mjs', 'cjs', 'py', 'rb', 'go', 'rs', 'java',
33
+ 'c', 'cpp', 'h', 'hpp', 'cs', 'php', 'swift', 'kt', 'scala', 'lua',
34
+ 'json', 'yaml', 'yml', 'toml', 'xml', 'ini', 'env', 'lock', 'md', 'txt',
35
+ 'css', 'scss', 'less', 'vue', 'svelte', 'astro', 'sql', 'graphql', 'proto',
36
+ 'wasm', 'map', 'png', 'jpg', 'jpeg', 'gif', 'svg', 'webp', 'ico', 'mp4',
37
+ 'mov', 'mp3', 'wav', 'ogg', 'pdf', 'zip', 'tar', 'gz', 'tgz'
38
+ ]);
39
+
40
+ const KNOWN_HOST_SUFFIXES = [
41
+ '.vercel.app',
42
+ '.netlify.app',
43
+ '.pages.dev',
44
+ '.github.io',
45
+ '.fly.dev',
46
+ '.railway.app',
47
+ '.render.com',
48
+ '.onrender.com',
49
+ '.herokuapp.com',
50
+ '.workers.dev',
51
+ '.web.app',
52
+ '.firebaseapp.com',
53
+ '.supabase.co',
54
+ '.amazonaws.com',
55
+ '.cloudfront.net',
56
+ 'vercel.com',
57
+ 'github.com',
58
+ 'gitlab.com',
59
+ 'npmjs.com',
60
+ 'pypi.org',
61
+ 'crates.io',
62
+ 'localhost'
63
+ ];
64
+
65
+ function stripTrailingPunctuation(raw: string): { clean: string; trimmedChars: number } {
66
+ let clean = raw;
67
+ let trimmedChars = 0;
68
+ while (clean.length > 0) {
69
+ const last = clean[clean.length - 1]!;
70
+ if (/[.,;:!?'"`\]>]/.test(last)) {
71
+ clean = clean.slice(0, -1);
72
+ trimmedChars++;
73
+ continue;
74
+ }
75
+ if (last === ')') {
76
+ const opens = (clean.match(/\(/g) || []).length;
77
+ const closes = (clean.match(/\)/g) || []).length;
78
+ if (closes > opens) {
79
+ clean = clean.slice(0, -1);
80
+ trimmedChars++;
81
+ continue;
82
+ }
83
+ }
84
+ break;
85
+ }
86
+ return { clean, trimmedChars };
87
+ }
88
+
89
+ function isLikelyBareWebDomain(token: string): boolean {
90
+ const withoutEllipsis = token.replace(/(?:…|\.{2,})+$/, '');
91
+ const slashIdx = withoutEllipsis.indexOf('/');
92
+ const hostPort = (slashIdx >= 0 ? withoutEllipsis.slice(0, slashIdx) : withoutEllipsis).toLowerCase();
93
+ const pathPart = slashIdx >= 0 ? withoutEllipsis.slice(slashIdx) : '';
94
+
95
+ if (/^(?:localhost|127\.0\.0\.1|0\.0\.0\.0):\d{2,5}$/.test(hostPort)) {
96
+ return true;
97
+ }
98
+
99
+ const host = hostPort.replace(/:\d{2,5}$/, '');
100
+ if (!host.includes('.') || host.startsWith('.') || host.endsWith('.')) return false;
101
+
102
+ for (const suffix of KNOWN_HOST_SUFFIXES) {
103
+ if (host === suffix || host.endsWith(suffix)) return true;
104
+ }
105
+
106
+ const parts = host.split('.');
107
+ if (parts.length < 2) return false;
108
+ const tld = parts[parts.length - 1]!;
109
+ if (!KNOWN_WEB_TLDS.has(tld)) return false;
110
+
111
+ if (!pathPart && CODE_FILE_EXTENSIONS.has(tld) && parts.length === 2) {
112
+ return false;
113
+ }
114
+
115
+ if (parts.some(p => !/^[a-z0-9-]+$/i.test(p) || p.startsWith('-') || p.endsWith('-'))) {
116
+ return false;
117
+ }
118
+
119
+ return true;
120
+ }
121
+
122
+ export function resolveFullUrlFromMessage(candidate: string, rawMessageText?: string): string {
123
+ const cleaned = candidate.trim();
124
+ const isTruncated = cleaned.endsWith('…') || cleaned.endsWith('...');
125
+ const prefix = cleaned
126
+ .replace(/(?:…|\.{2,})+$/, '')
127
+ .replace(/^https?:\/\//i, '')
128
+ .replace(/^www\./i, '');
129
+
130
+ if (rawMessageText && prefix.length >= 4) {
131
+ const urlRegex = /https?:\/\/[^\s<>"'`)\]]+/gi;
132
+ let match: RegExpExecArray | null;
133
+ while ((match = urlRegex.exec(rawMessageText)) !== null) {
134
+ const fullUrl = stripTrailingPunctuation(match[0]).clean;
135
+ const normalizedFull = fullUrl.replace(/^https?:\/\//i, '').replace(/^www\./i, '');
136
+ if (isTruncated) {
137
+ if (normalizedFull.startsWith(prefix)) return fullUrl;
138
+ } else if (normalizedFull === prefix) {
139
+ return fullUrl;
140
+ }
141
+ }
142
+ }
143
+
144
+ const withoutEllipsis = cleaned.replace(/(?:…|\.{2,})+$/, '');
145
+ if (/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//.test(withoutEllipsis)) {
146
+ return withoutEllipsis;
147
+ }
148
+ if (/^(?:localhost|127\.0\.0\.1|0\.0\.0\.0):\d{2,5}/i.test(withoutEllipsis)) {
149
+ return `http://${withoutEllipsis}`;
150
+ }
151
+ return `https://${withoutEllipsis}`;
152
+ }
153
+
154
+ function findUnclosedOsc8Url(rawRow: string | undefined): string | null {
155
+ if (!rawRow || !rawRow.includes('\x1b]8;')) return null;
156
+ let active: string | null = null;
157
+ const osc8Re = /\x1b\]8;[^;]*;([^\x07\x1b]*)(?:\x07|\x1b\\)/g;
158
+ let match: RegExpExecArray | null;
159
+ while ((match = osc8Re.exec(rawRow)) !== null) {
160
+ const target = match[1] ?? '';
161
+ active = target.length > 0 ? target : null;
162
+ }
163
+ return active;
164
+ }
165
+
166
+ /**
167
+ * Extract all clickable links (both OSC 8 hyperlinks and visible URLs / bare domains)
168
+ * along with their exact visible column intervals `[startCol, endCol]` on a single row.
169
+ */
170
+ export function extractRowLinks(
171
+ rawRow: string,
172
+ rowIndex = 0,
173
+ rawMessageText?: string,
174
+ prevRawRow?: string
175
+ ): DetectedLink[] {
176
+ if (!rawRow) return [];
177
+ const links: DetectedLink[] = [];
178
+
179
+ let col = 0;
180
+ let i = 0;
181
+ let activeOsc8Url: string | null = findUnclosedOsc8Url(prevRawRow);
182
+ let osc8StartCol = 0;
183
+ let osc8Label = '';
184
+
185
+ const charToColStart: number[] = [];
186
+ const charToColEnd: number[] = [];
187
+ let stripped = '';
188
+
189
+ while (i < rawRow.length) {
190
+ if (rawRow.startsWith('\x1b]8;', i)) {
191
+ const rest = rawRow.slice(i + 4);
192
+ const semi = rest.indexOf(';');
193
+ if (semi !== -1) {
194
+ const afterParams = rest.slice(semi + 1);
195
+ const belIdx = afterParams.indexOf('\x07');
196
+ const stIdx = afterParams.indexOf('\x1b\\');
197
+ let endOffset = -1;
198
+ let terminatorLen = 0;
199
+ if (belIdx !== -1 && (stIdx === -1 || belIdx < stIdx)) {
200
+ endOffset = belIdx;
201
+ terminatorLen = 1;
202
+ } else if (stIdx !== -1) {
203
+ endOffset = stIdx;
204
+ terminatorLen = 2;
205
+ }
206
+ if (endOffset !== -1) {
207
+ const urlParam = afterParams.slice(0, endOffset);
208
+ if (urlParam.length > 0) {
209
+ activeOsc8Url = urlParam;
210
+ osc8StartCol = col;
211
+ osc8Label = '';
212
+ } else if (activeOsc8Url) {
213
+ if (col > osc8StartCol) {
214
+ const resolved = resolveFullUrlFromMessage(
215
+ activeOsc8Url.endsWith('…') ? osc8Label || activeOsc8Url : activeOsc8Url,
216
+ rawMessageText
217
+ );
218
+ links.push({
219
+ url: resolved,
220
+ label: osc8Label,
221
+ startCol: osc8StartCol,
222
+ endCol: col - 1,
223
+ row: rowIndex,
224
+ isOsc8: true
225
+ });
226
+ }
227
+ activeOsc8Url = null;
228
+ osc8Label = '';
229
+ }
230
+ i += 4 + semi + 1 + endOffset + terminatorLen;
231
+ continue;
232
+ }
233
+ }
234
+ }
235
+
236
+ if (rawRow[i] === '\x1b') {
237
+ const csi = /^\x1b\[[0-?]*[ -/]*[@-~]/.exec(rawRow.slice(i));
238
+ if (csi) {
239
+ i += csi[0].length;
240
+ continue;
241
+ }
242
+ const osc = /^\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)/.exec(rawRow.slice(i));
243
+ if (osc) {
244
+ i += osc[0].length;
245
+ continue;
246
+ }
247
+ i++;
248
+ continue;
249
+ }
250
+
251
+ const code = rawRow.codePointAt(i)!;
252
+ const ch = String.fromCodePoint(code);
253
+ const w = Math.max(0, visibleWidth(ch));
254
+ charToColStart.push(col);
255
+ charToColEnd.push(w > 0 ? col + w - 1 : col);
256
+ stripped += ch;
257
+ if (activeOsc8Url) osc8Label += ch;
258
+ col += w;
259
+ i += ch.length;
260
+ }
261
+
262
+ if (activeOsc8Url && col > osc8StartCol) {
263
+ const resolved = resolveFullUrlFromMessage(
264
+ activeOsc8Url.endsWith('…') ? osc8Label || activeOsc8Url : activeOsc8Url,
265
+ rawMessageText
266
+ );
267
+ links.push({
268
+ url: resolved,
269
+ label: osc8Label,
270
+ startCol: osc8StartCol,
271
+ endCol: col - 1,
272
+ row: rowIndex,
273
+ isOsc8: true
274
+ });
275
+ }
276
+
277
+ const tokenRe = /(?:https?:\/\/|file:\/\/)[^\s<>"'`)\]]+|(?:localhost|127\.0\.0\.1|0\.0\.0\.0):\d{2,5}(?:\/[^\s<>"'`)\]]*)?|(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,24}(?:\/[^\s<>"'`)\]]*)?/g;
278
+ let tokenMatch: RegExpExecArray | null;
279
+ while ((tokenMatch = tokenRe.exec(stripped)) !== null) {
280
+ const rawToken = tokenMatch[0];
281
+ const { clean } = stripTrailingPunctuation(rawToken);
282
+ if (!clean) continue;
283
+
284
+ const isExplicitScheme = /^(?:https?|file):\/\//i.test(clean);
285
+ if (!isExplicitScheme && !isLikelyBareWebDomain(clean)) continue;
286
+
287
+ const startCharIdx = Array.from(stripped.slice(0, tokenMatch.index)).length;
288
+ const cleanCodePoints = Array.from(clean).length;
289
+ const endCharIdx = startCharIdx + cleanCodePoints - 1;
290
+ const startCol = charToColStart[startCharIdx];
291
+ const endCol = charToColEnd[endCharIdx];
292
+ if (startCol === undefined || endCol === undefined) continue;
293
+
294
+ const overlapsOsc8 = links.some(
295
+ existing => existing.isOsc8 && startCol <= existing.endCol && endCol >= existing.startCol
296
+ );
297
+ if (overlapsOsc8) continue;
298
+
299
+ const resolvedUrl = resolveFullUrlFromMessage(clean, rawMessageText);
300
+ links.push({
301
+ url: resolvedUrl,
302
+ label: clean,
303
+ startCol,
304
+ endCol,
305
+ row: rowIndex,
306
+ isOsc8: false
307
+ });
308
+ }
309
+
310
+ return links;
311
+ }
312
+
313
+ /**
314
+ * Check if a screen point `(point.x, point.y)` lands on a clickable URL/link in the transcript.
315
+ */
316
+ export function detectLinkAtPoint(
317
+ surface: SmartLinkSurface | null,
318
+ point: { x: number; y: number },
319
+ marker?: MessageMarker | null
320
+ ): DetectedLink | null {
321
+ if (!surface?.stage.reserved || !Number.isFinite(point.x) || !Number.isFinite(point.y)) return null;
322
+ const mainWidth = sidebarVisible(surface.width) ? sessionMainWidth(surface.width) : surface.width;
323
+ const leftGutter = (surface.turnRailLayout?.turns?.length ?? 0) > 0 ? 3 : 0;
324
+ if (point.x < leftGutter || point.x >= Math.min(mainWidth, surface.viewport.width + leftGutter)) return null;
325
+
326
+ const top = Math.max(0, (surface.out.rows || surface.stage.height) - surface.stage.height);
327
+ const viewRow = point.y - top;
328
+ if (viewRow < 0 || viewRow >= surface.viewport.height) return null;
329
+
330
+ const flat = surface.transcript.flatten(surface.viewport.width);
331
+ const visible = Math.max(0, Math.min(surface.viewport.height, flat.rows.length - surface.viewport.scrollTop));
332
+ const padding = surface.viewport.height - visible;
333
+ if (viewRow < padding) return null;
334
+
335
+ const row = surface.viewport.scrollTop + viewRow - padding;
336
+ const rawRow = flat.rows[row];
337
+ if (!rawRow) return null;
338
+
339
+ const prevRawRow = row > 0 ? flat.rows[row - 1] : undefined;
340
+ const rawMessageText = marker?.meta?.messageText;
341
+ const links = extractRowLinks(rawRow, row, rawMessageText, prevRawRow);
342
+ if (!links.length) return null;
343
+
344
+ const col = point.x - leftGutter;
345
+ for (const link of links) {
346
+ if (col >= link.startCol && col <= link.endCol) {
347
+ return link;
348
+ }
349
+ }
350
+ return null;
351
+ }
352
+
353
+ let lastOpenedUrl = '';
354
+ let lastOpenedAt = 0;
355
+
356
+ export interface OpenLinkOptions {
357
+ platform?: NodeJS.Platform;
358
+ spawnImpl?: typeof spawn;
359
+ now?: number;
360
+ debounceMs?: number;
361
+ }
362
+
363
+ /**
364
+ * Open an HTTP/HTTPS/file URL in the system default browser or handler without blocking the TUI.
365
+ */
366
+ export function openDetectedLink(url: string, options: OpenLinkOptions = {}): boolean {
367
+ if (!url || !/^(?:https?|file):\/\//i.test(url)) return false;
368
+
369
+ const now = options.now ?? Date.now();
370
+ const debounceMs = options.debounceMs ?? 800;
371
+ if (url === lastOpenedUrl && now - lastOpenedAt < debounceMs) {
372
+ return true;
373
+ }
374
+ lastOpenedUrl = url;
375
+ lastOpenedAt = now;
376
+
377
+ const platform = options.platform ?? process.platform;
378
+ const spawnFn = options.spawnImpl ?? spawn;
379
+
380
+ let command: string;
381
+ let args: string[];
382
+ if (platform === 'darwin') {
383
+ command = 'open';
384
+ args = [url];
385
+ } else if (platform === 'win32') {
386
+ command = 'rundll32.exe';
387
+ args = ['url.dll,FileProtocolHandler', url];
388
+ } else {
389
+ command = 'xdg-open';
390
+ args = [url];
391
+ }
392
+
393
+ try {
394
+ const child = spawnFn(command, args, {
395
+ detached: true,
396
+ stdio: 'ignore',
397
+ shell: false,
398
+ windowsHide: true
399
+ });
400
+ child.on?.('error', () => {
401
+ // Ignore missing browser opener errors on headless hosts.
402
+ });
403
+ child.unref?.();
404
+ return true;
405
+ } catch {
406
+ return false;
407
+ }
408
+ }
409
+
410
+ export function resetLinkOpenDebounceForTests(): void {
411
+ lastOpenedUrl = '';
412
+ lastOpenedAt = 0;
413
+ }
@@ -24,6 +24,10 @@ const CREATIVE_MUTATORS = new Set([
24
24
  'blender_act', 'creative_apps', 'execute_procedural_media', 'generate_media_via_api',
25
25
  'native_engine', 'resolve_act', 'palmier_act', 'game_audio_synth'
26
26
  ]);
27
+ const READ_ONLY_CREATIVE_ACTIONS = new Set([
28
+ 'discover', 'status', 'inspect', 'inspectactive', 'verify', 'verify_bridge',
29
+ 'pipeline_plan', 'probe', 'list', 'info', 'check', 'ping', 'health'
30
+ ]);
27
31
  const WEB_PATH = /\.(?:html?|css|scss|jsx|tsx|vue|svelte)$/i;
28
32
  const CODE_PATH = /\.(?:[cm]?[jt]s|py|rb|php|go|rs|java|kt|kts|swift|c|cc|cpp|h|hpp|cs|sh|sql)$/i;
29
33
  const DOCUMENT_PATH = /\.(?:pdf|docx?|pptx?|odt|rtf|epub)$/i;
@@ -32,11 +36,21 @@ const RUN_COMMAND = /^\s*(?:node|python3?|ruby|php|deno|bun|go\s+run|cargo\s+run
32
36
  const MEDIA_PROBE = /\b(?:ffprobe|afinfo|soxi|identify|mediainfo|exiftool)\b/i;
33
37
  const READBACK_TOOLS = new Set(['pdf_read', 'fs_read', 'view_image', 'vision_inspect_ui', 'screenshot']);
34
38
  const LOOK_TOOLS = new Set(['view_image', 'vision_inspect_ui', 'screenshot']);
39
+ function isCreativeMutation(outcome) {
40
+ if (!CREATIVE_MUTATORS.has(outcome.tool))
41
+ return false;
42
+ if (outcome.args?.simulate === true || outcome.args?.dryRun === true)
43
+ return false;
44
+ const action = String(outcome.args?.action ?? outcome.args?.operation ?? '').toLowerCase().trim();
45
+ if (action && READ_ONLY_CREATIVE_ACTIONS.has(action))
46
+ return false;
47
+ return true;
48
+ }
35
49
  function isMutation(outcome) {
36
50
  if (!outcome.success)
37
51
  return false;
38
52
  const tool = outcome.tool;
39
- if (CODE_MUTATORS.has(tool) || CREATIVE_MUTATORS.has(tool))
53
+ if (CODE_MUTATORS.has(tool) || isCreativeMutation(outcome))
40
54
  return true;
41
55
  if (tool === 'document_forge')
42
56
  return true;
@@ -47,7 +61,7 @@ function domainsOf(input, mutations) {
47
61
  for (const outcome of mutations) {
48
62
  const tool = outcome.tool;
49
63
  const target = outcome.path || '';
50
- if (CREATIVE_MUTATORS.has(tool))
64
+ if (isCreativeMutation(outcome))
51
65
  found.add('creative');
52
66
  else if (tool === 'document_forge' || DOCUMENT_PATH.test(target))
53
67
  found.add('document');
@@ -68,7 +82,7 @@ function after(outcomes, domain) {
68
82
  return false;
69
83
  const target = outcome.path || '';
70
84
  switch (domain) {
71
- case 'creative': return CREATIVE_MUTATORS.has(outcome.tool);
85
+ case 'creative': return isCreativeMutation(outcome);
72
86
  case 'document': return outcome.tool === 'document_forge' || DOCUMENT_PATH.test(target);
73
87
  case 'web': return CODE_MUTATORS.has(outcome.tool) && WEB_PATH.test(target);
74
88
  case 'code': return CODE_MUTATORS.has(outcome.tool) && CODE_PATH.test(target);
@@ -87,7 +101,8 @@ function satisfied(domain, evidence) {
87
101
  return ok.some((outcome) => outcome.rendered === true);
88
102
  case 'creative':
89
103
  return ok.some((outcome) => outcome.observedImage === true
90
- || MEDIA_PROBE.test(outcome.command));
104
+ || MEDIA_PROBE.test(outcome.command)
105
+ || (outcome.tool === 'native_engine' && ['probe', 'inspect', 'verify', 'status'].includes(String(outcome.args?.action ?? '').toLowerCase())));
91
106
  case 'document':
92
107
  return ok.some((outcome) => outcome.observedImage === true
93
108
  || (['pdf_read', 'fs_read'].includes(outcome.tool) && DOCUMENT_PATH.test(outcome.path)));
@@ -51,6 +51,10 @@ const CREATIVE_MUTATORS = new Set([
51
51
  'blender_act', 'creative_apps', 'execute_procedural_media', 'generate_media_via_api',
52
52
  'native_engine', 'resolve_act', 'palmier_act', 'game_audio_synth'
53
53
  ]);
54
+ const READ_ONLY_CREATIVE_ACTIONS = new Set([
55
+ 'discover', 'status', 'inspect', 'inspectactive', 'verify', 'verify_bridge',
56
+ 'pipeline_plan', 'probe', 'list', 'info', 'check', 'ping', 'health'
57
+ ]);
54
58
 
55
59
  const WEB_PATH = /\.(?:html?|css|scss|jsx|tsx|vue|svelte)$/i;
56
60
  const CODE_PATH = /\.(?:[cm]?[jt]s|py|rb|php|go|rs|java|kt|kts|swift|c|cc|cpp|h|hpp|cs|sh|sql)$/i;
@@ -63,10 +67,18 @@ const MEDIA_PROBE = /\b(?:ffprobe|afinfo|soxi|identify|mediainfo|exiftool)\b/i;
63
67
  const READBACK_TOOLS = new Set(['pdf_read', 'fs_read', 'view_image', 'vision_inspect_ui', 'screenshot']);
64
68
  const LOOK_TOOLS = new Set(['view_image', 'vision_inspect_ui', 'screenshot']);
65
69
 
70
+ function isCreativeMutation(outcome: ToolOutcome): boolean {
71
+ if (!CREATIVE_MUTATORS.has(outcome.tool)) return false;
72
+ if (outcome.args?.simulate === true || outcome.args?.dryRun === true) return false;
73
+ const action = String(outcome.args?.action ?? outcome.args?.operation ?? '').toLowerCase().trim();
74
+ if (action && READ_ONLY_CREATIVE_ACTIONS.has(action)) return false;
75
+ return true;
76
+ }
77
+
66
78
  function isMutation(outcome: ToolOutcome): boolean {
67
79
  if (!outcome.success) return false;
68
80
  const tool = outcome.tool;
69
- if (CODE_MUTATORS.has(tool) || CREATIVE_MUTATORS.has(tool)) return true;
81
+ if (CODE_MUTATORS.has(tool) || isCreativeMutation(outcome)) return true;
70
82
  if (tool === 'document_forge') return true;
71
83
  return false;
72
84
  }
@@ -76,7 +88,7 @@ function domainsOf(input: VerificationInput, mutations: readonly ToolOutcome[]):
76
88
  for (const outcome of mutations) {
77
89
  const tool = outcome.tool;
78
90
  const target = outcome.path || '';
79
- if (CREATIVE_MUTATORS.has(tool)) found.add('creative');
91
+ if (isCreativeMutation(outcome)) found.add('creative');
80
92
  else if (tool === 'document_forge' || DOCUMENT_PATH.test(target)) found.add('document');
81
93
  else if (CODE_MUTATORS.has(tool)) {
82
94
  if (WEB_PATH.test(target)) found.add('web');
@@ -92,7 +104,7 @@ function after(outcomes: readonly ToolOutcome[], domain: VerificationDomain): re
92
104
  if (!isMutation(outcome)) return false;
93
105
  const target = outcome.path || '';
94
106
  switch (domain) {
95
- case 'creative': return CREATIVE_MUTATORS.has(outcome.tool);
107
+ case 'creative': return isCreativeMutation(outcome);
96
108
  case 'document': return outcome.tool === 'document_forge' || DOCUMENT_PATH.test(target);
97
109
  case 'web': return CODE_MUTATORS.has(outcome.tool) && WEB_PATH.test(target);
98
110
  case 'code': return CODE_MUTATORS.has(outcome.tool) && CODE_PATH.test(target);
@@ -112,7 +124,8 @@ function satisfied(domain: VerificationDomain, evidence: readonly ToolOutcome[])
112
124
  return ok.some((outcome) => outcome.rendered === true);
113
125
  case 'creative':
114
126
  return ok.some((outcome) => outcome.observedImage === true
115
- || MEDIA_PROBE.test(outcome.command));
127
+ || MEDIA_PROBE.test(outcome.command)
128
+ || (outcome.tool === 'native_engine' && ['probe', 'inspect', 'verify', 'status'].includes(String(outcome.args?.action ?? '').toLowerCase())));
116
129
  case 'document':
117
130
  return ok.some((outcome) => outcome.observedImage === true
118
131
  || (['pdf_read', 'fs_read'].includes(outcome.tool) && DOCUMENT_PATH.test(outcome.path)));