Skip to content

Commit 143e705

Browse files
committed
fix: restore gateway from pm2 dump layout
1 parent 1f5cd15 commit 143e705

3 files changed

Lines changed: 6 additions & 4 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "opencode-supertask",
3-
"version": "0.1.30",
3+
"version": "0.1.31",
44
"description": "AI Agent 任务调度系统 — OpenCode 插件 + CLI + Gateway 常驻进程",
55
"type": "module",
66
"main": "dist/plugin/supertask.js",

src/daemon/pm2.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ interface Pm2Process {
2929
pid?: number;
3030
args?: string[] | string;
3131
pm_exec_path?: string;
32+
pm_cwd?: string;
3233
env?: Record<string, unknown>;
3334
kill_timeout?: number;
3435
pm2_env?: {
@@ -667,7 +668,7 @@ function pm2JsonList(env: NodeJS.ProcessEnv = process.env): Pm2Process[] {
667668
function gatewayEntryFromProcess(processInfo: Pm2Process | undefined): string | null {
668669
const args = processInfo?.pm2_env?.args ?? processInfo?.args;
669670
const candidates = Array.isArray(args) ? [...args].reverse() : typeof args === "string" ? [args] : [];
670-
const savedCwd = processInfo?.pm2_env?.pm_cwd;
671+
const savedCwd = processInfo?.pm2_env?.pm_cwd ?? processInfo?.pm_cwd;
671672
for (const candidate of candidates) {
672673
const path = typeof savedCwd === "string" ? runtimePath(candidate, savedCwd) : candidate;
673674
if (existsSync(path)) return resolve(path);
@@ -690,7 +691,7 @@ function gatewayRuntimeFromProcess(processInfo: Pm2Process | undefined): Gateway
690691
const gatewayEntry = gatewayEntryFromProcess(processInfo);
691692
if (!gatewayEntry) return null;
692693
const savedBunPath = processInfo?.pm2_env?.pm_exec_path ?? processInfo?.pm_exec_path;
693-
const savedCwd = processInfo?.pm2_env?.pm_cwd;
694+
const savedCwd = processInfo?.pm2_env?.pm_cwd ?? processInfo?.pm_cwd;
694695
const savedEnv = gatewayEnvironmentFromProcess(processInfo);
695696
if (typeof savedBunPath !== "string" || typeof savedCwd !== "string") return null;
696697
try {

tests/pm2.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,8 @@ if (args[0] === 'bootstrap' && readFileSync(${JSON.stringify(plist)}, 'utf8') !=
241241
name: 'supertask-gateway',
242242
pm_exec_path: fakePm2,
243243
args: [gateway],
244-
pm2_env: { args: [gateway], pm_exec_path: fakePm2, pm_cwd: dir, env: { HOME: dir, PM2_HOME: pm2Home } },
244+
pm_cwd: dir,
245+
env: { HOME: dir, PM2_HOME: pm2Home },
245246
}]));
246247
writeFileSync(fakeLaunchctl, `#!/usr/bin/env bun
247248
console.log('path = ${plist}');

0 commit comments

Comments
 (0)