@phnx-labs/agents-cli 1.23.5 → 1.23.7
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,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.23.7
|
|
4
|
+
|
|
5
|
+
- **A tab watching a session names the workspace its editor window has open.** Each `observerTerminals` entry in `agents feed watch --json` now carries the tab's `workspaceDir`, so AGI EXT can group sessions by the window that holds their tab and label it `agents` or `agents-cli` instead of "Window 2". An entry that comes only from a session's origin terminal has no tab row and still carries none. Source: `cli/src/lib/session/projection.ts`.
|
|
6
|
+
|
|
7
|
+
- **A session opened over ssh reads as a terminal session, not headless.** An interactive session reached through `ssh -tt` (how AGI EXT opens a remote session in an editor tab) runs under sshd with a real pty but no known terminal app, so `sessions --active` labelled it `headless` and the extension filed it under Background. A process with a controlling tty is now `terminal` (with `presence: attached`); detached runs such as daemon jobs and teams stay `headless`. Answering such a session's open question no longer runs `--resume` beside the live process (which would start a second writer on its transcript); with no tmux or iTerm rail to type into, the answer is refused with the recovery hint. Source: `cli/src/lib/session/active.ts`, `cli/src/lib/answer-router.ts`.
|
|
8
|
+
|
|
9
|
+
## 1.23.6
|
|
10
|
+
|
|
11
|
+
- **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`.
|
|
12
|
+
|
|
3
13
|
## 1.23.5
|
|
4
14
|
|
|
5
15
|
- **`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,8 +17,8 @@ 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,
|
|
21
|
-
type ActiveContext = 'terminal' | 'teams' | 'cloud' | 'headless';
|
|
20
|
+
export declare function filterCachedUnattributed(sessions: ActiveSession[], attributed: Set<number>, alive: (pid: number, processStartedAtMs?: number) => boolean, ppidMap?: Map<number, number>): ActiveSession[];
|
|
21
|
+
export 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;
|
|
24
24
|
export declare function sessionAccountLabel(kind: string, session: Pick<SessionMeta, 'accountId' | 'accountKey' | 'account'>, accounts?: import("../account-registry.js").NativeAccount[]): string | undefined;
|
|
@@ -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,
|
|
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): {
|
|
@@ -211,6 +212,7 @@ interface ProcRow {
|
|
|
211
212
|
export declare function parseWin32ProcessCsv(out: string): ProcRow[];
|
|
212
213
|
export declare function resolveCwds(pids: number[], probe?: (pid: number) => Promise<string | undefined>): Promise<(string | undefined)[]>;
|
|
213
214
|
export declare function hostFromPid(pid: number): Promise<string | undefined>;
|
|
215
|
+
export declare function unattributedContext(host: string | undefined, tty: string | undefined): ActiveContext;
|
|
214
216
|
export interface AgentCandidate {
|
|
215
217
|
pid: number;
|
|
216
218
|
kind: string;
|
|
@@ -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.
|
|
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,
|
|
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 (
|
|
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 >
|
|
357
|
+
if (procStartMs !== null && procStartMs > processStartedAtMs + PID_REUSE_TOLERANCE_MS) {
|
|
358
358
|
return false;
|
|
359
359
|
}
|
|
360
360
|
}
|
|
@@ -968,6 +968,9 @@ const UI_HOSTS = new Set([
|
|
|
968
968
|
'iterm', 'terminal', 'warp', 'alacritty', 'kitty', 'hyper', 'wezterm', 'ghostty',
|
|
969
969
|
'tmux', 'screen',
|
|
970
970
|
]);
|
|
971
|
+
export function unattributedContext(host, tty) {
|
|
972
|
+
return tty || (host && UI_HOSTS.has(host)) ? 'terminal' : 'headless';
|
|
973
|
+
}
|
|
971
974
|
export function readAncestorSessionEntry(pid, ppidMap, kind, readEntry = readPidSessionEntry) {
|
|
972
975
|
let cur = ppidMap.get(pid);
|
|
973
976
|
const seen = new Set();
|
|
@@ -1094,11 +1097,15 @@ async function listUnattributedActiveLive(attributed) {
|
|
|
1094
1097
|
if (stateRec)
|
|
1095
1098
|
exactId = stateRec.session_id;
|
|
1096
1099
|
}
|
|
1100
|
+
const launchId = entry?.launchId ?? hookRec?.launch_id;
|
|
1101
|
+
if (!exactId && !launchId)
|
|
1102
|
+
continue;
|
|
1097
1103
|
const cwd = cwds[i] ?? entry?.cwd ?? undefined;
|
|
1098
1104
|
const sessionFile = findSessionFileForKind(kind, cwd, exactId);
|
|
1099
1105
|
const topic = sessionFile ? quickExtractTopic(sessionFile) : undefined;
|
|
1100
1106
|
const host = detectHost(pid, procByPid);
|
|
1101
|
-
const
|
|
1107
|
+
const tty = procByPid.get(pid)?.tty;
|
|
1108
|
+
const context = unattributedContext(host, tty);
|
|
1102
1109
|
const { state, tokPerSec } = computeLiveSignals(kind, sessionFile, cwd, true);
|
|
1103
1110
|
const { birthtimeMs, mtimeMs } = sessionFileTimes(sessionFile);
|
|
1104
1111
|
const resolvedId = exactId ?? sessionIdFromFile(kind, sessionFile);
|
|
@@ -1109,7 +1116,7 @@ async function listUnattributedActiveLive(attributed) {
|
|
|
1109
1116
|
kind,
|
|
1110
1117
|
harness: entry?.harness,
|
|
1111
1118
|
host,
|
|
1112
|
-
tty
|
|
1119
|
+
tty,
|
|
1113
1120
|
pid,
|
|
1114
1121
|
cwd,
|
|
1115
1122
|
sessionId: resolvedId,
|
|
@@ -1119,10 +1126,11 @@ async function listUnattributedActiveLive(attributed) {
|
|
|
1119
1126
|
tokPerSec,
|
|
1120
1127
|
sessionFile,
|
|
1121
1128
|
startedAtMs: hookRec?.ts ?? birthtimeMs,
|
|
1129
|
+
processStartedAtMs: parseStartMs(procByPid.get(pid)?.startTime ?? '') ?? undefined,
|
|
1122
1130
|
lastActivityMs: mtimeMs,
|
|
1123
1131
|
pidCount: 1 + (foldedByRoot.get(pid) ?? 0),
|
|
1124
1132
|
owner: resolveOwner(entry?.actor, resolvedId),
|
|
1125
|
-
launchId
|
|
1133
|
+
launchId,
|
|
1126
1134
|
terminalId: entry?.terminalId ?? hookRec?.terminal_id,
|
|
1127
1135
|
originTerminal: entry?.originTerminal,
|
|
1128
1136
|
}, state, sessionFile, true));
|
|
@@ -63,7 +63,7 @@ export class SessionProjection {
|
|
|
63
63
|
continue;
|
|
64
64
|
selected.set(`${candidate.scope}\0${chosen.rowKey}`, rowKey);
|
|
65
65
|
const observerTerminals = observations.filter(item => !item.row.previous && (item.row.terminalId || item.row.viewingIn || item.row.provenance?.reply))
|
|
66
|
-
.map(({ scope: device, row }) => ({ device, terminalId: row.terminalId, launchId: row.launchId, viewingIn: row.viewingIn, provenance: row.provenance }));
|
|
66
|
+
.map(({ scope: device, row }) => ({ device, terminalId: row.terminalId, launchId: row.launchId, viewingIn: row.viewingIn, provenance: row.provenance, ...(row.workspaceDir ? { workspaceDir: row.workspaceDir } : {}) }));
|
|
67
67
|
const origin = chosen.originTerminal;
|
|
68
68
|
if (!chosen.previous && origin && normalizeHost(origin.device) !== owner) {
|
|
69
69
|
const device = normalizeHost(origin.device);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@phnx-labs/agents-cli",
|
|
3
|
-
"version": "1.23.
|
|
3
|
+
"version": "1.23.7",
|
|
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",
|