@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
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
import fs from 'node:fs';
|
|
8
8
|
import path from 'node:path';
|
|
9
9
|
import os from 'node:os';
|
|
10
|
+
import { pathToFileURL } from 'node:url';
|
|
10
11
|
import { spawn } from 'node:child_process';
|
|
11
12
|
const PALETTES = {
|
|
12
13
|
corporate: {
|
|
@@ -38,7 +39,8 @@ const PALETTES = {
|
|
|
38
39
|
* Compile formal publication document to pixel-perfect HTML + CSS Paged Media.
|
|
39
40
|
*/
|
|
40
41
|
export function compileDocumentHtml(spec) {
|
|
41
|
-
const
|
|
42
|
+
const paletteKey = spec.palette && Object.hasOwn(PALETTES, spec.palette) ? spec.palette : 'corporate';
|
|
43
|
+
const p = PALETTES[paletteKey];
|
|
42
44
|
const css = `
|
|
43
45
|
:root {
|
|
44
46
|
--primary: ${p.primary};
|
|
@@ -302,6 +304,7 @@ export async function renderHtmlToPdf(htmlFilePath, outputPdfPath, timeoutMs = 2
|
|
|
302
304
|
}
|
|
303
305
|
const profileDir = fs.mkdtempSync(path.join(os.tmpdir(), 'causyne-pdf-profile-'));
|
|
304
306
|
return new Promise((resolve) => {
|
|
307
|
+
let settled = false;
|
|
305
308
|
const proc = spawn(chromePath, [
|
|
306
309
|
'--headless',
|
|
307
310
|
'--disable-gpu',
|
|
@@ -309,7 +312,7 @@ export async function renderHtmlToPdf(htmlFilePath, outputPdfPath, timeoutMs = 2
|
|
|
309
312
|
'--no-pdf-header-footer',
|
|
310
313
|
`--user-data-dir=${profileDir}`,
|
|
311
314
|
`--print-to-pdf=${absOut}`,
|
|
312
|
-
|
|
315
|
+
pathToFileURL(absHtml).href
|
|
313
316
|
], { stdio: 'ignore' });
|
|
314
317
|
let prevSize = -1;
|
|
315
318
|
let stableCount = 0;
|
|
@@ -317,25 +320,36 @@ export async function renderHtmlToPdf(htmlFilePath, outputPdfPath, timeoutMs = 2
|
|
|
317
320
|
let elapsed = 0;
|
|
318
321
|
const timer = setInterval(() => {
|
|
319
322
|
elapsed += interval;
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
323
|
+
try {
|
|
324
|
+
if (fs.existsSync(absOut)) {
|
|
325
|
+
const stat = fs.statSync(absOut);
|
|
326
|
+
if (stat.size === prevSize && stat.size > 0) {
|
|
327
|
+
stableCount++;
|
|
328
|
+
if (stableCount >= 3) {
|
|
329
|
+
cleanupAndResolve(true);
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
else {
|
|
334
|
+
stableCount = 0;
|
|
335
|
+
prevSize = stat.size;
|
|
327
336
|
}
|
|
328
337
|
}
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
}
|
|
338
|
+
}
|
|
339
|
+
catch {
|
|
340
|
+
// Ignore transient stat race while PDF is being written
|
|
333
341
|
}
|
|
334
342
|
if (elapsed >= timeoutMs) {
|
|
335
343
|
cleanupAndResolve(false, 'Render timed out waiting for PDF file stabilization.');
|
|
336
344
|
}
|
|
337
345
|
}, interval);
|
|
346
|
+
proc.on('error', (err) => {
|
|
347
|
+
cleanupAndResolve(false, `Failed to launch Chrome: ${err.message}`);
|
|
348
|
+
});
|
|
338
349
|
function cleanupAndResolve(success, error) {
|
|
350
|
+
if (settled)
|
|
351
|
+
return;
|
|
352
|
+
settled = true;
|
|
339
353
|
clearInterval(timer);
|
|
340
354
|
try {
|
|
341
355
|
proc.kill();
|
|
@@ -349,7 +363,14 @@ export async function renderHtmlToPdf(htmlFilePath, outputPdfPath, timeoutMs = 2
|
|
|
349
363
|
resolve({ success: false, error: error || 'Failed to generate PDF.' });
|
|
350
364
|
return;
|
|
351
365
|
}
|
|
352
|
-
|
|
366
|
+
let stat;
|
|
367
|
+
try {
|
|
368
|
+
stat = fs.statSync(absOut);
|
|
369
|
+
}
|
|
370
|
+
catch {
|
|
371
|
+
resolve({ success: false, error: 'Failed to stat generated PDF.' });
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
353
374
|
const sizeKb = Math.round(stat.size / 1024);
|
|
354
375
|
const exceeds2Mb = sizeKb > 2048;
|
|
355
376
|
resolve({
|
|
@@ -410,9 +431,17 @@ except Exception as e:
|
|
|
410
431
|
print(json.dumps({"success": False, "error": str(e)}))
|
|
411
432
|
`;
|
|
412
433
|
return new Promise((resolve) => {
|
|
413
|
-
|
|
434
|
+
let settled = false;
|
|
435
|
+
const pyBin = process.platform === 'win32' ? 'python' : 'python3';
|
|
436
|
+
const py = spawn(pyBin, ['-c', script, absPdf, outputImagesDir || '']);
|
|
414
437
|
let stdout = '';
|
|
415
438
|
let stderr = '';
|
|
439
|
+
py.on('error', (err) => {
|
|
440
|
+
if (settled)
|
|
441
|
+
return;
|
|
442
|
+
settled = true;
|
|
443
|
+
resolve({ success: false, error: `Failed to spawn ${pyBin}: ${err.message}` });
|
|
444
|
+
});
|
|
416
445
|
py.stdout.on('data', (d) => {
|
|
417
446
|
stdout += d.toString();
|
|
418
447
|
});
|
|
@@ -420,6 +449,9 @@ except Exception as e:
|
|
|
420
449
|
stderr += d.toString();
|
|
421
450
|
});
|
|
422
451
|
py.on('close', (code) => {
|
|
452
|
+
if (settled)
|
|
453
|
+
return;
|
|
454
|
+
settled = true;
|
|
423
455
|
if (code !== 0) {
|
|
424
456
|
resolve({ success: false, error: stderr.trim() || `Python process exited with code ${code}` });
|
|
425
457
|
return;
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
import fs from 'node:fs';
|
|
9
9
|
import path from 'node:path';
|
|
10
10
|
import os from 'node:os';
|
|
11
|
+
import { pathToFileURL } from 'node:url';
|
|
11
12
|
import { spawn } from 'node:child_process';
|
|
12
13
|
|
|
13
14
|
export type DocumentPalette = 'corporate' | 'editorial_dair' | 'minimal_clean';
|
|
@@ -88,7 +89,8 @@ const PALETTES: Record<DocumentPalette, { primary: string; primaryDark: string;
|
|
|
88
89
|
* Compile formal publication document to pixel-perfect HTML + CSS Paged Media.
|
|
89
90
|
*/
|
|
90
91
|
export function compileDocumentHtml(spec: FormalDocumentSpec): { html: string; css: string } {
|
|
91
|
-
const
|
|
92
|
+
const paletteKey = spec.palette && Object.hasOwn(PALETTES, spec.palette) ? spec.palette : 'corporate';
|
|
93
|
+
const p = PALETTES[paletteKey];
|
|
92
94
|
|
|
93
95
|
const css = `
|
|
94
96
|
:root {
|
|
@@ -365,6 +367,7 @@ export async function renderHtmlToPdf(htmlFilePath: string, outputPdfPath: strin
|
|
|
365
367
|
const profileDir = fs.mkdtempSync(path.join(os.tmpdir(), 'causyne-pdf-profile-'));
|
|
366
368
|
|
|
367
369
|
return new Promise((resolve) => {
|
|
370
|
+
let settled = false;
|
|
368
371
|
const proc = spawn(
|
|
369
372
|
chromePath,
|
|
370
373
|
[
|
|
@@ -374,7 +377,7 @@ export async function renderHtmlToPdf(htmlFilePath: string, outputPdfPath: strin
|
|
|
374
377
|
'--no-pdf-header-footer',
|
|
375
378
|
`--user-data-dir=${profileDir}`,
|
|
376
379
|
`--print-to-pdf=${absOut}`,
|
|
377
|
-
|
|
380
|
+
pathToFileURL(absHtml).href
|
|
378
381
|
],
|
|
379
382
|
{ stdio: 'ignore' }
|
|
380
383
|
);
|
|
@@ -386,18 +389,22 @@ export async function renderHtmlToPdf(htmlFilePath: string, outputPdfPath: strin
|
|
|
386
389
|
|
|
387
390
|
const timer = setInterval(() => {
|
|
388
391
|
elapsed += interval;
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
392
|
+
try {
|
|
393
|
+
if (fs.existsSync(absOut)) {
|
|
394
|
+
const stat = fs.statSync(absOut);
|
|
395
|
+
if (stat.size === prevSize && stat.size > 0) {
|
|
396
|
+
stableCount++;
|
|
397
|
+
if (stableCount >= 3) {
|
|
398
|
+
cleanupAndResolve(true);
|
|
399
|
+
return;
|
|
400
|
+
}
|
|
401
|
+
} else {
|
|
402
|
+
stableCount = 0;
|
|
403
|
+
prevSize = stat.size;
|
|
396
404
|
}
|
|
397
|
-
} else {
|
|
398
|
-
stableCount = 0;
|
|
399
|
-
prevSize = stat.size;
|
|
400
405
|
}
|
|
406
|
+
} catch {
|
|
407
|
+
// Ignore transient stat race while PDF is being written
|
|
401
408
|
}
|
|
402
409
|
|
|
403
410
|
if (elapsed >= timeoutMs) {
|
|
@@ -405,7 +412,13 @@ export async function renderHtmlToPdf(htmlFilePath: string, outputPdfPath: strin
|
|
|
405
412
|
}
|
|
406
413
|
}, interval);
|
|
407
414
|
|
|
415
|
+
proc.on('error', (err) => {
|
|
416
|
+
cleanupAndResolve(false, `Failed to launch Chrome: ${err.message}`);
|
|
417
|
+
});
|
|
418
|
+
|
|
408
419
|
function cleanupAndResolve(success: boolean, error?: string) {
|
|
420
|
+
if (settled) return;
|
|
421
|
+
settled = true;
|
|
409
422
|
clearInterval(timer);
|
|
410
423
|
try {
|
|
411
424
|
proc.kill();
|
|
@@ -419,7 +432,13 @@ export async function renderHtmlToPdf(htmlFilePath: string, outputPdfPath: strin
|
|
|
419
432
|
return;
|
|
420
433
|
}
|
|
421
434
|
|
|
422
|
-
|
|
435
|
+
let stat: fs.Stats;
|
|
436
|
+
try {
|
|
437
|
+
stat = fs.statSync(absOut);
|
|
438
|
+
} catch {
|
|
439
|
+
resolve({ success: false, error: 'Failed to stat generated PDF.' });
|
|
440
|
+
return;
|
|
441
|
+
}
|
|
423
442
|
const sizeKb = Math.round(stat.size / 1024);
|
|
424
443
|
const exceeds2Mb = sizeKb > 2048;
|
|
425
444
|
|
|
@@ -484,10 +503,18 @@ except Exception as e:
|
|
|
484
503
|
`;
|
|
485
504
|
|
|
486
505
|
return new Promise((resolve) => {
|
|
487
|
-
|
|
506
|
+
let settled = false;
|
|
507
|
+
const pyBin = process.platform === 'win32' ? 'python' : 'python3';
|
|
508
|
+
const py = spawn(pyBin, ['-c', script, absPdf, outputImagesDir || '']);
|
|
488
509
|
let stdout = '';
|
|
489
510
|
let stderr = '';
|
|
490
511
|
|
|
512
|
+
py.on('error', (err) => {
|
|
513
|
+
if (settled) return;
|
|
514
|
+
settled = true;
|
|
515
|
+
resolve({ success: false, error: `Failed to spawn ${pyBin}: ${err.message}` });
|
|
516
|
+
});
|
|
517
|
+
|
|
491
518
|
py.stdout.on('data', (d) => {
|
|
492
519
|
stdout += d.toString();
|
|
493
520
|
});
|
|
@@ -496,6 +523,8 @@ except Exception as e:
|
|
|
496
523
|
});
|
|
497
524
|
|
|
498
525
|
py.on('close', (code) => {
|
|
526
|
+
if (settled) return;
|
|
527
|
+
settled = true;
|
|
499
528
|
if (code !== 0) {
|
|
500
529
|
resolve({ success: false, error: stderr.trim() || `Python process exited with code ${code}` });
|
|
501
530
|
return;
|
package/src/dynamicCatalogue.js
CHANGED
|
@@ -16,6 +16,7 @@ import { execFile } from 'node:child_process';
|
|
|
16
16
|
import { promisify } from 'node:util';
|
|
17
17
|
import { causyneHome } from './utils/paths.js';
|
|
18
18
|
import { MODEL_CATALOGUE, PEER_MODEL_CATALOGUE, DEFAULT_MODEL_BY_PROVIDER } from './modelCatalogue.js';
|
|
19
|
+
import { validateProviderEndpointUrl, readBoundedResponseText } from './providers/byokHttp.js';
|
|
19
20
|
import { BASELINE_ANTIGRAVITY_MODELS, ANTIGRAVITY_MODELS, ANTIGRAVITY_MODEL_IDS, ANTIGRAVITY_LABEL_BY_ID, registerAntigravityModel, replaceAntigravityModels, parseAgyModelsOutput, isAntigravityOnboarded, resolveAgyBinary } from './providers/antigravity.js';
|
|
20
21
|
import { isBinaryOnPath, BUILTIN_PEER_PRESETS, probePresetAuth, testPeerHandshake } from './acp/agentCatalog.js';
|
|
21
22
|
import { getPeerProfile } from './acp/peerProfiles.js';
|
|
@@ -881,16 +882,30 @@ export async function fetchLiveModels(provider, config = {}) {
|
|
|
881
882
|
const peer = peerIdFromProviderKey(norm);
|
|
882
883
|
if (peer)
|
|
883
884
|
return discoverPeerModels(peer);
|
|
885
|
+
const MAX_DISCOVERY_BYTES = 4 * 1024 * 1024;
|
|
886
|
+
const fetchDiscoveryJson = async (rawUrl, headers = {}, hasApiKey = false) => {
|
|
887
|
+
const safeUrl = validateProviderEndpointUrl(rawUrl, {
|
|
888
|
+
hasApiKey,
|
|
889
|
+
providerLabel: norm
|
|
890
|
+
});
|
|
891
|
+
const res = await fetch(safeUrl, {
|
|
892
|
+
headers,
|
|
893
|
+
redirect: 'error',
|
|
894
|
+
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)
|
|
895
|
+
});
|
|
896
|
+
if (!res.ok)
|
|
897
|
+
return null;
|
|
898
|
+
if (!res.body && typeof res.text !== 'function' && typeof res.json === 'function') {
|
|
899
|
+
return (await res.json());
|
|
900
|
+
}
|
|
901
|
+
const text = await readBoundedResponseText(res, MAX_DISCOVERY_BYTES, { truncate: false, label: norm });
|
|
902
|
+
return JSON.parse(text);
|
|
903
|
+
};
|
|
884
904
|
try {
|
|
885
905
|
if (norm === 'ollama') {
|
|
886
906
|
const host = (baseUrl || 'http://127.0.0.1:11434').replace(/\/+$/, '');
|
|
887
|
-
const
|
|
888
|
-
|
|
889
|
-
});
|
|
890
|
-
if (!res.ok)
|
|
891
|
-
return [];
|
|
892
|
-
const data = await res.json();
|
|
893
|
-
if (Array.isArray(data.models)) {
|
|
907
|
+
const data = await fetchDiscoveryJson(`${host}/api/tags`, {}, false);
|
|
908
|
+
if (Array.isArray(data?.models)) {
|
|
894
909
|
return data.models
|
|
895
910
|
.map((m) => (m.name || '').replace(/:latest$/, ''))
|
|
896
911
|
.filter(Boolean);
|
|
@@ -900,14 +915,8 @@ export async function fetchLiveModels(provider, config = {}) {
|
|
|
900
915
|
if (!apiKey)
|
|
901
916
|
return [];
|
|
902
917
|
const host = (baseUrl || 'https://api.openai.com/v1').replace(/\/+$/, '');
|
|
903
|
-
const
|
|
904
|
-
|
|
905
|
-
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)
|
|
906
|
-
});
|
|
907
|
-
if (!res.ok)
|
|
908
|
-
return [];
|
|
909
|
-
const data = await res.json();
|
|
910
|
-
if (Array.isArray(data.data)) {
|
|
918
|
+
const data = await fetchDiscoveryJson(`${host}/models`, { Authorization: `Bearer ${apiKey}` }, true);
|
|
919
|
+
if (Array.isArray(data?.data)) {
|
|
911
920
|
return data.data
|
|
912
921
|
.map((m) => m.id || '')
|
|
913
922
|
.filter((id) => /^(gpt|o1|o3|chatgpt)/i.test(id))
|
|
@@ -917,13 +926,9 @@ export async function fetchLiveModels(provider, config = {}) {
|
|
|
917
926
|
if (norm === 'gemini') {
|
|
918
927
|
if (!apiKey)
|
|
919
928
|
return [];
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
if (!res.ok)
|
|
924
|
-
return [];
|
|
925
|
-
const data = await res.json();
|
|
926
|
-
if (Array.isArray(data.models)) {
|
|
929
|
+
// Send API key in x-goog-api-key header rather than query string (CWE-598).
|
|
930
|
+
const data = await fetchDiscoveryJson('https://generativelanguage.googleapis.com/v1beta/models', { 'x-goog-api-key': apiKey }, true);
|
|
931
|
+
if (Array.isArray(data?.models)) {
|
|
927
932
|
return data.models
|
|
928
933
|
.filter((m) => m.supportedGenerationMethods?.includes('generateContent'))
|
|
929
934
|
.map((m) => (m.name || '').replace(/^models\//, ''))
|
|
@@ -934,17 +939,11 @@ export async function fetchLiveModels(provider, config = {}) {
|
|
|
934
939
|
if (norm === 'anthropic') {
|
|
935
940
|
if (!apiKey)
|
|
936
941
|
return [];
|
|
937
|
-
const
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)
|
|
943
|
-
});
|
|
944
|
-
if (!res.ok)
|
|
945
|
-
return [];
|
|
946
|
-
const data = await res.json();
|
|
947
|
-
if (Array.isArray(data.data)) {
|
|
942
|
+
const data = await fetchDiscoveryJson('https://api.anthropic.com/v1/models', {
|
|
943
|
+
'x-api-key': apiKey,
|
|
944
|
+
'anthropic-version': '2023-06-01'
|
|
945
|
+
}, true);
|
|
946
|
+
if (Array.isArray(data?.data)) {
|
|
948
947
|
return data.data
|
|
949
948
|
.map((m) => m.id || '')
|
|
950
949
|
.filter(Boolean)
|
|
@@ -954,14 +953,8 @@ export async function fetchLiveModels(provider, config = {}) {
|
|
|
954
953
|
if (norm === 'deepseek') {
|
|
955
954
|
if (!apiKey)
|
|
956
955
|
return [];
|
|
957
|
-
const
|
|
958
|
-
|
|
959
|
-
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)
|
|
960
|
-
});
|
|
961
|
-
if (!res.ok)
|
|
962
|
-
return [];
|
|
963
|
-
const data = await res.json();
|
|
964
|
-
if (Array.isArray(data.data)) {
|
|
956
|
+
const data = await fetchDiscoveryJson('https://api.deepseek.com/models', { Authorization: `Bearer ${apiKey}` }, true);
|
|
957
|
+
if (Array.isArray(data?.data)) {
|
|
965
958
|
return data.data.map((m) => m.id || '').filter(Boolean).sort();
|
|
966
959
|
}
|
|
967
960
|
}
|
|
@@ -969,14 +962,8 @@ export async function fetchLiveModels(provider, config = {}) {
|
|
|
969
962
|
if (!apiKey)
|
|
970
963
|
return [];
|
|
971
964
|
const host = (baseUrl || 'https://api.x.ai/v1').replace(/\/+$/, '');
|
|
972
|
-
const
|
|
973
|
-
|
|
974
|
-
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)
|
|
975
|
-
});
|
|
976
|
-
if (!res.ok)
|
|
977
|
-
return [];
|
|
978
|
-
const data = await res.json();
|
|
979
|
-
if (Array.isArray(data.data)) {
|
|
965
|
+
const data = await fetchDiscoveryJson(`${host}/models`, { Authorization: `Bearer ${apiKey}` }, true);
|
|
966
|
+
if (Array.isArray(data?.data)) {
|
|
980
967
|
return data.data.map((m) => m.id || '').filter((id) => /^(grok)/i.test(id)).sort();
|
|
981
968
|
}
|
|
982
969
|
}
|
|
@@ -984,14 +971,8 @@ export async function fetchLiveModels(provider, config = {}) {
|
|
|
984
971
|
if (!apiKey)
|
|
985
972
|
return [];
|
|
986
973
|
const host = (baseUrl || 'https://api.moonshot.cn/v1').replace(/\/+$/, '');
|
|
987
|
-
const
|
|
988
|
-
|
|
989
|
-
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)
|
|
990
|
-
});
|
|
991
|
-
if (!res.ok)
|
|
992
|
-
return [];
|
|
993
|
-
const data = await res.json();
|
|
994
|
-
if (Array.isArray(data.data)) {
|
|
974
|
+
const data = await fetchDiscoveryJson(`${host}/models`, { Authorization: `Bearer ${apiKey}` }, true);
|
|
975
|
+
if (Array.isArray(data?.data)) {
|
|
995
976
|
return data.data.map((m) => m.id || '').filter((id) => /^(kimi|moonshot)/i.test(id)).sort();
|
|
996
977
|
}
|
|
997
978
|
}
|
|
@@ -999,14 +980,8 @@ export async function fetchLiveModels(provider, config = {}) {
|
|
|
999
980
|
if (!apiKey)
|
|
1000
981
|
return [];
|
|
1001
982
|
const host = (baseUrl || 'https://dashscope.aliyuncs.com/compatible-mode/v1').replace(/\/+$/, '');
|
|
1002
|
-
const
|
|
1003
|
-
|
|
1004
|
-
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)
|
|
1005
|
-
});
|
|
1006
|
-
if (!res.ok)
|
|
1007
|
-
return [];
|
|
1008
|
-
const data = await res.json();
|
|
1009
|
-
if (Array.isArray(data.data)) {
|
|
983
|
+
const data = await fetchDiscoveryJson(`${host}/models`, { Authorization: `Bearer ${apiKey}` }, true);
|
|
984
|
+
if (Array.isArray(data?.data)) {
|
|
1010
985
|
return data.data.map((m) => m.id || '').filter((id) => /^(qwen)/i.test(id)).sort();
|
|
1011
986
|
}
|
|
1012
987
|
}
|
|
@@ -1024,14 +999,8 @@ export async function fetchLiveModels(provider, config = {}) {
|
|
|
1024
999
|
const headers = {};
|
|
1025
1000
|
if (apiKey)
|
|
1026
1001
|
headers['Authorization'] = `Bearer ${apiKey}`;
|
|
1027
|
-
const
|
|
1028
|
-
|
|
1029
|
-
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)
|
|
1030
|
-
});
|
|
1031
|
-
if (!res.ok)
|
|
1032
|
-
return [];
|
|
1033
|
-
const data = await res.json();
|
|
1034
|
-
if (Array.isArray(data.data)) {
|
|
1002
|
+
const data = await fetchDiscoveryJson(`${host}/models`, headers, Boolean(apiKey));
|
|
1003
|
+
if (Array.isArray(data?.data)) {
|
|
1035
1004
|
return data.data.map((m) => m.id || '').filter(Boolean).sort();
|
|
1036
1005
|
}
|
|
1037
1006
|
}
|
package/src/dynamicCatalogue.ts
CHANGED
|
@@ -17,6 +17,7 @@ import { execFile } from 'node:child_process';
|
|
|
17
17
|
import { promisify } from 'node:util';
|
|
18
18
|
import { causyneHome } from './utils/paths.js';
|
|
19
19
|
import { MODEL_CATALOGUE, PEER_MODEL_CATALOGUE, DEFAULT_MODEL_BY_PROVIDER } from './modelCatalogue.js';
|
|
20
|
+
import { validateProviderEndpointUrl, readBoundedResponseText } from './providers/byokHttp.js';
|
|
20
21
|
import {
|
|
21
22
|
BASELINE_ANTIGRAVITY_MODELS,
|
|
22
23
|
ANTIGRAVITY_MODELS,
|
|
@@ -953,15 +954,34 @@ export async function fetchLiveModels(
|
|
|
953
954
|
const peer = peerIdFromProviderKey(norm);
|
|
954
955
|
if (peer) return discoverPeerModels(peer);
|
|
955
956
|
|
|
957
|
+
const MAX_DISCOVERY_BYTES = 4 * 1024 * 1024;
|
|
958
|
+
const fetchDiscoveryJson = async <T>(
|
|
959
|
+
rawUrl: string,
|
|
960
|
+
headers: Record<string, string> = {},
|
|
961
|
+
hasApiKey = false
|
|
962
|
+
): Promise<T | null> => {
|
|
963
|
+
const safeUrl = validateProviderEndpointUrl(rawUrl, {
|
|
964
|
+
hasApiKey,
|
|
965
|
+
providerLabel: norm
|
|
966
|
+
});
|
|
967
|
+
const res = await fetch(safeUrl, {
|
|
968
|
+
headers,
|
|
969
|
+
redirect: 'error',
|
|
970
|
+
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)
|
|
971
|
+
});
|
|
972
|
+
if (!res.ok) return null;
|
|
973
|
+
if (!res.body && typeof res.text !== 'function' && typeof res.json === 'function') {
|
|
974
|
+
return (await res.json()) as T;
|
|
975
|
+
}
|
|
976
|
+
const text = await readBoundedResponseText(res, MAX_DISCOVERY_BYTES, { truncate: false, label: norm });
|
|
977
|
+
return JSON.parse(text) as T;
|
|
978
|
+
};
|
|
979
|
+
|
|
956
980
|
try {
|
|
957
981
|
if (norm === 'ollama') {
|
|
958
982
|
const host = (baseUrl || 'http://127.0.0.1:11434').replace(/\/+$/, '');
|
|
959
|
-
const
|
|
960
|
-
|
|
961
|
-
});
|
|
962
|
-
if (!res.ok) return [];
|
|
963
|
-
const data = await res.json() as { models?: Array<{ name?: string }> };
|
|
964
|
-
if (Array.isArray(data.models)) {
|
|
983
|
+
const data = await fetchDiscoveryJson<{ models?: Array<{ name?: string }> }>(`${host}/api/tags`, {}, false);
|
|
984
|
+
if (Array.isArray(data?.models)) {
|
|
965
985
|
return data.models
|
|
966
986
|
.map((m) => (m.name || '').replace(/:latest$/, ''))
|
|
967
987
|
.filter(Boolean);
|
|
@@ -971,13 +991,12 @@ export async function fetchLiveModels(
|
|
|
971
991
|
if (norm === 'openai') {
|
|
972
992
|
if (!apiKey) return [];
|
|
973
993
|
const host = (baseUrl || 'https://api.openai.com/v1').replace(/\/+$/, '');
|
|
974
|
-
const
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
if (Array.isArray(data.data)) {
|
|
994
|
+
const data = await fetchDiscoveryJson<{ data?: Array<{ id?: string }> }>(
|
|
995
|
+
`${host}/models`,
|
|
996
|
+
{ Authorization: `Bearer ${apiKey}` },
|
|
997
|
+
true
|
|
998
|
+
);
|
|
999
|
+
if (Array.isArray(data?.data)) {
|
|
981
1000
|
return data.data
|
|
982
1001
|
.map((m) => m.id || '')
|
|
983
1002
|
.filter((id) => /^(gpt|o1|o3|chatgpt)/i.test(id))
|
|
@@ -987,12 +1006,13 @@ export async function fetchLiveModels(
|
|
|
987
1006
|
|
|
988
1007
|
if (norm === 'gemini') {
|
|
989
1008
|
if (!apiKey) return [];
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
1009
|
+
// Send API key in x-goog-api-key header rather than query string (CWE-598).
|
|
1010
|
+
const data = await fetchDiscoveryJson<{ models?: Array<{ name?: string; supportedGenerationMethods?: string[] }> }>(
|
|
1011
|
+
'https://generativelanguage.googleapis.com/v1beta/models',
|
|
1012
|
+
{ 'x-goog-api-key': apiKey },
|
|
1013
|
+
true
|
|
1014
|
+
);
|
|
1015
|
+
if (Array.isArray(data?.models)) {
|
|
996
1016
|
return data.models
|
|
997
1017
|
.filter((m) => m.supportedGenerationMethods?.includes('generateContent'))
|
|
998
1018
|
.map((m) => (m.name || '').replace(/^models\//, ''))
|
|
@@ -1003,16 +1023,15 @@ export async function fetchLiveModels(
|
|
|
1003
1023
|
|
|
1004
1024
|
if (norm === 'anthropic') {
|
|
1005
1025
|
if (!apiKey) return [];
|
|
1006
|
-
const
|
|
1007
|
-
|
|
1026
|
+
const data = await fetchDiscoveryJson<{ data?: Array<{ id?: string }> }>(
|
|
1027
|
+
'https://api.anthropic.com/v1/models',
|
|
1028
|
+
{
|
|
1008
1029
|
'x-api-key': apiKey,
|
|
1009
1030
|
'anthropic-version': '2023-06-01'
|
|
1010
1031
|
},
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
if (
|
|
1014
|
-
const data = await res.json() as { data?: Array<{ id?: string }> };
|
|
1015
|
-
if (Array.isArray(data.data)) {
|
|
1032
|
+
true
|
|
1033
|
+
);
|
|
1034
|
+
if (Array.isArray(data?.data)) {
|
|
1016
1035
|
return data.data
|
|
1017
1036
|
.map((m) => m.id || '')
|
|
1018
1037
|
.filter(Boolean)
|
|
@@ -1022,13 +1041,12 @@ export async function fetchLiveModels(
|
|
|
1022
1041
|
|
|
1023
1042
|
if (norm === 'deepseek') {
|
|
1024
1043
|
if (!apiKey) return [];
|
|
1025
|
-
const
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
if (Array.isArray(data.data)) {
|
|
1044
|
+
const data = await fetchDiscoveryJson<{ data?: Array<{ id?: string }> }>(
|
|
1045
|
+
'https://api.deepseek.com/models',
|
|
1046
|
+
{ Authorization: `Bearer ${apiKey}` },
|
|
1047
|
+
true
|
|
1048
|
+
);
|
|
1049
|
+
if (Array.isArray(data?.data)) {
|
|
1032
1050
|
return data.data.map((m) => m.id || '').filter(Boolean).sort();
|
|
1033
1051
|
}
|
|
1034
1052
|
}
|
|
@@ -1036,13 +1054,12 @@ export async function fetchLiveModels(
|
|
|
1036
1054
|
if (norm === 'xai') {
|
|
1037
1055
|
if (!apiKey) return [];
|
|
1038
1056
|
const host = (baseUrl || 'https://api.x.ai/v1').replace(/\/+$/, '');
|
|
1039
|
-
const
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
if (Array.isArray(data.data)) {
|
|
1057
|
+
const data = await fetchDiscoveryJson<{ data?: Array<{ id?: string }> }>(
|
|
1058
|
+
`${host}/models`,
|
|
1059
|
+
{ Authorization: `Bearer ${apiKey}` },
|
|
1060
|
+
true
|
|
1061
|
+
);
|
|
1062
|
+
if (Array.isArray(data?.data)) {
|
|
1046
1063
|
return data.data.map((m) => m.id || '').filter((id) => /^(grok)/i.test(id)).sort();
|
|
1047
1064
|
}
|
|
1048
1065
|
}
|
|
@@ -1050,13 +1067,12 @@ export async function fetchLiveModels(
|
|
|
1050
1067
|
if (norm === 'moonshot') {
|
|
1051
1068
|
if (!apiKey) return [];
|
|
1052
1069
|
const host = (baseUrl || 'https://api.moonshot.cn/v1').replace(/\/+$/, '');
|
|
1053
|
-
const
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
if (Array.isArray(data.data)) {
|
|
1070
|
+
const data = await fetchDiscoveryJson<{ data?: Array<{ id?: string }> }>(
|
|
1071
|
+
`${host}/models`,
|
|
1072
|
+
{ Authorization: `Bearer ${apiKey}` },
|
|
1073
|
+
true
|
|
1074
|
+
);
|
|
1075
|
+
if (Array.isArray(data?.data)) {
|
|
1060
1076
|
return data.data.map((m) => m.id || '').filter((id) => /^(kimi|moonshot)/i.test(id)).sort();
|
|
1061
1077
|
}
|
|
1062
1078
|
}
|
|
@@ -1064,13 +1080,12 @@ export async function fetchLiveModels(
|
|
|
1064
1080
|
if (norm === 'dashscope-byok' || norm === 'qwen') {
|
|
1065
1081
|
if (!apiKey) return [];
|
|
1066
1082
|
const host = (baseUrl || 'https://dashscope.aliyuncs.com/compatible-mode/v1').replace(/\/+$/, '');
|
|
1067
|
-
const
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
if (Array.isArray(data.data)) {
|
|
1083
|
+
const data = await fetchDiscoveryJson<{ data?: Array<{ id?: string }> }>(
|
|
1084
|
+
`${host}/models`,
|
|
1085
|
+
{ Authorization: `Bearer ${apiKey}` },
|
|
1086
|
+
true
|
|
1087
|
+
);
|
|
1088
|
+
if (Array.isArray(data?.data)) {
|
|
1074
1089
|
return data.data.map((m) => m.id || '').filter((id) => /^(qwen)/i.test(id)).sort();
|
|
1075
1090
|
}
|
|
1076
1091
|
}
|
|
@@ -1088,13 +1103,12 @@ export async function fetchLiveModels(
|
|
|
1088
1103
|
const host = baseUrl.replace(/\/+$/, '');
|
|
1089
1104
|
const headers: Record<string, string> = {};
|
|
1090
1105
|
if (apiKey) headers['Authorization'] = `Bearer ${apiKey}`;
|
|
1091
|
-
const
|
|
1106
|
+
const data = await fetchDiscoveryJson<{ data?: Array<{ id?: string }> }>(
|
|
1107
|
+
`${host}/models`,
|
|
1092
1108
|
headers,
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
if (
|
|
1096
|
-
const data = await res.json() as { data?: Array<{ id?: string }> };
|
|
1097
|
-
if (Array.isArray(data.data)) {
|
|
1109
|
+
Boolean(apiKey)
|
|
1110
|
+
);
|
|
1111
|
+
if (Array.isArray(data?.data)) {
|
|
1098
1112
|
return data.data.map((m) => m.id || '').filter(Boolean).sort();
|
|
1099
1113
|
}
|
|
1100
1114
|
}
|
package/src/engines/design.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import os from 'node:os';
|
|
1
2
|
import path from 'node:path';
|
|
2
3
|
// Multi-page layout, vector illustration, and publication engine for Causyne Agent.
|
|
3
4
|
// Headless document composer, IDML/ePub/PDF/SVG/PNG renderer, and batch pipeline.
|
|
@@ -56,7 +57,7 @@ export const designEngine = {
|
|
|
56
57
|
case 'inspect':
|
|
57
58
|
case 'probe': {
|
|
58
59
|
const file = request.action === 'inspect' ? requireProject(context, 'inspect') : positional(request.query ?? '');
|
|
59
|
-
args = ['run', '--in', file, '--export',
|
|
60
|
+
args = ['run', '--in', file, '--export', os.devNull];
|
|
60
61
|
break;
|
|
61
62
|
}
|
|
62
63
|
case 'execute':
|