@causyne/agent 1.20.34 → 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 +35 -24
- package/src/agentLoop.ts +36 -23
- package/src/memory/episodicStore.js +6 -6
- package/src/memory/episodicStore.ts +6 -6
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
|
}
|
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 {
|
|
@@ -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,
|