@phnx-labs/agents-cli 1.23.25 → 1.23.27
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 +8 -0
- package/dist/commands/ps-roster.js +3 -1
- package/dist/lib/exec.js +2 -2
- package/dist/lib/memory.js +2 -2
- package/dist/lib/project-key.d.ts +1 -0
- package/dist/lib/project-key.js +8 -0
- package/dist/lib/session/active.d.ts +5 -2
- package/dist/lib/session/active.js +21 -14
- package/dist/lib/session/presentation.js +3 -3
- package/dist/lib/session/session-cache.d.ts +1 -1
- package/dist/lib/session/session-cache.js +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.23.27
|
|
4
|
+
|
|
5
|
+
- **A Claude session started in a symlinked folder shows its real state (PHNX-4387).** `agents ps` and the session feed looked for the transcript under the folder's path as typed, while Claude stores it under the folder's real path, so such a session showed "Running · no transcript" forever. They now look under both and take the newest; `agents run` and project memory sync use the real path too. Source: `cli/src/lib/session/active.ts`, `cli/src/lib/project-key.ts`, `cli/src/lib/exec.ts`, `cli/src/lib/memory.ts`.
|
|
6
|
+
|
|
7
|
+
## 1.23.26
|
|
8
|
+
|
|
9
|
+
- **`agents ps` says how long a working Claude turn has been quiet (PHNX-4387).** The list row shows `quiet Nm` where it showed `idle Nm` for a turn Claude reports busy, including one whose transcript tail holds only request records (Claude 2.1.261 appends 100+ KB of them after a step), where no quiet time was shown. `agents ps --json` carries `quietSinceMs`, when the turn went silent, in place of `quietMs`: a timestamp is stable across polls, so a quiet row no longer rewrites the active-sessions journal on every poll, and the age is computed when it is shown. Source: `cli/src/lib/session/active.ts`, `cli/src/commands/ps-roster.ts`, `cli/src/lib/session/presentation.ts`.
|
|
10
|
+
|
|
3
11
|
## 1.23.25
|
|
4
12
|
|
|
5
13
|
- **A Claude turn quiet for over two minutes stays `running` in `agents ps`.** Claude writes nothing to its transcript while it thinks or streams one long tool call, so a live turn turned idle after two minutes. agents-cli now passes the turn state Claude Code records in `<config>/sessions/<pid>.json` (`busy` / `idle`) to the state engine (`@phnx-labs/sessions-cli` 0.8.6): `busy` is `running`, `idle` is `idle`, and other harnesses keep the two-minute window. `agents ps --json` rows carry `quietMs` once a running turn has been silent past two minutes, and `agents ps <id>` shows `quiet Nm` beside `working`. Source: `cli/src/lib/session/active.ts`, `cli/src/lib/session/presentation.ts`.
|
|
@@ -96,7 +96,9 @@ function activeTimeCell(s) {
|
|
|
96
96
|
const parts = [];
|
|
97
97
|
if (s.startedAtMs)
|
|
98
98
|
parts.push(`created ${formatCompactAge(new Date(s.startedAtMs).toISOString())}`);
|
|
99
|
-
if (s.
|
|
99
|
+
if (s.activity === 'working' && s.quietSinceMs != null)
|
|
100
|
+
parts.push(`quiet ${formatCompactAge(new Date(s.quietSinceMs).toISOString())}`);
|
|
101
|
+
else if (s.lastActivityMs)
|
|
100
102
|
parts.push(`idle ${formatCompactAge(new Date(s.lastActivityMs).toISOString())}`);
|
|
101
103
|
return parts.join(' · ');
|
|
102
104
|
}
|
package/dist/lib/exec.js
CHANGED
|
@@ -42,7 +42,7 @@ import { claudeWorkerLoginTrapPreflight } from './harness/adapters/claude.js';
|
|
|
42
42
|
import { resolveConfigVersion } from './harness/exec-config-version.js';
|
|
43
43
|
import { getAccountInfo } from './agents.js';
|
|
44
44
|
import { getUsageLookupKey, noteClaudeSessionLimit, noteClaudeOutOfCredits, clearClaudeAccountRefusal, parseClaudeSessionLimitReset, noteClaudeModelRefusal, clearClaudeModelRefusal, parseClaudeModelRefusal, claudeModelRefusalKey, } from './accounting/usage.js';
|
|
45
|
-
import { claudeProjectDirName } from './project-key.js';
|
|
45
|
+
import { claudeProjectDirName, realCwd } from './project-key.js';
|
|
46
46
|
import { bootMark, flushBootProfile } from './boot-profile.js';
|
|
47
47
|
export function normalizeMode(input) {
|
|
48
48
|
if (!input) {
|
|
@@ -1061,7 +1061,7 @@ async function spawnAgent(options) {
|
|
|
1061
1061
|
const home = resolveExecConfigHome(options).versionHome;
|
|
1062
1062
|
const modelKey = claudeModelRefusalKey(options.accountId, home);
|
|
1063
1063
|
const transcript = options.agent === 'claude' && home && options.sessionId
|
|
1064
|
-
? path.join(home, '.claude', 'projects', claudeProjectDirName(options.cwd || process.cwd()), `${options.sessionId}.jsonl`)
|
|
1064
|
+
? path.join(home, '.claude', 'projects', claudeProjectDirName(realCwd(options.cwd || process.cwd())), `${options.sessionId}.jsonl`)
|
|
1065
1065
|
: undefined;
|
|
1066
1066
|
let offset = transcript && fs.existsSync(transcript) ? fs.statSync(transcript).size : 0;
|
|
1067
1067
|
const observeTranscript = () => {
|
package/dist/lib/memory.js
CHANGED
|
@@ -3,7 +3,7 @@ import * as path from 'path';
|
|
|
3
3
|
import { getUserAgentsDir, getSystemAgentsDir, getProjectAgentsDir, ensureAgentsDir, getRuntimeStateDir, } from './state.js';
|
|
4
4
|
import { agentConfigDirName } from './agents.js';
|
|
5
5
|
import { supports } from './capabilities.js';
|
|
6
|
-
import { claudeProjectDirName } from './project-key.js';
|
|
6
|
+
import { claudeProjectDirName, realCwd } from './project-key.js';
|
|
7
7
|
export function getUserMemoryDir() {
|
|
8
8
|
return path.join(getUserAgentsDir(), 'memory');
|
|
9
9
|
}
|
|
@@ -249,7 +249,7 @@ export function getClaudeProjectMemoryDir(cwd) {
|
|
|
249
249
|
export function syncClaudeProjectMemoryDir(versionHome, cwd = process.cwd()) {
|
|
250
250
|
const projectKey = claudeProjectDirName(path.resolve(cwd));
|
|
251
251
|
const canonicalDir = path.join(getRuntimeStateDir(), 'claude-project-memory', projectKey);
|
|
252
|
-
const projectDir = path.join(versionHome, agentConfigDirName('claude'), 'projects',
|
|
252
|
+
const projectDir = path.join(versionHome, agentConfigDirName('claude'), 'projects', claudeProjectDirName(realCwd(path.resolve(cwd))));
|
|
253
253
|
const nativeMemoryDir = path.join(projectDir, 'memory');
|
|
254
254
|
fs.mkdirSync(canonicalDir, { recursive: true, mode: 0o700 });
|
|
255
255
|
let existing;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare function claudeProjectDirName(cwd: string): string;
|
|
2
|
+
export declare function realCwd(cwd: string): string;
|
|
2
3
|
export declare function projectKeyFromCwd(cwd?: string | null): string | undefined;
|
|
3
4
|
export declare function repoRootForCwd(dir: string, home?: string): string | undefined;
|
|
4
5
|
export declare function repoAgentsDirForCwd(cwd?: string | null, home?: string): string | undefined;
|
package/dist/lib/project-key.js
CHANGED
|
@@ -5,6 +5,14 @@ const WORKTREE_SEGMENT = '/.agents/worktrees/';
|
|
|
5
5
|
export function claudeProjectDirName(cwd) {
|
|
6
6
|
return cwd.replace(/[/.]/g, '-');
|
|
7
7
|
}
|
|
8
|
+
export function realCwd(cwd) {
|
|
9
|
+
try {
|
|
10
|
+
return fs.realpathSync(cwd);
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
return cwd;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
8
16
|
export function projectKeyFromCwd(cwd) {
|
|
9
17
|
if (!cwd)
|
|
10
18
|
return undefined;
|
|
@@ -124,7 +124,7 @@ export interface ActiveSession {
|
|
|
124
124
|
accountLabel?: string;
|
|
125
125
|
lastActivityMs?: number;
|
|
126
126
|
lastEventMs?: number;
|
|
127
|
-
|
|
127
|
+
quietSinceMs?: number;
|
|
128
128
|
status: ActiveStatus;
|
|
129
129
|
phase?: SessionPhase;
|
|
130
130
|
origin?: 'cli' | 'routine';
|
|
@@ -198,8 +198,11 @@ export declare function lifecycleStatus(pidAlive: boolean, mtimeMs: number | und
|
|
|
198
198
|
export declare function resolveFallbackStatus(sessionFile: string | undefined, pidAlive: boolean, nowMs?: number): ActiveStatus;
|
|
199
199
|
export declare function findSessionFileForKind(kind: string, cwd?: string, sessionId?: string): string | undefined;
|
|
200
200
|
export declare function sessionIdFromFile(kind: string, file?: string): string | undefined;
|
|
201
|
+
type LiveState = SessionState & {
|
|
202
|
+
quietSinceMs?: number;
|
|
203
|
+
};
|
|
201
204
|
interface LiveSignals {
|
|
202
|
-
state?:
|
|
205
|
+
state?: LiveState;
|
|
203
206
|
tokPerSec?: number;
|
|
204
207
|
}
|
|
205
208
|
export declare function clearLiveSignalsCacheForTest(): void;
|
|
@@ -34,7 +34,7 @@ import { classifyHostLink, hostWindowLost, HOST_HEARTBEAT_STALE_MS } from './hos
|
|
|
34
34
|
import { mapBounded } from '../concurrency.js';
|
|
35
35
|
import { linearIssueUrl } from '@phnx-labs/sessions-cli/reader';
|
|
36
36
|
import { viewingInLabel } from './viewing-in.js';
|
|
37
|
-
import { claudeProjectDirName } from '../project-key.js';
|
|
37
|
+
import { claudeProjectDirName, realCwd } from '../project-key.js';
|
|
38
38
|
import { gatherRemoteActive, NO_FANOUT_ENV } from './remote-active.js';
|
|
39
39
|
import { hostToken, remoteHostsToDial, shouldIncludeLocal } from './remote-list.js';
|
|
40
40
|
const execFileAsync = promisify(execFile);
|
|
@@ -450,21 +450,23 @@ function findClaudeSessionFile(cwd, sessionId) {
|
|
|
450
450
|
return pickClaudeSessionFileAcrossRoots(getAgentSessionDirs('claude', 'projects'), cwd, sessionId);
|
|
451
451
|
}
|
|
452
452
|
export function pickClaudeSessionFileAcrossRoots(projectRoots, cwd, sessionId) {
|
|
453
|
-
const
|
|
453
|
+
const encs = [...new Set([cwd, realCwd(cwd)].map(claudeProjectDirName))];
|
|
454
454
|
let best;
|
|
455
455
|
for (const root of projectRoots) {
|
|
456
|
-
const
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
456
|
+
for (const enc of encs) {
|
|
457
|
+
const hit = pickSessionFile(path.join(root, enc), sessionId);
|
|
458
|
+
if (!hit)
|
|
459
|
+
continue;
|
|
460
|
+
let mtime;
|
|
461
|
+
try {
|
|
462
|
+
mtime = fs.statSync(hit).mtimeMs;
|
|
463
|
+
}
|
|
464
|
+
catch {
|
|
465
|
+
continue;
|
|
466
|
+
}
|
|
467
|
+
if (!best || mtime > best.mtime)
|
|
468
|
+
best = { path: hit, mtime };
|
|
465
469
|
}
|
|
466
|
-
if (!best || mtime > best.mtime)
|
|
467
|
-
best = { path: hit, mtime };
|
|
468
470
|
}
|
|
469
471
|
return best?.path;
|
|
470
472
|
}
|
|
@@ -591,6 +593,11 @@ export function computeLiveSignals(kind, sessionFile, cwd, pidAlive, nowMs = Dat
|
|
|
591
593
|
if (tail.events.length === 0 && harnessStatus !== 'busy')
|
|
592
594
|
return {};
|
|
593
595
|
const state = inferSessionState(tail.events, { cwd, pidAlive, mtimeMs, harnessStatus, activeWindowMs: ACTIVE_MTIME_WINDOW_MS, nowMs });
|
|
596
|
+
if (harnessStatus === 'busy' && state.activity === 'working') {
|
|
597
|
+
const quietSinceMs = state.quietMs != null ? nowMs - state.quietMs : tail.events.length === 0 ? mtimeMs : undefined;
|
|
598
|
+
if (quietSinceMs != null && nowMs - quietSinceMs >= ACTIVE_MTIME_WINDOW_MS)
|
|
599
|
+
state.quietSinceMs = quietSinceMs;
|
|
600
|
+
}
|
|
594
601
|
return { state, tokPerSec: tail.tokPerSec };
|
|
595
602
|
}
|
|
596
603
|
function statusFromActivity(activity) {
|
|
@@ -611,7 +618,7 @@ function applyState(base, state, fallbackFile, pidAlive) {
|
|
|
611
618
|
awaitingReason: state.awaitingReason,
|
|
612
619
|
question: state.question,
|
|
613
620
|
lastEventMs: state.lastEventMs,
|
|
614
|
-
|
|
621
|
+
quietSinceMs: state.quietSinceMs,
|
|
615
622
|
plan: state.plan,
|
|
616
623
|
todos: state.todos,
|
|
617
624
|
tail: state.tail,
|
|
@@ -9,7 +9,7 @@ import { homeDir, toComparablePath } from '../platform/index.js';
|
|
|
9
9
|
import { redactSecrets, sanitizeForTerminal } from '../redact.js';
|
|
10
10
|
import { listBookmarks } from './bookmarks.js';
|
|
11
11
|
import { readArchivedSessionPreview, readSessionContent, readSessionTimelineAny } from './db.js';
|
|
12
|
-
import { formatRelativeTime, sessionAgeParts } from './relative-time.js';
|
|
12
|
+
import { formatCompactAge, formatRelativeTime, sessionAgeParts } from './relative-time.js';
|
|
13
13
|
import { ticketLabel } from './selection.js';
|
|
14
14
|
import { sessionHeadline } from './title.js';
|
|
15
15
|
import { padToWidth, stringWidth, terminalWidth, truncateToWidth } from './width.js';
|
|
@@ -340,8 +340,8 @@ export function formatLiveStatusHeadline(live, bookmarked = false) {
|
|
|
340
340
|
const needsYou = isAwaitingUser(live);
|
|
341
341
|
const reason = live.awaitingReason ? ` (${live.awaitingReason.replace('_', ' ')})` : '';
|
|
342
342
|
let suffix = needsYou ? chalk.yellow(` ← needs you${reason}`) : '';
|
|
343
|
-
if (word === 'working' && live.
|
|
344
|
-
suffix = chalk.dim(` quiet ${
|
|
343
|
+
if (word === 'working' && live.quietSinceMs != null)
|
|
344
|
+
suffix = chalk.dim(` quiet ${formatCompactAge(new Date(live.quietSinceMs).toISOString())}`);
|
|
345
345
|
if (live.status === 'crashed') {
|
|
346
346
|
suffix = chalk.redBright(' ← the host app or connection went away and took the agent with it');
|
|
347
347
|
}
|
|
@@ -38,7 +38,7 @@ interface ImmutableSessionFields {
|
|
|
38
38
|
context?: ActiveSession['context'];
|
|
39
39
|
}
|
|
40
40
|
export declare const IMMUTABLE_FIELD_KEYS: readonly ["topic", "firstUserMessage", "label", "name", "cwd", "project", "attachments", "startedAtMs", "version", "pr", "worktree", "ticket", "createdTickets", "spawnedTeam", "sessionFile", "owner", "assignedTask", "kind", "context"];
|
|
41
|
-
export declare const LIVE_STATUS_KEYS: readonly ["status", "activity", "model", "failures", "activityHistogram", "userTurns", "subagents", "pending", "effort", "fast", "preview", "tokPerSec", "awaitingReason", "question", "todos", "tail", "lastActivityMs", "lastEventMs", "hostLink", "presence", "pidAlive", "tmuxClients", "windowHeartbeatMs", "provenance", "rateLimited", "plan"];
|
|
41
|
+
export declare const LIVE_STATUS_KEYS: readonly ["status", "activity", "model", "failures", "activityHistogram", "userTurns", "subagents", "pending", "effort", "fast", "preview", "tokPerSec", "awaitingReason", "question", "todos", "tail", "lastActivityMs", "lastEventMs", "quietSinceMs", "hostLink", "presence", "pidAlive", "tmuxClients", "windowHeartbeatMs", "provenance", "rateLimited", "plan"];
|
|
42
42
|
export declare const ACTIVE_SESSIONS_READER_IDLE_WINDOW_MS = 45000;
|
|
43
43
|
export declare function setActiveSessionsSnapshotPathForTest(p: string | null): string | null;
|
|
44
44
|
export declare function clearActiveSnapshotMemoryForTest(): void;
|
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.27",
|
|
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",
|