@causyne/agent 1.20.8 → 1.20.10
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 +2 -1
- package/src/agentLoop.js +291 -103
- package/src/agentLoop.ts +322 -109
- package/src/browser/causyneBrowser.js +36 -0
- package/src/browser/causyneBrowser.ts +36 -1
- package/src/commands.js +25 -0
- 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/contextManager.js +16 -0
- 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 +191 -28
- package/src/providers/antigravity.ts +192 -27
- package/src/providers/base.d.ts +2 -0
- package/src/providers/pi.js +3 -1
- package/src/providers/pi.ts +4 -2
- package/src/provisioning/capabilityProvisioner.js +2 -7
- package/src/provisioning/npmInstall.js +19 -0
- package/src/provisioning/npmInstall.ts +19 -0
- package/src/sandbox.js +7 -10
- package/src/smartToolsUse.js +223 -0
- package/src/smartToolsUse.ts +284 -0
- package/src/stallGuard.js +356 -0
- package/src/stallGuard.ts +432 -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/browserAutomator.js +3 -3
- package/src/tools/browserAutomator.ts +3 -3
- package/src/tools/documentForge.js +1 -1
- package/src/tools/documentForge.ts +1 -1
- package/src/tools/fsRead.js +91 -80
- package/src/tools/fsRead.ts +125 -0
- package/src/tools/peerAgent.js +1 -1
- package/src/tools/peerAgent.ts +1 -1
- package/src/tools/screenshot.js +5 -1
- package/src/tools/screenshot.ts +5 -1
- package/src/tools/toolScanner.js +19 -0
- package/src/tools/toolScanner.ts +17 -0
- package/src/tools/toolSelfRepair.js +63 -1
- package/src/tools/toolSelfRepair.ts +61 -1
- package/src/tools/visionInspector.js +80 -142
- package/src/tools/visionInspector.ts +110 -0
- package/src/tui/chatboxClipboard.js +152 -0
- package/src/tui/chatboxClipboard.ts +201 -0
- package/src/tui/clipboardSync.js +38 -7
- package/src/tui/clipboardSync.ts +39 -7
- package/src/tui/codeProgress.js +89 -18
- package/src/tui/codeProgress.ts +102 -17
- package/src/tui/codeStreamRenderer.js +7 -2
- package/src/tui/codeStreamRenderer.ts +7 -2
- package/src/tui/composerControls.js +9 -0
- package/src/tui/composerControls.ts +9 -0
- package/src/tui/dialogs.js +8 -3
- package/src/tui/diff.d.ts +1 -0
- package/src/tui/lineEditor.js +166 -14
- package/src/tui/mouseHover.js +6 -2
- package/src/tui/mouseHover.ts +7 -2
- package/src/tui/prompt.js +96 -19
- package/src/tui/stageSurface.js +3 -1
|
@@ -0,0 +1,223 @@
|
|
|
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
|
+
import { PACK_PLAYBOOKS } from './toolPacks.js';
|
|
11
|
+
// ---------------------------------------------------------------------------
|
|
12
|
+
// Intent Matchers & Negative Filters
|
|
13
|
+
// ---------------------------------------------------------------------------
|
|
14
|
+
// Personalization / desktop actions (setting wallpaper, changing desktop background)
|
|
15
|
+
const DESKTOP_PERSONALIZATION_PATTERN = /\b(desktop (picture|wallpaper|background|image)|set wallpaper|change wallpaper)\b/i;
|
|
16
|
+
// Pure web search / retrieval without UI/frontend construction
|
|
17
|
+
const PURE_WEB_SEARCH_PATTERN = /\b(search(ing)? (the )?web|web search|look up online|find on google|brows(e|ing) (the )?web)\b/i;
|
|
18
|
+
const WEB_CONSTRUCTION_EXCLUSION = /\b(build|create|make|design|develop|scaffold|code|program|css|html|tailwind|component|frontend|front-end|landing page|website|webpage|dashboard)\b/i;
|
|
19
|
+
// System admin / process & terminal operations
|
|
20
|
+
const SYSTEM_ADMIN_PATTERN = /\b(kill process|kill port|check port|port \d+|lsof|ps aux|terminate process|zip folder|unzip file|extract archive|compress folder)\b/i;
|
|
21
|
+
// Simple file management operations
|
|
22
|
+
const SIMPLE_FILE_OP_PATTERN = /\b(list (the )?files|show files|count files|rename file(s)?|delete file(s)?|move file(s)?|clean (up )?folder)\b/i;
|
|
23
|
+
// Media generation intent (explicit creation of 3D, video, audio, or synthesized speech)
|
|
24
|
+
const EXPLICIT_MEDIA_GENERATION_PATTERN = /\b(blender|3d model|render 3d|render frame|render animation|da vinci|resolve|audio synth|synthesizer|text to speech|tts|voiceover|dubbing)\b/i;
|
|
25
|
+
// Explicit web engineering intent
|
|
26
|
+
const EXPLICIT_WEB_ENGINEERING_PATTERN = /\b(build.*(website|webpage|landing page|dashboard|ui component|frontend)|create.*(website|webpage|landing page|dashboard|ui)|develop.*(website|web app|webapp))\b/i;
|
|
27
|
+
// Explicit game development intent
|
|
28
|
+
const EXPLICIT_GAME_DEV_PATTERN = /\b(build.*game|create.*game|develop.*game|godot|unity|unreal|platformer 2d|rpg game|arcade game)\b/i;
|
|
29
|
+
/**
|
|
30
|
+
* Select tools to preload based on prompt intent. This is never an allowlist:
|
|
31
|
+
* tool_search can add capabilities as the task develops.
|
|
32
|
+
*/
|
|
33
|
+
export function determineToolScope(prompt, _taskShape) {
|
|
34
|
+
const text = (prompt || '').trim();
|
|
35
|
+
if (!text) {
|
|
36
|
+
return { toolScope: null, archetype: 'empty', suppressedPacks: [] };
|
|
37
|
+
}
|
|
38
|
+
// 1. Desktop personalization (e.g. wallpaper / desktop background)
|
|
39
|
+
if (DESKTOP_PERSONALIZATION_PATTERN.test(text)) {
|
|
40
|
+
const tools = new Set([
|
|
41
|
+
'sysRun',
|
|
42
|
+
'web_search',
|
|
43
|
+
'web_fetch',
|
|
44
|
+
'fs_read',
|
|
45
|
+
'fs_write',
|
|
46
|
+
'fs_list',
|
|
47
|
+
'update_plan',
|
|
48
|
+
'tool_search'
|
|
49
|
+
]);
|
|
50
|
+
return {
|
|
51
|
+
toolScope: tools,
|
|
52
|
+
archetype: 'desktop_personalization',
|
|
53
|
+
suppressedPacks: ['media', 'web', 'game', 'advanced', 'system'],
|
|
54
|
+
reason: 'Start with search and system execution; discover desktop or browser tools if direct execution is unsuitable.'
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
// 2. Pure web research (searching/fetching online information without web app construction)
|
|
58
|
+
if (PURE_WEB_SEARCH_PATTERN.test(text) && !WEB_CONSTRUCTION_EXCLUSION.test(text)) {
|
|
59
|
+
const tools = new Set([
|
|
60
|
+
'web_search',
|
|
61
|
+
'web_fetch',
|
|
62
|
+
'sysRun',
|
|
63
|
+
'fs_read',
|
|
64
|
+
'fs_write',
|
|
65
|
+
'update_plan',
|
|
66
|
+
'tool_search'
|
|
67
|
+
]);
|
|
68
|
+
return {
|
|
69
|
+
toolScope: tools,
|
|
70
|
+
archetype: 'web_research_only',
|
|
71
|
+
suppressedPacks: ['media', 'game', 'web', 'advanced'],
|
|
72
|
+
reason: 'Pure information retrieval requires web search tools; suppresses UI forge and creative packs.'
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
// 3. System process or archive administration
|
|
76
|
+
if (SYSTEM_ADMIN_PATTERN.test(text)) {
|
|
77
|
+
const tools = new Set([
|
|
78
|
+
'sysRun',
|
|
79
|
+
'proc_term',
|
|
80
|
+
'process_list',
|
|
81
|
+
'archive',
|
|
82
|
+
'fs_read',
|
|
83
|
+
'fs_list',
|
|
84
|
+
'update_plan',
|
|
85
|
+
'tool_search'
|
|
86
|
+
]);
|
|
87
|
+
return {
|
|
88
|
+
toolScope: tools,
|
|
89
|
+
archetype: 'system_admin',
|
|
90
|
+
suppressedPacks: ['media', 'game', 'web'],
|
|
91
|
+
reason: 'System administration uses process and archive utilities; suppresses creative packs.'
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
// 4. Simple local file manipulation
|
|
95
|
+
if (SIMPLE_FILE_OP_PATTERN.test(text) && !EXPLICIT_WEB_ENGINEERING_PATTERN.test(text) && !EXPLICIT_GAME_DEV_PATTERN.test(text)) {
|
|
96
|
+
const tools = new Set([
|
|
97
|
+
'fs_read',
|
|
98
|
+
'fs_write',
|
|
99
|
+
'fs_edit',
|
|
100
|
+
'fs_list',
|
|
101
|
+
'fs_search',
|
|
102
|
+
'sysRun',
|
|
103
|
+
'update_plan',
|
|
104
|
+
'tool_search'
|
|
105
|
+
]);
|
|
106
|
+
return {
|
|
107
|
+
toolScope: tools,
|
|
108
|
+
archetype: 'simple_file_op',
|
|
109
|
+
suppressedPacks: ['media', 'game', 'web', 'advanced'],
|
|
110
|
+
reason: 'Simple filesystem operation; suppresses external domain packs.'
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
// 5. Media / 3D generation & creative audio intent
|
|
114
|
+
if (EXPLICIT_MEDIA_GENERATION_PATTERN.test(text)) {
|
|
115
|
+
const tools = new Set([
|
|
116
|
+
'blender_act',
|
|
117
|
+
'creative_apps',
|
|
118
|
+
'execute_procedural_media',
|
|
119
|
+
'fs_read',
|
|
120
|
+
'fs_write',
|
|
121
|
+
'sysRun',
|
|
122
|
+
'view_image',
|
|
123
|
+
'update_plan',
|
|
124
|
+
'tool_search'
|
|
125
|
+
]);
|
|
126
|
+
return {
|
|
127
|
+
toolScope: tools,
|
|
128
|
+
archetype: 'media_3d_generation',
|
|
129
|
+
suppressedPacks: ['web', 'game', 'advanced', 'system'],
|
|
130
|
+
reason: 'Media generation intent prioritizes 3D studio, procedural media, and image inspection; suppresses web and game packs.'
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
// Default: unconstrained (standard progressive disclosure and packs apply)
|
|
134
|
+
return {
|
|
135
|
+
toolScope: null,
|
|
136
|
+
archetype: 'generalist',
|
|
137
|
+
suppressedPacks: []
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Filter out packs that have been explicitly suppressed for a given prompt intent.
|
|
142
|
+
*/
|
|
143
|
+
export function filterSuppressedPacks(candidatePacks, prompt) {
|
|
144
|
+
const result = new Set();
|
|
145
|
+
const scopeResult = determineToolScope(prompt);
|
|
146
|
+
const suppressed = new Set(scopeResult.suppressedPacks);
|
|
147
|
+
for (const pack of candidatePacks) {
|
|
148
|
+
if (!suppressed.has(pack)) {
|
|
149
|
+
result.add(pack);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return result;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Resolve lazy playbooks. Discloses full multi-page mandates only when tools from that
|
|
156
|
+
* domain have been actively invoked or explicitly demanded. Otherwise generates micro-indicators.
|
|
157
|
+
*/
|
|
158
|
+
export function resolveLazyPlaybooks(unlockedPacks, observedTools = [], prompt = '') {
|
|
159
|
+
const packs = new Set(unlockedPacks);
|
|
160
|
+
const tools = new Set(observedTools);
|
|
161
|
+
const text = prompt || '';
|
|
162
|
+
const activePlaybooks = [];
|
|
163
|
+
const microAnnouncements = [];
|
|
164
|
+
const activeDomains = [];
|
|
165
|
+
let tokenSavings = 0;
|
|
166
|
+
// 1. Web Domain
|
|
167
|
+
if (packs.has('web')) {
|
|
168
|
+
const webToolInvoked = tools.has('ui_forge') ||
|
|
169
|
+
tools.has('browser_act') ||
|
|
170
|
+
tools.has('vision_inspect_ui') ||
|
|
171
|
+
tools.has('screenshot') ||
|
|
172
|
+
tools.has('astryx_oracle');
|
|
173
|
+
const webExplicitDemand = EXPLICIT_WEB_ENGINEERING_PATTERN.test(text);
|
|
174
|
+
if ((webToolInvoked || webExplicitDemand) && PACK_PLAYBOOKS.web) {
|
|
175
|
+
activePlaybooks.push(PACK_PLAYBOOKS.web);
|
|
176
|
+
activeDomains.push('web');
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
microAnnouncements.push('- web: browser automation & UI forge available on demand via tool_search.');
|
|
180
|
+
tokenSavings += Math.round((PACK_PLAYBOOKS.web?.length || 0) / 4);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
// 2. Media Domain
|
|
184
|
+
if (packs.has('media')) {
|
|
185
|
+
const mediaToolInvoked = tools.has('blender_act') ||
|
|
186
|
+
tools.has('creative_apps') ||
|
|
187
|
+
tools.has('native_engine') ||
|
|
188
|
+
tools.has('execute_procedural_media') ||
|
|
189
|
+
tools.has('generate_media_via_api') ||
|
|
190
|
+
tools.has('open_source_tool_provisioner');
|
|
191
|
+
const mediaExplicitDemand = EXPLICIT_MEDIA_GENERATION_PATTERN.test(text);
|
|
192
|
+
if ((mediaToolInvoked || mediaExplicitDemand) && PACK_PLAYBOOKS.media) {
|
|
193
|
+
activePlaybooks.push(PACK_PLAYBOOKS.media);
|
|
194
|
+
activeDomains.push('media');
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
microAnnouncements.push('- media: 3D Blender, audio synthesis & creative engines available on demand via tool_search.');
|
|
198
|
+
tokenSavings += Math.round((PACK_PLAYBOOKS.media?.length || 0) / 4);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
// 3. Game Domain
|
|
202
|
+
if (packs.has('game')) {
|
|
203
|
+
const gameToolInvoked = tools.has('godot_act') ||
|
|
204
|
+
tools.has('game_build_html5') ||
|
|
205
|
+
tools.has('game_scene_build') ||
|
|
206
|
+
tools.has('game_asset_harvest');
|
|
207
|
+
const gameExplicitDemand = EXPLICIT_GAME_DEV_PATTERN.test(text);
|
|
208
|
+
if ((gameToolInvoked || gameExplicitDemand) && PACK_PLAYBOOKS.game) {
|
|
209
|
+
activePlaybooks.push(PACK_PLAYBOOKS.game);
|
|
210
|
+
activeDomains.push('game');
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
microAnnouncements.push('- game: Godot 2D/3D & HTML5 game development cascade available on demand via tool_search.');
|
|
214
|
+
tokenSavings += Math.round((PACK_PLAYBOOKS.game?.length || 0) / 4);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
return {
|
|
218
|
+
fullPlaybooks: activePlaybooks.join('\n\n'),
|
|
219
|
+
microAnnouncements: microAnnouncements.join('\n'),
|
|
220
|
+
activePlaybookDomains: activeDomains,
|
|
221
|
+
tokenSavingsEstimate: tokenSavings
|
|
222
|
+
};
|
|
223
|
+
}
|
|
@@ -0,0 +1,284 @@
|
|
|
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
|
+
// 5. Media / 3D generation & creative audio intent
|
|
155
|
+
if (EXPLICIT_MEDIA_GENERATION_PATTERN.test(text)) {
|
|
156
|
+
const tools = new Set([
|
|
157
|
+
'blender_act',
|
|
158
|
+
'creative_apps',
|
|
159
|
+
'execute_procedural_media',
|
|
160
|
+
'fs_read',
|
|
161
|
+
'fs_write',
|
|
162
|
+
'sysRun',
|
|
163
|
+
'view_image',
|
|
164
|
+
'update_plan',
|
|
165
|
+
'tool_search'
|
|
166
|
+
]);
|
|
167
|
+
return {
|
|
168
|
+
toolScope: tools,
|
|
169
|
+
archetype: 'media_3d_generation',
|
|
170
|
+
suppressedPacks: ['web', 'game', 'advanced', 'system'],
|
|
171
|
+
reason: 'Media generation intent prioritizes 3D studio, procedural media, and image inspection; suppresses web and game packs.'
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// Default: unconstrained (standard progressive disclosure and packs apply)
|
|
176
|
+
return {
|
|
177
|
+
toolScope: null,
|
|
178
|
+
archetype: 'generalist',
|
|
179
|
+
suppressedPacks: []
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Filter out packs that have been explicitly suppressed for a given prompt intent.
|
|
185
|
+
*/
|
|
186
|
+
export function filterSuppressedPacks(
|
|
187
|
+
candidatePacks: Iterable<string>,
|
|
188
|
+
prompt: string
|
|
189
|
+
): Set<string> {
|
|
190
|
+
const result = new Set<string>();
|
|
191
|
+
const scopeResult = determineToolScope(prompt);
|
|
192
|
+
const suppressed = new Set(scopeResult.suppressedPacks);
|
|
193
|
+
|
|
194
|
+
for (const pack of candidatePacks) {
|
|
195
|
+
if (!suppressed.has(pack)) {
|
|
196
|
+
result.add(pack);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
return result;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Resolve lazy playbooks. Discloses full multi-page mandates only when tools from that
|
|
205
|
+
* domain have been actively invoked or explicitly demanded. Otherwise generates micro-indicators.
|
|
206
|
+
*/
|
|
207
|
+
export function resolveLazyPlaybooks(
|
|
208
|
+
unlockedPacks: Iterable<string>,
|
|
209
|
+
observedTools: Iterable<string> = [],
|
|
210
|
+
prompt = ''
|
|
211
|
+
): LazyPlaybookResult {
|
|
212
|
+
const packs = new Set(unlockedPacks);
|
|
213
|
+
const tools = new Set(observedTools);
|
|
214
|
+
const text = prompt || '';
|
|
215
|
+
|
|
216
|
+
const activePlaybooks: string[] = [];
|
|
217
|
+
const microAnnouncements: string[] = [];
|
|
218
|
+
const activeDomains: string[] = [];
|
|
219
|
+
let tokenSavings = 0;
|
|
220
|
+
|
|
221
|
+
// 1. Web Domain
|
|
222
|
+
if (packs.has('web')) {
|
|
223
|
+
const webToolInvoked =
|
|
224
|
+
tools.has('ui_forge') ||
|
|
225
|
+
tools.has('browser_act') ||
|
|
226
|
+
tools.has('vision_inspect_ui') ||
|
|
227
|
+
tools.has('screenshot') ||
|
|
228
|
+
tools.has('astryx_oracle');
|
|
229
|
+
const webExplicitDemand = EXPLICIT_WEB_ENGINEERING_PATTERN.test(text);
|
|
230
|
+
|
|
231
|
+
if ((webToolInvoked || webExplicitDemand) && PACK_PLAYBOOKS.web) {
|
|
232
|
+
activePlaybooks.push(PACK_PLAYBOOKS.web);
|
|
233
|
+
activeDomains.push('web');
|
|
234
|
+
} else {
|
|
235
|
+
microAnnouncements.push('- web: browser automation & UI forge available on demand via tool_search.');
|
|
236
|
+
tokenSavings += Math.round((PACK_PLAYBOOKS.web?.length || 0) / 4);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// 2. Media Domain
|
|
241
|
+
if (packs.has('media')) {
|
|
242
|
+
const mediaToolInvoked =
|
|
243
|
+
tools.has('blender_act') ||
|
|
244
|
+
tools.has('creative_apps') ||
|
|
245
|
+
tools.has('native_engine') ||
|
|
246
|
+
tools.has('execute_procedural_media') ||
|
|
247
|
+
tools.has('generate_media_via_api') ||
|
|
248
|
+
tools.has('open_source_tool_provisioner');
|
|
249
|
+
const mediaExplicitDemand = EXPLICIT_MEDIA_GENERATION_PATTERN.test(text);
|
|
250
|
+
|
|
251
|
+
if ((mediaToolInvoked || mediaExplicitDemand) && PACK_PLAYBOOKS.media) {
|
|
252
|
+
activePlaybooks.push(PACK_PLAYBOOKS.media);
|
|
253
|
+
activeDomains.push('media');
|
|
254
|
+
} else {
|
|
255
|
+
microAnnouncements.push('- media: 3D Blender, audio synthesis & creative engines available on demand via tool_search.');
|
|
256
|
+
tokenSavings += Math.round((PACK_PLAYBOOKS.media?.length || 0) / 4);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// 3. Game Domain
|
|
261
|
+
if (packs.has('game')) {
|
|
262
|
+
const gameToolInvoked =
|
|
263
|
+
tools.has('godot_act') ||
|
|
264
|
+
tools.has('game_build_html5') ||
|
|
265
|
+
tools.has('game_scene_build') ||
|
|
266
|
+
tools.has('game_asset_harvest');
|
|
267
|
+
const gameExplicitDemand = EXPLICIT_GAME_DEV_PATTERN.test(text);
|
|
268
|
+
|
|
269
|
+
if ((gameToolInvoked || gameExplicitDemand) && PACK_PLAYBOOKS.game) {
|
|
270
|
+
activePlaybooks.push(PACK_PLAYBOOKS.game);
|
|
271
|
+
activeDomains.push('game');
|
|
272
|
+
} else {
|
|
273
|
+
microAnnouncements.push('- game: Godot 2D/3D & HTML5 game development cascade available on demand via tool_search.');
|
|
274
|
+
tokenSavings += Math.round((PACK_PLAYBOOKS.game?.length || 0) / 4);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
return {
|
|
279
|
+
fullPlaybooks: activePlaybooks.join('\n\n'),
|
|
280
|
+
microAnnouncements: microAnnouncements.join('\n'),
|
|
281
|
+
activePlaybookDomains: activeDomains,
|
|
282
|
+
tokenSavingsEstimate: tokenSavings
|
|
283
|
+
};
|
|
284
|
+
}
|