File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11{
22 "name" : " opencode-supertask" ,
3- "version" : " 0.1.29 " ,
3+ "version" : " 0.1.30 " ,
44 "description" : " AI Agent 任务调度系统 — OpenCode 插件 + CLI + Gateway 常驻进程" ,
55 "type" : " module" ,
66 "main" : " dist/plugin/supertask.js" ,
Original file line number Diff line number Diff line change @@ -277,15 +277,17 @@ function launchctlBin(): string {
277277 return process . env . SUPERTASK_LAUNCHCTL_BIN ?? "launchctl" ;
278278}
279279
280- function resolvePm2SupervisorEntry ( ) : string {
280+ export function resolvePm2SupervisorEntry ( baseDir = __dirname ) : string {
281281 const override = process . env . SUPERTASK_PM2_SUPERVISOR_ENTRY ;
282282 if ( override ) {
283283 if ( ! existsSync ( override ) ) throw new Error ( `[supertask] PM2 supervisor entry not found: ${ override } ` ) ;
284284 return resolve ( override ) ;
285285 }
286286 const candidates = [
287- join ( __dirname , "pm2-supervisor.js" ) ,
288- join ( __dirname , "pm2-supervisor.ts" ) ,
287+ join ( baseDir , "pm2-supervisor.js" ) ,
288+ join ( baseDir , "pm2-supervisor.ts" ) ,
289+ join ( baseDir , "../daemon/pm2-supervisor.js" ) ,
290+ join ( baseDir , "../daemon/pm2-supervisor.ts" ) ,
289291 ] ;
290292 const entry = candidates . find ( ( candidate ) => existsSync ( candidate ) ) ;
291293 if ( ! entry ) throw new Error ( `[supertask] PM2 supervisor entry not found. Checked: ${ candidates . join ( ", " ) } ` ) ;
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import {
1212 isMacLaunchAgentConfigured ,
1313 isGatewayRunning ,
1414 resolveGatewayEntry ,
15+ resolvePm2SupervisorEntry ,
1516 uninstall ,
1617 upgrade ,
1718 withGatewayMaintenance ,
@@ -288,6 +289,18 @@ console.log('state = running');
288289 expect ( resolveGatewayEntry ( ) ) . toBe ( join ( process . cwd ( ) , 'src/gateway/index.ts' ) ) ;
289290 } ) ;
290291
292+ test ( '构建后的 CLI 能定位 daemon 目录中的 PM2 supervisor' , ( ) => {
293+ const dir = mkdtempSync ( join ( tmpdir ( ) , 'supertask-built-supervisor-' ) ) ;
294+ dirs . push ( dir ) ;
295+ const cliDir = join ( dir , 'dist/cli' ) ;
296+ const supervisorEntry = join ( dir , 'dist/daemon/pm2-supervisor.js' ) ;
297+ mkdirSync ( cliDir , { recursive : true } ) ;
298+ mkdirSync ( join ( dir , 'dist/daemon' ) , { recursive : true } ) ;
299+ writeFileSync ( supervisorEntry , '' ) ;
300+
301+ expect ( resolvePm2SupervisorEntry ( cliDir ) ) . toBe ( supervisorEntry ) ;
302+ } ) ;
303+
291304 test ( '插件探测不到 pm2 时不执行全局安装' , ( ) => {
292305 process . env . SUPERTASK_PM2_BIN = join ( tmpdir ( ) , '不存在的-pm2' ) ;
293306 expect ( ensureGateway ( ) ) . toEqual ( { ok : false , reason : 'pm2-not-installed' } ) ;
You can’t perform that action at this time.
0 commit comments