@causyne/agent 1.20.73 → 1.20.75
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 +28 -1
- package/src/agentLoop.ts +28 -1
- package/src/assets/logo.png +0 -0
- package/src/auth/openrouterAuth.js +412 -109
- package/src/auth/openrouterAuth.ts +416 -113
- package/src/browser/causyneBrowser.js +34 -17
- package/src/browser/causyneBrowser.ts +35 -17
- package/src/providers/openrouter.js +42 -1
- package/src/providers/openrouter.ts +43 -1
- package/src/tools/sysRun.js +24 -2
- package/src/tools/sysRun.ts +19 -2
- package/src/tools/toolSelfRepair.js +32 -2
- package/src/tools/toolSelfRepair.ts +26 -2
package/package.json
CHANGED
package/src/agentLoop.js
CHANGED
|
@@ -27,7 +27,7 @@ import { lookupPlan, recordPlan, recordPlanAsync, recordMiss, renderPlanHint, to
|
|
|
27
27
|
import { routedConfig } from './modelRouter.js';
|
|
28
28
|
import { assessStep, isThrashing } from './uncertainty.js';
|
|
29
29
|
import { assessDecisionRequirement, isMutatingToolCall, requiresImplementationPlan } from './decisionPolicy.js';
|
|
30
|
-
import { normalizePeerPlanEntries, extractLivePlanFromText, stripToolCallMarkup, stripThinkBlocks } from './implementationPlan.js';
|
|
30
|
+
import { normalizePeerPlanEntries, extractLivePlanFromText, stripToolCallMarkup, stripThinkBlocks, extractToolCallJsonObjects, resolveToolCallEnvelopeArguments } from './implementationPlan.js';
|
|
31
31
|
import { requiresToolApproval, withToolAutonomyMode } from './approvalPolicy.js';
|
|
32
32
|
import { AGENT_USER_POLICY } from './agentPolicy.js';
|
|
33
33
|
import { VFETracker } from './vfeTracker.js';
|
|
@@ -2748,6 +2748,33 @@ You are operating in a text-and-code modality without direct image pixel renderi
|
|
|
2748
2748
|
}
|
|
2749
2749
|
}
|
|
2750
2750
|
}
|
|
2751
|
+
// General Provider Tool Call Extraction Fallback:
|
|
2752
|
+
// If the model did not emit structured API tool calls, but output <tool_call> envelopes
|
|
2753
|
+
// in its content text, extract them so tools execute seamlessly across all general providers.
|
|
2754
|
+
if ((!response.toolCalls || response.toolCalls.length === 0) && response.content) {
|
|
2755
|
+
const textCalls = [];
|
|
2756
|
+
let callIndex = 0;
|
|
2757
|
+
for (const parsed of extractToolCallJsonObjects(response.content)) {
|
|
2758
|
+
const fnObj = parsed.function && typeof parsed.function === 'object'
|
|
2759
|
+
? parsed.function
|
|
2760
|
+
: null;
|
|
2761
|
+
const name = String(parsed.name || parsed.tool || fnObj?.name || '').trim();
|
|
2762
|
+
if (!name)
|
|
2763
|
+
continue;
|
|
2764
|
+
const rawArgs = resolveToolCallEnvelopeArguments(parsed);
|
|
2765
|
+
textCalls.push({
|
|
2766
|
+
id: `text_call_${Date.now()}_${callIndex++}`,
|
|
2767
|
+
type: 'function',
|
|
2768
|
+
function: {
|
|
2769
|
+
name: canonicalToolName(name),
|
|
2770
|
+
arguments: typeof rawArgs === 'string' ? rawArgs : JSON.stringify(rawArgs || {})
|
|
2771
|
+
}
|
|
2772
|
+
});
|
|
2773
|
+
}
|
|
2774
|
+
if (textCalls.length > 0) {
|
|
2775
|
+
response.toolCalls = textCalls;
|
|
2776
|
+
}
|
|
2777
|
+
}
|
|
2751
2778
|
// Add assistant response to history. This is the ONLY place the turn is
|
|
2752
2779
|
// recorded — the completion and guard branches below used to push it a
|
|
2753
2780
|
// second time, duplicating every finished turn in the history.
|
package/src/agentLoop.ts
CHANGED
|
@@ -39,7 +39,7 @@ import {
|
|
|
39
39
|
import { routedConfig } from './modelRouter.js';
|
|
40
40
|
import { assessStep, isThrashing } from './uncertainty.js';
|
|
41
41
|
import { assessDecisionRequirement, isMutatingToolCall, requiresImplementationPlan } from './decisionPolicy.js';
|
|
42
|
-
import { normalizePeerPlanEntries, extractLivePlanFromText, stripToolCallMarkup, stripThinkBlocks } from './implementationPlan.js';
|
|
42
|
+
import { normalizePeerPlanEntries, extractLivePlanFromText, stripToolCallMarkup, stripThinkBlocks, extractToolCallJsonObjects, resolveToolCallEnvelopeArguments } from './implementationPlan.js';
|
|
43
43
|
import { requiresToolApproval, withToolAutonomyMode } from './approvalPolicy.js';
|
|
44
44
|
import { AGENT_USER_POLICY } from './agentPolicy.js';
|
|
45
45
|
import { VFETracker } from './vfeTracker.js';
|
|
@@ -2867,6 +2867,33 @@ You are operating in a text-and-code modality without direct image pixel renderi
|
|
|
2867
2867
|
}
|
|
2868
2868
|
}
|
|
2869
2869
|
|
|
2870
|
+
// General Provider Tool Call Extraction Fallback:
|
|
2871
|
+
// If the model did not emit structured API tool calls, but output <tool_call> envelopes
|
|
2872
|
+
// in its content text, extract them so tools execute seamlessly across all general providers.
|
|
2873
|
+
if ((!response.toolCalls || response.toolCalls.length === 0) && response.content) {
|
|
2874
|
+
const textCalls: any[] = [];
|
|
2875
|
+
let callIndex = 0;
|
|
2876
|
+
for (const parsed of extractToolCallJsonObjects(response.content)) {
|
|
2877
|
+
const fnObj = parsed.function && typeof parsed.function === 'object'
|
|
2878
|
+
? (parsed.function as Record<string, unknown>)
|
|
2879
|
+
: null;
|
|
2880
|
+
const name = String(parsed.name || parsed.tool || fnObj?.name || '').trim();
|
|
2881
|
+
if (!name) continue;
|
|
2882
|
+
const rawArgs = resolveToolCallEnvelopeArguments(parsed);
|
|
2883
|
+
textCalls.push({
|
|
2884
|
+
id: `text_call_${Date.now()}_${callIndex++}`,
|
|
2885
|
+
type: 'function',
|
|
2886
|
+
function: {
|
|
2887
|
+
name: canonicalToolName(name),
|
|
2888
|
+
arguments: typeof rawArgs === 'string' ? rawArgs : JSON.stringify(rawArgs || {})
|
|
2889
|
+
}
|
|
2890
|
+
});
|
|
2891
|
+
}
|
|
2892
|
+
if (textCalls.length > 0) {
|
|
2893
|
+
response.toolCalls = textCalls;
|
|
2894
|
+
}
|
|
2895
|
+
}
|
|
2896
|
+
|
|
2870
2897
|
// Add assistant response to history. This is the ONLY place the turn is
|
|
2871
2898
|
// recorded — the completion and guard branches below used to push it a
|
|
2872
2899
|
// second time, duplicating every finished turn in the history.
|
package/src/assets/logo.png
CHANGED
|
Binary file
|