@causyne/agent 1.20.12 → 1.20.14
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/LICENSE +1 -1
- package/package.json +1 -1
- package/src/SmartTools.js +33 -0
- package/src/SmartTools.ts +37 -0
- package/src/acp/client.js +157 -4
- package/src/acp/client.ts +152 -5
- package/src/agentLoop.js +857 -178
- package/src/agentLoop.ts +865 -183
- package/src/browser/browserRuntime.js +8 -1
- package/src/browser/browserRuntime.ts +8 -1
- package/src/browser/causyneBrowser.js +20 -4
- package/src/browser/causyneBrowser.ts +20 -4
- package/src/browser/urlPolicy.js +35 -0
- package/src/browser/urlPolicy.ts +34 -0
- package/src/cliMode.js +6 -2
- package/src/commands.js +14 -0
- package/src/contextManager.d.ts +1 -0
- package/src/core/contextCompactor.js +277 -0
- package/src/core/contextCompactor.ts +353 -0
- package/src/decideTools.js +157 -0
- package/src/decideTools.ts +195 -0
- package/src/decisionPolicy.js +5 -3
- package/src/decisionPolicy.ts +5 -3
- package/src/implementationPlan.js +284 -0
- package/src/implementationPlan.ts +275 -0
- package/src/observer/coldObserver.js +10 -4
- package/src/observer/coldObserver.ts +15 -7
- package/src/observer/evidence.js +11 -5
- package/src/observer/evidence.ts +13 -6
- package/src/observer.js +196 -0
- package/src/observer.ts +287 -0
- package/src/providers/acp.js +362 -109
- package/src/providers/acp.ts +359 -111
- package/src/providers/antigravity.js +133 -105
- package/src/providers/antigravity.ts +130 -109
- package/src/providers/base.d.ts +3 -0
- package/src/providers/budgetEnforcer.js +13 -0
- package/src/providers/budgetEnforcer.ts +13 -3
- package/src/provisioning/capabilityProvisioner.js +14 -10
- package/src/sandbox.js +4 -2
- package/src/saveTools.js +146 -0
- package/src/saveTools.ts +169 -0
- package/src/session/cachePressure.js +77 -0
- package/src/session/cachePressure.ts +122 -0
- package/src/smartToolsUse.js +69 -12
- package/src/smartToolsUse.ts +103 -12
- package/src/taskShape.js +7 -7
- package/src/taskShape.ts +7 -7
- package/src/timeMachine.js +55 -20
- package/src/timeMachine.ts +64 -20
- package/src/toolPacks.js +217 -310
- package/src/toolPacks.ts +505 -0
- package/src/tools/deferredMcpSearch.js +21 -13
- package/src/tools/deferredMcpSearch.ts +23 -15
- package/src/tools/updatePlan.js +2 -2
- package/src/tools/updatePlan.ts +2 -2
- package/src/toolsList.js +203 -0
- package/src/toolsList.ts +224 -0
- package/src/tui/chatRenderer.js +49 -14
- package/src/tui/codeStreamRenderer.js +16 -5
- package/src/tui/codeStreamRenderer.ts +14 -4
- package/src/tui/prompt.js +4 -2
- package/src/tui/sessionSidebar.js +10 -2
- package/src/tui/sessionSidebar.ts +10 -3
- package/src/tui/stageSurface.js +27 -1
- package/src/tui/text.d.ts +1 -0
- package/src/tui/turnRail.js +274 -0
- package/src/tui/turnRail.ts +334 -0
- package/src/types/contracts.ts +103 -0
- package/src/verificationPlan.js +141 -0
- package/src/verificationPlan.ts +166 -0
- package/src/toolPacks.d.ts +0 -10
package/src/toolPacks.js
CHANGED
|
@@ -11,204 +11,170 @@
|
|
|
11
11
|
// 3. Auto-unlock recovery — calling a locked-but-real tool unlocks its pack
|
|
12
12
|
//
|
|
13
13
|
// Set config.grantAllTools = true to disable deferral entirely.
|
|
14
|
-
|
|
15
|
-
// ---------------------------------------------------------------------------
|
|
16
|
-
// Pack membership. Names match the `name` field of each tool schema, with dots
|
|
17
|
-
// already normalised to underscores (see tools/registry.js TOOL_DEFINITIONS).
|
|
18
|
-
// ---------------------------------------------------------------------------
|
|
19
|
-
|
|
20
14
|
export const CORE_TOOLS = [
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
15
|
+
'sysRun',
|
|
16
|
+
'sysRunBg',
|
|
17
|
+
'terminal_persistent_shell',
|
|
18
|
+
'fs_read',
|
|
19
|
+
'fs_write',
|
|
20
|
+
'fs_edit',
|
|
21
|
+
'MultiEdit',
|
|
22
|
+
'fs_list',
|
|
23
|
+
'fs_search',
|
|
24
|
+
'fs_find',
|
|
25
|
+
'fs_move',
|
|
26
|
+
'fs_delete',
|
|
27
|
+
'gitOp',
|
|
28
|
+
'code_search_ripgrep',
|
|
29
|
+
'codebase_search',
|
|
30
|
+
'code_verify_syntax',
|
|
31
|
+
'web_search',
|
|
32
|
+
'web_fetch',
|
|
33
|
+
'update_plan',
|
|
34
|
+
'request_decision',
|
|
35
|
+
'memory_write',
|
|
36
|
+
'fs_read_skill',
|
|
37
|
+
'skill_create',
|
|
38
|
+
'tool_search'
|
|
45
39
|
];
|
|
46
|
-
|
|
47
40
|
export const PACKS = {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
41
|
+
game: [
|
|
42
|
+
// Stage 1 of the game cascade calls check_system_specs to verify the
|
|
43
|
+
// engine, so it must travel with this pack as well as with media.
|
|
44
|
+
'check_system_specs',
|
|
45
|
+
'godot_act',
|
|
46
|
+
'game_build_html5',
|
|
47
|
+
'game_asset_fetch',
|
|
48
|
+
'game_asset_harvest',
|
|
49
|
+
'game_lore_forge',
|
|
50
|
+
'game_dialogue_tree_gen',
|
|
51
|
+
'game_quest_arc_builder',
|
|
52
|
+
'game_animation_rig',
|
|
53
|
+
'game_ai_behavior_tree',
|
|
54
|
+
'game_cinematic_sequencer',
|
|
55
|
+
'game_audio_synth',
|
|
56
|
+
'game_vfx_emitter_gen',
|
|
57
|
+
'game_shader_forge',
|
|
58
|
+
'game_scene_build',
|
|
59
|
+
'game_entity_spawner',
|
|
60
|
+
'game_tilemap_gen',
|
|
61
|
+
'game_ui_hud_builder',
|
|
62
|
+
'game_economy_balancer',
|
|
63
|
+
'game_data_forge',
|
|
64
|
+
'game_web_runtime_inspector',
|
|
65
|
+
'game_canvas_audit'
|
|
66
|
+
],
|
|
67
|
+
web: [
|
|
68
|
+
'browser_act',
|
|
69
|
+
'screenshot',
|
|
70
|
+
'vision_inspect_ui',
|
|
71
|
+
'view_image',
|
|
72
|
+
'astryx_oracle',
|
|
73
|
+
'ui_forge'
|
|
74
|
+
],
|
|
75
|
+
media: [
|
|
76
|
+
'generate_media_via_api',
|
|
77
|
+
'execute_procedural_media',
|
|
78
|
+
'check_system_specs',
|
|
79
|
+
'manage_local_dependencies',
|
|
80
|
+
'blender_act',
|
|
81
|
+
'creative_apps',
|
|
82
|
+
'native_engine',
|
|
83
|
+
'resolve_act',
|
|
84
|
+
'palmier_act',
|
|
85
|
+
'document_forge',
|
|
86
|
+
'open_source_tool_provisioner'
|
|
87
|
+
],
|
|
88
|
+
system: [
|
|
89
|
+
// Channel B of the Three-Channel Doctrine: reading the screen as structured
|
|
90
|
+
// text instead of pixels. Lives here rather than in core because most tasks
|
|
91
|
+
// never touch a GUI, and tool_search brings it in the moment one does.
|
|
92
|
+
'ax_snapshot',
|
|
93
|
+
// Channel C. Ships beside its observer on purpose: acting on a screen you
|
|
94
|
+
// have not read is how an agent clicks the wrong button confidently.
|
|
95
|
+
'desktop_act',
|
|
96
|
+
'computer_use',
|
|
97
|
+
'process_list',
|
|
98
|
+
'proc_term',
|
|
99
|
+
'archive',
|
|
100
|
+
'clipboard',
|
|
101
|
+
'desktop_open',
|
|
102
|
+
'printer_print',
|
|
103
|
+
'printer_list_printers',
|
|
104
|
+
'printer_get_status'
|
|
105
|
+
],
|
|
106
|
+
advanced: [
|
|
107
|
+
'tool_forge',
|
|
108
|
+
'plugin_manager',
|
|
109
|
+
'document_forge',
|
|
110
|
+
'agent_subagent_orchestrate',
|
|
111
|
+
'peer_agent_delegate',
|
|
112
|
+
'code_search_ast',
|
|
113
|
+
'code_list_symbols',
|
|
114
|
+
'pdf_read'
|
|
115
|
+
]
|
|
123
116
|
};
|
|
124
|
-
|
|
125
117
|
export const PACK_NAMES = Object.keys(PACKS);
|
|
126
|
-
|
|
127
118
|
/**
|
|
128
119
|
* The core tools that ship in EVERY request on a provider with no native
|
|
129
120
|
* schema deferral. The rest of CORE_TOOLS is withheld until the model asks for
|
|
130
121
|
* it with `tool_search`, exactly as a capability pack is.
|
|
131
|
-
*
|
|
132
|
-
* WHY: Anthropic can hold schemas server-side (`defer_loading` +
|
|
133
|
-
* `tool_search_tool_regex`), so on Claude the full core costs nothing to
|
|
134
|
-
* advertise. That is one provider out of eleven. On OpenAI, Gemini, DeepSeek,
|
|
135
|
-
* Qwen, Muse, xAI, Moonshot, Ollama and the two BYOK paths, all 24 core
|
|
136
|
-
* schemas were serialised into every single request — 3,341 tokens, of which a
|
|
137
|
-
* typical turn calls two.
|
|
138
|
-
*
|
|
139
|
-
* WHAT IS IN, AND WHY EXACTLY THESE: read, write, edit, list and search cover
|
|
140
|
-
* every file operation a first turn can need; `sysRun` is the escape hatch that
|
|
141
|
-
* can reach anything the other resident tools cannot; `update_plan` is how a
|
|
142
|
-
* multi-step task announces its plan on step one; `tool_search` is the door to
|
|
143
|
-
* deferred tools. `request_decision` is injected on the first turn only when
|
|
144
|
-
* task policy detects an unresolved durable choice. With this set the agent is
|
|
145
|
-
* never stuck — worst case it spends one call
|
|
146
|
-
* discovering the tool it wants, and the tool it discovers stays loaded for the
|
|
147
|
-
* rest of the task.
|
|
148
|
-
*
|
|
149
|
-
* WHAT WITHHOLDING DOES NOT DO: it does not remove capability. `resolveTool()`
|
|
150
|
-
* still resolves a withheld core tool by name, so a model that calls one from
|
|
151
|
-
* memory simply gets it. Only the schema is absent, never the tool.
|
|
152
122
|
*/
|
|
153
123
|
export const RESIDENT_TOOLS = [
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
124
|
+
'fs_read',
|
|
125
|
+
'fs_write',
|
|
126
|
+
'fs_edit',
|
|
127
|
+
'fs_list',
|
|
128
|
+
'fs_search',
|
|
129
|
+
'sysRun',
|
|
130
|
+
'update_plan',
|
|
131
|
+
'tool_search'
|
|
162
132
|
];
|
|
163
|
-
|
|
164
133
|
const RESIDENT_TOOL_SET = new Set(RESIDENT_TOOLS);
|
|
165
|
-
|
|
166
134
|
/** True when this core tool ships in every request even without native deferral. */
|
|
167
135
|
export function isResidentTool(toolName) {
|
|
168
|
-
|
|
136
|
+
return RESIDENT_TOOL_SET.has(toolName);
|
|
169
137
|
}
|
|
170
|
-
|
|
171
138
|
// A tool may legitimately belong to more than one pack — check_system_specs is
|
|
172
139
|
// Stage 1 of the game cascade and Stage 2 of the media hierarchy — so
|
|
173
140
|
// membership is a set, not a single value.
|
|
174
141
|
const TOOL_TO_PACKS = (() => {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
142
|
+
const map = new Map();
|
|
143
|
+
for (const packName of PACK_NAMES) {
|
|
144
|
+
for (const toolName of PACKS[packName]) {
|
|
145
|
+
let set = map.get(toolName);
|
|
146
|
+
if (!set) {
|
|
147
|
+
set = new Set();
|
|
148
|
+
map.set(toolName, set);
|
|
149
|
+
}
|
|
150
|
+
set.add(packName);
|
|
151
|
+
}
|
|
180
152
|
}
|
|
181
|
-
|
|
182
|
-
return map;
|
|
153
|
+
return map;
|
|
183
154
|
})();
|
|
184
|
-
|
|
185
155
|
const CORE_TOOL_SET = new Set(CORE_TOOLS);
|
|
186
|
-
|
|
187
156
|
/** Every pack a tool belongs to. Empty for core and forged tools. */
|
|
188
157
|
export function packsForTool(toolName) {
|
|
189
|
-
|
|
158
|
+
return TOOL_TO_PACKS.get(toolName) || null;
|
|
190
159
|
}
|
|
191
|
-
|
|
192
160
|
/** Primary pack for a tool, or 'core' if it is always loaded. */
|
|
193
161
|
export function packForTool(toolName) {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
162
|
+
if (CORE_TOOL_SET.has(toolName))
|
|
163
|
+
return 'core';
|
|
164
|
+
const packs = TOOL_TO_PACKS.get(toolName);
|
|
165
|
+
return packs ? ([...packs][0] ?? null) : null;
|
|
197
166
|
}
|
|
198
|
-
|
|
199
167
|
export function isCoreTool(toolName) {
|
|
200
|
-
|
|
168
|
+
return CORE_TOOL_SET.has(toolName);
|
|
201
169
|
}
|
|
202
|
-
|
|
203
170
|
// ---------------------------------------------------------------------------
|
|
204
171
|
// Pack playbooks. These were previously hardcoded into the always-on
|
|
205
172
|
// SYSTEM_PROMPT, costing every task ~2,000 tokens of instructions about game
|
|
206
173
|
// cascades and media hierarchies it would never use. They now travel with their
|
|
207
174
|
// pack, so they arrive exactly when they become relevant.
|
|
208
175
|
// ---------------------------------------------------------------------------
|
|
209
|
-
|
|
210
176
|
export const PACK_PLAYBOOKS = {
|
|
211
|
-
|
|
177
|
+
web: `# FRONTEND ENGINEERING MANDATE (CREATIVE DIVERSITY ENGINE)
|
|
212
178
|
When building websites, UIs, dashboards, or web applications, follow this design system hierarchy:
|
|
213
179
|
## Design System Selection
|
|
214
180
|
1. **If the user specifies a design system** (Tailwind, Material-UI, Astryx, etc.) — use it without question.
|
|
@@ -228,8 +194,7 @@ You MUST produce visually UNIQUE output on every project. Specifically:
|
|
|
228
194
|
- **REQUIRED**: After building, use 'screenshot' or 'browser_act' to VISUALLY VERIFY your work. If it looks like every other AI-generated site, tear it down and rebuild with a different approach.
|
|
229
195
|
- **REQUIRED**: Once the design is finished, call 'memory_write' with the creativePattern argument (project, designApproach, colorPalette, fonts). This is what lets the next project deliberately differ from this one instead of drifting back into the same house style.
|
|
230
196
|
- **ENFORCED, NOT ADVISORY**: every HTML/CSS file you write is read back and scored by an automatic gate before the task can finish (src/slopDetector.js). It looks for the stock gradient hexes, purple-to-blue ramps, placeholder marketing copy, emoji used as icons, default-only typography, the centered-hero/3-cards/"Get Started" skeleton and the stock soft shadow. Score too high and you will be sent back to rebuild with a named design movement. Design it properly the first time; the gate is not fooled by swapping one gradient for another.`,
|
|
231
|
-
|
|
232
|
-
media: `# Media Generation Protocol (Sovereign 5-Stage Hierarchy & Seamless Consent Routing)
|
|
197
|
+
media: `# Media Generation Protocol (Sovereign 5-Stage Hierarchy & Seamless Consent Routing)
|
|
233
198
|
|
|
234
199
|
## Native engine-first for file media work
|
|
235
200
|
For editing or producing media from files in the workspace, check \`native_engine\` status first; engines are added one at a time, starting with film. If the engine is missing, explain the download and ask before calling \`install\` with \`confirm: true\`. When the needed engine is installed, use \`catalog\` -> \`execute\` or \`batch\`. Pass \`project\` to edit an existing document or \`saveAs\` for a new one, then \`render\` a preview and inspect it before exporting. Engines are headless: never use MCP servers, \`computer_use\`, or screenshots to drive them. The generation chain below applies only when no native engine capability exists or the user explicitly asks for generated media.
|
|
@@ -346,191 +311,133 @@ Blender genuinely missing. Then say so plainly, offer the two options — instal
|
|
|
346
311
|
with \`execute_procedural_media\` — and let the user choose. Never start a large
|
|
347
312
|
download on your own initiative.
|
|
348
313
|
`,
|
|
349
|
-
|
|
350
|
-
game: `# Sovereign Game Development Cascade & Enforcement Engine
|
|
314
|
+
game: `# Sovereign Game Development Cascade & Enforcement Engine
|
|
351
315
|
When the user asks you to build, create, test, expand, or develop a game, follow these rules:
|
|
352
316
|
|
|
353
317
|
- **Browser / Three.js / WebGL / Python Games**: If the user explicitly requests a Three.js, WebGL, Canvas, HTML5, or Python game (or mentions libraries like Three.js, 3js, NumPy, Pygame), you do NOT need Godot. Build the game directly in HTML/JS/CSS or Python using \`fs_write\` (or \`file_write\`) and run/verify using \`sysRun\` or \`game_build_html5\`.
|
|
354
318
|
- **Godot / Full Engine Games**: When building a full engine game (Godot), follow the 7-stage production methodology using \`godot_act\`, \`game_lore_forge\`, \`game_asset_harvest\`, \`game_scene_build\`, and verify with \`game_web_runtime_inspector\` and \`game_canvas_audit\`.`
|
|
355
319
|
};
|
|
356
|
-
|
|
357
320
|
// ---------------------------------------------------------------------------
|
|
358
321
|
// Intent routing.
|
|
359
322
|
//
|
|
360
|
-
// The previous implementation used bare substring matching, which produced
|
|
361
|
-
// catastrophic false positives: 'ui' matched "build", "quick" and
|
|
362
|
-
// "requirements"; 'race' matched "trace". Those false positives triggered
|
|
363
|
-
// completion-blocking guards that forced dozens of extra LLM round trips on
|
|
364
|
-
// tasks that had nothing to do with games or web UI.
|
|
365
|
-
//
|
|
366
323
|
// Every matcher below is anchored on word boundaries and tested against the
|
|
367
324
|
// raw prompt only.
|
|
368
325
|
// ---------------------------------------------------------------------------
|
|
369
|
-
|
|
370
|
-
const
|
|
371
|
-
|
|
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|three\.?js|threejs|webgl|canvas|babylon)\b/i;
|
|
373
|
-
|
|
326
|
+
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|simulator|simulation|simulasi)\b|\.(tscn|gd)\b|[-_]3d\b|\b3d[-_]/i;
|
|
327
|
+
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|three?\.?js|three?js|webgl|canvas|babylon)\b/i;
|
|
374
328
|
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
|
-
|
|
376
329
|
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
|
-
|
|
378
330
|
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
|
-
|
|
380
331
|
const INTENT_MATCHERS = {
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
332
|
+
game: GAME_INTENT,
|
|
333
|
+
web: WEB_INTENT,
|
|
334
|
+
media: MEDIA_INTENT,
|
|
335
|
+
system: SYSTEM_INTENT,
|
|
336
|
+
advanced: ADVANCED_INTENT
|
|
386
337
|
};
|
|
387
|
-
|
|
388
338
|
/** True when the prompt genuinely describes game development work. */
|
|
389
339
|
export function isGameIntent(prompt) {
|
|
390
|
-
|
|
340
|
+
return GAME_INTENT.test(prompt || '');
|
|
391
341
|
}
|
|
392
|
-
|
|
393
342
|
/** True when the prompt genuinely describes web/UI work. */
|
|
394
343
|
export function isWebIntent(prompt) {
|
|
395
|
-
|
|
344
|
+
return WEB_INTENT.test(prompt || '');
|
|
396
345
|
}
|
|
397
|
-
|
|
398
346
|
/**
|
|
399
347
|
* Decide which packs to unlock before the first LLM call, so the common case
|
|
400
348
|
* costs zero discovery round trips.
|
|
401
|
-
*
|
|
402
|
-
* @param {string} prompt The user's task text.
|
|
403
|
-
* @param {object} workspaceContext Optional perception output; its detected
|
|
404
|
-
* frameworks and files are strong signals.
|
|
405
|
-
* @returns {string[]} pack names to unlock
|
|
406
349
|
*/
|
|
407
350
|
export function routePacks(prompt, workspaceContext = null) {
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
351
|
+
const unlocked = new Set();
|
|
352
|
+
const text = prompt || '';
|
|
353
|
+
for (const packName of PACK_NAMES) {
|
|
354
|
+
if (INTENT_MATCHERS[packName].test(text)) {
|
|
355
|
+
unlocked.add(packName);
|
|
356
|
+
}
|
|
414
357
|
}
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
return [...unlocked];
|
|
358
|
+
// Workspace signals. A Godot project on disk is far more reliable evidence of
|
|
359
|
+
// game work than any keyword, and a detected web framework means the agent
|
|
360
|
+
// will eventually need to look at what it built.
|
|
361
|
+
if (workspaceContext) {
|
|
362
|
+
const signals = [
|
|
363
|
+
workspaceContext.framework,
|
|
364
|
+
workspaceContext.projectType,
|
|
365
|
+
workspaceContext.designSystem,
|
|
366
|
+
Array.isArray(workspaceContext.keyFiles) ? workspaceContext.keyFiles.join(' ') : ''
|
|
367
|
+
]
|
|
368
|
+
.filter(Boolean)
|
|
369
|
+
.join(' ')
|
|
370
|
+
.toLowerCase();
|
|
371
|
+
if (/godot|project\.godot|unity|\.tscn/.test(signals))
|
|
372
|
+
unlocked.add('game');
|
|
373
|
+
if (/react|vue|svelte|next|nuxt|astro|angular|tailwind|vite|html/.test(signals))
|
|
374
|
+
unlocked.add('web');
|
|
375
|
+
}
|
|
376
|
+
return [...unlocked];
|
|
436
377
|
}
|
|
437
|
-
|
|
438
378
|
/**
|
|
439
379
|
* Resolve the tool schemas that should enter the context window.
|
|
440
380
|
* Core tools always load; pack tools load only once their pack is unlocked.
|
|
441
|
-
*
|
|
442
|
-
* Ordering is APPEND-ONLY and this matters a great deal for cost. Every
|
|
443
|
-
* provider's prompt cache binds on an identical prefix, and tool definitions
|
|
444
|
-
* sit at the very front of that prefix — so if unlocking a pack mid-task
|
|
445
|
-
* reshuffles the array, the cache is invalidated from the first changed byte
|
|
446
|
-
* onward, taking the system prompt and the whole message history with it.
|
|
447
|
-
* Sorting pack tools alphabetically did exactly that: unlocking `system`
|
|
448
|
-
* inserted `archive` ahead of `astryx_oracle` and truncated the stable prefix
|
|
449
|
-
* to 82%. Ordering by unlock sequence instead keeps 100% of the previously
|
|
450
|
-
* cached prefix intact and appends only the new tail.
|
|
451
|
-
*
|
|
452
|
-
* @param {Array} allDefinitions Full TOOL_DEFINITIONS list.
|
|
453
|
-
* @param {Set} unlockedPacks Pack names unlocked for this task.
|
|
454
|
-
* @param {Set} unlockedTools Individually unlocked tool names.
|
|
455
|
-
* @param {Array} unlockOrder Pack names in the order they were unlocked.
|
|
456
|
-
* @returns {Array} filtered definitions, deterministically ordered
|
|
457
381
|
*/
|
|
458
382
|
export function resolveActiveTools(allDefinitions, unlockedPacks, unlockedTools, unlockOrder = null, options = {}) {
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
let best = Number.MAX_SAFE_INTEGER;
|
|
509
|
-
for (const pack of memberOf) {
|
|
510
|
-
const rank = rankOfPack.get(pack);
|
|
511
|
-
if (rank !== undefined && rank < best) best = rank;
|
|
512
|
-
}
|
|
513
|
-
return best;
|
|
514
|
-
};
|
|
515
|
-
|
|
516
|
-
const rest = active.filter(d => !isCoreTool(d.name) || !isHead(d.name));
|
|
517
|
-
rest.sort((a, b) => {
|
|
518
|
-
const diff = rankOf(a) - rankOf(b);
|
|
519
|
-
return diff !== 0 ? diff : a.name.localeCompare(b.name);
|
|
520
|
-
});
|
|
521
|
-
|
|
522
|
-
return [...coreFirst, ...rest];
|
|
383
|
+
const packs = unlockedPacks instanceof Set ? unlockedPacks : new Set(unlockedPacks || []);
|
|
384
|
+
const tools = unlockedTools instanceof Set ? unlockedTools : new Set(unlockedTools || []);
|
|
385
|
+
const residentOnly = options.residentOnly === true;
|
|
386
|
+
const active = allDefinitions.filter(def => {
|
|
387
|
+
if (isCoreTool(def.name)) {
|
|
388
|
+
if (!residentOnly)
|
|
389
|
+
return true;
|
|
390
|
+
return isResidentTool(def.name) || tools.has(def.name);
|
|
391
|
+
}
|
|
392
|
+
if (tools.has(def.name))
|
|
393
|
+
return true;
|
|
394
|
+
if (def.xCausyneDeferred === true)
|
|
395
|
+
return false;
|
|
396
|
+
const memberOf = packsForTool(def.name);
|
|
397
|
+
if (!memberOf)
|
|
398
|
+
return true;
|
|
399
|
+
for (const pack of memberOf) {
|
|
400
|
+
if (packs.has(pack))
|
|
401
|
+
return true;
|
|
402
|
+
}
|
|
403
|
+
return false;
|
|
404
|
+
});
|
|
405
|
+
const isHead = (name) => !residentOnly || isResidentTool(name);
|
|
406
|
+
const coreFirst = active.filter(d => isCoreTool(d.name) && isHead(d.name));
|
|
407
|
+
coreFirst.sort((a, b) => CORE_TOOLS.indexOf(a.name) - CORE_TOOLS.indexOf(b.name));
|
|
408
|
+
const sequence = Array.isArray(unlockOrder) && unlockOrder.length > 0
|
|
409
|
+
? unlockOrder
|
|
410
|
+
: [...packs];
|
|
411
|
+
const rankOfPack = new Map(sequence.map((name, index) => [name, index]));
|
|
412
|
+
const rankOf = (def) => {
|
|
413
|
+
if (isCoreTool(def.name))
|
|
414
|
+
return -1;
|
|
415
|
+
const memberOf = packsForTool(def.name);
|
|
416
|
+
if (!memberOf)
|
|
417
|
+
return Number.MAX_SAFE_INTEGER;
|
|
418
|
+
let best = Number.MAX_SAFE_INTEGER;
|
|
419
|
+
for (const pack of memberOf) {
|
|
420
|
+
const rank = rankOfPack.get(pack);
|
|
421
|
+
if (rank !== undefined && rank < best)
|
|
422
|
+
best = rank;
|
|
423
|
+
}
|
|
424
|
+
return best;
|
|
425
|
+
};
|
|
426
|
+
const rest = active.filter(d => !isCoreTool(d.name) || !isHead(d.name));
|
|
427
|
+
rest.sort((a, b) => {
|
|
428
|
+
const diff = rankOf(a) - rankOf(b);
|
|
429
|
+
return diff !== 0 ? diff : a.name.localeCompare(b.name);
|
|
430
|
+
});
|
|
431
|
+
return [...coreFirst, ...rest];
|
|
523
432
|
}
|
|
524
|
-
|
|
525
433
|
/** Human-readable catalogue injected into the system prompt so the model knows what it can unlock. */
|
|
526
434
|
export function getPackCatalogue(unlockedPacks) {
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
return `# EXTENDED CAPABILITY PACKS
|
|
435
|
+
const packs = unlockedPacks instanceof Set ? unlockedPacks : new Set(unlockedPacks || []);
|
|
436
|
+
const lines = PACK_NAMES.map(name => {
|
|
437
|
+
const state = packs.has(name) ? 'LOADED' : 'available';
|
|
438
|
+
return `- ${name} (${PACKS[name].length} tools, ${state})`;
|
|
439
|
+
});
|
|
440
|
+
return `# EXTENDED CAPABILITY PACKS
|
|
534
441
|
Beyond the tools currently in your context you have access to specialised capability packs. Nothing is disabled — packs load on demand to keep your context focused.
|
|
535
442
|
${lines.join('\n')}
|
|
536
443
|
To load a pack, call \`tool_search\` with a query describing what you need (for example "godot scene", "generate music", "kill process on port"). The matching tool schemas become available immediately on your next turn. Never claim a capability is missing without searching first.`;
|