@causyne/agent 1.20.121 → 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 +6 -2
- package/src/agent/errorClassifier.ts +6 -2
- package/src/agentLoop.js +11 -5
- package/src/agentLoop.ts +11 -5
- 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 +5 -2
- package/src/autoUpdate.ts +5 -2
- 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/config.js +287 -250
- package/src/config.ts +342 -0
- package/src/configVault.js +84 -17
- package/src/configVault.ts +77 -17
- 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/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/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/headlessCli.js +2 -1
- package/src/headlessCli.ts +2 -1
- 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/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 +62 -8
- package/src/osKeychain.ts +50 -8
- 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 +327 -401
- 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 +58 -15
- package/src/providers/byokHttp.ts +59 -16
- package/src/providers/byokStream.js +142 -51
- package/src/providers/byokStream.ts +146 -42
- package/src/providers/dashscope-byok.js +97 -89
- package/src/providers/dashscope-byok.ts +114 -0
- package/src/providers/deepseek.js +73 -72
- 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 +227 -278
- 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 +70 -72
- 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 +114 -106
- package/src/providers/ollama.ts +135 -0
- package/src/providers/openai-compatible.js +113 -96
- 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 +136 -74
- package/src/providers/openrouter.ts +133 -72
- package/src/providers/pi.js +6 -0
- package/src/providers/pi.ts +6 -0
- package/src/providers/qwen-byok.js +96 -87
- 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 +73 -72
- 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 +489 -554
- package/src/sandbox.ts +552 -0
- package/src/sandboxPolicy.js +95 -16
- package/src/sandboxPolicy.ts +97 -16
- package/src/sessionJournal.js +8 -3
- package/src/sessionJournal.ts +9 -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 +54 -14
- package/src/tools/osSandbox.ts +48 -14
- 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/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/sysRun.js +69 -29
- package/src/tools/sysRun.ts +66 -24
- 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
package/src/tools/webFetch.ts
CHANGED
|
@@ -21,16 +21,90 @@ function decodeEntities(text: string): string {
|
|
|
21
21
|
return Number.isInteger(codePoint) && codePoint > 0 && codePoint <= 0x10ffff &&
|
|
22
22
|
!(codePoint >= 0xd800 && codePoint <= 0xdfff) ? String.fromCodePoint(codePoint) : full;
|
|
23
23
|
}
|
|
24
|
-
return named[normalized]
|
|
24
|
+
return Object.hasOwn(named, normalized) ? named[normalized]! : full;
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
const SKIP_CONTENT_TAGS = new Set(['script', 'style', 'svg', 'noscript']);
|
|
29
|
+
const BLOCK_CLOSE_TAGS = new Set(['p', 'div', 'article', 'section', 'li', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'tr']);
|
|
30
|
+
|
|
28
31
|
export function htmlToReadableText(html: string): string {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
const src = String(html ?? '');
|
|
33
|
+
const parts: string[] = [];
|
|
34
|
+
let skipTag: string | null = null;
|
|
35
|
+
let i = 0;
|
|
36
|
+
|
|
37
|
+
while (i < src.length) {
|
|
38
|
+
const lt = src.indexOf('<', i);
|
|
39
|
+
if (lt === -1) {
|
|
40
|
+
if (!skipTag) parts.push(src.slice(i));
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
if (!skipTag && lt > i) {
|
|
44
|
+
parts.push(src.slice(i, lt));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// HTML comments: <!-- ... -->
|
|
48
|
+
if (src.startsWith('<!--', lt)) {
|
|
49
|
+
const commentEnd = src.indexOf('-->', lt + 4);
|
|
50
|
+
i = commentEnd === -1 ? src.length : commentEnd + 3;
|
|
51
|
+
if (!skipTag) parts.push(' ');
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
let gt = lt + 1;
|
|
56
|
+
let quote: string | null = null;
|
|
57
|
+
while (gt < src.length) {
|
|
58
|
+
const ch = src[gt]!;
|
|
59
|
+
if (quote) {
|
|
60
|
+
if (ch === quote) quote = null;
|
|
61
|
+
} else if (ch === '"' || ch === "'") {
|
|
62
|
+
quote = ch;
|
|
63
|
+
} else if (ch === '>') {
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
gt++;
|
|
67
|
+
}
|
|
68
|
+
if (gt >= src.length) {
|
|
69
|
+
// Unclosed '<': emit remaining literal text if not inside a skipped element
|
|
70
|
+
if (!skipTag) parts.push(src.slice(lt));
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const rawTag = src.slice(lt + 1, gt).trim();
|
|
75
|
+
const isClosing = rawTag.startsWith('/');
|
|
76
|
+
const isSelfClosing = !isClosing && rawTag.endsWith('/');
|
|
77
|
+
let nameStart = isClosing ? 1 : 0;
|
|
78
|
+
while (nameStart < rawTag.length && (rawTag[nameStart] === ' ' || rawTag[nameStart] === '\t' || rawTag[nameStart] === '\n' || rawTag[nameStart] === '\r')) {
|
|
79
|
+
nameStart++;
|
|
80
|
+
}
|
|
81
|
+
let nameEnd = nameStart;
|
|
82
|
+
while (nameEnd < rawTag.length) {
|
|
83
|
+
const code = rawTag.charCodeAt(nameEnd);
|
|
84
|
+
const isAlphaNum = (code >= 48 && code <= 57) || (code >= 65 && code <= 90) || (code >= 97 && code <= 122);
|
|
85
|
+
if (!isAlphaNum) break;
|
|
86
|
+
nameEnd++;
|
|
87
|
+
}
|
|
88
|
+
const tagName = rawTag.slice(nameStart, nameEnd).toLowerCase();
|
|
89
|
+
|
|
90
|
+
if (skipTag) {
|
|
91
|
+
if (isClosing && tagName === skipTag) {
|
|
92
|
+
skipTag = null;
|
|
93
|
+
parts.push(' ');
|
|
94
|
+
}
|
|
95
|
+
} else if (!isClosing && !isSelfClosing && SKIP_CONTENT_TAGS.has(tagName)) {
|
|
96
|
+
skipTag = tagName;
|
|
97
|
+
parts.push(' ');
|
|
98
|
+
} else if (tagName === 'br' || (isClosing && BLOCK_CLOSE_TAGS.has(tagName))) {
|
|
99
|
+
parts.push('\n');
|
|
100
|
+
} else {
|
|
101
|
+
parts.push(' ');
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
i = gt + 1;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return decodeEntities(parts.join(''))
|
|
34
108
|
.replace(/[ \t]+/g, ' ')
|
|
35
109
|
.replace(/ *\n */g, '\n')
|
|
36
110
|
.replace(/\n{3,}/g, '\n\n')
|
|
@@ -207,13 +281,20 @@ export const webFetch = {
|
|
|
207
281
|
|
|
208
282
|
async execute(
|
|
209
283
|
args: { url?: string; method?: string; headers?: unknown; body?: string; outputFile?: string },
|
|
210
|
-
sandbox?: { workspacePaths?: string[]; workspaceRoot?: string }
|
|
284
|
+
sandbox?: { workspacePaths?: string[]; workspaceRoot?: string; signal?: AbortSignal; parentLoop?: { workspaceRoot?: string } }
|
|
211
285
|
) {
|
|
212
286
|
const controller = new AbortController();
|
|
213
287
|
const timer = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
|
|
288
|
+
const requestSignal = sandbox?.signal ? AbortSignal.any([sandbox.signal, controller.signal]) : controller.signal;
|
|
214
289
|
try {
|
|
215
|
-
if (!args
|
|
216
|
-
|
|
290
|
+
if (!args || typeof args !== 'object' || typeof args.url !== 'string' || !args.url.trim()) {
|
|
291
|
+
return { success: false, error: 'url is required' };
|
|
292
|
+
}
|
|
293
|
+
const rawWorkspace = sandbox?.workspacePaths?.find((p): p is string => typeof p === 'string' && p.trim().length > 0)?.trim()
|
|
294
|
+
?? sandbox?.parentLoop?.workspaceRoot?.trim()
|
|
295
|
+
?? sandbox?.workspaceRoot?.trim()
|
|
296
|
+
?? process.cwd();
|
|
297
|
+
const workspace = path.resolve(rawWorkspace);
|
|
217
298
|
if (args.method !== undefined && typeof args.method !== 'string') {
|
|
218
299
|
return { success: false, error: 'HTTP method must be a string' };
|
|
219
300
|
}
|
|
@@ -224,6 +305,16 @@ export const webFetch = {
|
|
|
224
305
|
if (args.outputFile !== undefined && (typeof args.outputFile !== 'string' || !args.outputFile.trim())) {
|
|
225
306
|
return { success: false, error: 'Download outputFile must be a non-empty string' };
|
|
226
307
|
}
|
|
308
|
+
if (args.outputFile) {
|
|
309
|
+
const trimmedOut = args.outputFile.trim();
|
|
310
|
+
if (trimmedOut.endsWith('/') || trimmedOut.endsWith('\\')) {
|
|
311
|
+
return { success: false, error: 'Download outputFile must point to a file, not a directory' };
|
|
312
|
+
}
|
|
313
|
+
const preTarget = path.resolve(workspace, trimmedOut);
|
|
314
|
+
if (!isWithin(workspace, preTarget)) {
|
|
315
|
+
return { success: false, error: 'Download target must stay inside the selected workspace' };
|
|
316
|
+
}
|
|
317
|
+
}
|
|
227
318
|
if (method === 'HEAD' && args.outputFile) {
|
|
228
319
|
return { success: false, error: 'HEAD responses cannot be downloaded as resource files' };
|
|
229
320
|
}
|
|
@@ -232,7 +323,7 @@ export const webFetch = {
|
|
|
232
323
|
Accept: 'text/html,application/xhtml+xml,application/json,text/plain,*/*;q=0.8',
|
|
233
324
|
...validatedHeaders(args.headers)
|
|
234
325
|
};
|
|
235
|
-
const request: RequestInit = { method, headers, signal:
|
|
326
|
+
const request: RequestInit = { method, headers, signal: requestSignal };
|
|
236
327
|
if (args.body !== undefined) {
|
|
237
328
|
if (typeof args.body !== 'string') return { success: false, error: 'HTTP request body must be a string' };
|
|
238
329
|
if (method === 'GET' || method === 'HEAD') return { success: false, error: `${method} requests cannot contain a body` };
|
|
@@ -330,8 +421,11 @@ export const webFetch = {
|
|
|
330
421
|
: readable;
|
|
331
422
|
return { success: true, output, status: response.status, finalUrl: finalUrl.href, contentType };
|
|
332
423
|
} catch (error) {
|
|
424
|
+
if (sandbox?.signal?.aborted) {
|
|
425
|
+
return { success: false, error: 'Request aborted' };
|
|
426
|
+
}
|
|
333
427
|
const message = error instanceof Error ? error.message : String(error);
|
|
334
|
-
const timedOut = error instanceof Error && (error.name === 'AbortError' || message === 'This operation was aborted');
|
|
428
|
+
const timedOut = controller.signal.aborted || (error instanceof Error && (error.name === 'AbortError' || message === 'This operation was aborted'));
|
|
335
429
|
return { success: false, error: timedOut ? `Request timed out after ${REQUEST_TIMEOUT_MS}ms` : message };
|
|
336
430
|
} finally {
|
|
337
431
|
clearTimeout(timer);
|
package/src/tui/banner.js
CHANGED
|
@@ -138,7 +138,7 @@ export function detect(o = {}, stream = process.stdout) {
|
|
|
138
138
|
else {
|
|
139
139
|
const f = env['FORCE_COLOR'];
|
|
140
140
|
if (f !== undefined && f !== '')
|
|
141
|
-
color = FORCE[f]
|
|
141
|
+
color = Object.hasOwn(FORCE, f) ? FORCE[f] : '16';
|
|
142
142
|
else if (env['NO_COLOR'] || env['CAUSYNE_NO_COLOR'] === '1')
|
|
143
143
|
color = 'none';
|
|
144
144
|
else if (!tty || env['TERM'] === 'dumb')
|
|
@@ -351,7 +351,8 @@ export function providerLabel(provider) {
|
|
|
351
351
|
'acp/copilot': 'Copilot (ACP)', 'acp/kimi': 'Kimi (ACP)',
|
|
352
352
|
'acp/goose': 'Goose (ACP)', 'acp/hermes': 'Hermes (ACP)'
|
|
353
353
|
};
|
|
354
|
-
|
|
354
|
+
const key = raw.toLowerCase();
|
|
355
|
+
return Object.hasOwn(known, key) ? known[key] : raw;
|
|
355
356
|
}
|
|
356
357
|
function sessionInfo(info) {
|
|
357
358
|
const provider = providerLabel(info.provider);
|
package/src/tui/banner.ts
CHANGED
|
@@ -174,7 +174,7 @@ export function detect(o: BannerOptions = {}, stream: TermStream = process.stdou
|
|
|
174
174
|
else if (typeof want === 'string' && VALID_COLORS.has(want as ColorMode)) color = want as ColorMode;
|
|
175
175
|
else {
|
|
176
176
|
const f = env['FORCE_COLOR'];
|
|
177
|
-
if (f !== undefined && f !== '') color = FORCE[f]
|
|
177
|
+
if (f !== undefined && f !== '') color = Object.hasOwn(FORCE, f) ? FORCE[f]! : '16';
|
|
178
178
|
else if (env['NO_COLOR'] || env['CAUSYNE_NO_COLOR'] === '1') color = 'none';
|
|
179
179
|
else if (!tty || env['TERM'] === 'dumb') color = 'none';
|
|
180
180
|
else {
|
|
@@ -350,7 +350,8 @@ export function providerLabel(provider: unknown): string {
|
|
|
350
350
|
'acp/copilot': 'Copilot (ACP)', 'acp/kimi': 'Kimi (ACP)',
|
|
351
351
|
'acp/goose': 'Goose (ACP)', 'acp/hermes': 'Hermes (ACP)'
|
|
352
352
|
};
|
|
353
|
-
|
|
353
|
+
const key = raw.toLowerCase();
|
|
354
|
+
return Object.hasOwn(known, key) ? known[key]! : raw;
|
|
354
355
|
}
|
|
355
356
|
|
|
356
357
|
function sessionInfo(info: BannerInfo): BannerInfo {
|
package/src/tui/consoleGuard.js
CHANGED
|
@@ -36,7 +36,9 @@ export function runWithStageWrite(fn) {
|
|
|
36
36
|
function chunkToText(chunk, encodingOrCb) {
|
|
37
37
|
if (typeof chunk === 'string')
|
|
38
38
|
return chunk;
|
|
39
|
-
const encoding = typeof encodingOrCb === 'string'
|
|
39
|
+
const encoding = typeof encodingOrCb === 'string' && Buffer.isEncoding(encodingOrCb)
|
|
40
|
+
? encodingOrCb
|
|
41
|
+
: 'utf8';
|
|
40
42
|
if (Buffer.isBuffer(chunk))
|
|
41
43
|
return chunk.toString(encoding);
|
|
42
44
|
if (chunk instanceof Uint8Array)
|
|
@@ -48,7 +50,7 @@ export function isAnyStageReservedOnStdout() {
|
|
|
48
50
|
return true;
|
|
49
51
|
}
|
|
50
52
|
for (const host of activeStageHosts) {
|
|
51
|
-
if (host
|
|
53
|
+
if (host?.stage?.reserved && (!host.out || host.out === process.stdout)) {
|
|
52
54
|
return true;
|
|
53
55
|
}
|
|
54
56
|
}
|
|
@@ -116,6 +118,8 @@ export function setStageConsoleGuardActive(active) {
|
|
|
116
118
|
* Register a StageSurface host so raw console writes are suppressed while its Stage is reserved.
|
|
117
119
|
*/
|
|
118
120
|
export function registerStageConsoleGuard(host) {
|
|
121
|
+
if (!host || typeof host !== 'object')
|
|
122
|
+
return () => { };
|
|
119
123
|
ensureConsoleGuardInstalled();
|
|
120
124
|
activeStageHosts.add(host);
|
|
121
125
|
return () => {
|
|
@@ -128,6 +132,8 @@ const noticeTimers = new WeakMap();
|
|
|
128
132
|
* if nothing else has overwritten `host.notice` in the meantime.
|
|
129
133
|
*/
|
|
130
134
|
export function setTransientNotice(host, message, ttlMs = 4000) {
|
|
135
|
+
if (!host || typeof host !== 'object')
|
|
136
|
+
return;
|
|
131
137
|
const existing = noticeTimers.get(host);
|
|
132
138
|
if (existing) {
|
|
133
139
|
clearTimeout(existing);
|
|
@@ -137,7 +143,8 @@ export function setTransientNotice(host, message, ttlMs = 4000) {
|
|
|
137
143
|
? safeDisplay(message).replace(/\s+/g, ' ').trim()
|
|
138
144
|
: '';
|
|
139
145
|
host.notice = cleanMessage;
|
|
140
|
-
host.scheduleDraw
|
|
146
|
+
if (typeof host.scheduleDraw === 'function')
|
|
147
|
+
host.scheduleDraw();
|
|
141
148
|
const safeTtlMs = !Number.isFinite(ttlMs)
|
|
142
149
|
? (Number.isNaN(ttlMs) ? 4000 : 0)
|
|
143
150
|
: Math.min(Math.floor(ttlMs), 2_147_483_647);
|
|
@@ -147,7 +154,8 @@ export function setTransientNotice(host, message, ttlMs = 4000) {
|
|
|
147
154
|
noticeTimers.delete(host);
|
|
148
155
|
if (host.notice === cleanMessage) {
|
|
149
156
|
host.notice = '';
|
|
150
|
-
host.scheduleDraw
|
|
157
|
+
if (typeof host.scheduleDraw === 'function')
|
|
158
|
+
host.scheduleDraw();
|
|
151
159
|
}
|
|
152
160
|
}, safeTtlMs);
|
|
153
161
|
timer.unref?.();
|
package/src/tui/consoleGuard.ts
CHANGED
|
@@ -51,7 +51,10 @@ export function runWithStageWrite<T>(fn: () => T): T {
|
|
|
51
51
|
|
|
52
52
|
function chunkToText(chunk: unknown, encodingOrCb?: unknown): string {
|
|
53
53
|
if (typeof chunk === 'string') return chunk;
|
|
54
|
-
const encoding
|
|
54
|
+
const encoding: BufferEncoding =
|
|
55
|
+
typeof encodingOrCb === 'string' && Buffer.isEncoding(encodingOrCb)
|
|
56
|
+
? encodingOrCb
|
|
57
|
+
: 'utf8';
|
|
55
58
|
if (Buffer.isBuffer(chunk)) return chunk.toString(encoding);
|
|
56
59
|
if (chunk instanceof Uint8Array) return Buffer.from(chunk).toString(encoding);
|
|
57
60
|
return String(chunk ?? '');
|
|
@@ -62,7 +65,7 @@ export function isAnyStageReservedOnStdout(): boolean {
|
|
|
62
65
|
return true;
|
|
63
66
|
}
|
|
64
67
|
for (const host of activeStageHosts) {
|
|
65
|
-
if (host
|
|
68
|
+
if (host?.stage?.reserved && (!host.out || host.out === process.stdout)) {
|
|
66
69
|
return true;
|
|
67
70
|
}
|
|
68
71
|
}
|
|
@@ -131,6 +134,7 @@ export function setStageConsoleGuardActive(active: boolean): void {
|
|
|
131
134
|
* Register a StageSurface host so raw console writes are suppressed while its Stage is reserved.
|
|
132
135
|
*/
|
|
133
136
|
export function registerStageConsoleGuard(host: ConsoleGuardStageHost): () => void {
|
|
137
|
+
if (!host || typeof host !== 'object') return () => {};
|
|
134
138
|
ensureConsoleGuardInstalled();
|
|
135
139
|
activeStageHosts.add(host);
|
|
136
140
|
return () => {
|
|
@@ -145,6 +149,7 @@ const noticeTimers = new WeakMap<TransientNoticeHost, ReturnType<typeof setTimeo
|
|
|
145
149
|
* if nothing else has overwritten `host.notice` in the meantime.
|
|
146
150
|
*/
|
|
147
151
|
export function setTransientNotice(host: TransientNoticeHost, message: string, ttlMs = 4000): void {
|
|
152
|
+
if (!host || typeof host !== 'object') return;
|
|
148
153
|
const existing = noticeTimers.get(host);
|
|
149
154
|
if (existing) {
|
|
150
155
|
clearTimeout(existing);
|
|
@@ -154,7 +159,7 @@ export function setTransientNotice(host: TransientNoticeHost, message: string, t
|
|
|
154
159
|
? safeDisplay(message).replace(/\s+/g, ' ').trim()
|
|
155
160
|
: '';
|
|
156
161
|
host.notice = cleanMessage;
|
|
157
|
-
host.scheduleDraw();
|
|
162
|
+
if (typeof host.scheduleDraw === 'function') host.scheduleDraw();
|
|
158
163
|
const safeTtlMs = !Number.isFinite(ttlMs)
|
|
159
164
|
? (Number.isNaN(ttlMs) ? 4000 : 0)
|
|
160
165
|
: Math.min(Math.floor(ttlMs), 2_147_483_647);
|
|
@@ -164,7 +169,7 @@ export function setTransientNotice(host: TransientNoticeHost, message: string, t
|
|
|
164
169
|
noticeTimers.delete(host);
|
|
165
170
|
if (host.notice === cleanMessage) {
|
|
166
171
|
host.notice = '';
|
|
167
|
-
host.scheduleDraw();
|
|
172
|
+
if (typeof host.scheduleDraw === 'function') host.scheduleDraw();
|
|
168
173
|
}
|
|
169
174
|
}, safeTtlMs);
|
|
170
175
|
timer.unref?.();
|
|
@@ -3,7 +3,7 @@ import { revokeAllAlways } from '../approvalGrants.js';
|
|
|
3
3
|
// @ts-expect-error Legacy checkpoints module has no TypeScript declarations yet.
|
|
4
4
|
import { undoLast } from '../checkpoints.js';
|
|
5
5
|
import { writeClipboardSync } from './clipboardSync.js';
|
|
6
|
-
import {
|
|
6
|
+
import { setTransientNotice } from './consoleGuard.js';
|
|
7
7
|
import { detectLinkAtPoint, openDetectedLink } from './smartLinkClick.js';
|
|
8
8
|
import { sidebarVisible, sessionMainWidth } from './sessionSidebar.js';
|
|
9
9
|
import { safeDisplay, stripAnsi, truncate, padEnd, visibleWidth } from './text.js';
|
|
@@ -102,7 +102,7 @@ export class MessageActionsLayer extends Layer {
|
|
|
102
102
|
this.onPick(this.items[this.list.selected] ?? null);
|
|
103
103
|
return 'close';
|
|
104
104
|
}
|
|
105
|
-
if (!event.ctrl && !event.alt && keyName && (keyName.length === 1 || keyName === 'space' || keyName === 'backspace')) {
|
|
105
|
+
if (!event.ctrl && !event.alt && !event.meta && keyName && (keyName === 'char' || keyName === 'paste' || keyName.length === 1 || keyName === 'space' || keyName === 'backspace')) {
|
|
106
106
|
this.settled = true;
|
|
107
107
|
this.onPick(null);
|
|
108
108
|
return 'dismiss';
|
|
@@ -235,7 +235,6 @@ export function messageAt(surface, point) {
|
|
|
235
235
|
}
|
|
236
236
|
/** Highlight only the visible non-empty rows of the hovered message, without altering transcript data. */
|
|
237
237
|
export function markHoveredMessage(rows, surface, contentWidth) {
|
|
238
|
-
registerStageConsoleGuard(surface);
|
|
239
238
|
if (!Array.isArray(rows) || rows.length === 0 || !surface?.transcript?.flatten)
|
|
240
239
|
return;
|
|
241
240
|
const safeContentWidth = Number.isFinite(contentWidth) && contentWidth > 0 ? Math.floor(contentWidth) : 1;
|
|
@@ -9,7 +9,7 @@ import { revokeAllAlways } from '../approvalGrants.js';
|
|
|
9
9
|
// @ts-expect-error Legacy checkpoints module has no TypeScript declarations yet.
|
|
10
10
|
import { undoLast } from '../checkpoints.js';
|
|
11
11
|
import { writeClipboardSync } from './clipboardSync.js';
|
|
12
|
-
import {
|
|
12
|
+
import { setTransientNotice } from './consoleGuard.js';
|
|
13
13
|
import { detectLinkAtPoint, openDetectedLink } from './smartLinkClick.js';
|
|
14
14
|
import { sidebarVisible, sessionMainWidth } from './sessionSidebar.js';
|
|
15
15
|
import { safeDisplay, stripAnsi, truncate, padEnd, visibleWidth } from './text.js';
|
|
@@ -156,7 +156,7 @@ export class MessageActionsLayer extends Layer {
|
|
|
156
156
|
this.onPick(this.items[this.list.selected] ?? null);
|
|
157
157
|
return 'close';
|
|
158
158
|
}
|
|
159
|
-
if (!event.ctrl && !event.alt && keyName && (keyName.length === 1 || keyName === 'space' || keyName === 'backspace')) {
|
|
159
|
+
if (!event.ctrl && !event.alt && !(event as { meta?: boolean }).meta && keyName && (keyName === 'char' || keyName === 'paste' || keyName.length === 1 || keyName === 'space' || keyName === 'backspace')) {
|
|
160
160
|
this.settled = true;
|
|
161
161
|
this.onPick(null);
|
|
162
162
|
return 'dismiss';
|
|
@@ -326,7 +326,6 @@ export function messageAt(surface: MessageSurface | null, point: MousePoint): Me
|
|
|
326
326
|
export function markHoveredMessage(
|
|
327
327
|
rows: string[], surface: MessageSurface, contentWidth: number
|
|
328
328
|
): void {
|
|
329
|
-
registerStageConsoleGuard(surface);
|
|
330
329
|
if (!Array.isArray(rows) || rows.length === 0 || !surface?.transcript?.flatten) return;
|
|
331
330
|
const safeContentWidth = Number.isFinite(contentWidth) && contentWidth > 0 ? Math.floor(contentWidth) : 1;
|
|
332
331
|
const id = surface.hoveredMessageFrameId;
|
package/src/tui/modelPicker.js
CHANGED
package/src/tui/modelPicker.ts
CHANGED
package/src/tui/overlay.js
CHANGED
|
@@ -156,10 +156,12 @@ export class Layer {
|
|
|
156
156
|
const maxH = vh - 4 >= 5 ? vh - 4 : vh;
|
|
157
157
|
const wanted = Math.max(3, Math.min(safePreferred, layerHeight));
|
|
158
158
|
const height = Math.min(wanted, Math.max(3, maxH));
|
|
159
|
+
const slackY = Math.max(0, vh - height);
|
|
160
|
+
const topGap = slackY > 0 ? Math.min(slackY, Math.max(1, Math.floor(slackY / 4))) : 0;
|
|
159
161
|
return {
|
|
160
162
|
x: vx + Math.floor((vw - width) / 2),
|
|
161
163
|
// A quarter down reads as centred; dead centre sits visually too low.
|
|
162
|
-
y: vy +
|
|
164
|
+
y: vy + topGap,
|
|
163
165
|
width,
|
|
164
166
|
height
|
|
165
167
|
};
|
package/src/tui/overlay.ts
CHANGED
|
@@ -208,10 +208,12 @@ export class Layer {
|
|
|
208
208
|
const maxH = vh - 4 >= 5 ? vh - 4 : vh;
|
|
209
209
|
const wanted = Math.max(3, Math.min(safePreferred, layerHeight));
|
|
210
210
|
const height = Math.min(wanted, Math.max(3, maxH));
|
|
211
|
+
const slackY = Math.max(0, vh - height);
|
|
212
|
+
const topGap = slackY > 0 ? Math.min(slackY, Math.max(1, Math.floor(slackY / 4))) : 0;
|
|
211
213
|
return {
|
|
212
214
|
x: vx + Math.floor((vw - width) / 2),
|
|
213
215
|
// A quarter down reads as centred; dead centre sits visually too low.
|
|
214
|
-
y: vy +
|
|
216
|
+
y: vy + topGap,
|
|
215
217
|
width,
|
|
216
218
|
height
|
|
217
219
|
};
|
package/src/tui/sessionPicker.js
CHANGED
|
@@ -171,8 +171,9 @@ export function formatSessionsTextReport(sessions, activeId, currentWorkspace, l
|
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
173
|
const formatRow = (s) => {
|
|
174
|
-
const
|
|
175
|
-
|
|
174
|
+
const dt = Number.isFinite(s.updatedAt) ? new Date(s.updatedAt) : null;
|
|
175
|
+
const when = dt && Number.isFinite(dt.getTime())
|
|
176
|
+
? dt.toISOString().slice(0, 16).replace('T', ' ')
|
|
176
177
|
: 'unknown date';
|
|
177
178
|
const where = s.workspace ? shortenWorkspacePath(s.workspace) : '(no workspace)';
|
|
178
179
|
const mark = s.id === activeId ? '*' : ' ';
|
package/src/tui/sessionPicker.ts
CHANGED
|
@@ -240,8 +240,9 @@ export function formatSessionsTextReport(
|
|
|
240
240
|
}
|
|
241
241
|
|
|
242
242
|
const formatRow = (s: Omit<SessionRecord, 'messages'> & { messageCount: number }): string => {
|
|
243
|
-
const
|
|
244
|
-
|
|
243
|
+
const dt = Number.isFinite(s.updatedAt) ? new Date(s.updatedAt) : null;
|
|
244
|
+
const when = dt && Number.isFinite(dt.getTime())
|
|
245
|
+
? dt.toISOString().slice(0, 16).replace('T', ' ')
|
|
245
246
|
: 'unknown date';
|
|
246
247
|
const where = s.workspace ? shortenWorkspacePath(s.workspace) : '(no workspace)';
|
|
247
248
|
const mark = s.id === activeId ? '*' : ' ';
|
|
@@ -385,7 +385,13 @@ export class SessionPickerLayer extends SelectLayer {
|
|
|
385
385
|
const selected = Math.max(0, Math.min(Math.floor(this.list.selected || 0), entries.length - 1));
|
|
386
386
|
const window = renderSessionRows(entries, offset, selected, this.lastWidth, available, this.renderOptions(entries));
|
|
387
387
|
const page = Math.max(1, window.lastIndex - offset + 1);
|
|
388
|
-
|
|
388
|
+
const target = Math.max(0, Math.min(entries.length - 1, selected + (event.name === 'pageup' ? -page : page)));
|
|
389
|
+
if (typeof this.list.moveTo === 'function') {
|
|
390
|
+
this.list.moveTo(target, available);
|
|
391
|
+
}
|
|
392
|
+
else {
|
|
393
|
+
this.list.move(target - selected, available);
|
|
394
|
+
}
|
|
389
395
|
return 'handled';
|
|
390
396
|
}
|
|
391
397
|
const previousQuery = this.list.query;
|
|
@@ -473,7 +473,12 @@ export class SessionPickerLayer extends SelectLayer {
|
|
|
473
473
|
const selected = Math.max(0, Math.min(Math.floor(this.list.selected || 0), entries.length - 1));
|
|
474
474
|
const window = renderSessionRows(entries, offset, selected, this.lastWidth, available, this.renderOptions(entries));
|
|
475
475
|
const page = Math.max(1, window.lastIndex - offset + 1);
|
|
476
|
-
|
|
476
|
+
const target = Math.max(0, Math.min(entries.length - 1, selected + (event.name === 'pageup' ? -page : page)));
|
|
477
|
+
if (typeof this.list.moveTo === 'function') {
|
|
478
|
+
this.list.moveTo(target, available);
|
|
479
|
+
} else {
|
|
480
|
+
this.list.move(target - selected, available);
|
|
481
|
+
}
|
|
477
482
|
return 'handled';
|
|
478
483
|
}
|
|
479
484
|
const previousQuery = this.list.query;
|
|
@@ -43,6 +43,7 @@ export function cleanToolOutputPreview(payload, toolName = '') {
|
|
|
43
43
|
if (!trimmed || trimmed.startsWith(DECAY_MARKER))
|
|
44
44
|
return '';
|
|
45
45
|
let text = payload
|
|
46
|
+
.replace(/\r\n?/g, '\n')
|
|
46
47
|
.replace(/\x1b\[(?:[12]K|\d*G)/g, '\n')
|
|
47
48
|
.replace(/(https?:\/\/[^\s"'<>]+?\.[a-z]{2,10})([A-Z][a-z]{2,15}:\s)/g, '$1\n$2');
|
|
48
49
|
// Strip renderSpillDocument metadata header up to the first `--- field: ... ---` marker
|
|
@@ -127,9 +128,7 @@ function recoverBrokenJsonOutput(raw, spillPath) {
|
|
|
127
128
|
if (outputMatch?.[1]) {
|
|
128
129
|
const body = outputMatch[1]
|
|
129
130
|
.replace(/"\s*\}\s*$/, '')
|
|
130
|
-
.replace(/\\
|
|
131
|
-
.replace(/\\"/g, '"')
|
|
132
|
-
.replace(/\\\\/g, '\\');
|
|
131
|
+
.replace(/\\([\\nrt"])/g, (_m, ch) => ch === 'n' ? '\n' : ch === 'r' ? '\r' : ch === 't' ? '\t' : ch);
|
|
133
132
|
return {
|
|
134
133
|
success,
|
|
135
134
|
output: body,
|
|
@@ -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');
|