@phren/cli 0.3.27 → 0.3.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bridge/codex-daemon.js +25 -1
- package/dist/bridge-hook.mjs +20 -3
- package/package.json +1 -1
|
@@ -146,6 +146,30 @@ async function recentRollouts(now) {
|
|
|
146
146
|
return files.slice(0, MAX_ROLLOUTS);
|
|
147
147
|
}
|
|
148
148
|
let rollouts;
|
|
149
|
+
/** Launcher wrappers may have the same command as their native server child.
|
|
150
|
+
* Count the server once, and keep the shared managed daemon ahead of private
|
|
151
|
+
* per-pane servers when the bounded probe is full. */
|
|
152
|
+
function daemonPids(rows) {
|
|
153
|
+
const byPid = new Map(rows.map(row => [row.pid, row]));
|
|
154
|
+
const servers = rows.filter(row => isCodexDaemon(row.command));
|
|
155
|
+
const serverIds = new Set(servers.map(row => row.pid));
|
|
156
|
+
const wrappers = new Set();
|
|
157
|
+
for (const server of servers) {
|
|
158
|
+
let parent = server.ppid;
|
|
159
|
+
for (let depth = 0; depth < 8 && parent > 1; depth++) {
|
|
160
|
+
if (serverIds.has(parent))
|
|
161
|
+
wrappers.add(parent);
|
|
162
|
+
const ancestor = byPid.get(parent);
|
|
163
|
+
if (!ancestor || ancestor.ppid === parent)
|
|
164
|
+
break;
|
|
165
|
+
parent = ancestor.ppid;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
const managed = (row) => /(?:^|\s)--managed-daemon(?:\s|$)/.test(row.command) ? 1 : 0;
|
|
169
|
+
return servers.filter(row => !wrappers.has(row.pid))
|
|
170
|
+
.sort((a, b) => managed(b) - managed(a) || a.startedAt - b.startedAt || a.pid - b.pid)
|
|
171
|
+
.slice(0, MAX_DAEMONS).map(row => row.pid);
|
|
172
|
+
}
|
|
149
173
|
/**
|
|
150
174
|
* The conversations a running Codex daemon holds open (by `openFiles`, the
|
|
151
175
|
* caller's lsof or /proc read), else, when it holds none, the recent rollouts
|
|
@@ -156,7 +180,7 @@ export function daemonRollouts(openFiles, now = Date.now()) {
|
|
|
156
180
|
if (rollouts && now - rollouts.at < CACHE_MS)
|
|
157
181
|
return rollouts.value;
|
|
158
182
|
const value = (async () => {
|
|
159
|
-
const daemons = (await processTable(now))
|
|
183
|
+
const daemons = daemonPids(await processTable(now));
|
|
160
184
|
if (!daemons.length)
|
|
161
185
|
return [];
|
|
162
186
|
countIdentity("codex-daemon");
|
package/dist/bridge-hook.mjs
CHANGED
|
@@ -25352,7 +25352,7 @@ var init_package_metadata = __esm({
|
|
|
25352
25352
|
__dirname = path15.dirname(fileURLToPath2(import.meta.url));
|
|
25353
25353
|
ROOT = path15.join(__dirname, "..");
|
|
25354
25354
|
PACKAGE_JSON_PATH = path15.join(ROOT, "package.json");
|
|
25355
|
-
BUNDLED_VERSION = true ? "0.3.
|
|
25355
|
+
BUNDLED_VERSION = true ? "0.3.28" : "0.0.0";
|
|
25356
25356
|
PACKAGE_JSON = readPackageJson();
|
|
25357
25357
|
PACKAGE_NAME = PACKAGE_JSON.name || "phren";
|
|
25358
25358
|
VERSION = PACKAGE_JSON.version || BUNDLED_VERSION;
|
|
@@ -29562,10 +29562,27 @@ async function recentRollouts(now) {
|
|
|
29562
29562
|
}
|
|
29563
29563
|
return files.slice(0, MAX_ROLLOUTS);
|
|
29564
29564
|
}
|
|
29565
|
+
function daemonPids(rows) {
|
|
29566
|
+
const byPid = new Map(rows.map((row) => [row.pid, row]));
|
|
29567
|
+
const servers2 = rows.filter((row) => isCodexDaemon(row.command));
|
|
29568
|
+
const serverIds = new Set(servers2.map((row) => row.pid));
|
|
29569
|
+
const wrappers = /* @__PURE__ */ new Set();
|
|
29570
|
+
for (const server of servers2) {
|
|
29571
|
+
let parent = server.ppid;
|
|
29572
|
+
for (let depth = 0; depth < 8 && parent > 1; depth++) {
|
|
29573
|
+
if (serverIds.has(parent)) wrappers.add(parent);
|
|
29574
|
+
const ancestor = byPid.get(parent);
|
|
29575
|
+
if (!ancestor || ancestor.ppid === parent) break;
|
|
29576
|
+
parent = ancestor.ppid;
|
|
29577
|
+
}
|
|
29578
|
+
}
|
|
29579
|
+
const managed = (row) => /(?:^|\s)--managed-daemon(?:\s|$)/.test(row.command) ? 1 : 0;
|
|
29580
|
+
return servers2.filter((row) => !wrappers.has(row.pid)).sort((a, b) => managed(b) - managed(a) || a.startedAt - b.startedAt || a.pid - b.pid).slice(0, MAX_DAEMONS).map((row) => row.pid);
|
|
29581
|
+
}
|
|
29565
29582
|
function daemonRollouts(openFiles, now = Date.now()) {
|
|
29566
29583
|
if (rollouts && now - rollouts.at < CACHE_MS) return rollouts.value;
|
|
29567
29584
|
const value2 = (async () => {
|
|
29568
|
-
const daemons = (await processTable(now))
|
|
29585
|
+
const daemons = daemonPids(await processTable(now));
|
|
29569
29586
|
if (!daemons.length) return [];
|
|
29570
29587
|
countIdentity("codex-daemon");
|
|
29571
29588
|
const held = (await openFiles(daemons).catch(() => [])).filter((file3) => ROLLOUT.test(file3)).slice(0, MAX_ROLLOUTS);
|
|
@@ -61130,7 +61147,7 @@ async function readSecret(prompt) {
|
|
|
61130
61147
|
// src/bridge/hook-main.ts
|
|
61131
61148
|
init_utils_helpers();
|
|
61132
61149
|
Object.assign(process.env, nonInteractiveGitEnv());
|
|
61133
|
-
runBridge(process.argv.slice(2), "0.3.
|
|
61150
|
+
runBridge(process.argv.slice(2), "0.3.28").then((code) => {
|
|
61134
61151
|
process.exitCode = code;
|
|
61135
61152
|
}).catch((error62) => {
|
|
61136
61153
|
console.error(error62 instanceof Error ? error62.message : "Phren Hook failed.");
|