@causyne/agent 1.20.120 → 1.20.122
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/README.md +3 -3
- package/package.json +1 -1
- package/src/acp/agentCatalog.js +81 -26
- package/src/acp/agentCatalog.ts +73 -29
- package/src/acp/client.js +210 -53
- package/src/acp/client.ts +202 -52
- package/src/acp/peerProfiles.js +55 -22
- package/src/acp/peerProfiles.ts +51 -22
- package/src/acp/protocol.js +37 -8
- package/src/acp/protocol.ts +30 -8
- package/src/acp/server.js +123 -25
- package/src/acp/server.ts +124 -24
- package/src/agent/errorClassifier.js +117 -0
- package/src/agent/errorClassifier.ts +165 -0
- package/src/agent/promptIntent.js +200 -0
- package/src/agent/promptIntent.ts +203 -0
- package/src/agent/toolArgValidator.js +97 -0
- package/src/agent/toolArgValidator.ts +112 -0
- package/src/agentLoop.js +33 -344
- package/src/agentLoop.ts +51 -352
- package/src/approvalGrants.js +19 -7
- package/src/approvalGrants.ts +20 -7
- package/src/approvalPolicy.js +48 -15
- package/src/approvalPolicy.ts +46 -15
- package/src/autoUpdate.js +116 -10
- package/src/autoUpdate.ts +149 -10
- package/src/browser/causyneBrowser.js +3 -2
- package/src/browser/causyneBrowser.ts +3 -2
- package/src/browser/searchProviders.js +1 -1
- package/src/browser/searchProviders.ts +1 -1
- package/src/cliMode.js +16 -2
- package/src/commands.js +10 -9
- package/src/config.js +288 -272
- package/src/config.ts +342 -0
- package/src/configVault.js +271 -0
- package/src/configVault.ts +273 -0
- package/src/continuum/compactor.js +2 -1
- package/src/continuum/compactor.ts +2 -1
- package/src/continuum/sanitizer.js +10 -3
- package/src/continuum/sanitizer.ts +9 -3
- package/src/continuum/ui/continuumPickerView.js +3 -2
- package/src/continuum/ui/continuumPickerView.ts +3 -2
- package/src/core/contextCompactor.js +70 -11
- package/src/core/contextCompactor.ts +83 -11
- package/src/cortex/vectorDb.js +26 -15
- package/src/cortex/vectorDb.ts +26 -16
- package/src/creative/liveBridge.js +7 -5
- package/src/creative/liveBridge.ts +7 -5
- package/src/creative/studioScripts.js +16 -5
- package/src/creative/studioScripts.ts +14 -5
- package/src/decisionPolicy.js +16 -4
- package/src/decisionPolicy.ts +14 -4
- package/src/documentEngine/antiSlopAuditor.js +10 -5
- package/src/documentEngine/antiSlopAuditor.ts +11 -5
- package/src/documentEngine/documentForge.js +47 -15
- package/src/documentEngine/documentForge.ts +43 -14
- package/src/dynamicCatalogue.js +42 -73
- package/src/dynamicCatalogue.ts +74 -60
- package/src/engines/design.js +2 -1
- package/src/engines/design.ts +2 -1
- package/src/engines/film.js +4 -4
- package/src/engines/film.ts +2 -2
- package/src/engines/light.js +2 -1
- package/src/engines/light.ts +2 -1
- package/src/engines/registry.js +1 -1
- package/src/engines/registry.ts +1 -1
- package/src/engines/reverseHarness.js +4 -3
- package/src/engines/reverseHarness.ts +4 -3
- package/src/entrypoint.js +77 -4
- package/src/headlessCli.js +305 -0
- package/src/headlessCli.ts +381 -0
- package/src/historyPruner.js +3 -2
- package/src/historyPruner.ts +3 -2
- package/src/hooks.js +3 -0
- package/src/hooks.ts +3 -0
- package/src/implementationPlan.js +21 -11
- package/src/implementationPlan.ts +21 -11
- package/src/infra/atomicWriter.js +4 -1
- package/src/infra/atomicWriter.ts +4 -1
- package/src/launchIntent.js +1 -1
- package/src/launchIntent.ts +1 -1
- package/src/mcp/mcpClient.js +38 -11
- package/src/mcp/mcpClient.ts +44 -11
- package/src/mcp/mcpRegistry.js +2 -5
- package/src/mcp/mcpRegistry.ts +2 -5
- package/src/mcp/mcpSecurity.js +189 -0
- package/src/mcp/mcpSecurity.ts +190 -0
- package/src/memory/scopedFacts.js +1 -1
- package/src/memory/scopedFacts.ts +1 -1
- package/src/memory/symbolFolder.js +1 -1
- package/src/memory/symbolFolder.ts +1 -1
- package/src/modelRouter.js +1 -1
- package/src/modelRouter.ts +1 -1
- package/src/observer/evidence.js +10 -4
- package/src/observer/evidence.ts +10 -4
- package/src/osKeychain.js +263 -0
- package/src/osKeychain.ts +287 -0
- package/src/perception.js +3 -2
- package/src/perception.ts +3 -2
- package/src/planCache.js +2 -2
- package/src/planCache.ts +2 -2
- package/src/pluginsFactory/pluginsFactory.js +19 -11
- package/src/pluginsFactory/pluginsFactory.ts +18 -11
- package/src/promptMentions.js +2 -2
- package/src/promptMentions.ts +2 -2
- package/src/providers/acp.js +1 -1
- package/src/providers/acp.ts +1 -1
- package/src/providers/anthropic.js +328 -385
- package/src/providers/anthropic.ts +386 -0
- package/src/providers/antigravity.js +10 -4
- package/src/providers/antigravity.ts +10 -4
- package/src/providers/base.js +221 -319
- package/src/providers/base.ts +340 -0
- package/src/providers/byokHttp.js +397 -0
- package/src/providers/byokHttp.ts +497 -0
- package/src/providers/byokStream.js +748 -0
- package/src/providers/byokStream.ts +863 -0
- package/src/providers/dashscope-byok.js +98 -81
- package/src/providers/dashscope-byok.ts +114 -0
- package/src/providers/deepseek.js +74 -64
- package/src/providers/deepseek.ts +99 -0
- package/src/providers/factory.js +35 -28
- package/src/providers/factory.ts +40 -0
- package/src/providers/gemini.js +229 -253
- package/src/providers/gemini.ts +261 -0
- package/src/providers/loopGuard.js +9 -5
- package/src/providers/loopGuard.ts +10 -5
- package/src/providers/moonshot.js +71 -64
- package/src/providers/moonshot.ts +93 -0
- package/src/providers/muse.js +82 -152
- package/src/providers/muse.ts +122 -0
- package/src/providers/ollama.js +116 -93
- package/src/providers/ollama.ts +135 -0
- package/src/providers/openai-compatible.js +114 -65
- package/src/providers/openai-compatible.ts +139 -0
- package/src/providers/openai.js +22 -15
- package/src/providers/openai.ts +30 -0
- package/src/providers/openrouter.js +194 -98
- package/src/providers/openrouter.ts +202 -97
- package/src/providers/pi.js +6 -0
- package/src/providers/pi.ts +6 -0
- package/src/providers/qwen-byok.js +97 -71
- package/src/providers/qwen-byok.ts +113 -0
- package/src/providers/toolContracts.js +40 -14
- package/src/providers/toolContracts.ts +35 -14
- package/src/providers/wireNormalizer.js +78 -11
- package/src/providers/wireNormalizer.ts +68 -12
- package/src/providers/xai.js +74 -64
- package/src/providers/xai.ts +97 -0
- package/src/reliability/assetEvidence.js +4 -2
- package/src/reliability/assetEvidence.ts +4 -2
- package/src/sandbox.js +486 -530
- package/src/sandbox.ts +552 -0
- package/src/sandboxPolicy.js +1287 -0
- package/src/sandboxPolicy.ts +1381 -0
- package/src/sessionJournal.js +55 -3
- package/src/sessionJournal.ts +58 -3
- package/src/skills/skillResourceSafety.js +19 -8
- package/src/skills/skillResourceSafety.ts +16 -7
- package/src/skillsManager.js +3 -3
- package/src/skillsManager.ts +3 -3
- package/src/smartToolsUse.js +28 -4
- package/src/smartToolsUse.ts +29 -7
- package/src/stallGuard.js +45 -22
- package/src/stallGuard.ts +46 -22
- package/src/subagentJournal.js +6 -4
- package/src/subagentJournal.ts +6 -4
- package/src/textDiff.js +6 -1
- package/src/textDiff.ts +6 -1
- package/src/timeMachine.js +7 -1
- package/src/timeMachine.ts +7 -1
- package/src/tokenTracker.js +43 -28
- package/src/tokenTracker.ts +44 -30
- package/src/toolPacks.js +3 -1
- package/src/toolPacks.ts +3 -1
- package/src/tools/archive.js +245 -35
- package/src/tools/archive.ts +244 -35
- package/src/tools/computerUse.js +7 -3
- package/src/tools/computerUse.ts +7 -3
- package/src/tools/creativeApps.js +13 -8
- package/src/tools/creativeApps.ts +22 -9
- package/src/tools/deferredMcpSearch.js +26 -14
- package/src/tools/deferredMcpSearch.ts +26 -14
- package/src/tools/desktopOpen.js +69 -10
- package/src/tools/desktopOpen.ts +70 -11
- package/src/tools/documentForge.js +167 -82
- package/src/tools/documentForge.ts +169 -84
- package/src/tools/fsEdit.js +101 -30
- package/src/tools/fsEdit.ts +105 -32
- package/src/tools/fsFind.js +8 -5
- package/src/tools/fsFind.ts +7 -4
- package/src/tools/fsRead.js +119 -13
- package/src/tools/fsRead.ts +124 -13
- package/src/tools/fsWrite.js +17 -5
- package/src/tools/fsWrite.ts +17 -7
- package/src/tools/generateMediaViaApi.js +82 -19
- package/src/tools/generateMediaViaApi.ts +80 -19
- package/src/tools/memoryRecall.js +62 -11
- package/src/tools/memoryRecall.ts +70 -13
- package/src/tools/memoryWrite.js +27 -14
- package/src/tools/memoryWrite.ts +30 -14
- package/src/tools/multiEdit.js +100 -30
- package/src/tools/multiEdit.ts +104 -32
- package/src/tools/nativeEngine.js +33 -18
- package/src/tools/nativeEngine.ts +31 -18
- package/src/tools/openSourceToolProvisioner.js +49 -14
- package/src/tools/openSourceToolProvisioner.ts +54 -15
- package/src/tools/osSandbox.js +513 -0
- package/src/tools/osSandbox.ts +588 -0
- package/src/tools/payloadSanitizer.js +40 -8
- package/src/tools/payloadSanitizer.ts +39 -8
- package/src/tools/peerAgent.js +96 -34
- package/src/tools/peerAgent.ts +114 -37
- package/src/tools/persistentShell.js +8 -3
- package/src/tools/pluginsFactory.js +38 -6
- package/src/tools/pluginsFactory.ts +42 -6
- package/src/tools/readNativeSkill.js +10 -8
- package/src/tools/readNativeSkill.ts +10 -8
- package/src/tools/requestDecision.js +10 -3
- package/src/tools/requestDecision.ts +10 -3
- package/src/tools/resolveAutomator.js +91 -17
- package/src/tools/resolveAutomator.ts +102 -17
- package/src/tools/reverseEngineering.js +168 -41
- package/src/tools/reverseEngineering.ts +161 -41
- package/src/tools/subprocessEnv.js +197 -0
- package/src/tools/subprocessEnv.ts +212 -0
- package/src/tools/sysRun.js +108 -35
- package/src/tools/sysRun.ts +119 -31
- package/src/tools/toolDispatch.js +24 -1
- package/src/tools/toolDispatch.ts +21 -1
- package/src/tools/toolOutputStore.js +62 -23
- package/src/tools/toolOutputStore.ts +56 -23
- package/src/tools/toolScanner.js +13 -10
- package/src/tools/toolScanner.ts +13 -10
- package/src/tools/toolSelfRepair.js +94 -28
- package/src/tools/toolSelfRepair.ts +96 -28
- package/src/tools/uiForge.js +71 -6
- package/src/tools/uiForge.ts +74 -6
- package/src/tools/viewImage.js +62 -17
- package/src/tools/viewImage.ts +57 -12
- package/src/tools/visionInspector.js +15 -3
- package/src/tools/visionInspector.ts +15 -3
- package/src/tools/walkerSafety.js +2 -0
- package/src/tools/walkerSafety.ts +1 -0
- package/src/tools/webFetch.js +105 -10
- package/src/tools/webFetch.ts +105 -11
- package/src/tui/banner.js +3 -2
- package/src/tui/banner.ts +3 -2
- package/src/tui/consoleGuard.js +12 -4
- package/src/tui/consoleGuard.ts +9 -4
- package/src/tui/messageInteraction.js +2 -3
- package/src/tui/messageInteraction.ts +2 -3
- package/src/tui/modelPicker.js +1 -0
- package/src/tui/modelPicker.ts +1 -0
- package/src/tui/overlay.js +3 -1
- package/src/tui/overlay.ts +3 -1
- package/src/tui/sessionPicker.js +3 -2
- package/src/tui/sessionPicker.ts +3 -2
- package/src/tui/sessionPickerView.js +7 -1
- package/src/tui/sessionPickerView.ts +6 -1
- package/src/tui/toolOutputNormalizer.js +2 -3
- package/src/tui/toolOutputNormalizer.ts +4 -3
- package/src/tui/viewport.js +4 -4
- package/src/tui/viewport.ts +5 -5
- package/src/tui/workspaceIdentity.js +2 -1
- package/src/tui/workspaceIdentity.ts +2 -1
- package/src/uncertainty.js +8 -3
- package/src/uncertainty.ts +8 -3
- package/src/utils/paths.js +8 -5
- package/src/utils/paths.ts +9 -7
- package/src/vfeTracker.js +9 -3
- package/src/vfeTracker.ts +9 -3
- package/src/config.d.ts +0 -2
- package/src/providers/base.d.ts +0 -94
- package/src/providers/factory.d.ts +0 -1
- package/src/sandbox.d.ts +0 -1
|
@@ -82,6 +82,7 @@ export function cleanToolOutputPreview(payload: string, toolName = ''): string {
|
|
|
82
82
|
if (!trimmed || trimmed.startsWith(DECAY_MARKER)) return '';
|
|
83
83
|
|
|
84
84
|
let text = payload
|
|
85
|
+
.replace(/\r\n?/g, '\n')
|
|
85
86
|
.replace(/\x1b\[(?:[12]K|\d*G)/g, '\n')
|
|
86
87
|
.replace(/(https?:\/\/[^\s"'<>]+?\.[a-z]{2,10})([A-Z][a-z]{2,15}:\s)/g, '$1\n$2');
|
|
87
88
|
|
|
@@ -158,9 +159,9 @@ function recoverBrokenJsonOutput(raw: string, spillPath?: string | undefined): R
|
|
|
158
159
|
if (outputMatch?.[1]) {
|
|
159
160
|
const body = outputMatch[1]
|
|
160
161
|
.replace(/"\s*\}\s*$/, '')
|
|
161
|
-
.replace(/\\
|
|
162
|
-
|
|
163
|
-
|
|
162
|
+
.replace(/\\([\\nrt"])/g, (_m, ch: string) =>
|
|
163
|
+
ch === 'n' ? '\n' : ch === 'r' ? '\r' : ch === 't' ? '\t' : ch
|
|
164
|
+
);
|
|
164
165
|
return {
|
|
165
166
|
success,
|
|
166
167
|
output: body,
|
package/src/tui/viewport.js
CHANGED
|
@@ -52,11 +52,11 @@ export class ScrollAcceleration {
|
|
|
52
52
|
this.streakTimeout = Number.isFinite(streakTimeout) && streakTimeout >= 0 ? streakTimeout : 150;
|
|
53
53
|
this.minTickInterval = Number.isFinite(minTickInterval) && minTickInterval >= 0 ? minTickInterval : 6;
|
|
54
54
|
this.intervals = [];
|
|
55
|
-
this.lastTick =
|
|
55
|
+
this.lastTick = null;
|
|
56
56
|
}
|
|
57
57
|
reset() {
|
|
58
58
|
this.intervals = [];
|
|
59
|
-
this.lastTick =
|
|
59
|
+
this.lastTick = null;
|
|
60
60
|
}
|
|
61
61
|
tick(now = Date.now()) {
|
|
62
62
|
if (!Number.isFinite(now))
|
|
@@ -64,13 +64,13 @@ export class ScrollAcceleration {
|
|
|
64
64
|
const A = 0.8;
|
|
65
65
|
const tau = 3;
|
|
66
66
|
const maxMultiplier = 6;
|
|
67
|
-
const gap = this.lastTick ? now - this.lastTick : Infinity;
|
|
67
|
+
const gap = this.lastTick !== null ? now - this.lastTick : Infinity;
|
|
68
68
|
if (gap === Infinity || gap > this.streakTimeout) {
|
|
69
69
|
this.lastTick = now;
|
|
70
70
|
this.intervals = [];
|
|
71
71
|
return 1;
|
|
72
72
|
}
|
|
73
|
-
if (gap < Math.max(0, this.minTickInterval))
|
|
73
|
+
if (gap <= 0 || gap < Math.max(0, this.minTickInterval))
|
|
74
74
|
return 1;
|
|
75
75
|
this.lastTick = now;
|
|
76
76
|
if (this.historySize > 0) {
|
package/src/tui/viewport.ts
CHANGED
|
@@ -54,19 +54,19 @@ export class ScrollAcceleration {
|
|
|
54
54
|
readonly streakTimeout: number;
|
|
55
55
|
readonly minTickInterval: number;
|
|
56
56
|
intervals: number[];
|
|
57
|
-
lastTick: number;
|
|
57
|
+
lastTick: number | null;
|
|
58
58
|
|
|
59
59
|
constructor({ history = 3, streakTimeout = 150, minTickInterval = 6 }: ScrollAccelerationOptions = {}) {
|
|
60
60
|
this.historySize = Number.isFinite(history) ? Math.max(0, Math.floor(history)) : 3;
|
|
61
61
|
this.streakTimeout = Number.isFinite(streakTimeout) && streakTimeout >= 0 ? streakTimeout : 150;
|
|
62
62
|
this.minTickInterval = Number.isFinite(minTickInterval) && minTickInterval >= 0 ? minTickInterval : 6;
|
|
63
63
|
this.intervals = [];
|
|
64
|
-
this.lastTick =
|
|
64
|
+
this.lastTick = null;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
reset(): void {
|
|
68
68
|
this.intervals = [];
|
|
69
|
-
this.lastTick =
|
|
69
|
+
this.lastTick = null;
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
tick(now: number = Date.now()): number {
|
|
@@ -75,13 +75,13 @@ export class ScrollAcceleration {
|
|
|
75
75
|
const tau = 3;
|
|
76
76
|
const maxMultiplier = 6;
|
|
77
77
|
|
|
78
|
-
const gap = this.lastTick ? now - this.lastTick : Infinity;
|
|
78
|
+
const gap = this.lastTick !== null ? now - this.lastTick : Infinity;
|
|
79
79
|
if (gap === Infinity || gap > this.streakTimeout) {
|
|
80
80
|
this.lastTick = now;
|
|
81
81
|
this.intervals = [];
|
|
82
82
|
return 1;
|
|
83
83
|
}
|
|
84
|
-
if (gap < Math.max(0, this.minTickInterval)) return 1;
|
|
84
|
+
if (gap <= 0 || gap < Math.max(0, this.minTickInterval)) return 1;
|
|
85
85
|
|
|
86
86
|
this.lastTick = now;
|
|
87
87
|
if (this.historySize > 0) {
|
|
@@ -84,7 +84,8 @@ export function shortenWorkspacePath(workspacePath) {
|
|
|
84
84
|
const prefix = cmpHome.endsWith(path.sep) ? cmpHome : `${cmpHome}${path.sep}`;
|
|
85
85
|
if (cmpResolved.startsWith(prefix)) {
|
|
86
86
|
const tail = resolved.slice(resolvedHome.length);
|
|
87
|
-
|
|
87
|
+
const joined = tail.startsWith(path.sep) ? `~${tail}` : `~${path.sep}${tail}`;
|
|
88
|
+
return cleanInlineText(joined) || '~';
|
|
88
89
|
}
|
|
89
90
|
}
|
|
90
91
|
return cleanInlineText(trimmed) || '(default)';
|
|
@@ -92,7 +92,8 @@ export function shortenWorkspacePath(workspacePath: string | undefined): string
|
|
|
92
92
|
const prefix = cmpHome.endsWith(path.sep) ? cmpHome : `${cmpHome}${path.sep}`;
|
|
93
93
|
if (cmpResolved.startsWith(prefix)) {
|
|
94
94
|
const tail = resolved.slice(resolvedHome.length);
|
|
95
|
-
|
|
95
|
+
const joined = tail.startsWith(path.sep) ? `~${tail}` : `~${path.sep}${tail}`;
|
|
96
|
+
return cleanInlineText(joined) || '~';
|
|
96
97
|
}
|
|
97
98
|
}
|
|
98
99
|
return cleanInlineText(trimmed) || '(default)';
|
package/src/uncertainty.js
CHANGED
|
@@ -82,7 +82,8 @@ export function assessStep(signals = {}) {
|
|
|
82
82
|
score += capped;
|
|
83
83
|
fired.push(name);
|
|
84
84
|
};
|
|
85
|
-
const
|
|
85
|
+
const rawFailures = Number(signals.consecutiveFailures);
|
|
86
|
+
const failures = Number.isFinite(rawFailures) && rawFailures > 0 ? Math.floor(rawFailures) : 0;
|
|
86
87
|
if (failures > 0)
|
|
87
88
|
add(Math.min(failures, 3) * WEIGHTS.consecutiveFailure, `failures:${failures}`);
|
|
88
89
|
if (signals.lastResult) {
|
|
@@ -96,8 +97,12 @@ export function assessStep(signals = {}) {
|
|
|
96
97
|
if (signals.vfePlateau) {
|
|
97
98
|
add(WEIGHTS.vfePlateau, 'vfe_plateau');
|
|
98
99
|
}
|
|
99
|
-
const
|
|
100
|
-
|
|
100
|
+
const finiteSim = (v) => {
|
|
101
|
+
const n = Number(v);
|
|
102
|
+
return Number.isFinite(n) ? n : 0;
|
|
103
|
+
};
|
|
104
|
+
const bestPrior = Math.max(0, finiteSim(signals.planSimilarity), finiteSim(signals.lessonSimilarity));
|
|
105
|
+
if (bestPrior <= 0)
|
|
101
106
|
add(WEIGHTS.noPriorArt, 'no_prior_art');
|
|
102
107
|
if (typeof signals.assistantText === 'string' && HEDGE.test(signals.assistantText)) {
|
|
103
108
|
add(WEIGHTS.hedging, 'model_hedged');
|
package/src/uncertainty.ts
CHANGED
|
@@ -170,7 +170,8 @@ export function assessStep(signals: StepSignals = {}): Assessment {
|
|
|
170
170
|
fired.push(name);
|
|
171
171
|
};
|
|
172
172
|
|
|
173
|
-
const
|
|
173
|
+
const rawFailures = Number(signals.consecutiveFailures);
|
|
174
|
+
const failures = Number.isFinite(rawFailures) && rawFailures > 0 ? Math.floor(rawFailures) : 0;
|
|
174
175
|
if (failures > 0) add(Math.min(failures, 3) * WEIGHTS.consecutiveFailure, `failures:${failures}`);
|
|
175
176
|
|
|
176
177
|
if (signals.lastResult) {
|
|
@@ -186,8 +187,12 @@ export function assessStep(signals: StepSignals = {}): Assessment {
|
|
|
186
187
|
add(WEIGHTS.vfePlateau, 'vfe_plateau');
|
|
187
188
|
}
|
|
188
189
|
|
|
189
|
-
const
|
|
190
|
-
|
|
190
|
+
const finiteSim = (v: unknown): number => {
|
|
191
|
+
const n = Number(v);
|
|
192
|
+
return Number.isFinite(n) ? n : 0;
|
|
193
|
+
};
|
|
194
|
+
const bestPrior = Math.max(0, finiteSim(signals.planSimilarity), finiteSim(signals.lessonSimilarity));
|
|
195
|
+
if (bestPrior <= 0) add(WEIGHTS.noPriorArt, 'no_prior_art');
|
|
191
196
|
|
|
192
197
|
if (typeof signals.assistantText === 'string' && HEDGE.test(signals.assistantText)) {
|
|
193
198
|
add(WEIGHTS.hedging, 'model_hedged');
|
package/src/utils/paths.js
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import os from 'node:os';
|
|
3
3
|
import path from 'node:path';
|
|
4
|
+
function isWithinDir(child, parent) {
|
|
5
|
+
const c = process.platform === 'win32' ? child.toLowerCase() : child;
|
|
6
|
+
const p = process.platform === 'win32' ? parent.toLowerCase() : parent;
|
|
7
|
+
const rel = path.relative(p, c);
|
|
8
|
+
return rel === '' || (rel !== '..' && !rel.startsWith(`..${path.sep}`) && !path.isAbsolute(rel));
|
|
9
|
+
}
|
|
4
10
|
function isTempHome(dir) {
|
|
5
11
|
const normalized = path.resolve(dir);
|
|
6
12
|
const tmp = path.resolve(os.tmpdir());
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
normalized.startsWith('/private/tmp/') ||
|
|
10
|
-
normalized.startsWith('/var/folders/') ||
|
|
11
|
-
normalized.startsWith('/private/var/folders/'));
|
|
13
|
+
const roots = [tmp, '/tmp', '/private/tmp', '/var/folders', '/private/var/folders'];
|
|
14
|
+
return roots.some((root) => isWithinDir(normalized, path.resolve(root)));
|
|
12
15
|
}
|
|
13
16
|
function isNodeTestRunner() {
|
|
14
17
|
if (process.env['NODE_TEST_CONTEXT'])
|
package/src/utils/paths.ts
CHANGED
|
@@ -2,16 +2,18 @@ import fs from 'node:fs';
|
|
|
2
2
|
import os from 'node:os';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
|
|
5
|
+
function isWithinDir(child: string, parent: string): boolean {
|
|
6
|
+
const c = process.platform === 'win32' ? child.toLowerCase() : child;
|
|
7
|
+
const p = process.platform === 'win32' ? parent.toLowerCase() : parent;
|
|
8
|
+
const rel = path.relative(p, c);
|
|
9
|
+
return rel === '' || (rel !== '..' && !rel.startsWith(`..${path.sep}`) && !path.isAbsolute(rel));
|
|
10
|
+
}
|
|
11
|
+
|
|
5
12
|
function isTempHome(dir: string): boolean {
|
|
6
13
|
const normalized = path.resolve(dir);
|
|
7
14
|
const tmp = path.resolve(os.tmpdir());
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
normalized.startsWith('/tmp/') ||
|
|
11
|
-
normalized.startsWith('/private/tmp/') ||
|
|
12
|
-
normalized.startsWith('/var/folders/') ||
|
|
13
|
-
normalized.startsWith('/private/var/folders/')
|
|
14
|
-
);
|
|
15
|
+
const roots = [tmp, '/tmp', '/private/tmp', '/var/folders', '/private/var/folders'];
|
|
16
|
+
return roots.some((root) => isWithinDir(normalized, path.resolve(root)));
|
|
15
17
|
}
|
|
16
18
|
|
|
17
19
|
function isNodeTestRunner(): boolean {
|
package/src/vfeTracker.js
CHANGED
|
@@ -38,9 +38,15 @@ export class VFETracker {
|
|
|
38
38
|
lastShiftStep;
|
|
39
39
|
totalSteps;
|
|
40
40
|
constructor(options = {}) {
|
|
41
|
-
this.windowSize = options.windowSize
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
this.windowSize = typeof options.windowSize === 'number' && Number.isFinite(options.windowSize) && options.windowSize >= 1
|
|
42
|
+
? Math.floor(options.windowSize)
|
|
43
|
+
: VFE_WINDOW_SIZE;
|
|
44
|
+
this.varianceEpsilon = typeof options.varianceEpsilon === 'number' && Number.isFinite(options.varianceEpsilon) && options.varianceEpsilon >= 0
|
|
45
|
+
? options.varianceEpsilon
|
|
46
|
+
: VARIANCE_EPSILON;
|
|
47
|
+
this.meanThreshold = typeof options.meanThreshold === 'number' && Number.isFinite(options.meanThreshold) && options.meanThreshold >= 0
|
|
48
|
+
? options.meanThreshold
|
|
49
|
+
: MEAN_ERROR_THRESHOLD;
|
|
44
50
|
this.history = [];
|
|
45
51
|
this.lastShiftStep = -SHIFT_COOLDOWN_STEPS;
|
|
46
52
|
this.totalSteps = 0;
|
package/src/vfeTracker.ts
CHANGED
|
@@ -93,9 +93,15 @@ export class VFETracker {
|
|
|
93
93
|
totalSteps: number;
|
|
94
94
|
|
|
95
95
|
constructor(options: VFETrackerOptions = {}) {
|
|
96
|
-
this.windowSize = options.windowSize
|
|
97
|
-
|
|
98
|
-
|
|
96
|
+
this.windowSize = typeof options.windowSize === 'number' && Number.isFinite(options.windowSize) && options.windowSize >= 1
|
|
97
|
+
? Math.floor(options.windowSize)
|
|
98
|
+
: VFE_WINDOW_SIZE;
|
|
99
|
+
this.varianceEpsilon = typeof options.varianceEpsilon === 'number' && Number.isFinite(options.varianceEpsilon) && options.varianceEpsilon >= 0
|
|
100
|
+
? options.varianceEpsilon
|
|
101
|
+
: VARIANCE_EPSILON;
|
|
102
|
+
this.meanThreshold = typeof options.meanThreshold === 'number' && Number.isFinite(options.meanThreshold) && options.meanThreshold >= 0
|
|
103
|
+
? options.meanThreshold
|
|
104
|
+
: MEAN_ERROR_THRESHOLD;
|
|
99
105
|
|
|
100
106
|
this.history = [];
|
|
101
107
|
this.lastShiftStep = -SHIFT_COOLDOWN_STEPS;
|
package/src/config.d.ts
DELETED
package/src/providers/base.d.ts
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import type { RequestPermissionRequest, RequestPermissionResponse } from '../acp/protocol.js';
|
|
2
|
-
|
|
3
|
-
export interface ProviderConfig {
|
|
4
|
-
apiKey?: string | undefined;
|
|
5
|
-
model?: string | undefined;
|
|
6
|
-
baseUrl?: string | undefined;
|
|
7
|
-
provider?: string | undefined;
|
|
8
|
-
command?: string | undefined;
|
|
9
|
-
args?: string[] | undefined;
|
|
10
|
-
peer?: string | undefined;
|
|
11
|
-
supportsVision?: boolean | undefined;
|
|
12
|
-
[key: string]: any;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export interface ChatResponseUsage {
|
|
16
|
-
promptTokens: number;
|
|
17
|
-
completionTokens: number;
|
|
18
|
-
cachedPromptTokens?: number | undefined;
|
|
19
|
-
uncachedPromptTokens?: number | undefined;
|
|
20
|
-
measurement?: 'provider_reported' | 'text_estimate' | undefined;
|
|
21
|
-
cacheMeasurement?: 'provider_reported' | 'unavailable' | undefined;
|
|
22
|
-
measurementScope?: 'last_model_call' | 'peer_reported' | undefined;
|
|
23
|
-
totalTokens?: number | undefined;
|
|
24
|
-
thinkingTokens?: number | undefined;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface ChatResponseToolCall {
|
|
28
|
-
id: string;
|
|
29
|
-
type: string;
|
|
30
|
-
function: {
|
|
31
|
-
name: string;
|
|
32
|
-
arguments: string;
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export interface ChatResponseAction {
|
|
37
|
-
id?: string | undefined;
|
|
38
|
-
name: string;
|
|
39
|
-
status: 'running' | 'completed' | 'failed';
|
|
40
|
-
detail?: string | undefined;
|
|
41
|
-
parameters?: Record<string, unknown> | undefined;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export interface ChatResponse {
|
|
45
|
-
content: string;
|
|
46
|
-
usage: ChatResponseUsage;
|
|
47
|
-
toolCalls?: ChatResponseToolCall[] | undefined;
|
|
48
|
-
reasoningContent?: string | undefined;
|
|
49
|
-
thinkingBlocks?: any[] | undefined;
|
|
50
|
-
externalActions?: ChatResponseAction[] | undefined;
|
|
51
|
-
toolRoutingError?: { tool: string; message: string; parameters?: Record<string, unknown> | undefined } | undefined;
|
|
52
|
-
incompleteTurn?: boolean | undefined;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export interface ChatOptions {
|
|
56
|
-
onPeerPermission?: ((request: RequestPermissionRequest) => Promise<RequestPermissionResponse['outcome']>) | undefined;
|
|
57
|
-
onPeerFileRead?: ((file: string, options?: { line?: number; limit?: number }) => Promise<string>) | undefined;
|
|
58
|
-
onPeerFileWrite?: ((file: string, content: string) => Promise<void>) | undefined;
|
|
59
|
-
peerMcpServers?: unknown[] | undefined;
|
|
60
|
-
tokenBudgetBasis?: 'total' | 'noncached' | undefined;
|
|
61
|
-
tools?: any[] | undefined;
|
|
62
|
-
temperature?: number | undefined;
|
|
63
|
-
maxRetries?: number | undefined;
|
|
64
|
-
signal?: AbortSignal | undefined;
|
|
65
|
-
onChunk?: ((chunk: string) => void) | undefined;
|
|
66
|
-
onReasoningChunk?: ((chunk: string) => void) | undefined;
|
|
67
|
-
onNativeAction?: ((action: ChatResponseAction) => void) | undefined;
|
|
68
|
-
onPlanUpdate?: ((plan: unknown) => void) | undefined;
|
|
69
|
-
coreToolCount?: number | undefined;
|
|
70
|
-
[key: string]: any;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export class LLMProvider {
|
|
74
|
-
apiKey?: string;
|
|
75
|
-
model: string;
|
|
76
|
-
baseUrl?: string;
|
|
77
|
-
visionModels: string[];
|
|
78
|
-
imagePayloadFormat: string;
|
|
79
|
-
visionOverride: boolean | null;
|
|
80
|
-
audioModels: string[];
|
|
81
|
-
audioPayloadFormat: string;
|
|
82
|
-
|
|
83
|
-
constructor(config?: ProviderConfig);
|
|
84
|
-
get supportsVision(): boolean;
|
|
85
|
-
get supportsAudio(): boolean;
|
|
86
|
-
supportsToolSearch?(): boolean;
|
|
87
|
-
prepareMessages(messages: any[]): any[];
|
|
88
|
-
normalizeUsage(rawUsage: any): ChatResponseUsage;
|
|
89
|
-
chat(messages: any[], options?: ChatOptions): Promise<ChatResponse>;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export function mimeTypeForAudioFormat(format: string): string;
|
|
93
|
-
export function audioFormatForMimeType(mimeType: string): string;
|
|
94
|
-
export function isAudioBlock(block: any): boolean;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export function createProvider(...args: any[]): any;
|
package/src/sandbox.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const Sandbox: any;
|