@phnx-labs/agents-cli 1.23.5 → 1.23.6

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/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.23.6
4
+
5
+ - **Live sessions no longer drop out of `sessions --active` (roster liveness).** A resumed session was dropped from the roster on every cached rescan because the PID-reuse check compared the live process against when the session was born, so fleet workers flipped between listing their sessions and listing none. The check now uses the process's own start time. A peer answering a fleet sweep scans fresh rather than serving its snapshot, and agent-named helper processes with no session or launch record (embedded app-servers, daemons) are no longer listed as sessions. Source: `cli/src/lib/session/active.ts`, `cli/src/commands/ps-roster.ts`.
6
+
3
7
  ## 1.23.5
4
8
 
5
9
  - **`agents ps` drops a dead offloaded tab once its owner answers.** A desktop editor
@@ -6,7 +6,7 @@ import { enumerateGhosttyTabs, assignGhosttyTabs } from '../lib/session/ghostty-
6
6
  import { mapPanesToTargets, listClients } from '../lib/tmux/session.js';
7
7
  import { resolveViewingIn, viewingInLabel } from '../lib/session/viewing-in.js';
8
8
  import { machineId, normalizeHost } from '../lib/session/sync/config.js';
9
- import { gatherRemoteActive } from '../lib/session/remote-active.js';
9
+ import { gatherRemoteActive, NO_FANOUT_ENV } from '../lib/session/remote-active.js';
10
10
  import { hostToken, remoteHostsToDial, shouldIncludeLocal } from '../lib/session/remote-list.js';
11
11
  import { loadFleetActiveSessions, loadLocalActiveSessions } from '../lib/session/session-cache.js';
12
12
  import { stringWidth, truncateToWidth, padToWidth, terminalWidth } from '../lib/session/width.js';
@@ -401,7 +401,8 @@ async function enrichTmuxLocators(local, surfaces = []) {
401
401
  }
402
402
  export async function gatherActiveSessions(opts = {}) {
403
403
  const forceRefresh = opts.forceRefresh === true
404
- || process.env.AGENTS_SESSIONS_FORCE_REFRESH === '1';
404
+ || process.env.AGENTS_SESSIONS_FORCE_REFRESH === '1'
405
+ || process.env[NO_FANOUT_ENV] === '1';
405
406
  const scoped = (opts.hosts?.length ?? 0) > 0;
406
407
  if (opts.local && !scoped) {
407
408
  const loaded = await loadLocalActiveSessions({ forceRefresh });
@@ -17,7 +17,7 @@ export declare function clearActiveScanCachesForTest(): void;
17
17
  export declare function processTableLiveReadCountForTest(): number;
18
18
  export declare function unattributedFullRescanCountForTest(): number;
19
19
  export declare function attributedSetLostPids(prev: Set<number>, next: Set<number>): boolean;
20
- export declare function filterCachedUnattributed(sessions: ActiveSession[], attributed: Set<number>, alive: (pid: number, startedAtMs?: number) => boolean, ppidMap?: Map<number, number>): ActiveSession[];
20
+ export declare function filterCachedUnattributed(sessions: ActiveSession[], attributed: Set<number>, alive: (pid: number, processStartedAtMs?: number) => boolean, ppidMap?: Map<number, number>): ActiveSession[];
21
21
  type ActiveContext = 'terminal' | 'teams' | 'cloud' | 'headless';
22
22
  export type BackfillMeta = Pick<SessionMeta, 'version' | 'account' | 'accountId' | 'accountKey' | 'timestamp' | 'label' | 'firstUserMessage' | 'lastUserMessage' | 'generatedTitle' | 'ticketId' | 'prUrl' | 'prNumber' | 'origin' | 'routineName' | 'harness' | 'tokenCount' | 'durationMs' | 'subAgentCount' | 'lastActivity'>;
23
23
  export declare function backfillActiveRowsFromMeta(sessions: ActiveSession[], metaById: Map<string, BackfillMeta>): void;
@@ -111,6 +111,7 @@ export interface ActiveSession {
111
111
  planFile?: string;
112
112
  sessionFile?: string;
113
113
  startedAtMs?: number;
114
+ processStartedAtMs?: number;
114
115
  version?: string;
115
116
  account?: string;
116
117
  accountLabel?: string;
@@ -178,7 +179,7 @@ export declare function resolveNamesToSessionIds(sessionNames: string[], deps: {
178
179
  }): Map<string, string>;
179
180
  export declare const PROCESS_START_CACHE_TTL_MS = 30000;
180
181
  export declare function processStartMs(pid: number, now?: number): number | null;
181
- export declare function isPidAlive(pid: number, startedAtMs?: number): boolean;
182
+ export declare function isPidAlive(pid: number, processStartedAtMs?: number): boolean;
182
183
  export declare function pickClaudeSessionFileAcrossRoots(projectRoots: string[], cwd: string, sessionId?: string): string | undefined;
183
184
  export declare function pickSessionFile(projectDir: string, sessionId?: string): string | undefined;
184
185
  export declare function sessionFileTimes(sessionFile: string | undefined): {
@@ -77,7 +77,7 @@ export function filterCachedUnattributed(sessions, attributed, alive, ppidMap) {
77
77
  return false;
78
78
  if (attributed.has(s.pid) || (ppidMap && hasAttributedAncestor(s.pid, ppidMap, attributed)))
79
79
  return false;
80
- return alive(s.pid, s.startedAtMs);
80
+ return alive(s.pid, s.processStartedAtMs);
81
81
  });
82
82
  }
83
83
  export function backfillActiveRowsFromMeta(sessions, metaById) {
@@ -341,7 +341,7 @@ export function processStartMs(pid, now = Date.now()) {
341
341
  processStartCache.set(pid, ms);
342
342
  return ms;
343
343
  }
344
- export function isPidAlive(pid, startedAtMs) {
344
+ export function isPidAlive(pid, processStartedAtMs) {
345
345
  if (!pid || pid < 1)
346
346
  return false;
347
347
  try {
@@ -351,10 +351,10 @@ export function isPidAlive(pid, startedAtMs) {
351
351
  if (err?.code !== 'EPERM')
352
352
  return false;
353
353
  }
354
- if (startedAtMs && startedAtMs > 0) {
354
+ if (processStartedAtMs && processStartedAtMs > 0) {
355
355
  // A live recycled PID must not revive an unrelated dead session.
356
356
  const procStartMs = processStartMs(pid);
357
- if (procStartMs !== null && procStartMs > startedAtMs + PID_REUSE_TOLERANCE_MS) {
357
+ if (procStartMs !== null && procStartMs > processStartedAtMs + PID_REUSE_TOLERANCE_MS) {
358
358
  return false;
359
359
  }
360
360
  }
@@ -1094,6 +1094,9 @@ async function listUnattributedActiveLive(attributed) {
1094
1094
  if (stateRec)
1095
1095
  exactId = stateRec.session_id;
1096
1096
  }
1097
+ const launchId = entry?.launchId ?? hookRec?.launch_id;
1098
+ if (!exactId && !launchId)
1099
+ continue;
1097
1100
  const cwd = cwds[i] ?? entry?.cwd ?? undefined;
1098
1101
  const sessionFile = findSessionFileForKind(kind, cwd, exactId);
1099
1102
  const topic = sessionFile ? quickExtractTopic(sessionFile) : undefined;
@@ -1119,10 +1122,11 @@ async function listUnattributedActiveLive(attributed) {
1119
1122
  tokPerSec,
1120
1123
  sessionFile,
1121
1124
  startedAtMs: hookRec?.ts ?? birthtimeMs,
1125
+ processStartedAtMs: parseStartMs(procByPid.get(pid)?.startTime ?? '') ?? undefined,
1122
1126
  lastActivityMs: mtimeMs,
1123
1127
  pidCount: 1 + (foldedByRoot.get(pid) ?? 0),
1124
1128
  owner: resolveOwner(entry?.actor, resolvedId),
1125
- launchId: entry?.launchId ?? hookRec?.launch_id,
1129
+ launchId,
1126
1130
  terminalId: entry?.terminalId ?? hookRec?.terminal_id,
1127
1131
  originTerminal: entry?.originTerminal,
1128
1132
  }, state, sessionFile, true));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phnx-labs/agents-cli",
3
- "version": "1.23.5",
3
+ "version": "1.23.6",
4
4
  "description": "One CLI for all your AI coding agents - versions, config, cloud dispatch, sessions, and teams (now with first-class Grok Build CLI support)",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",