fix: enable host settings persistence in runtime-7.3
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import { readFileSync, writeFileSync } from 'node:fs';
|
||||
import { join, resolve } from 'node:path';
|
||||
import { pathToFileURL } from 'node:url';
|
||||
|
||||
export const target = 'const persistence = ctx.remote.$host.isLoopback ? "host" : "memory";';
|
||||
const replacement = 'const persistence = "host"; /* dsh-mgr: authenticated remote settings */';
|
||||
|
||||
// Deliberately scoped to the settings UI, not connection.isLoopback or auth.
|
||||
// Fail closed on upstream changes instead of silently shipping a broken UI.
|
||||
export function patchSettings(source, version) {
|
||||
if (version !== '0.2.0-rc.2') throw new Error('unsupported DSH version for host settings patch');
|
||||
if (source.split(target).length !== 2 || source.includes(replacement)) {
|
||||
throw new Error('expected exactly one unpatched settings persistence selector');
|
||||
}
|
||||
return source.replace(target, replacement);
|
||||
}
|
||||
|
||||
export function install(root = '/usr/local/lib/node_modules/@deepseek-ai/dsh') {
|
||||
const { version } = JSON.parse(readFileSync(join(root, 'package.json'), 'utf8'));
|
||||
const file = join(root, 'node_modules/@deepseek-ai/dsh-client-ui-settings/lib/client.js');
|
||||
const source = readFileSync(file, 'utf8');
|
||||
writeFileSync(file, patchSettings(source, version));
|
||||
}
|
||||
|
||||
if (process.argv[1] && import.meta.url === pathToFileURL(resolve(process.argv[1])).href) {
|
||||
install();
|
||||
}
|
||||
Reference in New Issue
Block a user