@causyne/agent 1.20.8 → 1.20.9
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 +1 -1
- package/src/agentLoop.js +167 -34
- package/src/agentLoop.ts +188 -37
- package/src/compiledSkills.js +7330 -319
- package/src/computerUse/types.js +8 -0
- package/src/computerUse/types.ts +121 -0
- package/src/computerUse/visionGrounding.js +87 -29
- package/src/computerUse/visionGrounding.ts +108 -36
- package/src/decisionPolicy.js +7 -9
- package/src/decisionPolicy.ts +7 -9
- package/src/documentEngine/antiSlopAuditor.js +13 -43
- package/src/documentEngine/antiSlopAuditor.ts +15 -47
- package/src/documentEngine/documentForge.js +3 -3
- package/src/documentEngine/documentForge.ts +3 -3
- package/src/launchIntent.js +3 -3
- package/src/launchIntent.ts +3 -3
- package/src/planCache.js +4 -14
- package/src/planCache.ts +4 -14
- package/src/providers/acp.js +4 -2
- package/src/providers/acp.ts +4 -2
- package/src/providers/antigravity.js +122 -22
- package/src/providers/antigravity.ts +121 -21
- package/src/providers/base.d.ts +2 -0
- package/src/providers/pi.js +3 -1
- package/src/providers/pi.ts +4 -2
- package/src/sandbox.js +7 -10
- package/src/smartToolsUse.js +203 -0
- package/src/smartToolsUse.ts +263 -0
- package/src/taskShape.js +7 -7
- package/src/taskShape.ts +7 -7
- package/src/toolPacks.js +5 -5
- package/src/tools/blenderAutomator.js +198 -11
- package/src/tools/documentForge.js +1 -1
- package/src/tools/documentForge.ts +1 -1
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file src/smartToolsUse.ts
|
|
3
|
+
* SmartToolsUse & LazyPlaybook Engine.
|
|
4
|
+
*
|
|
5
|
+
* Provides intent-based tool preloading and lazy playbook disclosure.
|
|
6
|
+
* Other capabilities remain discoverable through tool_search.
|
|
7
|
+
*
|
|
8
|
+
* Authorship: Strict TypeScript (Causyne Agent).
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { PACK_PLAYBOOKS } from './toolPacks.js';
|
|
12
|
+
|
|
13
|
+
export interface SmartToolsScopeResult {
|
|
14
|
+
readonly toolScope: Set<string> | null;
|
|
15
|
+
readonly archetype: string;
|
|
16
|
+
readonly suppressedPacks: readonly string[];
|
|
17
|
+
readonly reason?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface LazyPlaybookResult {
|
|
21
|
+
readonly fullPlaybooks: string;
|
|
22
|
+
readonly microAnnouncements: string;
|
|
23
|
+
readonly activePlaybookDomains: string[];
|
|
24
|
+
readonly tokenSavingsEstimate: number;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// ---------------------------------------------------------------------------
|
|
28
|
+
// Intent Matchers & Negative Filters
|
|
29
|
+
// ---------------------------------------------------------------------------
|
|
30
|
+
|
|
31
|
+
// Personalization / desktop actions (setting wallpaper, changing desktop background)
|
|
32
|
+
const DESKTOP_PERSONALIZATION_PATTERN =
|
|
33
|
+
/\b(desktop (picture|wallpaper|background|image)|set wallpaper|change wallpaper)\b/i;
|
|
34
|
+
|
|
35
|
+
// Pure web search / retrieval without UI/frontend construction
|
|
36
|
+
const PURE_WEB_SEARCH_PATTERN =
|
|
37
|
+
/\b(search(ing)? (the )?web|web search|look up online|find on google|brows(e|ing) (the )?web)\b/i;
|
|
38
|
+
|
|
39
|
+
const WEB_CONSTRUCTION_EXCLUSION =
|
|
40
|
+
/\b(build|create|make|design|develop|scaffold|code|program|css|html|tailwind|component|frontend|front-end|landing page|website|webpage|dashboard)\b/i;
|
|
41
|
+
|
|
42
|
+
// System admin / process & terminal operations
|
|
43
|
+
const SYSTEM_ADMIN_PATTERN =
|
|
44
|
+
/\b(kill process|kill port|check port|port \d+|lsof|ps aux|terminate process|zip folder|unzip file|extract archive|compress folder)\b/i;
|
|
45
|
+
|
|
46
|
+
// Simple file management operations
|
|
47
|
+
const SIMPLE_FILE_OP_PATTERN =
|
|
48
|
+
/\b(list (the )?files|show files|count files|rename file(s)?|delete file(s)?|move file(s)?|clean (up )?folder)\b/i;
|
|
49
|
+
|
|
50
|
+
// Media generation intent (explicit creation of 3D, video, audio, or synthesized speech)
|
|
51
|
+
const EXPLICIT_MEDIA_GENERATION_PATTERN =
|
|
52
|
+
/\b(blender|3d model|render 3d|render frame|render animation|da vinci|resolve|audio synth|synthesizer|text to speech|tts|voiceover|dubbing)\b/i;
|
|
53
|
+
|
|
54
|
+
// Explicit web engineering intent
|
|
55
|
+
const EXPLICIT_WEB_ENGINEERING_PATTERN =
|
|
56
|
+
/\b(build.*(website|webpage|landing page|dashboard|ui component|frontend)|create.*(website|webpage|landing page|dashboard|ui)|develop.*(website|web app|webapp))\b/i;
|
|
57
|
+
|
|
58
|
+
// Explicit game development intent
|
|
59
|
+
const EXPLICIT_GAME_DEV_PATTERN =
|
|
60
|
+
/\b(build.*game|create.*game|develop.*game|godot|unity|unreal|platformer 2d|rpg game|arcade game)\b/i;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Select tools to preload based on prompt intent. This is never an allowlist:
|
|
64
|
+
* tool_search can add capabilities as the task develops.
|
|
65
|
+
*/
|
|
66
|
+
export function determineToolScope(
|
|
67
|
+
prompt: string,
|
|
68
|
+
_taskShape?: unknown
|
|
69
|
+
): SmartToolsScopeResult {
|
|
70
|
+
const text = (prompt || '').trim();
|
|
71
|
+
if (!text) {
|
|
72
|
+
return { toolScope: null, archetype: 'empty', suppressedPacks: [] };
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// 1. Desktop personalization (e.g. wallpaper / desktop background)
|
|
76
|
+
if (DESKTOP_PERSONALIZATION_PATTERN.test(text)) {
|
|
77
|
+
const tools = new Set([
|
|
78
|
+
'sysRun',
|
|
79
|
+
'web_search',
|
|
80
|
+
'web_fetch',
|
|
81
|
+
'fs_read',
|
|
82
|
+
'fs_write',
|
|
83
|
+
'fs_list',
|
|
84
|
+
'update_plan',
|
|
85
|
+
'tool_search'
|
|
86
|
+
]);
|
|
87
|
+
return {
|
|
88
|
+
toolScope: tools,
|
|
89
|
+
archetype: 'desktop_personalization',
|
|
90
|
+
suppressedPacks: ['media', 'web', 'game', 'advanced', 'system'],
|
|
91
|
+
reason: 'Start with search and system execution; discover desktop or browser tools if direct execution is unsuitable.'
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// 2. Pure web research (searching/fetching online information without web app construction)
|
|
96
|
+
if (PURE_WEB_SEARCH_PATTERN.test(text) && !WEB_CONSTRUCTION_EXCLUSION.test(text)) {
|
|
97
|
+
const tools = new Set([
|
|
98
|
+
'web_search',
|
|
99
|
+
'web_fetch',
|
|
100
|
+
'sysRun',
|
|
101
|
+
'fs_read',
|
|
102
|
+
'fs_write',
|
|
103
|
+
'update_plan',
|
|
104
|
+
'tool_search'
|
|
105
|
+
]);
|
|
106
|
+
return {
|
|
107
|
+
toolScope: tools,
|
|
108
|
+
archetype: 'web_research_only',
|
|
109
|
+
suppressedPacks: ['media', 'game', 'web', 'advanced'],
|
|
110
|
+
reason: 'Pure information retrieval requires web search tools; suppresses UI forge and creative packs.'
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// 3. System process or archive administration
|
|
115
|
+
if (SYSTEM_ADMIN_PATTERN.test(text)) {
|
|
116
|
+
const tools = new Set([
|
|
117
|
+
'sysRun',
|
|
118
|
+
'proc_term',
|
|
119
|
+
'process_list',
|
|
120
|
+
'archive',
|
|
121
|
+
'fs_read',
|
|
122
|
+
'fs_list',
|
|
123
|
+
'update_plan',
|
|
124
|
+
'tool_search'
|
|
125
|
+
]);
|
|
126
|
+
return {
|
|
127
|
+
toolScope: tools,
|
|
128
|
+
archetype: 'system_admin',
|
|
129
|
+
suppressedPacks: ['media', 'game', 'web'],
|
|
130
|
+
reason: 'System administration uses process and archive utilities; suppresses creative packs.'
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// 4. Simple local file manipulation
|
|
135
|
+
if (SIMPLE_FILE_OP_PATTERN.test(text) && !EXPLICIT_WEB_ENGINEERING_PATTERN.test(text) && !EXPLICIT_GAME_DEV_PATTERN.test(text)) {
|
|
136
|
+
const tools = new Set([
|
|
137
|
+
'fs_read',
|
|
138
|
+
'fs_write',
|
|
139
|
+
'fs_edit',
|
|
140
|
+
'fs_list',
|
|
141
|
+
'fs_search',
|
|
142
|
+
'sysRun',
|
|
143
|
+
'update_plan',
|
|
144
|
+
'tool_search'
|
|
145
|
+
]);
|
|
146
|
+
return {
|
|
147
|
+
toolScope: tools,
|
|
148
|
+
archetype: 'simple_file_op',
|
|
149
|
+
suppressedPacks: ['media', 'game', 'web', 'advanced'],
|
|
150
|
+
reason: 'Simple filesystem operation; suppresses external domain packs.'
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// Default: unconstrained (standard progressive disclosure and packs apply)
|
|
155
|
+
return {
|
|
156
|
+
toolScope: null,
|
|
157
|
+
archetype: 'generalist',
|
|
158
|
+
suppressedPacks: []
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Filter out packs that have been explicitly suppressed for a given prompt intent.
|
|
164
|
+
*/
|
|
165
|
+
export function filterSuppressedPacks(
|
|
166
|
+
candidatePacks: Iterable<string>,
|
|
167
|
+
prompt: string
|
|
168
|
+
): Set<string> {
|
|
169
|
+
const result = new Set<string>();
|
|
170
|
+
const scopeResult = determineToolScope(prompt);
|
|
171
|
+
const suppressed = new Set(scopeResult.suppressedPacks);
|
|
172
|
+
|
|
173
|
+
for (const pack of candidatePacks) {
|
|
174
|
+
if (!suppressed.has(pack)) {
|
|
175
|
+
result.add(pack);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return result;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Resolve lazy playbooks. Discloses full multi-page mandates only when tools from that
|
|
184
|
+
* domain have been actively invoked or explicitly demanded. Otherwise generates micro-indicators.
|
|
185
|
+
*/
|
|
186
|
+
export function resolveLazyPlaybooks(
|
|
187
|
+
unlockedPacks: Iterable<string>,
|
|
188
|
+
observedTools: Iterable<string> = [],
|
|
189
|
+
prompt = ''
|
|
190
|
+
): LazyPlaybookResult {
|
|
191
|
+
const packs = new Set(unlockedPacks);
|
|
192
|
+
const tools = new Set(observedTools);
|
|
193
|
+
const text = prompt || '';
|
|
194
|
+
|
|
195
|
+
const activePlaybooks: string[] = [];
|
|
196
|
+
const microAnnouncements: string[] = [];
|
|
197
|
+
const activeDomains: string[] = [];
|
|
198
|
+
let tokenSavings = 0;
|
|
199
|
+
|
|
200
|
+
// 1. Web Domain
|
|
201
|
+
if (packs.has('web')) {
|
|
202
|
+
const webToolInvoked =
|
|
203
|
+
tools.has('ui_forge') ||
|
|
204
|
+
tools.has('browser_act') ||
|
|
205
|
+
tools.has('vision_inspect_ui') ||
|
|
206
|
+
tools.has('screenshot') ||
|
|
207
|
+
tools.has('astryx_oracle');
|
|
208
|
+
const webExplicitDemand = EXPLICIT_WEB_ENGINEERING_PATTERN.test(text);
|
|
209
|
+
|
|
210
|
+
if ((webToolInvoked || webExplicitDemand) && PACK_PLAYBOOKS.web) {
|
|
211
|
+
activePlaybooks.push(PACK_PLAYBOOKS.web);
|
|
212
|
+
activeDomains.push('web');
|
|
213
|
+
} else {
|
|
214
|
+
microAnnouncements.push('- web: browser automation & UI forge available on demand via tool_search.');
|
|
215
|
+
tokenSavings += Math.round((PACK_PLAYBOOKS.web?.length || 0) / 4);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// 2. Media Domain
|
|
220
|
+
if (packs.has('media')) {
|
|
221
|
+
const mediaToolInvoked =
|
|
222
|
+
tools.has('blender_act') ||
|
|
223
|
+
tools.has('creative_apps') ||
|
|
224
|
+
tools.has('native_engine') ||
|
|
225
|
+
tools.has('execute_procedural_media') ||
|
|
226
|
+
tools.has('generate_media_via_api') ||
|
|
227
|
+
tools.has('open_source_tool_provisioner');
|
|
228
|
+
const mediaExplicitDemand = EXPLICIT_MEDIA_GENERATION_PATTERN.test(text);
|
|
229
|
+
|
|
230
|
+
if ((mediaToolInvoked || mediaExplicitDemand) && PACK_PLAYBOOKS.media) {
|
|
231
|
+
activePlaybooks.push(PACK_PLAYBOOKS.media);
|
|
232
|
+
activeDomains.push('media');
|
|
233
|
+
} else {
|
|
234
|
+
microAnnouncements.push('- media: 3D Blender, audio synthesis & creative engines available on demand via tool_search.');
|
|
235
|
+
tokenSavings += Math.round((PACK_PLAYBOOKS.media?.length || 0) / 4);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// 3. Game Domain
|
|
240
|
+
if (packs.has('game')) {
|
|
241
|
+
const gameToolInvoked =
|
|
242
|
+
tools.has('godot_act') ||
|
|
243
|
+
tools.has('game_build_html5') ||
|
|
244
|
+
tools.has('game_scene_build') ||
|
|
245
|
+
tools.has('game_asset_harvest');
|
|
246
|
+
const gameExplicitDemand = EXPLICIT_GAME_DEV_PATTERN.test(text);
|
|
247
|
+
|
|
248
|
+
if ((gameToolInvoked || gameExplicitDemand) && PACK_PLAYBOOKS.game) {
|
|
249
|
+
activePlaybooks.push(PACK_PLAYBOOKS.game);
|
|
250
|
+
activeDomains.push('game');
|
|
251
|
+
} else {
|
|
252
|
+
microAnnouncements.push('- game: Godot 2D/3D & HTML5 game development cascade available on demand via tool_search.');
|
|
253
|
+
tokenSavings += Math.round((PACK_PLAYBOOKS.game?.length || 0) / 4);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
return {
|
|
258
|
+
fullPlaybooks: activePlaybooks.join('\n\n'),
|
|
259
|
+
microAnnouncements: microAnnouncements.join('\n'),
|
|
260
|
+
activePlaybookDomains: activeDomains,
|
|
261
|
+
tokenSavingsEstimate: tokenSavings
|
|
262
|
+
};
|
|
263
|
+
}
|
package/src/taskShape.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
const PACK_SIGNALS = {
|
|
2
2
|
game: {
|
|
3
|
-
strong: ['game', 'gamedev', '
|
|
3
|
+
strong: ['game', 'gamedev', 'godot', 'unity', 'unreal', 'rpg', 'platformer', 'roguelike', 'arcade', 'voxel', 'minecraft', 'tilemap', 'spritesheet', 'boss fight', 'level design'],
|
|
4
4
|
weak: ['sprite', 'player', 'enemy', 'quest', 'npc', 'gameplay', 'multiplayer', 'leaderboard']
|
|
5
5
|
},
|
|
6
6
|
web: {
|
|
7
|
-
strong: ['web app', 'webapp', 'website', '
|
|
8
|
-
weak: ['web', 'ui', 'ux', 'page', '
|
|
7
|
+
strong: ['web app', 'webapp', 'website', 'landing page', 'homepage', 'frontend', 'front-end', 'dashboard', 'portfolio', 'react', 'vue', 'svelte', 'angular', 'nextjs', 'next.js', 'nuxt', 'astro', 'tailwind', 'html', 'css'],
|
|
8
|
+
weak: ['web', 'ui', 'ux', 'page', 'responsive', 'browser', 'dom', 'component', 'layout', 'design']
|
|
9
9
|
},
|
|
10
10
|
media: {
|
|
11
|
-
strong: ['generate image', 'generate video', 'generate music', 'text to speech', 'voiceover', 'blender', 'davinci', 'resolve', 'render', '3d model', 'animation'
|
|
12
|
-
weak: ['image', '
|
|
11
|
+
strong: ['generate image', 'generate video', 'generate music', 'text to speech', 'voiceover', 'blender', 'davinci', 'resolve', 'render', '3d model', 'animation'],
|
|
12
|
+
weak: ['image', 'photo', 'video', 'audio', 'sound', 'music', 'thumbnail', 'poster', 'logo', 'illustration']
|
|
13
13
|
},
|
|
14
14
|
system: {
|
|
15
|
-
strong: ['kill process', 'port', 'zip', 'unzip', 'tar', 'archive', 'clipboard', 'printer', 'print'
|
|
16
|
-
weak: ['process', '
|
|
15
|
+
strong: ['kill process', 'port', 'zip', 'unzip', 'tar', 'archive', 'clipboard', 'printer', 'print'],
|
|
16
|
+
weak: ['process', 'compress', 'extract', 'open app', 'launch']
|
|
17
17
|
},
|
|
18
18
|
advanced: {
|
|
19
19
|
strong: ['pdf', 'forge a tool', 'custom tool', 'plugin', 'plugins', 'custom plugin', 'subagent', 'sub-agent', 'parallel agent'],
|
package/src/taskShape.ts
CHANGED
|
@@ -18,20 +18,20 @@ interface ArchetypeDefinition {
|
|
|
18
18
|
|
|
19
19
|
const PACK_SIGNALS: Record<string, SignalSet> = {
|
|
20
20
|
game: {
|
|
21
|
-
strong: ['game', 'gamedev', '
|
|
21
|
+
strong: ['game', 'gamedev', 'godot', 'unity', 'unreal', 'rpg', 'platformer', 'roguelike', 'arcade', 'voxel', 'minecraft', 'tilemap', 'spritesheet', 'boss fight', 'level design'],
|
|
22
22
|
weak: ['sprite', 'player', 'enemy', 'quest', 'npc', 'gameplay', 'multiplayer', 'leaderboard']
|
|
23
23
|
},
|
|
24
24
|
web: {
|
|
25
|
-
strong: ['web app', 'webapp', 'website', '
|
|
26
|
-
weak: ['web', 'ui', 'ux', 'page', '
|
|
25
|
+
strong: ['web app', 'webapp', 'website', 'landing page', 'homepage', 'frontend', 'front-end', 'dashboard', 'portfolio', 'react', 'vue', 'svelte', 'angular', 'nextjs', 'next.js', 'nuxt', 'astro', 'tailwind', 'html', 'css'],
|
|
26
|
+
weak: ['web', 'ui', 'ux', 'page', 'responsive', 'browser', 'dom', 'component', 'layout', 'design']
|
|
27
27
|
},
|
|
28
28
|
media: {
|
|
29
|
-
strong: ['generate image', 'generate video', 'generate music', 'text to speech', 'voiceover', 'blender', 'davinci', 'resolve', 'render', '3d model', 'animation'
|
|
30
|
-
weak: ['image', '
|
|
29
|
+
strong: ['generate image', 'generate video', 'generate music', 'text to speech', 'voiceover', 'blender', 'davinci', 'resolve', 'render', '3d model', 'animation'],
|
|
30
|
+
weak: ['image', 'photo', 'video', 'audio', 'sound', 'music', 'thumbnail', 'poster', 'logo', 'illustration']
|
|
31
31
|
},
|
|
32
32
|
system: {
|
|
33
|
-
strong: ['kill process', 'port', 'zip', 'unzip', 'tar', 'archive', 'clipboard', 'printer', 'print'
|
|
34
|
-
weak: ['process', '
|
|
33
|
+
strong: ['kill process', 'port', 'zip', 'unzip', 'tar', 'archive', 'clipboard', 'printer', 'print'],
|
|
34
|
+
weak: ['process', 'compress', 'extract', 'open app', 'launch']
|
|
35
35
|
},
|
|
36
36
|
advanced: {
|
|
37
37
|
strong: ['pdf', 'forge a tool', 'custom tool', 'plugin', 'plugins', 'custom plugin', 'subagent', 'sub-agent', 'parallel agent'],
|
package/src/toolPacks.js
CHANGED
|
@@ -367,15 +367,15 @@ When the user asks you to build, create, test, expand, or develop a game, follow
|
|
|
367
367
|
// raw prompt only.
|
|
368
368
|
// ---------------------------------------------------------------------------
|
|
369
369
|
|
|
370
|
-
const GAME_INTENT = /\b(game|games|gamedev|
|
|
370
|
+
const GAME_INTENT = /\b(game|games|gamedev|godot|unity|unreal|rpg|platformer|roguelike|arcade|sprite|spritesheet|tilemap|voxel|minecraft|aetheria|voxellia|nes|snes|gameplay|player character|level design|boss fight)\b|\.(tscn|gd)\b/i;
|
|
371
371
|
|
|
372
|
-
const WEB_INTENT = /\b(web|webpage|website|
|
|
372
|
+
const WEB_INTENT = /\b(web|webpage|website|frontend|front-end|landing page|homepage|dashboard|portfolio|html|css|scss|tailwind|bootstrap|react|vue|svelte|angular|next\.?js|nuxt|astro|ui|ux|user interface|web app|webapp|spa|dom|responsive|ui forge|component forge|component generation|ui component)\b/i;
|
|
373
373
|
|
|
374
|
-
const MEDIA_INTENT = /\b(image|images|picture|photo|
|
|
374
|
+
const MEDIA_INTENT = /\b(image|images|picture|photo|render|3d model|blender|animation|animate|video|movie|film|audio|sound|sfx|music|song|voice|tts|text.to.speech|narration|podcast|thumbnail|poster|illustration|logo)\b/i;
|
|
375
375
|
|
|
376
|
-
const SYSTEM_INTENT = /\b(process|processes|pid|kill|port|zip|unzip|tar|archive|compress|extract|clipboard|copy to clipboard|print|printer|
|
|
376
|
+
const SYSTEM_INTENT = /\b(process|processes|pid|kill|port|zip|unzip|tar|archive|compress|extract|clipboard|copy to clipboard|print|printer|open in browser|launch app|computer use|vision grounding|desktop vision|gui agent|coordinate click|desktop control)\b/i;
|
|
377
377
|
|
|
378
|
-
const ADVANCED_INTENT = /\b(pdf|document|proposal|
|
|
378
|
+
const ADVANCED_INTENT = /\b(pdf|document|proposal|screenplay|shotlist|shot list|voiceover|dubbing|forge a tool|custom tool|new tool|plugin|plugins|custom plugin|subagent|sub-agent|parallel agent|swarm|ast|symbols|refactor across)\b/i;
|
|
379
379
|
|
|
380
380
|
const INTENT_MATCHERS = {
|
|
381
381
|
game: GAME_INTENT,
|
|
@@ -234,37 +234,166 @@ export const blenderAct = {
|
|
|
234
234
|
}
|
|
235
235
|
else if (action.type === 'autoFrameCamera') {
|
|
236
236
|
{
|
|
237
|
-
const camCode = `import bpy, math
|
|
237
|
+
const camCode = `import bpy, math
|
|
238
|
+
cam = bpy.context.scene.camera
|
|
239
|
+
if not cam:
|
|
240
|
+
cd = bpy.data.cameras.new('Cam')
|
|
241
|
+
cam = bpy.data.objects.new('Cam', cd)
|
|
242
|
+
bpy.context.scene.collection.objects.link(cam)
|
|
243
|
+
bpy.context.scene.camera = cam
|
|
244
|
+
cam.location = (10, -10, 8)
|
|
245
|
+
cam.rotation_euler = (math.radians(50), 0, math.radians(45))
|
|
246
|
+
if hasattr(cam.data, "lens"):
|
|
247
|
+
cam.data.lens = ${action.focal_length || 65.0}
|
|
248
|
+
print('Headless 65mm camera framed at studio angle')`;
|
|
238
249
|
await runHeadlessCli(null, camCode, results);
|
|
239
250
|
}
|
|
240
251
|
}
|
|
241
252
|
else if (action.type === 'smartGeometry') {
|
|
242
253
|
{
|
|
243
|
-
const geomCode = `import bpy, math
|
|
254
|
+
const geomCode = `import bpy, math
|
|
255
|
+
target_name = ${JSON.stringify(action.name || "")}
|
|
256
|
+
targets = [bpy.data.objects.get(target_name)] if target_name else [o for o in bpy.context.scene.objects if o.type == 'MESH' and o.visible_get() and not any(k in o.name.lower() for k in ['floor', 'plane', 'backdrop', 'studio', 'ground', 'cove'])]
|
|
257
|
+
targets = [t for t in targets if t]
|
|
258
|
+
for o in targets:
|
|
259
|
+
if hasattr(o.data, "use_auto_smooth"):
|
|
260
|
+
o.data.use_auto_smooth = True
|
|
261
|
+
for p in o.data.polygons:
|
|
262
|
+
p.use_smooth = True
|
|
263
|
+
if not any(m.type == 'BEVEL' for m in o.modifiers):
|
|
264
|
+
bev = o.modifiers.new(name="StudioBevel", type='BEVEL')
|
|
265
|
+
bev.width = ${action.bevel_width || 0.015}
|
|
266
|
+
bev.segments = 3
|
|
267
|
+
bev.limit_method = 'ANGLE'
|
|
268
|
+
bev.angle_limit = math.radians(35)
|
|
269
|
+
if ${action.subsurf !== false} and not any(m.type == 'SUBSURF' for m in o.modifiers):
|
|
270
|
+
sub = o.modifiers.new(name="StudioSubsurf", type='SUBSURF')
|
|
271
|
+
sub.levels = 2
|
|
272
|
+
sub.render_levels = 2
|
|
273
|
+
print("Headless applied Studio Bevel and Subsurf")`;
|
|
244
274
|
await runHeadlessCli(null, geomCode, results);
|
|
245
275
|
}
|
|
246
276
|
}
|
|
247
277
|
else if (action.type === 'smartMaterial') {
|
|
248
278
|
{
|
|
249
|
-
const matCode = `import bpy, time
|
|
279
|
+
const matCode = `import bpy, time
|
|
280
|
+
preset = ${JSON.stringify(action.preset || "custom")}.lower()
|
|
281
|
+
target_name = ${JSON.stringify(action.name || "")}
|
|
282
|
+
targets = [bpy.data.objects.get(target_name)] if target_name else [o for o in bpy.context.scene.objects if o.type == 'MESH' and o.visible_get() and not any(k in o.name.lower() for k in ['floor', 'plane', 'backdrop', 'studio', 'ground', 'cove'])]
|
|
283
|
+
targets = [t for t in targets if t]
|
|
284
|
+
mat = bpy.data.materials.new(name=f"CausynePBR_{preset.capitalize()}_{int(time.time()*1000)%10000}")
|
|
285
|
+
mat.use_nodes = True
|
|
286
|
+
nodes = mat.node_tree.nodes
|
|
287
|
+
links = mat.node_tree.links
|
|
288
|
+
nodes.clear()
|
|
289
|
+
bsdf = nodes.new(type="ShaderNodeBsdfPrincipled")
|
|
290
|
+
bsdf.location = (0, 0)
|
|
291
|
+
out = nodes.new(type="ShaderNodeOutputMaterial")
|
|
292
|
+
out.location = (300, 0)
|
|
293
|
+
links.new(bsdf.outputs["BSDF"], out.inputs["Surface"])
|
|
294
|
+
if preset in ["gold", "gold_brushed", "aztec_gold"]:
|
|
295
|
+
bsdf.inputs["Base Color"].default_value = (1.0, 0.766, 0.336, 1.0)
|
|
296
|
+
bsdf.inputs["Metallic"].default_value = 1.0
|
|
297
|
+
bsdf.inputs["Roughness"].default_value = 0.18
|
|
298
|
+
elif preset in ["sandstone", "ancient_stone", "pyramid_stone"]:
|
|
299
|
+
bsdf.inputs["Base Color"].default_value = (0.68, 0.55, 0.40, 1.0)
|
|
300
|
+
bsdf.inputs["Roughness"].default_value = 0.85
|
|
301
|
+
elif preset in ["velvet", "cushion_velvet", "watch_cushion"]:
|
|
302
|
+
bsdf.inputs["Base Color"].default_value = (0.05, 0.06, 0.08, 1.0)
|
|
303
|
+
bsdf.inputs["Roughness"].default_value = 0.9
|
|
304
|
+
elif preset in ["chrome", "steel", "watch_case"]:
|
|
305
|
+
bsdf.inputs["Base Color"].default_value = (0.88, 0.89, 0.90, 1.0)
|
|
306
|
+
bsdf.inputs["Metallic"].default_value = 1.0
|
|
307
|
+
bsdf.inputs["Roughness"].default_value = 0.08
|
|
308
|
+
for o in targets:
|
|
309
|
+
if len(o.data.materials) == 0:
|
|
310
|
+
o.data.materials.append(mat)
|
|
311
|
+
else:
|
|
312
|
+
o.data.materials[0] = mat
|
|
313
|
+
print(f"Headless applied Smart PBR Material ({preset})")`;
|
|
250
314
|
await runHeadlessCli(null, matCode, results);
|
|
251
315
|
}
|
|
252
316
|
}
|
|
253
317
|
else if (action.type === 'cinematicAtmosphere') {
|
|
254
318
|
{
|
|
255
|
-
const atmoCode = `import bpy, math
|
|
319
|
+
const atmoCode = `import bpy, math
|
|
320
|
+
w = bpy.context.scene.world or bpy.data.worlds.new("CausyneWorld")
|
|
321
|
+
bpy.context.scene.world = w
|
|
322
|
+
w.use_nodes = True
|
|
323
|
+
nodes = w.node_tree.nodes
|
|
324
|
+
links = w.node_tree.links
|
|
325
|
+
nodes.clear()
|
|
326
|
+
bg = nodes.new("ShaderNodeBackground")
|
|
327
|
+
out = nodes.new("ShaderNodeOutputWorld")
|
|
328
|
+
sky = nodes.new("ShaderNodeTexSky")
|
|
329
|
+
sky.sky_type = 'MULTIPLE_SCATTERING' if hasattr(sky, 'sky_type') else 'HOSEK_WILKIE'
|
|
330
|
+
if hasattr(sky, 'sun_elevation'):
|
|
331
|
+
sky.sun_elevation = math.radians(${action.sun_elevation || 12.0})
|
|
332
|
+
sky.sun_rotation = math.radians(-45.0)
|
|
333
|
+
links.new(sky.outputs["Color"], bg.inputs["Color"])
|
|
334
|
+
links.new(bg.outputs["Background"], out.inputs["Surface"])
|
|
335
|
+
if ${action.volumetric_fog !== false}:
|
|
336
|
+
fm = bpy.data.materials.new("CausyneFog")
|
|
337
|
+
fm.use_nodes = True
|
|
338
|
+
fn = fm.node_tree.nodes
|
|
339
|
+
fl = fm.node_tree.links
|
|
340
|
+
fn.clear()
|
|
341
|
+
vol = fn.new("ShaderNodeVolumeScatter")
|
|
342
|
+
vol.inputs["Density"].default_value = ${action.fog_density || 0.015}
|
|
343
|
+
fo = fn.new("ShaderNodeOutputMaterial")
|
|
344
|
+
fl.new(vol.outputs["Volume"], fo.inputs["Volume"])
|
|
345
|
+
bpy.ops.mesh.primitive_cube_add(size=40.0, location=(0,0,10))
|
|
346
|
+
fb = bpy.context.active_object
|
|
347
|
+
fb.name = "CausyneAtmosphereVolume"
|
|
348
|
+
fb.display_type = 'WIRE'
|
|
349
|
+
fb.data.materials.append(fm)
|
|
350
|
+
print("Headless applied Cinematic Atmosphere (Nishita Sky + Volumetric Fog)")`;
|
|
256
351
|
await runHeadlessCli(null, atmoCode, results);
|
|
257
352
|
}
|
|
258
353
|
}
|
|
259
354
|
else if (action.type === 'smartGeoNodes') {
|
|
260
355
|
{
|
|
261
|
-
const gnCode = `import bpy
|
|
356
|
+
const gnCode = `import bpy
|
|
357
|
+
gen = ${JSON.stringify(action.generator || "masonry_brick_wall")}
|
|
358
|
+
targets = [o for o in bpy.context.scene.objects if o.type == 'MESH' and "Volume" not in o.name and "Floor" not in o.name]
|
|
359
|
+
for o in targets:
|
|
360
|
+
mod = o.modifiers.new(name=f"GeoNode_{gen}", type='NODES')
|
|
361
|
+
ng = bpy.data.node_groups.get(f"GN_{gen}")
|
|
362
|
+
if not ng:
|
|
363
|
+
ng = bpy.data.node_groups.new(f"GN_{gen}", 'GeometryNodeTree')
|
|
364
|
+
ng.interface.new_socket("Geometry", in_out='INPUT', socket_type='NodeSocketGeometry')
|
|
365
|
+
ng.interface.new_socket("Geometry", in_out='OUTPUT', socket_type='NodeSocketGeometry')
|
|
366
|
+
gi = ng.nodes.new('NodeGroupInput')
|
|
367
|
+
gi.location = (-400,0)
|
|
368
|
+
go = ng.nodes.new('NodeGroupOutput')
|
|
369
|
+
go.location = (400,0)
|
|
370
|
+
if gen == "masonry_brick_wall":
|
|
371
|
+
s = ng.nodes.new('GeometryNodeSubdivideMesh')
|
|
372
|
+
s.location = (-150,0)
|
|
373
|
+
s.inputs["Level"].default_value = ${action.subdivisions || 3}
|
|
374
|
+
ng.links.new(gi.outputs["Geometry"], s.inputs["Mesh"])
|
|
375
|
+
ng.links.new(s.outputs["Mesh"], go.inputs["Geometry"])
|
|
376
|
+
else:
|
|
377
|
+
ng.links.new(gi.outputs["Geometry"], go.inputs["Geometry"])
|
|
378
|
+
mod.node_group = ng
|
|
379
|
+
print(f"Headless attached Geometry Nodes ({gen})")`;
|
|
262
380
|
await runHeadlessCli(null, gnCode, results);
|
|
263
381
|
}
|
|
264
382
|
}
|
|
265
383
|
else if (action.type === 'setupStudioLighting') {
|
|
266
384
|
{
|
|
267
|
-
const lightCode = `import bpy, math
|
|
385
|
+
const lightCode = `import bpy, math
|
|
386
|
+
for o in list(bpy.context.scene.objects):
|
|
387
|
+
if o.type == 'LIGHT':
|
|
388
|
+
bpy.data.objects.remove(o, do_unlink=True)
|
|
389
|
+
kd = bpy.data.lights.new('Key', 'AREA')
|
|
390
|
+
kd.energy = ${action.key_energy || 800}
|
|
391
|
+
kd.size = 5.0
|
|
392
|
+
ko = bpy.data.objects.new('Key', kd)
|
|
393
|
+
ko.location = (6, -6, 8)
|
|
394
|
+
ko.rotation_euler = (math.radians(45), 0, math.radians(45))
|
|
395
|
+
bpy.context.scene.collection.objects.link(ko)
|
|
396
|
+
print('Headless studio lighting built')`;
|
|
268
397
|
await runHeadlessCli(null, lightCode, results);
|
|
269
398
|
}
|
|
270
399
|
}
|
|
@@ -274,14 +403,31 @@ export const blenderAct = {
|
|
|
274
403
|
const fmts = action.formats || ['blend', 'glb'];
|
|
275
404
|
|
|
276
405
|
{
|
|
277
|
-
const exportCode = `import bpy, os
|
|
406
|
+
const exportCode = `import bpy, os
|
|
407
|
+
d = "${destDir}"
|
|
408
|
+
os.makedirs(d, exist_ok=True)
|
|
409
|
+
if "blend" in ${JSON.stringify(fmts)}:
|
|
410
|
+
bpy.ops.wm.save_as_mainfile(filepath=os.path.join(d, "${prefix}.blend"))
|
|
411
|
+
if "glb" in ${JSON.stringify(fmts)}:
|
|
412
|
+
bpy.ops.export_scene.gltf(filepath=os.path.join(d, "${prefix}.glb"), export_format="GLB")
|
|
413
|
+
if "obj" in ${JSON.stringify(fmts)}:
|
|
414
|
+
if hasattr(bpy.ops.wm, "obj_export"):
|
|
415
|
+
bpy.ops.wm.obj_export(filepath=os.path.join(d, "${prefix}.obj"))
|
|
416
|
+
else:
|
|
417
|
+
bpy.ops.export_scene.obj(filepath=os.path.join(d, "${prefix}.obj"))
|
|
418
|
+
print(f"Headless exported formats to {d}")`;
|
|
278
419
|
await runHeadlessCli(null, exportCode, results);
|
|
279
420
|
}
|
|
280
421
|
}
|
|
281
422
|
else if (action.type === 'clearScene') {
|
|
282
423
|
const keep = action.keep_lights_camera !== false;
|
|
283
424
|
{
|
|
284
|
-
const clearCode = `import bpy
|
|
425
|
+
const clearCode = `import bpy
|
|
426
|
+
for o in list(bpy.context.scene.objects):
|
|
427
|
+
if ${keep} and o.type in ['CAMERA', 'LIGHT']:
|
|
428
|
+
continue
|
|
429
|
+
bpy.data.objects.remove(o, do_unlink=True)
|
|
430
|
+
print("Headless cleared scene meshes")`;
|
|
285
431
|
await runHeadlessCli(null, clearCode, results);
|
|
286
432
|
}
|
|
287
433
|
}
|
|
@@ -306,7 +452,10 @@ export const blenderAct = {
|
|
|
306
452
|
else if (action.type === 'captureViewport') {
|
|
307
453
|
const targetPath = action.filepath || path.join(getWorkspaceTempDir(), `causyne_3d_preview_${Date.now()}.png`);
|
|
308
454
|
{
|
|
309
|
-
const captureCode = `import bpy, os
|
|
455
|
+
const captureCode = `import bpy, os
|
|
456
|
+
os.makedirs(os.path.dirname("${targetPath}"), exist_ok=True)
|
|
457
|
+
bpy.ops.render.opengl(write_still=True, filepath="${targetPath}")
|
|
458
|
+
print("Captured headless viewport to ${targetPath}")`;
|
|
310
459
|
try {
|
|
311
460
|
await runHeadlessCli(null, captureCode, results);
|
|
312
461
|
} catch (cliErr) {
|
|
@@ -322,8 +471,46 @@ export const blenderAct = {
|
|
|
322
471
|
|
|
323
472
|
{
|
|
324
473
|
const renderCode = isAnimation ?
|
|
325
|
-
`import bpy, os, time
|
|
326
|
-
|
|
474
|
+
`import bpy, os, time
|
|
475
|
+
os.makedirs(os.path.dirname("${targetPath}"), exist_ok=True)
|
|
476
|
+
bpy.context.scene.frame_start = ${startFrame}
|
|
477
|
+
bpy.context.scene.frame_end = ${endFrame}
|
|
478
|
+
if "${action.engine || ''}":
|
|
479
|
+
bpy.context.scene.render.engine = "${action.engine || ''}"
|
|
480
|
+
try:
|
|
481
|
+
bpy.context.scene.render.filepath = "${targetPath}"
|
|
482
|
+
bpy.context.scene.render.image_settings.file_format = 'FFMPEG'
|
|
483
|
+
if hasattr(bpy.context.scene.render, 'ffmpeg'):
|
|
484
|
+
bpy.context.scene.render.ffmpeg.format = 'MPEG4' if "${targetPath}".lower().endsWith('.mp4') else 'MKV'
|
|
485
|
+
bpy.context.scene.render.ffmpeg.codec = 'H264'
|
|
486
|
+
bpy.ops.render.render(animation=True)
|
|
487
|
+
print(f"Rendered MP4 animation directly to ${targetPath}")
|
|
488
|
+
except Exception:
|
|
489
|
+
import subprocess, shutil as sh_util
|
|
490
|
+
td = os.path.join(os.path.dirname("${targetPath}"), ".causyne_temp_frames_" + str(int(time.time())))
|
|
491
|
+
os.makedirs(td, exist_ok=True)
|
|
492
|
+
bpy.context.scene.render.image_settings.file_format = 'PNG'
|
|
493
|
+
bpy.context.scene.render.filepath = os.path.join(td, "frame_")
|
|
494
|
+
bpy.ops.render.render(animation=True)
|
|
495
|
+
fps = getattr(bpy.context.scene.render, "fps", 30)
|
|
496
|
+
fb = sh_util.which("ffmpeg")
|
|
497
|
+
if not fb:
|
|
498
|
+
for cand in ["/opt/homebrew/bin/ffmpeg", "/usr/local/bin/ffmpeg", "C:\\\\Program Files\\\\ffmpeg\\\\bin\\\\ffmpeg.exe"]:
|
|
499
|
+
if os.path.exists(cand):
|
|
500
|
+
fb = cand
|
|
501
|
+
break
|
|
502
|
+
if not fb:
|
|
503
|
+
fb = "ffmpeg"
|
|
504
|
+
subprocess.run([fb, "-y", "-framerate", str(fps), "-i", os.path.join(td, "frame_%04d.png"), "-c:v", "libx264", "-pix_fmt", "yuv420p", "${targetPath}"], check=True)
|
|
505
|
+
sh_util.rmtree(td, ignore_errors=True)
|
|
506
|
+
print(f"Rendered MP4 animation via sequence to ${targetPath}")` :
|
|
507
|
+
`import bpy, os
|
|
508
|
+
os.makedirs(os.path.dirname("${targetPath}"), exist_ok=True)
|
|
509
|
+
bpy.context.scene.render.filepath = "${targetPath}"
|
|
510
|
+
if "${action.engine || ''}":
|
|
511
|
+
bpy.context.scene.render.engine = "${action.engine || ''}"
|
|
512
|
+
bpy.ops.render.render(write_still=True)
|
|
513
|
+
print(f"Rendered still frame to ${targetPath}")`;
|
|
327
514
|
try {
|
|
328
515
|
await runHeadlessCli(null, renderCode, results);
|
|
329
516
|
} catch (cliErr) {
|
|
@@ -15,7 +15,7 @@ import { resolveUserPath } from '../utils/paths.js';
|
|
|
15
15
|
export const documentForgeTool = {
|
|
16
16
|
schema: {
|
|
17
17
|
name: 'document_forge',
|
|
18
|
-
description: 'Causyne Document Forge: Professional document & media production harness. Generates pixel-perfect A4/Letter publications via HTML/CSS-First Paged Media and Headless Chrome, renders vector PDFs (<2MB compliant), extracts page images for visual QA ("
|
|
18
|
+
description: 'Causyne Document Forge: Professional document & media production harness. Generates pixel-perfect A4/Letter publications via HTML/CSS-First Paged Media and Headless Chrome, renders vector PDFs (<2MB compliant), extracts page images for visual QA ("Inspect Results"), audits anti-slop and math integrity, formats Hollywood Courier 12pt screenplays, creates production shot lists, and times VO narration.',
|
|
19
19
|
parameters: {
|
|
20
20
|
type: 'object',
|
|
21
21
|
properties: {
|
|
@@ -55,7 +55,7 @@ export interface DocumentForgeArgs {
|
|
|
55
55
|
export const documentForgeTool = {
|
|
56
56
|
schema: {
|
|
57
57
|
name: 'document_forge',
|
|
58
|
-
description: 'Causyne Document Forge: Professional document & media production harness. Generates pixel-perfect A4/Letter publications via HTML/CSS-First Paged Media and Headless Chrome, renders vector PDFs (<2MB compliant), extracts page images for visual QA ("
|
|
58
|
+
description: 'Causyne Document Forge: Professional document & media production harness. Generates pixel-perfect A4/Letter publications via HTML/CSS-First Paged Media and Headless Chrome, renders vector PDFs (<2MB compliant), extracts page images for visual QA ("Inspect Results"), audits anti-slop and math integrity, formats Hollywood Courier 12pt screenplays, creates production shot lists, and times VO narration.',
|
|
59
59
|
parameters: {
|
|
60
60
|
type: 'object',
|
|
61
61
|
properties: {
|