@@ -16,7 +16,10 @@ import { spawnEnvForAgent } from './runtimes/env.js';
1616import { execAgentFile } from './runtimes/invocation.js' ;
1717import { applyAgentLaunchEnv , resolveAgentLaunch } from './runtimes/launch.js' ;
1818import { getAgentDef } from './runtimes/registry.js' ;
19- import { hasOpenDesignProfile } from './runtimes/defs/deepseek-harness.js' ;
19+ import {
20+ hasOpenDesignProfile ,
21+ resolveOpenDesignProfileDir ,
22+ } from './runtimes/defs/deepseek-harness.js' ;
2023
2124const execFileAsync = promisify ( execFile ) ;
2225const DSH_AGENT_ID = 'deepseek-harness' ;
@@ -111,7 +114,7 @@ async function resolveVerifiedBundle(options: {
111114 projectRoot : string ;
112115 resourceRoot : string ;
113116 runtimeDataDir : string ;
114- } ) : Promise < { manifest : RuntimeManifest ; tarballPath : string } > {
117+ } ) : Promise < { bytes : Buffer ; manifest : RuntimeManifest } > {
115118 let directory = path . join ( options . resourceRoot , DSH_RUNTIME_RESOURCE_DIRECTORY ) ;
116119 if ( ! ( await fileExists ( path . join ( directory , 'manifest.json' ) ) ) ) {
117120 directory = await materializeDevelopmentBundle ( options . projectRoot , options . runtimeDataDir ) ;
@@ -135,11 +138,48 @@ async function resolveVerifiedBundle(options: {
135138 throw new AgentCompanionSetupError ( 'BUNDLED_COMPANION_INVALID' , 'Invalid connection package manifest.' ) ;
136139 }
137140 const tarballPath = path . join ( directory , manifest . file ) ;
138- const actualHash = createHash ( 'sha256' ) . update ( await readFile ( tarballPath ) ) . digest ( 'hex' ) ;
141+ const bytes = await readFile ( tarballPath ) ;
142+ const actualHash = createHash ( 'sha256' ) . update ( bytes ) . digest ( 'hex' ) ;
139143 if ( actualHash !== manifest . sha256 ) {
140144 throw new AgentCompanionSetupError ( 'BUNDLED_COMPANION_INVALID' , 'Connection package integrity check failed.' ) ;
141145 }
142- return { manifest, tarballPath } ;
146+ return { bytes, manifest } ;
147+ }
148+
149+ async function stageVerifiedBundleInProfile (
150+ env : NodeJS . ProcessEnv ,
151+ manifest : RuntimeManifest ,
152+ bytes : Buffer ,
153+ ) : Promise < string > {
154+ const relativeDirectory = '.open-design' ;
155+ const file = `${ manifest . sha256 } .tgz` ;
156+ const profileDirectory = resolveOpenDesignProfileDir ( env ) ;
157+ const bundleDirectory = path . join ( profileDirectory , relativeDirectory ) ;
158+ await mkdir ( bundleDirectory , { recursive : true } ) ;
159+ await writeFile ( path . join ( bundleDirectory , file ) , bytes ) ;
160+ // dsh runs pnpm with the profile directory as cwd. Keeping this spec
161+ // relative avoids rc.6's Windows shell forwarder splitting an absolute
162+ // packaged-app path such as "Open Design" at its spaces.
163+ return `${ relativeDirectory } /${ file } ` ;
164+ }
165+
166+ function commandFailureDetail ( error : unknown ) : string | null {
167+ if ( ! error || typeof error !== 'object' ) return null ;
168+ const candidate = error as { code ?: unknown ; signal ?: unknown ; stderr ?: unknown } ;
169+ let stderr = '' ;
170+ if ( typeof candidate . stderr === 'string' ) {
171+ stderr = candidate . stderr . trim ( ) ;
172+ } else if ( Buffer . isBuffer ( candidate . stderr ) ) {
173+ stderr = candidate . stderr . toString ( 'utf8' ) . trim ( ) ;
174+ }
175+ const parts = [
176+ typeof candidate . code === 'string' || typeof candidate . code === 'number'
177+ ? `code=${ candidate . code } `
178+ : null ,
179+ typeof candidate . signal === 'string' ? `signal=${ candidate . signal } ` : null ,
180+ stderr ? `stderr=${ stderr . slice ( - 4_000 ) } ` : null ,
181+ ] . filter ( ( part ) : part is string => part !== null ) ;
182+ return parts . length > 0 ? parts . join ( ' ' ) : null ;
143183}
144184
145185let activeSetup : Promise < AgentCompanionSetupResponse > | null = null ;
@@ -168,7 +208,7 @@ async function installDeepSeekHarnessCompanionOnce(options: {
168208 const appConfig = await readAppConfig ( options . runtimeDataDir ) ;
169209 const configuredEnv = agentCliEnvForAgent ( appConfig . agentCliEnv , DSH_AGENT_ID ) ;
170210 const before = await detectAgent ( def , configuredEnv ) ;
171- const { manifest , tarballPath } = await resolveVerifiedBundle ( options ) ;
211+ const { bytes , manifest } = await resolveVerifiedBundle ( options ) ;
172212 if ( before . available ) {
173213 return { action : 'already-compatible' , agent : before , ok : true , packageVersion : manifest . version } ;
174214 }
@@ -185,13 +225,18 @@ async function installDeepSeekHarnessCompanionOnce(options: {
185225 launch ,
186226 ) ;
187227 const profileWasPresent = hasOpenDesignProfile ( childEnv ) ;
228+ const packageSpec = await stageVerifiedBundleInProfile ( childEnv , manifest , bytes ) ;
188229 try {
189230 await execAgentFile (
190231 launch . launchPath ,
191- [ 'plugin' , '--profile' , 'open-design' , 'add' , tarballPath ] ,
232+ [ 'plugin' , '--profile' , 'open-design' , 'add' , packageSpec ] ,
192233 { env : childEnv , timeout : 120_000 , maxBuffer : 2 * 1024 * 1024 } ,
193234 ) ;
194- } catch {
235+ } catch ( error ) {
236+ console . error (
237+ '[od] DeepSeek Harness connection component install failed' ,
238+ commandFailureDetail ( error ) ?? 'no command diagnostics were available' ,
239+ ) ;
195240 throw new AgentCompanionSetupError (
196241 'COMPANION_INSTALL_FAILED' ,
197242 'DeepSeek Harness could not install the Open Design connection component. No agent selection was changed.' ,
0 commit comments