fix(dsh): preserve acrylic and restore durable native model settings
Core regression / Python core and release configuration (push) Successful in 15s
Core regression / JavaScript syntax (push) Successful in 3s
Core regression / Python core and release configuration (pull_request) Successful in 15s
Core regression / JavaScript syntax (pull_request) Successful in 3s
Core regression / Python core and release configuration (push) Successful in 15s
Core regression / JavaScript syntax (push) Successful in 3s
Core regression / Python core and release configuration (pull_request) Successful in 15s
Core regression / JavaScript syntax (pull_request) Successful in 3s
This commit is contained in:
1 parent
3cec9adc5f
commit
374e1cd5bf
11 files changed
+262
-17
No files matched your search
@@ -1,7 +1,8 @@
|
||||
/** Application-owned composition around the unmodified official Harness web UI. */
|
||||
import {createRequire} from 'node:module';
|
||||
import {fileURLToPath} from 'node:url';
|
||||
import {mkdir, writeFile, readFile, cp} from 'node:fs/promises';
|
||||
import {mkdir, writeFile, readFile, cp, rename} from 'node:fs/promises';
|
||||
import {createHash,randomUUID} from 'node:crypto';
|
||||
import path from 'node:path';
|
||||
import {createInterface} from 'node:readline';
|
||||
|
||||
@@ -28,12 +29,14 @@ export const DISABLED = [
|
||||
// This embedded tool uses its application-owned API configuration, without
|
||||
// upstream accounts, billing, credential onboarding or product feedback.
|
||||
'ui-settings-account','account-controller','deepseek-account','llm-deepseek-account',
|
||||
'ui-settings-models','ui-message-feedback','message-feedback','command-feedback',
|
||||
'ui-message-feedback','message-feedback','command-feedback',
|
||||
];
|
||||
|
||||
export function overlay() {
|
||||
const rows = DISABLED.map(id => ({id, disabled:true}));
|
||||
rows.push({id:'agent-preset-registry',config:{default:'dx-task'}});
|
||||
rows.push({id:'ui-settings-general',config:{welcomeNoticeVersion:'2026-09-28.1'}});
|
||||
rows.push({id:'ui-settings-models',config:{credentialOnboarding:false}});
|
||||
rows.push({id:'web-runtime',config:{openBrowser:false,printUrl:false,surfaceContext:false}});
|
||||
rows.push({id:'sandbox-policy',config:{mode:'read-only',workspaceRoot:process.env.DX_DSH_WORKSPACE}});
|
||||
rows.push({id:'permission',config:{presets:{'read-only':{sandbox:'read-only',approval:'ask'}}}});
|
||||
@@ -55,6 +58,48 @@ export function overlay() {
|
||||
return rows;
|
||||
}
|
||||
|
||||
async function replaceJson(filename,value) {
|
||||
const temporary=filename+'.'+randomUUID()+'.tmp';
|
||||
const {unlink}=await import('node:fs/promises');
|
||||
try{await writeFile(temporary,JSON.stringify(value,null,2));await rename(temporary,filename);}
|
||||
finally{await unlink(temporary).catch(error=>{if(error.code!=='ENOENT')throw error;});}
|
||||
}
|
||||
|
||||
export async function prepareProfileDirectory(dir) {
|
||||
// The official settings page writes the user patch. Application defaults
|
||||
// belong to a bundle below that patch, so rebooting must never overwrite it.
|
||||
await mkdir(dir,{recursive:true});
|
||||
const userPatch=path.join(dir,'cordis.patch.yml');
|
||||
let prior;
|
||||
try{prior=await readFile(userPatch,'utf8');}catch(error){if(error.code!=='ENOENT')throw error;}
|
||||
if(prior!==undefined){
|
||||
const {load}=require('js-yaml');
|
||||
const rows=load(prior);
|
||||
const legacy=Array.isArray(rows)&&rows.some(row=>Array.isArray(row?.insert)
|
||||
&&row.insert.some(entry=>entry.id==='dx-task'&&entry.name==='@dx/dsh-task')
|
||||
&&row.insert.some(entry=>entry.id==='preset-dx-task'));
|
||||
if(legacy){
|
||||
const digest=createHash('sha256').update(prior).digest('hex');
|
||||
const backup=userPatch+'.legacy-'+digest+'.bak';
|
||||
try{await writeFile(backup,prior,{flag:'wx'});}catch(error){
|
||||
if(error.code!=='EEXIST'||await readFile(backup,'utf8')!==prior)throw error;
|
||||
}
|
||||
const editable=new Set(['llm-pi-ai','llm-deepseek','agent-default-model']);
|
||||
await replaceJson(userPatch,rows.filter(row=>editable.has(row?.id)&&row.config)
|
||||
.map(({id,config})=>({id,config})));
|
||||
}
|
||||
}
|
||||
const policyDir=path.join(dir,'node_modules','@dx','dsh-policy');
|
||||
await mkdir(policyDir,{recursive:true});
|
||||
await cp(path.join(root,'task-plugin'),path.join(dir,'node_modules','@dx','dsh-task'),{recursive:true});
|
||||
await replaceJson(path.join(policyDir,'package.json'),{name:'@dx/dsh-policy',version:VERSION,
|
||||
private:true,dsh:{bundle:{patch:'./cordis.patch.yml'}}});
|
||||
await replaceJson(path.join(policyDir,'cordis.patch.yml'),overlay());
|
||||
await replaceJson(path.join(dir,'package.json'),{private:true,type:'module',
|
||||
dependencies:{'@dx/dsh-task':'file:'+path.join(root,'task-plugin'),'@dx/dsh-policy':'file:'+policyDir},
|
||||
dsh:{profile:{bundles:['@deepseek-ai/dsh-base','@deepseek-ai/dsh-web-app','@dx/dsh-policy']}}});
|
||||
}
|
||||
|
||||
export async function bootRuntime({announce=true} = {}) {
|
||||
const installed = require('@deepseek-ai/dsh/package.json');
|
||||
if (installed.version !== VERSION) throw Error('Unsupported Harness version: ' + installed.version);
|
||||
@@ -73,12 +118,7 @@ export async function bootRuntime({announce=true} = {}) {
|
||||
process.env.DX_DSH_WORKSPACE = path.join(process.env.DX_DSH_HOME,'workspace');
|
||||
await mkdir(process.env.DX_DSH_WORKSPACE,{recursive:true});
|
||||
const dir = path.join(process.env.DX_DSH_HOME,'profiles','dx-task');
|
||||
await mkdir(path.join(dir,'node_modules','@dx'),{recursive:true});
|
||||
await cp(path.join(root,'task-plugin'),path.join(dir,'node_modules','@dx','dsh-task'),{recursive:true});
|
||||
await writeFile(path.join(dir,'package.json'), JSON.stringify({private:true,type:'module',
|
||||
dependencies:{'@dx/dsh-task':'file:'+path.join(root,'task-plugin')},
|
||||
dsh:{profile:{bundles:['@deepseek-ai/dsh-base','@deepseek-ai/dsh-web-app']}}}));
|
||||
await writeFile(path.join(dir,'cordis.patch.yml'),JSON.stringify(overlay(),null,2));
|
||||
await prepareProfileDirectory(dir);
|
||||
const {runProfile, INSTALL_ANCHOR} = await import('@deepseek-ai/dsh/profile-boot');
|
||||
const {loadProfileDirectory,composeEntries} = await import('@deepseek-ai/dsh-app-boot');
|
||||
const {createLaunchEnvironmentSnapshot} = await import('@deepseek-ai/dsh-launch-environment');
|
||||
|
||||
Reference in new issue
Block a user