@@ -5,6 +5,7 @@ import path from "node:path";
55import process from "node:process" ;
66import { setTimeout as delay } from "node:timers/promises" ;
77import { pathToFileURL } from "node:url" ;
8+ import { createPnpmRunnerSpawnSpec } from "../pnpm-runner.mjs" ;
89
910const PLUGIN_SPEC =
1011 process . env . OPENCLAW_KITCHEN_SINK_NPM_SPEC || "npm:@openclaw/kitchen-sink@latest" ;
@@ -46,7 +47,7 @@ function resolveOpenClawRunner() {
4647 return { command : "node" , baseArgs : [ resolved ] , label : resolved } ;
4748 }
4849 }
49- return { command : "pnpm" , baseArgs : [ "openclaw" ] , label : "pnpm openclaw" } ;
50+ return { pnpm : true , baseArgs : [ "openclaw" ] , label : "pnpm openclaw" } ;
5051}
5152
5253function makeEnv ( ) {
@@ -119,12 +120,31 @@ function runCommand(command, args, options = {}) {
119120}
120121
121122async function runOpenClaw ( runner , args , env , options = { } ) {
122- return runCommand ( runner . command , [ ...runner . baseArgs , ...args ] , {
123+ const command = resolveOpenClawCommand ( runner , args , env , {
124+ stdio : [ "ignore" , "pipe" , "pipe" ] ,
125+ } ) ;
126+ return runCommand ( command . command , command . args , {
127+ ...command . options ,
123128 env,
124129 timeoutMs : options . timeoutMs ?? COMMAND_TIMEOUT_MS ,
125130 } ) ;
126131}
127132
133+ function resolveOpenClawCommand ( runner , args , env , options = { } ) {
134+ if ( runner . pnpm ) {
135+ return createPnpmRunnerSpawnSpec ( {
136+ env,
137+ pnpmArgs : [ ...runner . baseArgs , ...args ] ,
138+ stdio : options . stdio ,
139+ } ) ;
140+ }
141+ return {
142+ command : runner . command ,
143+ args : [ ...runner . baseArgs , ...args ] ,
144+ options : { env, stdio : options . stdio } ,
145+ } ;
146+ }
147+
128148function parseJsonOutput ( stdout ) {
129149 const trimmed = stdout . trim ( ) ;
130150 if ( ! trimmed ) {
@@ -319,23 +339,26 @@ function configureKitchenSink(env, port) {
319339
320340function startGateway ( runner , port , env , logPath ) {
321341 const log = fs . openSync ( logPath , "w" ) ;
322- const child = childProcess . spawn (
323- runner . command ,
342+ const command = resolveOpenClawCommand (
343+ runner ,
324344 [
325- ...runner . baseArgs ,
326345 "gateway" ,
327346 "--port" ,
328347 String ( port ) ,
329348 "--bind" ,
330349 "loopback" ,
331350 "--allow-unconfigured" ,
332351 ] ,
352+ env ,
333353 {
334- env,
335354 stdio : [ "ignore" , log , log ] ,
336- detached : false ,
337355 } ,
338356 ) ;
357+ const child = childProcess . spawn ( command . command , command . args , {
358+ ...command . options ,
359+ env,
360+ detached : false ,
361+ } ) ;
339362 fs . closeSync ( log ) ;
340363 return child ;
341364}
0 commit comments