@causyne/agent 1.20.29 → 1.20.31

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@causyne/agent",
3
- "version": "1.20.29",
3
+ "version": "1.20.31",
4
4
  "description": "Agentic AI for software, tools, and computer workflows",
5
5
  "main": "bin/causyne.js",
6
6
  "type": "module",
package/src/acp/client.js CHANGED
@@ -485,7 +485,7 @@ export class AcpClient {
485
485
  pending.notifyActivity?.();
486
486
  }
487
487
  }
488
- inspectPeerDiagnostics(sessionId) {
488
+ inspectPeerDiagnostics(sessionId, sinceEpochMs) {
489
489
  if (this.exitError) {
490
490
  return this.exitError.message;
491
491
  }
@@ -517,13 +517,13 @@ export class AcpClient {
517
517
  const isOpencode = cmd.includes('opencode')
518
518
  || (this.options.args && this.options.args.some(a => String(a).toLowerCase().includes('opencode')));
519
519
  if (isOpencode) {
520
- const opencodeErr = this.inspectOpencodeLog(sessionId);
520
+ const opencodeErr = this.inspectOpencodeLog(sessionId, sinceEpochMs);
521
521
  if (opencodeErr)
522
522
  return opencodeErr;
523
523
  }
524
524
  return null;
525
525
  }
526
- inspectOpencodeLog(sessionId) {
526
+ inspectOpencodeLog(sessionId, sinceEpochMs) {
527
527
  try {
528
528
  const logPath = path.join(os.homedir(), '.local', 'share', 'opencode', 'log', 'opencode.log');
529
529
  if (!fsSync.existsSync(logPath))
@@ -548,6 +548,19 @@ export class AcpClient {
548
548
  continue;
549
549
  if (sessionId && !line.includes(sessionId))
550
550
  continue;
551
+ // Ignore normal stream cancellations triggered by session/cancel after <tool_call> detection
552
+ if (/\berror=Aborted\b|\bAbortError\b|\bMessageAbortedError\b/i.test(line)) {
553
+ continue;
554
+ }
555
+ if (sinceEpochMs !== undefined) {
556
+ const tsMatch = line.match(/timestamp=([^\s]+)/);
557
+ if (tsMatch?.[1]) {
558
+ const lineEpochMs = Date.parse(tsMatch[1]);
559
+ if (Number.isFinite(lineEpochMs) && lineEpochMs < sinceEpochMs - 250) {
560
+ continue;
561
+ }
562
+ }
563
+ }
551
564
  if (line.includes('level=ERROR') || line.includes('AI_APICallError') || line.includes('Free usage limit reached') || line.includes('AI_RetryError')) {
552
565
  const match = line.match(/error\.error="([^"]+)"/) || line.match(/message="([^"]+)"/);
553
566
  if (match && match[1]) {
@@ -570,6 +583,7 @@ export class AcpClient {
570
583
  if (this.exitError)
571
584
  return Promise.reject(this.exitError);
572
585
  const id = this.nextId++;
586
+ const requestStartMs = Date.now();
573
587
  return new Promise((resolve, reject) => {
574
588
  let inactivityTimer;
575
589
  let snifferInterval;
@@ -589,7 +603,7 @@ export class AcpClient {
589
603
  const timer = setTimeout(() => {
590
604
  cleanup();
591
605
  this.pending.delete(id);
592
- const diag = this.inspectPeerDiagnostics(options?.sessionId);
606
+ const diag = this.inspectPeerDiagnostics(options?.sessionId, requestStartMs);
593
607
  if (diag) {
594
608
  reject(new Error(`ACP Peer Agent (${this.options.command}) Error: ${diag}`));
595
609
  }
@@ -608,7 +622,7 @@ export class AcpClient {
608
622
  inactivityTimer = setTimeout(() => {
609
623
  cleanup();
610
624
  this.pending.delete(id);
611
- const diag = this.inspectPeerDiagnostics(options?.sessionId);
625
+ const diag = this.inspectPeerDiagnostics(options?.sessionId, requestStartMs);
612
626
  if (diag) {
613
627
  reject(new Error(`ACP Peer Agent (${this.options.command}) Error: ${diag}`));
614
628
  }
@@ -622,7 +636,7 @@ export class AcpClient {
622
636
  const sid = options?.sessionId;
623
637
  if (sid) {
624
638
  snifferInterval = setInterval(() => {
625
- const fatalDiag = this.inspectPeerDiagnostics(sid);
639
+ const fatalDiag = this.inspectPeerDiagnostics(sid, requestStartMs);
626
640
  if (fatalDiag) {
627
641
  cleanup();
628
642
  clearTimeout(timer);
package/src/acp/client.ts CHANGED
@@ -549,7 +549,7 @@ export class AcpClient {
549
549
  }
550
550
  }
551
551
 
552
- inspectPeerDiagnostics(sessionId?: string): string | null {
552
+ inspectPeerDiagnostics(sessionId?: string, sinceEpochMs?: number): string | null {
553
553
  if (this.exitError) {
554
554
  return this.exitError.message;
555
555
  }
@@ -580,13 +580,13 @@ export class AcpClient {
580
580
  const isOpencode = cmd.includes('opencode')
581
581
  || (this.options.args && this.options.args.some(a => String(a).toLowerCase().includes('opencode')));
582
582
  if (isOpencode) {
583
- const opencodeErr = this.inspectOpencodeLog(sessionId);
583
+ const opencodeErr = this.inspectOpencodeLog(sessionId, sinceEpochMs);
584
584
  if (opencodeErr) return opencodeErr;
585
585
  }
586
586
  return null;
587
587
  }
588
588
 
589
- private inspectOpencodeLog(sessionId?: string): string | null {
589
+ private inspectOpencodeLog(sessionId?: string, sinceEpochMs?: number): string | null {
590
590
  try {
591
591
  const logPath = path.join(os.homedir(), '.local', 'share', 'opencode', 'log', 'opencode.log');
592
592
  if (!fsSync.existsSync(logPath)) return null;
@@ -606,6 +606,19 @@ export class AcpClient {
606
606
  const line = lines[i];
607
607
  if (!line) continue;
608
608
  if (sessionId && !line.includes(sessionId)) continue;
609
+ // Ignore normal stream cancellations triggered by session/cancel after <tool_call> detection
610
+ if (/\berror=Aborted\b|\bAbortError\b|\bMessageAbortedError\b/i.test(line)) {
611
+ continue;
612
+ }
613
+ if (sinceEpochMs !== undefined) {
614
+ const tsMatch = line.match(/timestamp=([^\s]+)/);
615
+ if (tsMatch?.[1]) {
616
+ const lineEpochMs = Date.parse(tsMatch[1]);
617
+ if (Number.isFinite(lineEpochMs) && lineEpochMs < sinceEpochMs - 250) {
618
+ continue;
619
+ }
620
+ }
621
+ }
609
622
  if (line.includes('level=ERROR') || line.includes('AI_APICallError') || line.includes('Free usage limit reached') || line.includes('AI_RetryError')) {
610
623
  const match = line.match(/error\.error="([^"]+)"/) || line.match(/message="([^"]+)"/);
611
624
  if (match && match[1]) {
@@ -631,6 +644,7 @@ export class AcpClient {
631
644
  if (!this.child || this.closed) return Promise.reject(new Error('agent process is not running'));
632
645
  if (this.exitError) return Promise.reject(this.exitError);
633
646
  const id = this.nextId++;
647
+ const requestStartMs = Date.now();
634
648
  return new Promise<T>((resolve, reject) => {
635
649
  let inactivityTimer: NodeJS.Timeout | undefined;
636
650
  let snifferInterval: NodeJS.Timeout | undefined;
@@ -649,7 +663,7 @@ export class AcpClient {
649
663
  const timer = setTimeout(() => {
650
664
  cleanup();
651
665
  this.pending.delete(id);
652
- const diag = this.inspectPeerDiagnostics(options?.sessionId);
666
+ const diag = this.inspectPeerDiagnostics(options?.sessionId, requestStartMs);
653
667
  if (diag) {
654
668
  reject(new Error(`ACP Peer Agent (${this.options.command}) Error: ${diag}`));
655
669
  } else {
@@ -665,7 +679,7 @@ export class AcpClient {
665
679
  inactivityTimer = setTimeout(() => {
666
680
  cleanup();
667
681
  this.pending.delete(id);
668
- const diag = this.inspectPeerDiagnostics(options?.sessionId);
682
+ const diag = this.inspectPeerDiagnostics(options?.sessionId, requestStartMs);
669
683
  if (diag) {
670
684
  reject(new Error(`ACP Peer Agent (${this.options.command}) Error: ${diag}`));
671
685
  } else {
@@ -678,7 +692,7 @@ export class AcpClient {
678
692
  const sid = options?.sessionId;
679
693
  if (sid) {
680
694
  snifferInterval = setInterval(() => {
681
- const fatalDiag = this.inspectPeerDiagnostics(sid);
695
+ const fatalDiag = this.inspectPeerDiagnostics(sid, requestStartMs);
682
696
  if (fatalDiag) {
683
697
  cleanup();
684
698
  clearTimeout(timer);
package/src/appChannel.js CHANGED
@@ -20,94 +20,72 @@
20
20
  // EXTENDING IT: A native automation bridge (ExtendScript bridge, Blender Python engine) is
21
21
  // one more CHANNEL_A row, not a parallel architecture. That is the whole point
22
22
  // of the table — "a native app API beats pixels".
23
-
24
- /**
25
- * Apps that already have a Channel A tool, keyed by matcher.
26
- *
27
- * `match` is tested against a lowercased app name, so "Blender", "blender" and
28
- * "Blender 4.2" all resolve. Order matters only for readability; the first hit
29
- * wins.
30
- */
31
23
  const CHANNEL_A = [
32
- { match: /\bblender\b/, tool: 'blender_act', app: 'Blender' },
33
- { match: /\b(davinci|resolve)\b/, tool: 'resolve_act', app: 'DaVinci Resolve' },
34
- { match: /\bgodot\b/, tool: 'godot_act', app: 'Godot' },
35
- { match: /\bpalmier\b/, tool: 'palmier_act', app: 'Palmier Pro' },
36
- {
37
- match: /\b(chrome|chromium|safari|firefox|edge|brave|arc)\b/,
38
- tool: 'browser_act',
39
- app: 'a web browser'
40
- },
41
- {
42
- match: /\b(photo-studio|video-studio|motion-studio|photostudio|videostudio|motionstudio)\b/,
43
- tool: 'creative_apps',
44
- app: 'Creative Studio Bridge'
45
- }
24
+ { match: /\bblender\b/, tool: 'blender_act', app: 'Blender' },
25
+ { match: /\b(davinci|resolve)\b/, tool: 'resolve_act', app: 'DaVinci Resolve' },
26
+ { match: /\bgodot\b/, tool: 'godot_act', app: 'Godot' },
27
+ { match: /\bpalmier\b/, tool: 'palmier_act', app: 'Palmier Pro' },
28
+ {
29
+ match: /\b(chrome|chromium|safari|firefox|edge|brave|arc)\b/,
30
+ tool: 'browser_act',
31
+ app: 'a web browser'
32
+ },
33
+ {
34
+ match: /\b(photo-studio|video-studio|motion-studio|vector-studio|layout-studio|encoder-studio|photostudio|videostudio|motionstudio|vectorstudio|layoutstudio|encoderstudio|photoshop|premiere(?:\s*pro)?|after\s*effects|illustrator|indesign|media\s*encoder|unreal(?:\s*engine|\s*editor)?|unity(?:\s*editor)?)\b/,
35
+ tool: 'creative_apps',
36
+ app: 'Creative & Game Engine Studio Bridge'
37
+ }
46
38
  ];
47
-
48
- /**
49
- * Apps a GUI actuator must never drive, because a text interface already
50
- * exists and driving it by pixels is strictly worse in every dimension —
51
- * slower, costlier, and unable to read its own output reliably.
52
- */
53
39
  const NEVER_BY_PIXEL = [
54
- { match: /\b(terminal|iterm|iterm2|konsole|gnome-terminal|powershell|cmd|wezterm|alacritty|kitty)\b/,
55
- tool: 'sysRun',
56
- reason: 'a shell is a text interface; clicking one is slower and cannot read its output reliably' }
40
+ {
41
+ match: /\b(terminal|iterm|iterm2|konsole|gnome-terminal|powershell|cmd|wezterm|alacritty|kitty)\b/,
42
+ tool: 'sysRun',
43
+ reason: 'a shell is a text interface; clicking one is slower and cannot read its output reliably'
44
+ }
57
45
  ];
58
-
59
- /** @typedef {{channel:'A'|'B'|'C', tool:string|null, reason:string, blocked:boolean}} ChannelChoice */
60
-
61
46
  /**
62
47
  * Decide the cheapest channel that can drive `appName`.
63
48
  *
64
49
  * Pure and total — an empty or unknown app name resolves to Channel C, which
65
50
  * is correct: "I do not recognise this app" is exactly when the universal
66
51
  * fallback is the right answer.
67
- *
68
- * @param {string} appName Application name, as the user or the OS reports it.
69
- * @returns {ChannelChoice}
70
52
  */
71
53
  export function resolveChannel(appName) {
72
- const name = String(appName || '').toLowerCase().trim();
73
-
74
- if (name !== '') {
75
- for (const entry of NEVER_BY_PIXEL) {
76
- if (entry.match.test(name)) {
77
- return {
78
- channel: 'A',
79
- tool: entry.tool,
80
- reason: `${appName} must not be driven by pixels — ${entry.reason}. Use ${entry.tool}.`,
81
- blocked: true
82
- };
83
- }
84
- }
85
-
86
- for (const entry of CHANNEL_A) {
87
- if (entry.match.test(name)) {
88
- return {
89
- channel: 'A',
90
- tool: entry.tool,
91
- reason: `${entry.app} has a native automation API. ${entry.tool} is exact, roughly 10x cheaper `
92
- + `per observation, and does not break when the window moves. Use it instead of clicking.`,
93
- blocked: true
94
- };
95
- }
54
+ const name = String(appName || '').toLowerCase().trim();
55
+ if (name !== '') {
56
+ for (const entry of NEVER_BY_PIXEL) {
57
+ if (entry.match.test(name)) {
58
+ return {
59
+ channel: 'A',
60
+ tool: entry.tool,
61
+ reason: `${appName} must not be driven by pixels — ${entry.reason}. Use ${entry.tool}.`,
62
+ blocked: true
63
+ };
64
+ }
65
+ }
66
+ for (const entry of CHANNEL_A) {
67
+ if (entry.match.test(name)) {
68
+ return {
69
+ channel: 'A',
70
+ tool: entry.tool,
71
+ reason: `${entry.app} has a native automation API. ${entry.tool} is exact, roughly 10x cheaper `
72
+ + `per observation, and does not break when the window moves. Use it instead of clicking.`,
73
+ blocked: true
74
+ };
75
+ }
76
+ }
96
77
  }
97
- }
98
-
99
- return {
100
- channel: 'C',
101
- tool: null,
102
- reason: name === ''
103
- ? 'No application named, so no native channel can be selected; the pixel path applies.'
104
- : `No native automation channel is registered for "${appName}". Read it with ax_snapshot first `
105
- + `(Channel B, structured and ~5x cheaper than a screenshot), and act by element name where possible.`,
106
- blocked: false
107
- };
78
+ return {
79
+ channel: 'C',
80
+ tool: null,
81
+ reason: name === ''
82
+ ? 'No application named, so no native channel can be selected; the pixel path applies.'
83
+ : `No native automation channel is registered for "${appName}". Read it with ax_snapshot first `
84
+ + `(Channel B, structured and ~5x cheaper than a screenshot), and act by element name where possible.`,
85
+ blocked: false
86
+ };
108
87
  }
109
-
110
88
  /** Every app name pattern with a Channel A tool. For tests and diagnostics. */
111
89
  export function channelATools() {
112
- return [...CHANNEL_A.map(e => e.tool), ...NEVER_BY_PIXEL.map(e => e.tool)];
90
+ return [...CHANNEL_A.map(e => e.tool), ...NEVER_BY_PIXEL.map(e => e.tool)];
113
91
  }
@@ -0,0 +1,106 @@
1
+ // The Three-Channel Doctrine, made executable.
2
+ //
3
+ // Channel A — the app's own API / plugin / CLI ~50-200 tok exact
4
+ // Channel B — the accessibility tree ~200-800 tok structured
5
+ // Channel C — pixels: screenshot + OCR + click ~1,500-2,500 universal, brittle
6
+ //
7
+ // Channel C costs 10-50x Channel A per observation. An agent that reaches for
8
+ // pixels first is not more capable — it is more expensive AND less reliable.
9
+ //
10
+ // THIS MODULE IS A GUARD, NOT ADVICE. A doctrine that lives only in a system
11
+ // prompt is a suggestion the model may ignore on any given turn, and the turn
12
+ // it ignores it is the turn it clicks blindly through Blender instead of
13
+ // calling `blender_act`. So the router is consulted by `desktop_act` BEFORE any
14
+ // actuation, and it refuses the pixel path for an app that has a native one.
15
+ //
16
+ // It is deliberately NOT a tool the model calls. Another tool schema is another
17
+ // ~200 tokens on every request to describe a decision the runtime can make on
18
+ // its own, and a decision the model is allowed to skip is not a guard.
19
+ //
20
+ // EXTENDING IT: A native automation bridge (ExtendScript bridge, Blender Python engine) is
21
+ // one more CHANNEL_A row, not a parallel architecture. That is the whole point
22
+ // of the table — "a native app API beats pixels".
23
+
24
+ export interface ChannelChoice {
25
+ channel: 'A' | 'B' | 'C';
26
+ tool: string | null;
27
+ reason: string;
28
+ blocked: boolean;
29
+ }
30
+
31
+ const CHANNEL_A: ReadonlyArray<{ match: RegExp; tool: string; app: string }> = [
32
+ { match: /\bblender\b/, tool: 'blender_act', app: 'Blender' },
33
+ { match: /\b(davinci|resolve)\b/, tool: 'resolve_act', app: 'DaVinci Resolve' },
34
+ { match: /\bgodot\b/, tool: 'godot_act', app: 'Godot' },
35
+ { match: /\bpalmier\b/, tool: 'palmier_act', app: 'Palmier Pro' },
36
+ {
37
+ match: /\b(chrome|chromium|safari|firefox|edge|brave|arc)\b/,
38
+ tool: 'browser_act',
39
+ app: 'a web browser'
40
+ },
41
+ {
42
+ match: /\b(photo-studio|video-studio|motion-studio|vector-studio|layout-studio|encoder-studio|photostudio|videostudio|motionstudio|vectorstudio|layoutstudio|encoderstudio|photoshop|premiere(?:\s*pro)?|after\s*effects|illustrator|indesign|media\s*encoder|unreal(?:\s*engine|\s*editor)?|unity(?:\s*editor)?)\b/,
43
+ tool: 'creative_apps',
44
+ app: 'Creative & Game Engine Studio Bridge'
45
+ }
46
+ ];
47
+
48
+ const NEVER_BY_PIXEL: ReadonlyArray<{ match: RegExp; tool: string; reason: string }> = [
49
+ {
50
+ match: /\b(terminal|iterm|iterm2|konsole|gnome-terminal|powershell|cmd|wezterm|alacritty|kitty)\b/,
51
+ tool: 'sysRun',
52
+ reason: 'a shell is a text interface; clicking one is slower and cannot read its output reliably'
53
+ }
54
+ ];
55
+
56
+ /**
57
+ * Decide the cheapest channel that can drive `appName`.
58
+ *
59
+ * Pure and total — an empty or unknown app name resolves to Channel C, which
60
+ * is correct: "I do not recognise this app" is exactly when the universal
61
+ * fallback is the right answer.
62
+ */
63
+ export function resolveChannel(appName?: string | null): ChannelChoice {
64
+ const name = String(appName || '').toLowerCase().trim();
65
+
66
+ if (name !== '') {
67
+ for (const entry of NEVER_BY_PIXEL) {
68
+ if (entry.match.test(name)) {
69
+ return {
70
+ channel: 'A',
71
+ tool: entry.tool,
72
+ reason: `${appName} must not be driven by pixels — ${entry.reason}. Use ${entry.tool}.`,
73
+ blocked: true
74
+ };
75
+ }
76
+ }
77
+
78
+ for (const entry of CHANNEL_A) {
79
+ if (entry.match.test(name)) {
80
+ return {
81
+ channel: 'A',
82
+ tool: entry.tool,
83
+ reason: `${entry.app} has a native automation API. ${entry.tool} is exact, roughly 10x cheaper `
84
+ + `per observation, and does not break when the window moves. Use it instead of clicking.`,
85
+ blocked: true
86
+ };
87
+ }
88
+ }
89
+ }
90
+
91
+ return {
92
+ channel: 'C',
93
+ tool: null,
94
+ reason: name === ''
95
+ ? 'No application named, so no native channel can be selected; the pixel path applies.'
96
+ : `No native automation channel is registered for "${appName}". Read it with ax_snapshot first `
97
+ + `(Channel B, structured and ~5x cheaper than a screenshot), and act by element name where possible.`,
98
+ blocked: false
99
+ };
100
+ }
101
+
102
+ /** Every app name pattern with a Channel A tool. For tests and diagnostics. */
103
+ export function channelATools(): string[] {
104
+ return [...CHANNEL_A.map(e => e.tool), ...NEVER_BY_PIXEL.map(e => e.tool)];
105
+ }
106
+
@@ -32,27 +32,186 @@ export async function findBlender() {
32
32
  }
33
33
  return null;
34
34
  }
35
+ export function unrealCandidates(platform = process.platform) {
36
+ const candidates = [];
37
+ if (platform === 'darwin') {
38
+ for (const root of ['/Users/Shared/Epic Games', '/Applications']) {
39
+ try {
40
+ const dirs = fs.readdirSync(root).filter(n => /^UE_\d/i.test(n)).sort().reverse();
41
+ for (const dir of dirs) {
42
+ candidates.push(path.join(root, dir, 'Engine/Binaries/Mac/UnrealEditor-Cmd'));
43
+ candidates.push(path.join(root, dir, 'Engine/Binaries/Mac/UnrealEditor.app/Contents/MacOS/UnrealEditor-Cmd'));
44
+ }
45
+ }
46
+ catch { /* ignore */ }
47
+ }
48
+ }
49
+ else if (platform === 'win32') {
50
+ const root = path.join(process.env.ProgramFiles || 'C:\\Program Files', 'Epic Games');
51
+ try {
52
+ const dirs = fs.readdirSync(root).filter(n => /^UE_\d/i.test(n)).sort().reverse();
53
+ for (const dir of dirs) {
54
+ candidates.push(path.join(root, dir, 'Engine\\Binaries\\Win64\\UnrealEditor-Cmd.exe'));
55
+ }
56
+ }
57
+ catch { /* ignore */ }
58
+ }
59
+ else {
60
+ candidates.push(path.join(os.homedir(), 'UnrealEngine/Engine/Binaries/Linux/UnrealEditor-Cmd'), '/opt/unreal-engine/Engine/Binaries/Linux/UnrealEditor-Cmd');
61
+ }
62
+ return candidates;
63
+ }
64
+ export function findUnrealEngine(platform = process.platform) {
65
+ for (const executable of unrealCandidates(platform)) {
66
+ if (!fs.existsSync(executable))
67
+ continue;
68
+ const match = executable.match(/UE_(\d+(?:\.\d+)*)/i);
69
+ return { executable, version: match?.[1] ? `Unreal Engine ${match[1]}` : 'Unreal Engine 5' };
70
+ }
71
+ return null;
72
+ }
73
+ export function unityCandidates(platform = process.platform) {
74
+ const candidates = [];
75
+ if (platform === 'darwin') {
76
+ const hubRoot = '/Applications/Unity/Hub/Editor';
77
+ try {
78
+ const versions = fs.readdirSync(hubRoot).sort().reverse();
79
+ for (const v of versions) {
80
+ candidates.push(path.join(hubRoot, v, 'Unity.app/Contents/MacOS/Unity'));
81
+ }
82
+ }
83
+ catch { /* ignore */ }
84
+ candidates.push('/Applications/Unity/Unity.app/Contents/MacOS/Unity');
85
+ }
86
+ else if (platform === 'win32') {
87
+ const hubRoot = path.join(process.env.ProgramFiles || 'C:\\Program Files', 'Unity\\Hub\\Editor');
88
+ try {
89
+ const versions = fs.readdirSync(hubRoot).sort().reverse();
90
+ for (const v of versions) {
91
+ candidates.push(path.join(hubRoot, v, 'Editor\\Unity.exe'));
92
+ }
93
+ }
94
+ catch { /* ignore */ }
95
+ candidates.push(path.join(process.env.ProgramFiles || 'C:\\Program Files', 'Unity\\Editor\\Unity.exe'));
96
+ }
97
+ else {
98
+ const hubRoot = path.join(os.homedir(), 'Unity/Hub/Editor');
99
+ try {
100
+ const versions = fs.readdirSync(hubRoot).sort().reverse();
101
+ for (const v of versions) {
102
+ candidates.push(path.join(hubRoot, v, 'Editor/Unity'));
103
+ }
104
+ }
105
+ catch { /* ignore */ }
106
+ candidates.push('/opt/unity/Editor/Unity');
107
+ }
108
+ return candidates;
109
+ }
110
+ export function findUnityEditor(platform = process.platform) {
111
+ for (const executable of unityCandidates(platform)) {
112
+ if (!fs.existsSync(executable))
113
+ continue;
114
+ const match = executable.match(/Editor[\\/]([^\\/]+)[\\/](?:Unity\.app|Editor)/i);
115
+ return { executable, version: match?.[1] ? `Unity ${match[1]}` : 'Unity Editor' };
116
+ }
117
+ return null;
118
+ }
119
+ export function godotCandidates(platform = process.platform) {
120
+ const homeDir = os.homedir();
121
+ const causyneGodotDir = path.join(homeDir, '.causyne', 'engines', 'godot');
122
+ if (platform === 'darwin') {
123
+ return [
124
+ path.join(causyneGodotDir, 'godot'),
125
+ '/Applications/Godot.app/Contents/MacOS/Godot',
126
+ '/Applications/Godot_4.app/Contents/MacOS/Godot',
127
+ '/opt/homebrew/bin/godot',
128
+ '/usr/local/bin/godot'
129
+ ];
130
+ }
131
+ if (platform === 'win32') {
132
+ return [
133
+ path.join(causyneGodotDir, 'Godot.exe'),
134
+ path.join(causyneGodotDir, 'godot.exe'),
135
+ 'C:\\Program Files\\Godot\\Godot_v4.exe',
136
+ 'C:\\Program Files\\Godot\\godot.exe'
137
+ ];
138
+ }
139
+ return [
140
+ path.join(causyneGodotDir, 'godot'),
141
+ '/usr/bin/godot',
142
+ '/usr/local/bin/godot'
143
+ ];
144
+ }
145
+ export function findGodotEngine(platform = process.platform) {
146
+ for (const executable of godotCandidates(platform)) {
147
+ if (fs.existsSync(executable)) {
148
+ return { executable, version: 'Godot 4.x' };
149
+ }
150
+ }
151
+ return null;
152
+ }
153
+ export function resolveCandidates(platform = process.platform) {
154
+ if (platform === 'darwin') {
155
+ return [
156
+ '/Applications/DaVinci Resolve/DaVinci Resolve.app/Contents/MacOS/Resolve',
157
+ '/Applications/DaVinci Resolve/DaVinci Resolve.app'
158
+ ];
159
+ }
160
+ if (platform === 'win32') {
161
+ const programFiles = process.env.ProgramFiles || 'C:\\Program Files';
162
+ return [
163
+ path.join(programFiles, 'Blackmagic Design\\DaVinci Resolve\\Resolve.exe')
164
+ ];
165
+ }
166
+ return ['/opt/resolve/bin/resolve'];
167
+ }
168
+ export function findDaVinciResolve(platform = process.platform) {
169
+ for (const executable of resolveCandidates(platform)) {
170
+ if (fs.existsSync(executable)) {
171
+ return { executable, version: 'DaVinci Resolve Studio' };
172
+ }
173
+ }
174
+ return null;
175
+ }
35
176
  /** Probes local creative application installations and native automation adapter readiness. */
36
177
  export async function creativeAppStatus() {
37
178
  const blender = await findBlender();
179
+ const resolve = findDaVinciResolve();
180
+ const unreal = findUnrealEngine();
181
+ const unity = findUnityEditor();
182
+ const godot = findGodotEngine();
38
183
  const roots = process.platform === 'darwin'
39
184
  ? ['/Applications', path.join(os.homedir(), 'Applications')]
40
185
  : process.platform === 'win32'
41
186
  ? [process.env.ProgramFiles || 'C:\\Program Files', process.env['ProgramFiles(x86)'] || 'C:\\Program Files (x86)']
42
187
  : [];
43
- const installedNames = roots.flatMap(root => { try {
44
- return fs.readdirSync(root);
45
- }
46
- catch {
47
- return [];
48
- } });
188
+ const installedNames = roots.flatMap(root => {
189
+ try {
190
+ const top = fs.readdirSync(root);
191
+ const adobeSub = top.filter(n => /Adobe/i.test(n)).flatMap(sub => {
192
+ try {
193
+ return fs.readdirSync(path.join(root, sub));
194
+ }
195
+ catch {
196
+ return [];
197
+ }
198
+ });
199
+ return [...top, ...adobeSub];
200
+ }
201
+ catch {
202
+ return [];
203
+ }
204
+ });
49
205
  return [
50
206
  { id: 'blender', label: '3D Studio (Blender)', installed: Boolean(blender), available: Boolean(blender),
51
207
  detail: blender ? `${blender.version} · native batch engine (geometry, materials, lighting, render)` : 'Install Blender to enable 3D batch modeling and rendering.' },
52
208
  ...[
53
- ['photoshop', 'Photo Studio', /Photoshop/i, '.psd/.png/.jpg', 'layer edits, transforms, resizing, flattening'],
54
- ['premiere', 'Video Studio', /Premiere/i, '.prproj', 'sequences, timeline media imports, cuts, markers'],
55
- ['after-effects', 'Motion Studio', /After\s*Effects/i, '.aep', 'compositions, footage import, typography, motion']
209
+ ['photoshop', 'Photo Studio', /Photoshop/i, '.psd/.png/.jpg', 'live canvas/selection mask bridge, layer edits, transforms, UXP'],
210
+ ['premiere', 'Video Studio', /Premiere/i, '.prproj', 'live active sequence insertion, timeline media imports, cuts, markers, UXP'],
211
+ ['after-effects', 'Motion Studio', /After\s*Effects/i, '.aep', 'live active composition bridge, footage import, typography, motion'],
212
+ ['illustrator', 'Vector Studio', /Illustrator/i, '.ai/.svg/.pdf', 'live artboard placement, vector paths, typography, SVG/PDF export'],
213
+ ['indesign', 'Layout Studio', /InDesign/i, '.indd/.idml/.pdf', 'live spread/frame placement, multi-page editorial layout'],
214
+ ['media-encoder', 'Encoder Studio', /Media\s*Encoder/i, '.mp4/.mov/.wav', 'render queue dispatch and hardware codec transcode']
56
215
  ].map(([id, label, pattern, ext, capabilities]) => {
57
216
  const installed = installedNames.some(n => pattern.test(n));
58
217
  return {
@@ -61,9 +220,45 @@ export async function creativeAppStatus() {
61
220
  installed,
62
221
  available: installed,
63
222
  detail: installed
64
- ? `Connected · native automation engine ready (${ext} · ${capabilities})`
223
+ ? `Connected · native automation & live session bridge ready (${ext} · ${capabilities})`
65
224
  : `Not installed · install ${label} host engine to enable native creative automation`
66
225
  };
67
- })
226
+ }),
227
+ {
228
+ id: 'resolve',
229
+ label: 'Cinema Studio (DaVinci Resolve)',
230
+ installed: Boolean(resolve),
231
+ available: true,
232
+ detail: resolve
233
+ ? `${resolve.version} (${resolve.executable}) · DaVinciResolveScript Python API (timeline assembly, RCM color management, LUT/CDL grading, render queue)`
234
+ : 'DaVinciResolveScript Python bridge & simulator ready (macOS/Windows/Linux) · install DaVinci Resolve for live NLE/grading execution'
235
+ },
236
+ {
237
+ id: 'unreal',
238
+ label: 'Unreal Engine (UE5)',
239
+ installed: Boolean(unreal),
240
+ available: true,
241
+ detail: unreal
242
+ ? `${unreal.version} (${unreal.executable}) · Remote Control HTTP/WS API (30010) & Python Editor automation ready`
243
+ : 'Staged Python & Remote Control HTTP (30010) bridge ready · install Unreal Engine 5 for local CLI execution'
244
+ },
245
+ {
246
+ id: 'unity',
247
+ label: 'Unity Engine',
248
+ installed: Boolean(unity),
249
+ available: true,
250
+ detail: unity
251
+ ? `${unity.version} (${unity.executable}) · C# Editor batchmode & AssetDatabase bridge ready`
252
+ : 'Staged C# Editor & AssetDatabase bridge ready · install Unity Editor for local batchmode execution'
253
+ },
254
+ {
255
+ id: 'godot',
256
+ label: 'Godot Engine',
257
+ installed: Boolean(godot),
258
+ available: true,
259
+ detail: godot
260
+ ? `${godot.version} (${godot.executable}) · headless SceneTree GDScript & resource import bridge ready`
261
+ : 'Staged GDScript & scene resource bridge ready · install Godot 4 for local headless execution'
262
+ }
68
263
  ];
69
264
  }