@causyne/agent 1.20.33 → 1.20.35
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/agentLoop.js +41 -26
- package/src/agentLoop.ts +44 -25
- package/src/memory/episodicStore.js +6 -6
- package/src/memory/episodicStore.ts +6 -6
- package/src/toolPacks.js +7 -1
- package/src/toolPacks.ts +6 -1
package/LICENSE
CHANGED
package/package.json
CHANGED
package/src/agentLoop.js
CHANGED
|
@@ -2562,6 +2562,37 @@ You are operating in a text-and-code modality without direct image pixel renderi
|
|
|
2562
2562
|
}
|
|
2563
2563
|
}
|
|
2564
2564
|
}
|
|
2565
|
+
// If the peer attempted to call a registered Causyne host tool through its
|
|
2566
|
+
// native channel and provided complete, valid arguments (or we can infer
|
|
2567
|
+
// the target for reverse_engineering), auto-bridge it into response.toolCalls
|
|
2568
|
+
// BEFORE recording assistantMsg so it executes immediately in this turn.
|
|
2569
|
+
if ((!response.toolCalls || response.toolCalls.length === 0) && response.toolRoutingError) {
|
|
2570
|
+
const rawName = response.toolRoutingError.tool;
|
|
2571
|
+
const resolved = resolveTool(rawName);
|
|
2572
|
+
if (resolved) {
|
|
2573
|
+
const canonical = canonicalToolName(rawName);
|
|
2574
|
+
const toolParams = { ...(response.toolRoutingError.parameters || {}) };
|
|
2575
|
+
if (canonical === 'reverse_engineering' && !toolParams.filePath && !toolParams.target && !toolParams.file && !toolParams.path) {
|
|
2576
|
+
const promptMatch = (this.currentTaskPrompt || this.userPrompt || '').match(/([a-zA-Z0-9_\-./]+\.(apk|aab|dex|dylib|so|dll|exe|asar))\b/i);
|
|
2577
|
+
if (promptMatch && promptMatch[1]) {
|
|
2578
|
+
toolParams.filePath = promptMatch[1];
|
|
2579
|
+
if (!toolParams.action)
|
|
2580
|
+
toolParams.action = 'inspect';
|
|
2581
|
+
}
|
|
2582
|
+
}
|
|
2583
|
+
if (Object.keys(toolParams).length > 0 && !this.validateToolArgs(canonical, toolParams)) {
|
|
2584
|
+
response.toolCalls = [{
|
|
2585
|
+
id: `host_auto_${Date.now()}`,
|
|
2586
|
+
type: 'function',
|
|
2587
|
+
function: {
|
|
2588
|
+
name: canonical,
|
|
2589
|
+
arguments: JSON.stringify(toolParams)
|
|
2590
|
+
}
|
|
2591
|
+
}];
|
|
2592
|
+
delete response.toolRoutingError;
|
|
2593
|
+
}
|
|
2594
|
+
}
|
|
2595
|
+
}
|
|
2565
2596
|
// Add assistant response to history. This is the ONLY place the turn is
|
|
2566
2597
|
// recorded — the completion and guard branches below used to push it a
|
|
2567
2598
|
// second time, duplicating every finished turn in the history.
|
|
@@ -2641,31 +2672,11 @@ You are operating in a text-and-code modality without direct image pixel renderi
|
|
|
2641
2672
|
if (!response.toolCalls || response.toolCalls.length === 0) {
|
|
2642
2673
|
if (response.toolRoutingError) {
|
|
2643
2674
|
const rawName = response.toolRoutingError.tool;
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
const canonical = canonicalToolName(rawName);
|
|
2647
|
-
const toolParams = { ...(response.toolRoutingError.parameters || {}) };
|
|
2648
|
-
if (canonical === 'reverse_engineering' && !toolParams.filePath && !toolParams.target && !toolParams.file && !toolParams.path) {
|
|
2649
|
-
const promptMatch = (this.currentTaskPrompt || this.userPrompt || '').match(/([a-zA-Z0-9_\-./]+\.(apk|aab|dex|dylib|so|dll|exe|asar))\b/i);
|
|
2650
|
-
if (promptMatch && promptMatch[1]) {
|
|
2651
|
-
toolParams.filePath = promptMatch[1];
|
|
2652
|
-
if (!toolParams.action)
|
|
2653
|
-
toolParams.action = 'inspect';
|
|
2654
|
-
}
|
|
2655
|
-
}
|
|
2656
|
-
// Direct auto-bridge: peer explicitly targeted a registered host tool
|
|
2657
|
-
response.toolCalls = [{
|
|
2658
|
-
id: `host_auto_${Date.now()}`,
|
|
2659
|
-
type: 'function',
|
|
2660
|
-
function: {
|
|
2661
|
-
name: canonical,
|
|
2662
|
-
arguments: JSON.stringify(toolParams)
|
|
2663
|
-
}
|
|
2664
|
-
}];
|
|
2665
|
-
delete response.toolRoutingError;
|
|
2675
|
+
if (typeof assistantMsg.content === 'string' && /^Turn completed by .+ over ACP\.$/i.test(assistantMsg.content.trim())) {
|
|
2676
|
+
this.messages.pop();
|
|
2666
2677
|
}
|
|
2667
|
-
|
|
2668
|
-
this.emitEvent({ type: 'error', message: `The peer repeatedly invoked
|
|
2678
|
+
if (toolRoutingRecoveries++ >= 3) {
|
|
2679
|
+
this.emitEvent({ type: 'error', message: `The peer repeatedly invoked host tool ${rawName} through the native channel instead of <tool_call>. Work remains unfinished.` });
|
|
2669
2680
|
this.memoryManager.saveHistory(this.messages);
|
|
2670
2681
|
break;
|
|
2671
2682
|
}
|
|
@@ -2928,7 +2939,9 @@ You are operating in a text-and-code modality without direct image pixel renderi
|
|
|
2928
2939
|
}
|
|
2929
2940
|
}
|
|
2930
2941
|
// Web Visual Validation Guard (Anti-Slop / Transcendence)
|
|
2931
|
-
const
|
|
2942
|
+
const outcomes = coldObserver.getToolOutcomes(this.taskId);
|
|
2943
|
+
const hasWebOrCodeMutation = this.webArtifacts.size > 0 || outcomes.some((o) => o.success !== false && ['fs_write', 'fs_edit', 'MultiEdit', 'ui_forge', 'write_file', 'write_to_file', 'edit_file', 'replace_file_content', 'multi_replace_file_content'].includes(String(o.tool || '')));
|
|
2944
|
+
const isWebTask = !isLaunchOnlyPrompt(taskPrompt) && !isPlanningOnlyRequest(taskPrompt) && isWebIntent(taskPrompt) && hasWebOrCodeMutation;
|
|
2932
2945
|
let browserReady = false;
|
|
2933
2946
|
let browserDeclined = false;
|
|
2934
2947
|
let browserRuntimeError = '';
|
|
@@ -2988,7 +3001,6 @@ You are operating in a text-and-code modality without direct image pixel renderi
|
|
|
2988
3001
|
// Tool availability and a completed plan are not evidence of visual
|
|
2989
3002
|
// inspection. A failed browser/capture attempt must not become a
|
|
2990
3003
|
// successful task merely because the provider says "verified".
|
|
2991
|
-
const outcomes = coldObserver.getToolOutcomes(this.taskId);
|
|
2992
3004
|
const hasBrowserActOutcome = outcomes.some((o) => o.tool === 'browser_act' && o.success !== false);
|
|
2993
3005
|
const hasPassingTests = outcomes.some((o) => o.success && (isVerificationCommand(o.command || o.tool || '') || /\b(?:test|unittest|vitest|jest|pytest)\b/i.test(o.command || ''))) || (Array.isArray(this._planSteps) && this._planSteps.some(s => s.success && /test/i.test(s.tool)));
|
|
2994
3006
|
let observerVerified = false;
|
|
@@ -3759,6 +3771,9 @@ You are operating in a text-and-code modality without direct image pixel renderi
|
|
|
3759
3771
|
this.emitEvent({ type: result?.success === false || typeof result?.error === 'string' ? 'step_error' : 'step_complete',
|
|
3760
3772
|
tool: functionName, result: eventResult, toolCallId: toolCall.id });
|
|
3761
3773
|
this.stepsCompleted++;
|
|
3774
|
+
if (this._implementationPlanSeeded && result?.success !== false && !result?.error && functionName !== 'update_plan') {
|
|
3775
|
+
this.advanceImplementationPlanProgress('mutation');
|
|
3776
|
+
}
|
|
3762
3777
|
// The procedure, as it actually ran. Tool name plus a whitelisted
|
|
3763
3778
|
// action token only — planCache.toStep() reads no paths, arguments or
|
|
3764
3779
|
// command lines, so what is cached is a route and never a transcript.
|
package/src/agentLoop.ts
CHANGED
|
@@ -2691,6 +2691,37 @@ You are operating in a text-and-code modality without direct image pixel renderi
|
|
|
2691
2691
|
}
|
|
2692
2692
|
}
|
|
2693
2693
|
|
|
2694
|
+
// If the peer attempted to call a registered Causyne host tool through its
|
|
2695
|
+
// native channel and provided complete, valid arguments (or we can infer
|
|
2696
|
+
// the target for reverse_engineering), auto-bridge it into response.toolCalls
|
|
2697
|
+
// BEFORE recording assistantMsg so it executes immediately in this turn.
|
|
2698
|
+
if ((!response.toolCalls || response.toolCalls.length === 0) && response.toolRoutingError) {
|
|
2699
|
+
const rawName = response.toolRoutingError.tool;
|
|
2700
|
+
const resolved = resolveTool(rawName);
|
|
2701
|
+
if (resolved) {
|
|
2702
|
+
const canonical = canonicalToolName(rawName);
|
|
2703
|
+
const toolParams: Record<string, unknown> = { ...(response.toolRoutingError.parameters || {}) };
|
|
2704
|
+
if (canonical === 'reverse_engineering' && !toolParams.filePath && !toolParams.target && !toolParams.file && !toolParams.path) {
|
|
2705
|
+
const promptMatch = (this.currentTaskPrompt || this.userPrompt || '').match(/([a-zA-Z0-9_\-./]+\.(apk|aab|dex|dylib|so|dll|exe|asar))\b/i);
|
|
2706
|
+
if (promptMatch && promptMatch[1]) {
|
|
2707
|
+
toolParams.filePath = promptMatch[1];
|
|
2708
|
+
if (!toolParams.action) toolParams.action = 'inspect';
|
|
2709
|
+
}
|
|
2710
|
+
}
|
|
2711
|
+
if (Object.keys(toolParams).length > 0 && !this.validateToolArgs(canonical, toolParams)) {
|
|
2712
|
+
response.toolCalls = [{
|
|
2713
|
+
id: `host_auto_${Date.now()}`,
|
|
2714
|
+
type: 'function',
|
|
2715
|
+
function: {
|
|
2716
|
+
name: canonical,
|
|
2717
|
+
arguments: JSON.stringify(toolParams)
|
|
2718
|
+
}
|
|
2719
|
+
}];
|
|
2720
|
+
delete response.toolRoutingError;
|
|
2721
|
+
}
|
|
2722
|
+
}
|
|
2723
|
+
}
|
|
2724
|
+
|
|
2694
2725
|
// Add assistant response to history. This is the ONLY place the turn is
|
|
2695
2726
|
// recorded — the completion and guard branches below used to push it a
|
|
2696
2727
|
// second time, duplicating every finished turn in the history.
|
|
@@ -2776,29 +2807,11 @@ You are operating in a text-and-code modality without direct image pixel renderi
|
|
|
2776
2807
|
if (!response.toolCalls || response.toolCalls.length === 0) {
|
|
2777
2808
|
if (response.toolRoutingError) {
|
|
2778
2809
|
const rawName = response.toolRoutingError.tool;
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
const promptMatch = (this.currentTaskPrompt || this.userPrompt || '').match(/([a-zA-Z0-9_\-./]+\.(apk|aab|dex|dylib|so|dll|exe|asar))\b/i);
|
|
2785
|
-
if (promptMatch && promptMatch[1]) {
|
|
2786
|
-
toolParams.filePath = promptMatch[1];
|
|
2787
|
-
if (!toolParams.action) toolParams.action = 'inspect';
|
|
2788
|
-
}
|
|
2789
|
-
}
|
|
2790
|
-
// Direct auto-bridge: peer explicitly targeted a registered host tool
|
|
2791
|
-
response.toolCalls = [{
|
|
2792
|
-
id: `host_auto_${Date.now()}`,
|
|
2793
|
-
type: 'function',
|
|
2794
|
-
function: {
|
|
2795
|
-
name: canonical,
|
|
2796
|
-
arguments: JSON.stringify(toolParams)
|
|
2797
|
-
}
|
|
2798
|
-
}];
|
|
2799
|
-
delete response.toolRoutingError;
|
|
2800
|
-
} else if (toolRoutingRecoveries++ >= 3) {
|
|
2801
|
-
this.emitEvent({ type: 'error', message: `The peer repeatedly invoked unknown host tool ${rawName}. Work remains unfinished.` });
|
|
2810
|
+
if (typeof assistantMsg.content === 'string' && /^Turn completed by .+ over ACP\.$/i.test(assistantMsg.content.trim())) {
|
|
2811
|
+
this.messages.pop();
|
|
2812
|
+
}
|
|
2813
|
+
if (toolRoutingRecoveries++ >= 3) {
|
|
2814
|
+
this.emitEvent({ type: 'error', message: `The peer repeatedly invoked host tool ${rawName} through the native channel instead of <tool_call>. Work remains unfinished.` });
|
|
2802
2815
|
this.memoryManager.saveHistory(this.messages);
|
|
2803
2816
|
break;
|
|
2804
2817
|
} else {
|
|
@@ -3084,7 +3097,11 @@ You are operating in a text-and-code modality without direct image pixel renderi
|
|
|
3084
3097
|
}
|
|
3085
3098
|
|
|
3086
3099
|
// Web Visual Validation Guard (Anti-Slop / Transcendence)
|
|
3087
|
-
const
|
|
3100
|
+
const outcomes = coldObserver.getToolOutcomes(this.taskId);
|
|
3101
|
+
const hasWebOrCodeMutation = this.webArtifacts.size > 0 || outcomes.some((o) =>
|
|
3102
|
+
o.success !== false && ['fs_write', 'fs_edit', 'MultiEdit', 'ui_forge', 'write_file', 'write_to_file', 'edit_file', 'replace_file_content', 'multi_replace_file_content'].includes(String(o.tool || ''))
|
|
3103
|
+
);
|
|
3104
|
+
const isWebTask = !isLaunchOnlyPrompt(taskPrompt) && !isPlanningOnlyRequest(taskPrompt) && isWebIntent(taskPrompt) && hasWebOrCodeMutation;
|
|
3088
3105
|
let browserReady = false;
|
|
3089
3106
|
let browserDeclined = false;
|
|
3090
3107
|
let browserRuntimeError = '';
|
|
@@ -3141,7 +3158,6 @@ You are operating in a text-and-code modality without direct image pixel renderi
|
|
|
3141
3158
|
// Tool availability and a completed plan are not evidence of visual
|
|
3142
3159
|
// inspection. A failed browser/capture attempt must not become a
|
|
3143
3160
|
// successful task merely because the provider says "verified".
|
|
3144
|
-
const outcomes = coldObserver.getToolOutcomes(this.taskId);
|
|
3145
3161
|
const hasBrowserActOutcome = outcomes.some(
|
|
3146
3162
|
(o) => o.tool === 'browser_act' && o.success !== false
|
|
3147
3163
|
);
|
|
@@ -3978,6 +3994,9 @@ You are operating in a text-and-code modality without direct image pixel renderi
|
|
|
3978
3994
|
this.emitEvent({ type: result?.success === false || typeof result?.error === 'string' ? 'step_error' : 'step_complete',
|
|
3979
3995
|
tool: functionName, result: eventResult, toolCallId: toolCall.id });
|
|
3980
3996
|
this.stepsCompleted++;
|
|
3997
|
+
if (this._implementationPlanSeeded && result?.success !== false && !result?.error && functionName !== 'update_plan') {
|
|
3998
|
+
this.advanceImplementationPlanProgress('mutation');
|
|
3999
|
+
}
|
|
3981
4000
|
|
|
3982
4001
|
// The procedure, as it actually ran. Tool name plus a whitelisted
|
|
3983
4002
|
// action token only — planCache.toStep() reads no paths, arguments or
|
|
@@ -139,18 +139,18 @@ export function compileToolObservation(params) {
|
|
|
139
139
|
...(params.nowMs !== undefined ? { createdAtEpochMs: params.nowMs } : {})
|
|
140
140
|
};
|
|
141
141
|
}
|
|
142
|
-
// 3. Browser / Visual Verification
|
|
143
|
-
if (['browser_act', 'screenshot', 'vision_inspect_ui'].includes(lowerTool)) {
|
|
142
|
+
// 3. Browser / Visual / Creative Bridge Verification
|
|
143
|
+
if (['browser_act', 'screenshot', 'vision_inspect_ui', 'creative_apps', 'resolve_act', 'blender_act', 'godot_act'].includes(lowerTool)) {
|
|
144
144
|
const action = String(args.action ?? 'verify').trim();
|
|
145
145
|
return {
|
|
146
146
|
taskId,
|
|
147
147
|
workspace,
|
|
148
148
|
type: 'verification',
|
|
149
|
-
title: `Verified
|
|
149
|
+
title: `Verified via ${normalizedTool} (${action})`,
|
|
150
150
|
subtitle: `${normalizedTool} ${action}`,
|
|
151
|
-
narrative: `Executed
|
|
152
|
-
facts: [`Verified
|
|
153
|
-
concepts: ['verification', 'ui'],
|
|
151
|
+
narrative: `Executed verification/bridge step using ${normalizedTool} (${action}).`,
|
|
152
|
+
facts: [`Verified with ${normalizedTool} (${action})`],
|
|
153
|
+
concepts: ['verification', ['creative_apps', 'resolve_act', 'blender_act', 'godot_act'].includes(lowerTool) ? 'creative' : 'ui'],
|
|
154
154
|
filesRead: relPath ? [relPath] : [],
|
|
155
155
|
filesModified: [],
|
|
156
156
|
toolName: normalizedTool,
|
|
@@ -211,18 +211,18 @@ export function compileToolObservation(params: {
|
|
|
211
211
|
};
|
|
212
212
|
}
|
|
213
213
|
|
|
214
|
-
// 3. Browser / Visual Verification
|
|
215
|
-
if (['browser_act', 'screenshot', 'vision_inspect_ui'].includes(lowerTool)) {
|
|
214
|
+
// 3. Browser / Visual / Creative Bridge Verification
|
|
215
|
+
if (['browser_act', 'screenshot', 'vision_inspect_ui', 'creative_apps', 'resolve_act', 'blender_act', 'godot_act'].includes(lowerTool)) {
|
|
216
216
|
const action = String(args.action ?? 'verify').trim();
|
|
217
217
|
return {
|
|
218
218
|
taskId,
|
|
219
219
|
workspace,
|
|
220
220
|
type: 'verification',
|
|
221
|
-
title: `Verified
|
|
221
|
+
title: `Verified via ${normalizedTool} (${action})`,
|
|
222
222
|
subtitle: `${normalizedTool} ${action}`,
|
|
223
|
-
narrative: `Executed
|
|
224
|
-
facts: [`Verified
|
|
225
|
-
concepts: ['verification', 'ui'],
|
|
223
|
+
narrative: `Executed verification/bridge step using ${normalizedTool} (${action}).`,
|
|
224
|
+
facts: [`Verified with ${normalizedTool} (${action})`],
|
|
225
|
+
concepts: ['verification', ['creative_apps', 'resolve_act', 'blender_act', 'godot_act'].includes(lowerTool) ? 'creative' : 'ui'],
|
|
226
226
|
filesRead: relPath ? [relPath] : [],
|
|
227
227
|
filesModified: [],
|
|
228
228
|
toolName: normalizedTool,
|
package/src/toolPacks.js
CHANGED
|
@@ -349,7 +349,13 @@ export function isGameIntent(prompt) {
|
|
|
349
349
|
}
|
|
350
350
|
/** True when the prompt genuinely describes web/UI work. */
|
|
351
351
|
export function isWebIntent(prompt) {
|
|
352
|
-
|
|
352
|
+
if (!prompt)
|
|
353
|
+
return false;
|
|
354
|
+
const sanitized = prompt
|
|
355
|
+
.replace(/\b(?:adobe|photoshop|premiere|after\s*effects|illustrator|indesign|extendscript|uxp)\s+dom\b/gi, '')
|
|
356
|
+
.replace(/\bdom\s*\/\s*python\b/gi, '')
|
|
357
|
+
.replace(/\bdom\s+simulat(?:or|ion)\b/gi, '');
|
|
358
|
+
return WEB_INTENT.test(sanitized);
|
|
353
359
|
}
|
|
354
360
|
/**
|
|
355
361
|
* Decide which packs to unlock before the first LLM call, so the common case
|
package/src/toolPacks.ts
CHANGED
|
@@ -397,7 +397,12 @@ export function isGameIntent(prompt?: string | null): boolean {
|
|
|
397
397
|
|
|
398
398
|
/** True when the prompt genuinely describes web/UI work. */
|
|
399
399
|
export function isWebIntent(prompt?: string | null): boolean {
|
|
400
|
-
|
|
400
|
+
if (!prompt) return false;
|
|
401
|
+
const sanitized = prompt
|
|
402
|
+
.replace(/\b(?:adobe|photoshop|premiere|after\s*effects|illustrator|indesign|extendscript|uxp)\s+dom\b/gi, '')
|
|
403
|
+
.replace(/\bdom\s*\/\s*python\b/gi, '')
|
|
404
|
+
.replace(/\bdom\s+simulat(?:or|ion)\b/gi, '');
|
|
405
|
+
return WEB_INTENT.test(sanitized);
|
|
401
406
|
}
|
|
402
407
|
|
|
403
408
|
/**
|