@causyne/agent 1.20.117 → 1.20.120
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +7 -2
- package/src/agentLoop.js +29 -12
- package/src/agentLoop.ts +29 -16
- package/src/browser/causyneBrowser.js +231 -136
- package/src/browser/causyneBrowser.ts +229 -140
- package/src/browser/searchProviders.js +41 -30
- package/src/browser/searchProviders.ts +24 -14
- package/src/browser/workspacePathSafety.js +50 -0
- package/src/browser/workspacePathSafety.ts +50 -0
- package/src/browser/workspacePreview.js +27 -4
- package/src/browser/workspacePreview.ts +28 -4
- package/src/cliMode.js +20 -4
- package/src/commands.js +12 -14
- package/src/creative/liveBridge.js +34 -1
- package/src/creative/liveBridge.ts +28 -1
- package/src/observer/evidence.js +23 -0
- package/src/observer/evidence.ts +21 -0
- package/src/plugins/pluginManager.js +74 -0
- package/src/providers/anthropic.js +33 -17
- package/src/providers/base.js +14 -0
- package/src/providers/dashscope-byok.js +13 -7
- package/src/providers/deepseek.js +13 -18
- package/src/providers/gemini.js +33 -25
- package/src/providers/moonshot.js +13 -12
- package/src/providers/ollama.js +21 -21
- package/src/providers/openai-compatible.js +12 -19
- package/src/providers/openrouter.js +20 -90
- package/src/providers/openrouter.ts +31 -94
- package/src/providers/qwen-byok.js +13 -7
- package/src/providers/toolContracts.js +9 -3
- package/src/providers/toolContracts.ts +9 -3
- package/src/providers/wireNormalizer.js +238 -0
- package/src/providers/wireNormalizer.ts +279 -0
- package/src/providers/xai.js +13 -12
- package/src/reporting.js +12 -4
- package/src/skillsManager.js +3 -2
- package/src/skillsManager.ts +3 -2
- package/src/tools/browserAutomator.js +13 -1
- package/src/tools/browserAutomator.ts +13 -0
- package/src/tools/creativeApps.js +2 -1
- package/src/tools/creativeApps.ts +2 -1
- package/src/tools/gameAssetFetcher.js +130 -26
- package/src/tools/gameAssetHarvester.js +80 -58
- package/src/tools/nativeEngine.js +1 -1
- package/src/tools/nativeEngine.ts +1 -1
- package/src/tools/pluginManager.js +17 -2
- package/src/tools/registry.js +13 -0
- package/src/tools/toolScanner.js +596 -140
- package/src/tools/toolScanner.ts +665 -147
- package/src/tools/toolSelfRepair.js +243 -114
- package/src/tools/toolSelfRepair.ts +262 -111
- package/src/tools/webFetch.js +161 -24
- package/src/tools/webFetch.ts +157 -22
- package/src/tools/webSearch.js +33 -4
- package/src/tools/webSearch.ts +27 -4
- package/src/tui/composerControls.js +16 -3
- package/src/tui/composerControls.ts +14 -3
- package/src/tui/prompt.js +122 -16
- package/src/tui/sessionPicker.js +132 -35
- package/src/tui/sessionPicker.ts +153 -32
- package/src/tui/sessionPickerView.js +277 -34
- package/src/tui/sessionPickerView.ts +328 -34
- package/src/tui/statusLine.js +3 -0
- package/src/tui/statusLine.ts +5 -0
- package/src/tui/usageCard.js +119 -47
- package/src/tui/usageCard.ts +133 -49
- package/src/tui/workspaceIdentity.js +133 -0
- package/src/tui/workspaceIdentity.ts +146 -0
- package/src/tui/workspaceSwitch.js +2 -0
- package/src/tui/workspaceSwitch.ts +1 -0
- package/src/verification/boundedExplorer.js +119 -0
- package/src/verification/cliProbe.js +116 -0
- package/src/verification/featureMap.js +78 -0
- package/src/verification/interactivePty.js +188 -0
- package/src/verification/propertyProbe.js +121 -0
- package/src/verification/ptyProbe.js +125 -0
- package/src/verification/skillCatalog.d.ts +1 -0
- package/src/verification/skillCatalog.js +60 -0
- package/src/verification/statechart.js +143 -0
- package/src/verification/uiRuntime.js +57 -0
- package/src/verificationPlan.js +1 -1
- package/src/verificationPlan.ts +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
BrowserBatchError,
|
|
2
3
|
BrowserCapabilityError,
|
|
3
4
|
causyneBrowser,
|
|
4
5
|
getSupportedSearchMacros,
|
|
@@ -130,6 +131,18 @@ export const browserAct = {
|
|
|
130
131
|
const results = await causyneBrowser({ workspace }).run(actions, { workspace });
|
|
131
132
|
return { success: true, output: JSON.stringify(results, null, 2), data: results };
|
|
132
133
|
} catch (error) {
|
|
134
|
+
if (error instanceof BrowserBatchError) {
|
|
135
|
+
return {
|
|
136
|
+
success: false,
|
|
137
|
+
error: error.message,
|
|
138
|
+
code: 'BROWSER_BATCH_PARTIAL_FAILURE',
|
|
139
|
+
failedActionIndex: error.failedActionIndex,
|
|
140
|
+
failedActionType: error.failedActionType,
|
|
141
|
+
completedActions: error.completedActions,
|
|
142
|
+
output: JSON.stringify(error.completedActions, null, 2),
|
|
143
|
+
retryGuidance: 'Do not repeat the completed browser actions. Inspect current page state and resume from the failed operation.'
|
|
144
|
+
};
|
|
145
|
+
}
|
|
133
146
|
if (error instanceof BrowserCapabilityError) {
|
|
134
147
|
return { success: false, error: error.message, requiresConsent: error.requiresConsent };
|
|
135
148
|
}
|
|
@@ -158,7 +158,8 @@ export const creativeApps = {
|
|
|
158
158
|
description: 'Unreal UProperty name for remote_control property read/write.'
|
|
159
159
|
},
|
|
160
160
|
propertyValue: {
|
|
161
|
-
|
|
161
|
+
type: ['string', 'number', 'boolean', 'object', 'array'],
|
|
162
|
+
description: 'Value to write for Unreal remote_control property access (string, number, boolean, object, or array; JSON-encoded strings like "42", "true", "{\\"X\\":1}", or "[1,2]" are decoded to native types, or wrap in JSON quotes like "\\"42\\"" for a literal numeric string).'
|
|
162
163
|
},
|
|
163
164
|
parameters: {
|
|
164
165
|
type: 'object',
|
|
@@ -165,7 +165,8 @@ export const creativeApps = {
|
|
|
165
165
|
description: 'Unreal UProperty name for remote_control property read/write.'
|
|
166
166
|
},
|
|
167
167
|
propertyValue: {
|
|
168
|
-
|
|
168
|
+
type: ['string', 'number', 'boolean', 'object', 'array'],
|
|
169
|
+
description: 'Value to write for Unreal remote_control property access (string, number, boolean, object, or array; JSON-encoded strings like "42", "true", "{\\"X\\":1}", or "[1,2]" are decoded to native types, or wrap in JSON quotes like "\\"42\\"" for a literal numeric string).'
|
|
169
170
|
},
|
|
170
171
|
parameters: {
|
|
171
172
|
type: 'object',
|
|
@@ -1,15 +1,123 @@
|
|
|
1
1
|
import fs from 'fs/promises';
|
|
2
2
|
import fsSync from 'fs';
|
|
3
3
|
import path from 'path';
|
|
4
|
+
import { randomUUID } from 'node:crypto';
|
|
5
|
+
import { ensureSafeWorkspaceOutputPath } from '../browser/workspacePathSafety.js';
|
|
6
|
+
import { assertPublicWebUrl } from '../browser/urlPolicy.js';
|
|
4
7
|
|
|
5
8
|
const MAX_ASSET_BYTES = 100 * 1024 * 1024;
|
|
6
9
|
|
|
7
|
-
function
|
|
8
|
-
const
|
|
9
|
-
if (
|
|
10
|
-
|
|
10
|
+
async function prepareAssetOutput(filePath, sandbox) {
|
|
11
|
+
const scopedWorkspace = sandbox?.workspaceRoot ?? sandbox?.workspacePaths?.[0] ?? (sandbox ? process.cwd() : null);
|
|
12
|
+
if (scopedWorkspace) {
|
|
13
|
+
await ensureSafeWorkspaceOutputPath(scopedWorkspace, filePath);
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
|
17
|
+
const existing = await fs.lstat(filePath).catch(error => {
|
|
18
|
+
if (error.code === 'ENOENT') return null;
|
|
19
|
+
throw error;
|
|
20
|
+
});
|
|
21
|
+
if (existing?.isSymbolicLink() || (existing && !existing.isFile())) {
|
|
22
|
+
throw new Error('Output target cannot be a symlink or directory');
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async function writeAssetAtomically(filePath, bytes) {
|
|
27
|
+
const temporary = `${filePath}.part-${randomUUID()}`;
|
|
28
|
+
try {
|
|
29
|
+
await fs.writeFile(temporary, bytes, { mode: 0o600 });
|
|
30
|
+
await fs.rename(temporary, filePath);
|
|
31
|
+
} finally {
|
|
32
|
+
await fs.unlink(temporary).catch(() => {});
|
|
11
33
|
}
|
|
12
|
-
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export async function streamAssetResponseToFile(response, filePath, maxBytes = MAX_ASSET_BYTES, sandbox) {
|
|
37
|
+
if (!response.body) throw new Error('Downloaded asset had no response body');
|
|
38
|
+
await prepareAssetOutput(filePath, sandbox);
|
|
39
|
+
const temporary = `${filePath}.part-${randomUUID()}`;
|
|
40
|
+
const reader = response.body.getReader();
|
|
41
|
+
let handle;
|
|
42
|
+
let received = 0;
|
|
43
|
+
const validateZip = filePath.toLowerCase().endsWith('.zip');
|
|
44
|
+
const signature = Buffer.alloc(4);
|
|
45
|
+
let signatureSize = 0;
|
|
46
|
+
try {
|
|
47
|
+
handle = await fs.open(temporary, 'wx', 0o600);
|
|
48
|
+
while (true) {
|
|
49
|
+
const { done, value } = await reader.read();
|
|
50
|
+
if (done) break;
|
|
51
|
+
if (!value || value.byteLength === 0) continue;
|
|
52
|
+
if (received + value.byteLength > maxBytes) {
|
|
53
|
+
throw new Error(`Asset exceeds the ${maxBytes / 1024 / 1024} MB download limit.`);
|
|
54
|
+
}
|
|
55
|
+
if (validateZip && signatureSize < 4) {
|
|
56
|
+
const length = Math.min(4 - signatureSize, value.byteLength);
|
|
57
|
+
signature.set(value.subarray(0, length), signatureSize);
|
|
58
|
+
signatureSize += length;
|
|
59
|
+
if (signatureSize === 4 && !(signature[0] === 0x50 && signature[1] === 0x4b &&
|
|
60
|
+
((signature[2] === 3 && signature[3] === 4) ||
|
|
61
|
+
(signature[2] === 5 && signature[3] === 6) ||
|
|
62
|
+
(signature[2] === 7 && signature[3] === 8)))) {
|
|
63
|
+
throw new Error('Downloaded ZIP archive has an invalid file signature');
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
let written = 0;
|
|
67
|
+
while (written < value.byteLength) {
|
|
68
|
+
const result = await handle.write(value, written, value.byteLength - written, null);
|
|
69
|
+
if (result.bytesWritten <= 0) throw new Error('Asset download made no write progress');
|
|
70
|
+
written += result.bytesWritten;
|
|
71
|
+
}
|
|
72
|
+
received += value.byteLength;
|
|
73
|
+
}
|
|
74
|
+
if (validateZip && signatureSize < 4) throw new Error('Downloaded ZIP archive is incomplete');
|
|
75
|
+
await handle.close();
|
|
76
|
+
handle = undefined;
|
|
77
|
+
await fs.rename(temporary, filePath);
|
|
78
|
+
return received;
|
|
79
|
+
} catch (error) {
|
|
80
|
+
await reader.cancel().catch(() => {});
|
|
81
|
+
throw error;
|
|
82
|
+
} finally {
|
|
83
|
+
reader.releaseLock();
|
|
84
|
+
await handle?.close().catch(() => {});
|
|
85
|
+
await fs.unlink(temporary).catch(() => {});
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
async function fetchCuratedAssetWithSafeRedirects(url) {
|
|
90
|
+
const signal = AbortSignal.timeout(30_000);
|
|
91
|
+
let current = new URL(url);
|
|
92
|
+
for (let redirects = 0; redirects <= 5; redirects++) {
|
|
93
|
+
const response = await fetch(current, {
|
|
94
|
+
headers: { 'User-Agent': 'Causyne-Agent-Sovereign/1.3.1' },
|
|
95
|
+
redirect: 'manual',
|
|
96
|
+
signal
|
|
97
|
+
});
|
|
98
|
+
if (![301, 302, 303, 307, 308].includes(response.status)) return response;
|
|
99
|
+
const location = response.headers.get('location');
|
|
100
|
+
await response.body?.cancel().catch(() => {});
|
|
101
|
+
if (redirects === 5) throw new Error('Asset download exceeded five redirects');
|
|
102
|
+
if (!location) throw new Error(`Asset HTTP ${response.status} redirect has no Location header`);
|
|
103
|
+
const next = await assertPublicWebUrl(new URL(location, current).href);
|
|
104
|
+
if (current.protocol === 'https:' && next.protocol !== 'https:') {
|
|
105
|
+
throw new Error('Asset redirect cannot downgrade HTTPS to HTTP');
|
|
106
|
+
}
|
|
107
|
+
current = next;
|
|
108
|
+
}
|
|
109
|
+
throw new Error('Asset redirect handling failed');
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function isSafeOutputFilename(value) {
|
|
113
|
+
return typeof value === 'string' && value.length > 0 && value.length <= 255
|
|
114
|
+
&& value !== '.' && value !== '..' && !/[\\\/:*?"<>|\x00-\x1f]/.test(value)
|
|
115
|
+
&& !/[. ]$/.test(value)
|
|
116
|
+
&& !/^(?:con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\.|$)/i.test(value);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function getWorkspaceTempDir() {
|
|
120
|
+
return path.join(process.cwd(), '.tmp_causyne_3d', 'assets');
|
|
13
121
|
}
|
|
14
122
|
|
|
15
123
|
// ── Curated CC0 Open-Source Game Asset Catalog ──
|
|
@@ -246,17 +354,14 @@ export const gameAssetFetcher = {
|
|
|
246
354
|
async execute(args, sandbox) {
|
|
247
355
|
try {
|
|
248
356
|
const { action, category = 'all', query = '', url, preset, outputFilename, outputDir } = args;
|
|
249
|
-
const
|
|
357
|
+
const workspace = sandbox?.workspaceRoot ?? sandbox?.workspacePaths?.[0];
|
|
358
|
+
const targetDir = outputDir || (workspace ? path.join(path.resolve(workspace), '.tmp_causyne_3d', 'assets') : getWorkspaceTempDir());
|
|
250
359
|
|
|
251
360
|
// Security Check: Ensure output path is allowed inside workspace boundary
|
|
252
361
|
if (sandbox && sandbox.isPathAllowed && !sandbox.isPathAllowed(path.resolve(targetDir))) {
|
|
253
362
|
return { success: false, error: `Path outside allowed workspace boundary: ${targetDir}` };
|
|
254
363
|
}
|
|
255
364
|
|
|
256
|
-
if (!fsSync.existsSync(targetDir)) {
|
|
257
|
-
await fs.mkdir(targetDir, { recursive: true });
|
|
258
|
-
}
|
|
259
|
-
|
|
260
365
|
if (action === 'search_cc0') {
|
|
261
366
|
let results = [];
|
|
262
367
|
const categories = category === 'all' ? Object.keys(CC0_CATALOG) : [category];
|
|
@@ -289,13 +394,17 @@ export const gameAssetFetcher = {
|
|
|
289
394
|
}
|
|
290
395
|
const requestedName = outputFilename || `sfx_${preset}.wav`;
|
|
291
396
|
const filename = path.basename(requestedName);
|
|
292
|
-
if (filename !== requestedName || filename
|
|
397
|
+
if (filename !== requestedName || !isSafeOutputFilename(filename)) {
|
|
293
398
|
return { success: false, error: 'outputFilename must be a plain file name without directory components.' };
|
|
294
399
|
}
|
|
400
|
+
if (path.extname(filename).toLowerCase() !== '.wav') {
|
|
401
|
+
return { success: false, error: 'Synthesized PCM audio must use a .wav output filename.' };
|
|
402
|
+
}
|
|
295
403
|
const filePath = path.join(targetDir, filename);
|
|
296
404
|
|
|
297
405
|
const wavBuffer = synthesizeWavBuffer(preset);
|
|
298
|
-
await
|
|
406
|
+
await prepareAssetOutput(filePath, sandbox);
|
|
407
|
+
await writeAssetAtomically(filePath, wavBuffer);
|
|
299
408
|
|
|
300
409
|
return {
|
|
301
410
|
success: true,
|
|
@@ -323,30 +432,25 @@ export const gameAssetFetcher = {
|
|
|
323
432
|
if (filename !== requestedName || filename === '.' || filename === '..') {
|
|
324
433
|
return { success: false, error: 'outputFilename must be a plain file name without directory components.' };
|
|
325
434
|
}
|
|
435
|
+
const sourceExtension = path.extname(new URL(url).pathname).toLowerCase();
|
|
436
|
+
if (path.extname(filename).toLowerCase() !== sourceExtension) {
|
|
437
|
+
return { success: false, error: 'Downloaded asset filename must preserve its source file extension.' };
|
|
438
|
+
}
|
|
326
439
|
const filePath = path.join(targetDir, filename);
|
|
327
440
|
|
|
328
441
|
console.log(`[game_asset_fetch] Downloading CC0 asset from: ${url}`);
|
|
329
|
-
const response = await
|
|
442
|
+
const response = await fetchCuratedAssetWithSafeRedirects(url);
|
|
330
443
|
if (!response.ok) {
|
|
444
|
+
await response.body?.cancel().catch(() => {});
|
|
331
445
|
return { success: false, error: `Failed to fetch asset from URL (${response.status} ${response.statusText}): ${url}` };
|
|
332
446
|
}
|
|
333
447
|
|
|
334
448
|
const declaredSize = Number(response.headers.get('content-length') || 0);
|
|
335
449
|
if (declaredSize > MAX_ASSET_BYTES) {
|
|
450
|
+
await response.body?.cancel().catch(() => {});
|
|
336
451
|
return { success: false, error: `Asset exceeds the ${MAX_ASSET_BYTES / 1024 / 1024} MB download limit.` };
|
|
337
452
|
}
|
|
338
|
-
const
|
|
339
|
-
let received = 0;
|
|
340
|
-
for await (const chunk of response.body) {
|
|
341
|
-
received += chunk.length;
|
|
342
|
-
if (received > MAX_ASSET_BYTES) {
|
|
343
|
-
response.body.destroy();
|
|
344
|
-
return { success: false, error: `Asset exceeds the ${MAX_ASSET_BYTES / 1024 / 1024} MB download limit.` };
|
|
345
|
-
}
|
|
346
|
-
chunks.push(chunk);
|
|
347
|
-
}
|
|
348
|
-
const buffer = Buffer.concat(chunks);
|
|
349
|
-
await fs.writeFile(filePath, buffer);
|
|
453
|
+
const received = await streamAssetResponseToFile(response, filePath, MAX_ASSET_BYTES, sandbox);
|
|
350
454
|
|
|
351
455
|
return {
|
|
352
456
|
success: true,
|
|
@@ -354,7 +458,7 @@ export const gameAssetFetcher = {
|
|
|
354
458
|
action: 'download_asset',
|
|
355
459
|
url: url,
|
|
356
460
|
output_file: filePath,
|
|
357
|
-
size_bytes:
|
|
461
|
+
size_bytes: received,
|
|
358
462
|
extracted_folder: null,
|
|
359
463
|
ready_to_use: !filename.toLowerCase().endsWith('.zip'),
|
|
360
464
|
instructions: filename.toLowerCase().endsWith('.zip')
|
|
@@ -1,38 +1,37 @@
|
|
|
1
1
|
import fs from 'fs/promises';
|
|
2
2
|
import fsSync from 'fs';
|
|
3
3
|
import path from 'path';
|
|
4
|
-
import
|
|
5
|
-
import
|
|
4
|
+
import { randomUUID } from 'node:crypto';
|
|
5
|
+
import { webFetch } from './webFetch.js';
|
|
6
|
+
import { ensureSafeWorkspaceOutputPath } from '../browser/workspacePathSafety.js';
|
|
7
|
+
import { assertPublicWebUrl } from '../browser/urlPolicy.js';
|
|
8
|
+
|
|
9
|
+
// A public, bounded, workspace-scoped download with an explicitly reported procedural fallback.
|
|
10
|
+
async function downloadOrGenerateFallback(url, targetPath, fallbackType = 'obj', workspaceRoot = path.dirname(targetPath)) {
|
|
11
|
+
await ensureSafeWorkspaceOutputPath(workspaceRoot, targetPath);
|
|
12
|
+
const download = await webFetch.execute(
|
|
13
|
+
{ url, outputFile: path.relative(workspaceRoot, targetPath) },
|
|
14
|
+
{ workspaceRoot }
|
|
15
|
+
);
|
|
16
|
+
if (download.success) {
|
|
17
|
+
const stat = await fs.stat(targetPath);
|
|
18
|
+
return { success: true, source: 'downloaded', size: stat.size };
|
|
19
|
+
}
|
|
20
|
+
if (!['.obj', '.svg', '.png'].includes(path.extname(targetPath).toLowerCase())) {
|
|
21
|
+
return { success: false, source: 'download_failed', downloadError: String(download.error ?? 'Download unavailable') };
|
|
22
|
+
}
|
|
23
|
+
const fallback = await generateFallbackAsset(targetPath, fallbackType);
|
|
24
|
+
return { ...fallback, downloadError: String(download.error ?? 'Download unavailable') };
|
|
25
|
+
}
|
|
6
26
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
res.pipe(fileStream);
|
|
16
|
-
fileStream.on('finish', () => {
|
|
17
|
-
fileStream.close();
|
|
18
|
-
resolve({ success: true, source: 'downloaded', size: fsSync.statSync(targetPath).size });
|
|
19
|
-
});
|
|
20
|
-
} else {
|
|
21
|
-
generateFallbackAsset(targetPath, fallbackType).then(resFall => resolve(resFall));
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
req.on('error', () => {
|
|
25
|
-
generateFallbackAsset(targetPath, fallbackType).then(resFall => resolve(resFall));
|
|
26
|
-
});
|
|
27
|
-
req.on('timeout', () => {
|
|
28
|
-
req.destroy();
|
|
29
|
-
generateFallbackAsset(targetPath, fallbackType).then(resFall => resolve(resFall));
|
|
30
|
-
});
|
|
31
|
-
} catch (e) {
|
|
32
|
-
const resFall = await generateFallbackAsset(targetPath, fallbackType);
|
|
33
|
-
resolve(resFall);
|
|
34
|
-
}
|
|
35
|
-
});
|
|
27
|
+
async function writeFallbackAtomically(targetPath, payload, encoding) {
|
|
28
|
+
const temp = `${targetPath}.part-${randomUUID()}`;
|
|
29
|
+
try {
|
|
30
|
+
await fs.writeFile(temp, payload, encoding ? { encoding, mode: 0o600 } : { mode: 0o600 });
|
|
31
|
+
await fs.rename(temp, targetPath);
|
|
32
|
+
} finally {
|
|
33
|
+
await fs.unlink(temp).catch(() => {});
|
|
34
|
+
}
|
|
36
35
|
}
|
|
37
36
|
|
|
38
37
|
async function generateFallbackAsset(targetPath, fallbackType) {
|
|
@@ -55,17 +54,32 @@ f 7 8 2 1
|
|
|
55
54
|
f 2 8 6 4
|
|
56
55
|
f 7 1 3 5
|
|
57
56
|
`;
|
|
58
|
-
await
|
|
59
|
-
} else if (fallbackType === '
|
|
57
|
+
await writeFallbackAtomically(targetPath, objContent, 'utf8');
|
|
58
|
+
} else if (fallbackType === 'png') {
|
|
59
|
+
await writeFallbackAtomically(targetPath, Buffer.from('iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAA9ElEQVR42u2bwRGDMAwE4SZVkaLyTwH8UxR1kRJCLFmW8OrN+O7W9/HYrNt+nsvEo2XyAQAAAAAAAAAAAAAAwKzziBY83q+f3zz3T5ifNeIwdCX0KBhdAViCR4HoAsAzeG8QqhS+x/qqFL6HjqqF99ZTxfCeuqoa3ktflcN7+OAsUH33rX5owB123+KLBgDgJvVv9UcDAAAAAAAAAAAAwOWJvLRomX/90QAABNQsa/1pgAVAtha0+qEBI6hn2X2XBoyGYNVXBhMjdZXJzAg9ZTQVqaPM5iLW540Qr8SC/xma8p0gx2EAAAAAAAAAAAAAAADkmy/UVmFrjmXOcQAAAABJRU5ErkJggg==', 'base64'));
|
|
60
|
+
} else if (fallbackType === 'svg') {
|
|
60
61
|
// Generate SVG/dummy texture for 2D sprite
|
|
61
62
|
const svgContent = `<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64"><rect width="64" height="64" fill="#3a86ff"/><circle cx="32" cy="32" r="20" fill="#ff006e"/></svg>`;
|
|
62
|
-
await
|
|
63
|
+
await writeFallbackAtomically(targetPath, svgContent, 'utf8');
|
|
63
64
|
} else {
|
|
64
|
-
await
|
|
65
|
+
await writeFallbackAtomically(targetPath, `[Sovereign Asset Stub: ${path.basename(targetPath)}]`, 'utf8');
|
|
65
66
|
}
|
|
66
67
|
return { success: true, source: 'procedural_cc0_fallback', size: fsSync.statSync(targetPath).size };
|
|
67
68
|
}
|
|
68
69
|
|
|
70
|
+
export function summarizeHarvestResults(results) {
|
|
71
|
+
const downloadedCount = results.filter(item => item.status?.source === 'downloaded').length;
|
|
72
|
+
const fallbackCount = results.filter(item => item.status?.source === 'procedural_cc0_fallback').length;
|
|
73
|
+
const failedCount = results.length - downloadedCount - fallbackCount;
|
|
74
|
+
return {
|
|
75
|
+
status: failedCount ? 'STARTER_PACK_INCOMPLETE'
|
|
76
|
+
: fallbackCount ? 'STARTER_PACK_WITH_PROCEDURAL_FALLBACKS' : 'STARTER_PACK_DOWNLOADED',
|
|
77
|
+
downloaded_count: downloadedCount,
|
|
78
|
+
fallback_count: fallbackCount,
|
|
79
|
+
failed_count: failedCount
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
69
83
|
export const gameAssetHarvester = {
|
|
70
84
|
schema: {
|
|
71
85
|
name: 'game.asset_harvest',
|
|
@@ -84,7 +98,7 @@ export const gameAssetHarvester = {
|
|
|
84
98
|
},
|
|
85
99
|
category: {
|
|
86
100
|
type: 'string',
|
|
87
|
-
enum: ['3d_model', '2d_sprite', 'tileset', 'sfx', 'shader'],
|
|
101
|
+
enum: ['all', '3d_model', '2d_sprite', 'tileset', 'sfx', 'shader'],
|
|
88
102
|
description: 'Category of asset.'
|
|
89
103
|
},
|
|
90
104
|
packType: {
|
|
@@ -111,7 +125,7 @@ export const gameAssetHarvester = {
|
|
|
111
125
|
|
|
112
126
|
async execute(args) {
|
|
113
127
|
try {
|
|
114
|
-
const { action, query, category = '
|
|
128
|
+
const { action, query, category = 'all', packType = 'rpg_starter_pack', projectDir, assetUrl, targetSubdir = '3d/props' } = args;
|
|
115
129
|
|
|
116
130
|
const catalog = [
|
|
117
131
|
{ id: 'kenney_knight_3d', title: 'CC0 Medieval Knight 3D (.obj/.gltf)', category: '3d_model', url: 'https://kenney.nl/assets/obj/knight.obj', tags: ['knight', 'rpg', 'character', '3d'] },
|
|
@@ -121,8 +135,11 @@ export const gameAssetHarvester = {
|
|
|
121
135
|
];
|
|
122
136
|
|
|
123
137
|
if (action === 'search_assets') {
|
|
124
|
-
const q = (query || '').toLowerCase();
|
|
125
|
-
const matches = catalog.filter(item =>
|
|
138
|
+
const q = String(query || '').trim().toLowerCase();
|
|
139
|
+
const matches = catalog.filter(item =>
|
|
140
|
+
(category === 'all' || item.category === category) &&
|
|
141
|
+
(!q || item.tags.some(tag => tag.includes(q)) || item.title.toLowerCase().includes(q))
|
|
142
|
+
);
|
|
126
143
|
return {
|
|
127
144
|
success: true,
|
|
128
145
|
output: JSON.stringify({
|
|
@@ -139,19 +156,28 @@ export const gameAssetHarvester = {
|
|
|
139
156
|
if (!projectDir || !fsSync.existsSync(projectDir)) {
|
|
140
157
|
return { success: false, error: `Valid projectDir is required for asset download. Found: ${projectDir}` };
|
|
141
158
|
}
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
|
|
159
|
+
const assetsRoot = path.resolve(projectDir, 'assets');
|
|
160
|
+
const targetDir = path.resolve(assetsRoot, targetSubdir);
|
|
161
|
+
const relativeDir = path.relative(assetsRoot, targetDir);
|
|
162
|
+
if (relativeDir === '..' || relativeDir.startsWith(`..${path.sep}`) || path.isAbsolute(relativeDir)) {
|
|
163
|
+
return { success: false, error: 'targetSubdir must remain inside project assets/' };
|
|
164
|
+
}
|
|
145
165
|
const urlToFetch = assetUrl || catalog[0].url;
|
|
146
|
-
|
|
166
|
+
await assertPublicWebUrl(urlToFetch);
|
|
167
|
+
const rawName = path.basename(new URL(urlToFetch).pathname) || `asset_${Date.now()}.obj`;
|
|
168
|
+
const fileName = rawName.replace(/[<>:"\\/|?*\x00-\x1f]/g, '_');
|
|
147
169
|
const destFile = path.join(targetDir, fileName);
|
|
148
170
|
|
|
149
|
-
const resDownload = await downloadOrGenerateFallback(urlToFetch, destFile, fileName.endsWith('.
|
|
171
|
+
const resDownload = await downloadOrGenerateFallback(urlToFetch, destFile, fileName.endsWith('.png') ? 'png' : fileName.endsWith('.svg') ? 'svg' : 'obj', projectDir);
|
|
172
|
+
if (!resDownload.success) {
|
|
173
|
+
return { success: false, error: resDownload.downloadError ?? 'Asset download failed', url: urlToFetch };
|
|
174
|
+
}
|
|
150
175
|
|
|
151
176
|
return {
|
|
152
177
|
success: true,
|
|
153
178
|
output: JSON.stringify({
|
|
154
|
-
status: '
|
|
179
|
+
status: resDownload.source === 'downloaded' ? 'ASSET_DOWNLOADED' : 'PROCEDURAL_FALLBACK_GENERATED',
|
|
180
|
+
downloaded: resDownload.source === 'downloaded',
|
|
155
181
|
url: urlToFetch,
|
|
156
182
|
destination: destFile,
|
|
157
183
|
download_result: resDownload
|
|
@@ -167,34 +193,30 @@ export const gameAssetHarvester = {
|
|
|
167
193
|
const assetsDir = path.join(projectDir, 'assets');
|
|
168
194
|
const results = [];
|
|
169
195
|
|
|
196
|
+
if (!['rpg_starter_pack', 'dungeon_pack', 'cyberpunk_racer_pack'].includes(packType)) {
|
|
197
|
+
return { success: false, error: 'Unknown starter pack type' };
|
|
198
|
+
}
|
|
170
199
|
if (packType === 'rpg_starter_pack' || packType === 'dungeon_pack') {
|
|
171
200
|
const charDir = path.join(assetsDir, '3d/characters');
|
|
172
201
|
const weaponDir = path.join(assetsDir, '3d/weapons');
|
|
173
202
|
const tileDir = path.join(assetsDir, '2d/tiles');
|
|
174
|
-
await
|
|
175
|
-
await
|
|
176
|
-
await
|
|
177
|
-
|
|
178
|
-
const r1 = await downloadOrGenerateFallback('https://kenney.nl/assets/obj/knight.obj', path.join(charDir, 'knight.obj'), 'obj');
|
|
179
|
-
const r2 = await downloadOrGenerateFallback('https://kenney.nl/assets/obj/sword.obj', path.join(weaponDir, 'sword.obj'), 'obj');
|
|
180
|
-
const r3 = await downloadOrGenerateFallback('https://kenney.nl/assets/2d/dungeon.svg', path.join(tileDir, 'dungeon_tiles.svg'), 'svg');
|
|
203
|
+
const r1 = await downloadOrGenerateFallback('https://kenney.nl/assets/obj/knight.obj', path.join(charDir, 'knight.obj'), 'obj', projectDir);
|
|
204
|
+
const r2 = await downloadOrGenerateFallback('https://kenney.nl/assets/obj/sword.obj', path.join(weaponDir, 'sword.obj'), 'obj', projectDir);
|
|
205
|
+
const r3 = await downloadOrGenerateFallback('https://kenney.nl/assets/2d/dungeon.svg', path.join(tileDir, 'dungeon_tiles.svg'), 'svg', projectDir);
|
|
181
206
|
results.push({ item: 'knight.obj', status: r1 }, { item: 'sword.obj', status: r2 }, { item: 'dungeon_tiles.svg', status: r3 });
|
|
182
207
|
} else {
|
|
183
208
|
// Cyberpunk racer
|
|
184
209
|
const carDir = path.join(assetsDir, '3d/vehicles');
|
|
185
210
|
const trackDir = path.join(assetsDir, '3d/environment');
|
|
186
|
-
await
|
|
187
|
-
await
|
|
188
|
-
|
|
189
|
-
const r1 = await downloadOrGenerateFallback('https://kenney.nl/assets/obj/race_car.obj', path.join(carDir, 'cyberpunk_racer.obj'), 'obj');
|
|
190
|
-
const r2 = await downloadOrGenerateFallback('https://kenney.nl/assets/obj/highway_barrier.obj', path.join(trackDir, 'barrier.obj'), 'obj');
|
|
211
|
+
const r1 = await downloadOrGenerateFallback('https://kenney.nl/assets/obj/race_car.obj', path.join(carDir, 'cyberpunk_racer.obj'), 'obj', projectDir);
|
|
212
|
+
const r2 = await downloadOrGenerateFallback('https://kenney.nl/assets/obj/highway_barrier.obj', path.join(trackDir, 'barrier.obj'), 'obj', projectDir);
|
|
191
213
|
results.push({ item: 'cyberpunk_racer.obj', status: r1 }, { item: 'barrier.obj', status: r2 });
|
|
192
214
|
}
|
|
193
215
|
|
|
194
216
|
return {
|
|
195
217
|
success: true,
|
|
196
218
|
output: JSON.stringify({
|
|
197
|
-
|
|
219
|
+
...summarizeHarvestResults(results),
|
|
198
220
|
pack_type: packType,
|
|
199
221
|
project_dir: projectDir,
|
|
200
222
|
assets_installed: results
|
|
@@ -348,7 +348,7 @@ export const nativeEngineTool = {
|
|
|
348
348
|
parameters: {
|
|
349
349
|
type: 'object',
|
|
350
350
|
properties: {
|
|
351
|
-
engine: { type: 'string',
|
|
351
|
+
engine: { type: 'string', description: 'Engine id, default film. status lists installed engines.' },
|
|
352
352
|
action: { type: 'string', enum: [...ACTIONS] },
|
|
353
353
|
command: { type: 'string', description: 'Command id for execute or describe.' },
|
|
354
354
|
params: { type: 'object', description: 'Command parameters for execute.' },
|
|
@@ -324,7 +324,7 @@ export const nativeEngineTool = {
|
|
|
324
324
|
parameters: {
|
|
325
325
|
type: 'object',
|
|
326
326
|
properties: {
|
|
327
|
-
engine: { type: 'string',
|
|
327
|
+
engine: { type: 'string', description: 'Engine id, default film. status lists installed engines.' },
|
|
328
328
|
action: { type: 'string', enum: [...ACTIONS] },
|
|
329
329
|
command: { type: 'string', description: 'Command id for execute or describe.' },
|
|
330
330
|
params: { type: 'object', description: 'Command parameters for execute.' },
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createPlugin,
|
|
3
|
+
createSkillPlugin,
|
|
3
4
|
disablePlugin,
|
|
4
5
|
enablePlugin,
|
|
5
6
|
listPlugins
|
|
@@ -8,17 +9,22 @@ import {
|
|
|
8
9
|
export const pluginManagerTool = {
|
|
9
10
|
schema: {
|
|
10
11
|
name: 'plugin.manager',
|
|
11
|
-
description: 'Create and manage local Causyne plugins.
|
|
12
|
+
description: 'Create and manage local Causyne plugins. create-skill-plugin packages reviewed MIT/Apache skill text as a disabled, non-executable plugin and retains its license; enable trusts the current directory digest.',
|
|
12
13
|
parameters: {
|
|
13
14
|
type: 'object',
|
|
14
15
|
properties: {
|
|
15
|
-
action: { type: 'string', enum: ['list', 'create', 'enable', 'disable'] },
|
|
16
|
+
action: { type: 'string', enum: ['list', 'create', 'create-skill-plugin', 'enable', 'disable'] },
|
|
16
17
|
name: { type: 'string', description: 'Lowercase plugin name using letters, digits, and hyphens.' },
|
|
17
18
|
description: { type: 'string' },
|
|
18
19
|
toolName: { type: 'string' },
|
|
19
20
|
toolDescription: { type: 'string' },
|
|
20
21
|
parametersSchema: { type: 'string', description: 'JSON object schema for the custom tool arguments.' },
|
|
21
22
|
javascriptCode: { type: 'string', description: 'Body of async execute(args, context), or a complete module exporting execute.' },
|
|
23
|
+
skillId: { type: 'string' },
|
|
24
|
+
skillName: { type: 'string' },
|
|
25
|
+
skillDescription: { type: 'string' },
|
|
26
|
+
skillContent: { type: 'string', description: 'Reviewed SKILL.md source, not executed as code.' },
|
|
27
|
+
licenseText: { type: 'string', description: 'Complete original MIT or Apache-2.0 license notice.' },
|
|
22
28
|
capabilities: {
|
|
23
29
|
type: 'array',
|
|
24
30
|
items: { type: 'string', enum: ['workspace:read', 'workspace:write', 'network', 'subprocess'] }
|
|
@@ -38,6 +44,15 @@ export const pluginManagerTool = {
|
|
|
38
44
|
const result = disablePlugin(args.name);
|
|
39
45
|
return result.ok ? { success: true, ...result } : { success: false, error: result.error };
|
|
40
46
|
}
|
|
47
|
+
if (args.action === 'create-skill-plugin') {
|
|
48
|
+
const result = createSkillPlugin({
|
|
49
|
+
name: args.name, description: args.description,
|
|
50
|
+
skillId: args.skillId, skillName: args.skillName,
|
|
51
|
+
skillDescription: args.skillDescription,
|
|
52
|
+
skillContent: args.skillContent, licenseText: args.licenseText
|
|
53
|
+
});
|
|
54
|
+
return result.ok ? { success: true, ...result } : { success: false, error: result.error };
|
|
55
|
+
}
|
|
41
56
|
if (args.action === 'create') {
|
|
42
57
|
let parameters;
|
|
43
58
|
try {
|
package/src/tools/registry.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { scanAndAdaptToolsForProvider, scanAllProvidersCompatibility } from './toolScanner.js';
|
|
1
2
|
import { creativeApps } from './creativeApps.js';
|
|
2
3
|
import { computerUse } from './computerUse.js';
|
|
3
4
|
import { uiForge } from './uiForge.js';
|
|
@@ -350,6 +351,18 @@ export async function getSearchableToolDefinitions() {
|
|
|
350
351
|
return dedupeDefinitions([...TOOL_DEFINITIONS, ...plugins, ...mcp]);
|
|
351
352
|
}
|
|
352
353
|
|
|
354
|
+
/**
|
|
355
|
+
* Scan every registered native, plugin, and MCP tool against one provider or
|
|
356
|
+
* the entire provider matrix (`toolsScan`) and report auto-adapted compatibility.
|
|
357
|
+
*/
|
|
358
|
+
export async function scanToolRegistry(provider = 'all', options = {}) {
|
|
359
|
+
const tools = await getSearchableToolDefinitions();
|
|
360
|
+
if (!provider || provider.toLowerCase() === 'all') {
|
|
361
|
+
return scanAllProvidersCompatibility(tools);
|
|
362
|
+
}
|
|
363
|
+
return scanAndAdaptToolsForProvider(tools, provider, options);
|
|
364
|
+
}
|
|
365
|
+
|
|
353
366
|
export async function getDynamicTools(autonomyMode = 'C', supportsVision = true, options = {}) {
|
|
354
367
|
// Plugin discovery reads validated JSON manifests only. Extension JavaScript
|
|
355
368
|
// is never imported into the host process during startup or tool assembly;
|