diff --git a/apps/ai-game-creator-shell/scripts/agent-swarm-test-chat.mjs b/apps/ai-game-creator-shell/scripts/agent-swarm-test-chat.mjs index 14a529600..32a9b8644 100644 --- a/apps/ai-game-creator-shell/scripts/agent-swarm-test-chat.mjs +++ b/apps/ai-game-creator-shell/scripts/agent-swarm-test-chat.mjs @@ -371,7 +371,15 @@ async function runMissingConfigWizard(setActiveChild, explicitConfigDir) { } } -async function secureWindowsPrivateRuntimePath(targetPath, options) { +async function secureWindowsPrivateRuntimePath( + targetPath, + options, + secureWindowsPath = null, +) { + if (secureWindowsPath) { + await secureWindowsPath(targetPath, options); + return; + } const { secureWindowsGameCreatorPathForCurrentUser } = await import( './game-creator-config-wizard.mjs' ); @@ -383,6 +391,7 @@ async function copyPrivateRuntimeConfigEntry( runtimeConfigDir, fileName, required, + secureWindowsPath = null, ) { const sourcePath = path.join(sourceConfigDir, fileName); const sourceMetadata = await lstat(sourcePath).catch((error) => { @@ -402,9 +411,11 @@ async function copyPrivateRuntimeConfigEntry( const sourceBytes = await readFile(sourcePath); const destinationFile = await open(destinationPath, 'wx', 0o600); try { - await secureWindowsPrivateRuntimePath(destinationPath, { - isDirectory: false, - }); + await secureWindowsPrivateRuntimePath( + destinationPath, + { isDirectory: false }, + secureWindowsPath, + ); await destinationFile.writeFile(sourceBytes); await destinationFile.sync(); } finally { @@ -437,7 +448,11 @@ async function copyPrivateRuntimeConfigEntry( return true; } -export async function prepareSwarmTestRuntimeConfig(sourceConfigDir, tempRoot) { +export async function prepareSwarmTestRuntimeConfig( + sourceConfigDir, + tempRoot, + { secureWindowsPath = null } = {}, +) { if (!path.isAbsolute(sourceConfigDir)) { throw new Error('配置来源目录必须是绝对路径'); } @@ -457,9 +472,11 @@ export async function prepareSwarmTestRuntimeConfig(sourceConfigDir, tempRoot) { ); try { if (process.platform === 'win32') { - await secureWindowsPrivateRuntimePath(runtimeConfigDir, { - isDirectory: true, - }); + await secureWindowsPrivateRuntimePath( + runtimeConfigDir, + { isDirectory: true }, + secureWindowsPath, + ); } else { await chmod(runtimeConfigDir, 0o700); } @@ -477,12 +494,14 @@ export async function prepareSwarmTestRuntimeConfig(sourceConfigDir, tempRoot) { runtimeConfigDir, configFileName, true, + secureWindowsPath, ); await copyPrivateRuntimeConfigEntry( canonicalSourceConfigDir, runtimeConfigDir, localConfigFileName, false, + secureWindowsPath, ); return { path: await realpath(runtimeConfigDir),