@phnx-labs/agents-cli 1.23.35 → 1.23.37

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.
Files changed (42) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/commands/config.js +9 -7
  3. package/dist/commands/feed-watch.js +2 -1
  4. package/dist/commands/lead.js +65 -13
  5. package/dist/commands/projects.js +34 -2
  6. package/dist/lib/config-keys.d.ts +1 -1
  7. package/dist/lib/config-keys.js +6 -4
  8. package/dist/lib/device-config.js +9 -0
  9. package/dist/lib/github/project-prs.d.ts +7 -0
  10. package/dist/lib/github/project-prs.js +22 -0
  11. package/dist/lib/lead/act.d.ts +10 -0
  12. package/dist/lib/lead/act.js +119 -0
  13. package/dist/lib/lead/brief.d.ts +2 -0
  14. package/dist/lib/lead/brief.js +16 -5
  15. package/dist/lib/lead/client.d.ts +0 -3
  16. package/dist/lib/lead/client.js +1 -50
  17. package/dist/lib/lead/confirm.d.ts +12 -10
  18. package/dist/lib/lead/confirm.js +1 -0
  19. package/dist/lib/lead/events.d.ts +4 -2
  20. package/dist/lib/lead/events.js +5 -3
  21. package/dist/lib/lead/harness.d.ts +2 -3
  22. package/dist/lib/lead/harness.js +4 -4
  23. package/dist/lib/lead/host.d.ts +15 -8
  24. package/dist/lib/lead/host.js +63 -35
  25. package/dist/lib/lead/roster.d.ts +18 -0
  26. package/dist/lib/lead/roster.js +75 -0
  27. package/dist/lib/lead/shapes.d.ts +42 -0
  28. package/dist/lib/lead/shapes.js +202 -1
  29. package/dist/lib/lead/speak.d.ts +35 -0
  30. package/dist/lib/lead/speak.js +165 -0
  31. package/dist/lib/lead/store.d.ts +1 -0
  32. package/dist/lib/lead/tools.d.ts +11 -0
  33. package/dist/lib/lead/tools.js +98 -37
  34. package/dist/lib/lead/visibility.d.ts +1 -1
  35. package/dist/lib/lead/visibility.js +14 -4
  36. package/dist/lib/session/active.js +2 -2
  37. package/dist/lib/session/hook-sessions.d.ts +2 -8
  38. package/dist/lib/session/hook-sessions.js +3 -36
  39. package/dist/lib/session/pid-registry.d.ts +11 -0
  40. package/dist/lib/session/pid-registry.js +41 -3
  41. package/dist/lib/session/touched.js +1 -0
  42. package/package.json +1 -1
@@ -57,21 +57,31 @@ export function hideLeadInSessionEnvelope(event, hostSessionIds) {
57
57
  }
58
58
  return event;
59
59
  }
60
- export function hideLeadInFeedEnvelope(event, hostSessionIds) {
60
+ export function hideLeadInFeedEnvelope(event, hostSessionIds, hidden = new Set()) {
61
61
  const e = event;
62
+ const isHiddenAsk = (a) => !!a.sessionId && (hidden.has(a.sessionId) || hostSessionIds.has(a.sessionId));
62
63
  if (e.type === 'reset') {
63
64
  const agents = e.agents ?? [];
64
65
  const attention = e.attention ?? [];
65
- const hidden = new Set(agents.filter((a) => isLeadSession(a, hostSessionIds)).map((a) => a.sessionId).filter(Boolean));
66
+ for (const a of agents)
67
+ if (a.sessionId && isLeadSession(a, hostSessionIds))
68
+ hidden.add(a.sessionId);
66
69
  return {
67
70
  ...event,
68
71
  agents: agents.filter((a) => !isLeadSession(a, hostSessionIds)),
69
- attention: attention.filter((a) => !a.sessionId || !hidden.has(a.sessionId)),
72
+ attention: attention.filter((a) => !isHiddenAsk(a)),
70
73
  };
71
74
  }
72
75
  if (e.type === 'agent.upsert' && isLeadSession(e.agent, hostSessionIds)) {
73
- const { agent: _agent, ...rest } = e;
76
+ const { agent, ...rest } = e;
77
+ const id = agent.sessionId;
78
+ if (id)
79
+ hidden.add(id);
74
80
  return { ...rest, type: 'agent.remove' };
75
81
  }
82
+ if (e.type === 'attention.upsert' && isHiddenAsk((e.attention ?? {}))) {
83
+ const { attention: _attention, ...rest } = e;
84
+ return { ...rest, type: 'attention.remove' };
85
+ }
76
86
  return event;
77
87
  }
@@ -11,9 +11,9 @@ import { AgentManager } from '../teams/agents.js';
11
11
  import { getTerminalsDir, readMeta } from '../state.js';
12
12
  import { listNativeAccounts } from '../account-registry.js';
13
13
  import { parseNativeIdentityKey } from '../native-accounts.js';
14
- import { readLivePidSessionEntry as readPidSessionEntry, listPidSessionEntries, prunePidSessionRegistry, sessionIdFromLivePid, } from './pid-registry.js';
14
+ import { readLivePidSessionEntry as readPidSessionEntry, listPidSessionEntries, prunePidSessionRegistry, readStateSessionRecord, sessionIdFromLivePid, } from './pid-registry.js';
15
15
  import { readSessionActorRecord, writeSessionAliasRecord } from './actor-sidecar.js';
16
- import { loadHookSessionIndex, resolveHookSessionRecord, readStateSessionRecord, readDoneVerdict } from './hook-sessions.js';
16
+ import { loadHookSessionIndex, resolveHookSessionRecord, readDoneVerdict } from './hook-sessions.js';
17
17
  import { extractClaudeUserText, getAgentSessionDirs, readClaudeLiveNames } from './discover.js';
18
18
  import { buildRunNameMap } from './run-names.js';
19
19
  import { cleanDisplayTitle, isPlaceholderSessionName, resolveSessionName, startedAsFromUserTurn } from './title.js';
@@ -1,14 +1,9 @@
1
- import { type PidSessionEntry } from './pid-registry.js';
2
- export interface HookSessionRecord {
3
- session_id: string;
1
+ import { type PidSessionEntry, type SessionStartRecord } from './pid-registry.js';
2
+ export interface HookSessionRecord extends SessionStartRecord {
4
3
  agent?: string;
5
- cwd?: string;
6
- pid: number;
7
4
  launch_id?: string;
8
5
  terminal_id?: string;
9
- ts?: number;
10
6
  completed?: boolean;
11
- verdict?: unknown;
12
7
  }
13
8
  export interface DoneVerdict {
14
9
  state: 'done' | 'open' | 'unchecked';
@@ -20,7 +15,6 @@ export interface HookSessionIndex {
20
15
  byTerminalId: Map<string, HookSessionRecord>;
21
16
  byPid: Map<number, HookSessionRecord>;
22
17
  }
23
- export declare function readStateSessionRecord(pid: number, startedAtMs?: number): HookSessionRecord | undefined;
24
18
  export declare function readDoneVerdict(pid: number, sessionId: string, processStartedAtMs?: number): DoneVerdict | undefined;
25
19
  export declare function captureLaunchBinding(pid: number | undefined, launchId: string): PidSessionEntry | undefined;
26
20
  export declare function recordCompletedLaunch(binding: PidSessionEntry | undefined): void;
@@ -4,34 +4,12 @@ import { execFileSync } from 'node:child_process';
4
4
  import { atomicWriteFileSync } from '../fs-atomic.js';
5
5
  import { hostProcessView } from './process-view.js';
6
6
  import path from 'path';
7
- import { getTerminalsDir, getRuntimeStateDir } from '../state.js';
8
- import { listPidSessionEntries, pidSessionEntryMatchesLiveProcess, readLivePidSessionEntry, readPidSessionEntry } from './pid-registry.js';
9
- const RECORD_SKEW_MS = 5_000;
7
+ import { getTerminalsDir } from '../state.js';
8
+ import { listPidSessionEntries, parseSessionRecord, pidSessionEntryMatchesLiveProcess, readLivePidSessionEntry, readPidSessionEntry, readStateSessionRecord, RECORD_SKEW_MS, stateSessionRecordPath, } from './pid-registry.js';
10
9
  const VERDICT_STATES = new Set(['done', 'open', 'unchecked']);
11
10
  function hookSessionsDir() {
12
11
  return path.join(getTerminalsDir(), 'sessions');
13
12
  }
14
- function stateSessionRecordPath(pid) {
15
- return path.join(getRuntimeStateDir(), 'sessions', `${pid}.json`);
16
- }
17
- export function readStateSessionRecord(pid, startedAtMs) {
18
- if (!pid || pid < 1)
19
- return undefined;
20
- let rec;
21
- try {
22
- rec = parseRecord(fs.readFileSync(stateSessionRecordPath(pid), 'utf8'));
23
- }
24
- catch {
25
- return undefined;
26
- }
27
- if (!rec)
28
- return undefined;
29
- if (startedAtMs !== undefined && typeof rec.ts === 'number') {
30
- if (rec.ts * 1000 < startedAtMs - RECORD_SKEW_MS)
31
- return undefined;
32
- }
33
- return rec;
34
- }
35
13
  export function readDoneVerdict(pid, sessionId, processStartedAtMs) {
36
14
  const rec = readStateSessionRecord(pid, processStartedAtMs);
37
15
  if (!rec || rec.pid !== pid || rec.session_id !== sessionId)
@@ -46,17 +24,6 @@ export function readDoneVerdict(pid, sessionId, processStartedAtMs) {
46
24
  const gaps = Array.isArray(v.gaps) ? v.gaps.filter((g) => typeof g === 'string' && g.length > 0) : [];
47
25
  return { state: v.state, gaps, at: new Date(v.at).toISOString() };
48
26
  }
49
- function parseRecord(raw) {
50
- try {
51
- const o = JSON.parse(raw);
52
- if (o && typeof o === 'object' && typeof o.session_id === 'string' && o.session_id) {
53
- return o;
54
- }
55
- }
56
- catch {
57
- }
58
- return undefined;
59
- }
60
27
  function keepNewest(map, key, rec) {
61
28
  const prev = map.get(key);
62
29
  if (!prev || (rec.ts ?? 0) > (prev.ts ?? 0))
@@ -158,7 +125,7 @@ export function loadHookSessionIndex() {
158
125
  for (const f of files) {
159
126
  let rec;
160
127
  try {
161
- rec = parseRecord(fs.readFileSync(path.join(hookSessionsDir(), f), 'utf8'));
128
+ rec = parseSessionRecord(fs.readFileSync(path.join(hookSessionsDir(), f), 'utf8'));
162
129
  }
163
130
  catch {
164
131
  }
@@ -21,6 +21,17 @@ export interface PidSessionEntry {
21
21
  startTime?: string;
22
22
  };
23
23
  }
24
+ export interface SessionStartRecord {
25
+ session_id: string;
26
+ pid: number;
27
+ cwd?: string;
28
+ ts?: number;
29
+ verdict?: unknown;
30
+ }
31
+ export declare const RECORD_SKEW_MS = 5000;
32
+ export declare function parseSessionRecord<T extends SessionStartRecord = SessionStartRecord>(raw: string): T | undefined;
33
+ export declare function stateSessionRecordPath(pid: number): string;
34
+ export declare function readStateSessionRecord<T extends SessionStartRecord = SessionStartRecord>(pid: number, startedAtMs?: number): T | undefined;
24
35
  export declare function processStartTimesMatch(recorded: string | undefined, observed: string | undefined): boolean | undefined;
25
36
  export declare function pidSessionEntryMatchesLiveProcess(entry: PidSessionEntry, startTime?: string): boolean | undefined;
26
37
  export declare function isSessionIdShape(value: string): boolean;
@@ -3,8 +3,46 @@ import { spanSync } from '../daemon/diagnostics.js';
3
3
  import path from 'path';
4
4
  import { execFileSync } from 'child_process';
5
5
  import { hostProcessView, writerProcessView } from './process-view.js';
6
- import { getTerminalsDir } from '../state.js';
6
+ import { getTerminalsDir, getRuntimeStateDir } from '../state.js';
7
7
  import { atomicWriteFileSync, withFileLock } from '../fs-atomic.js';
8
+ export const RECORD_SKEW_MS = 5_000;
9
+ export function parseSessionRecord(raw) {
10
+ try {
11
+ const o = JSON.parse(raw);
12
+ if (o && typeof o === 'object' && typeof o.session_id === 'string' && o.session_id)
13
+ return o;
14
+ }
15
+ catch {
16
+ }
17
+ return undefined;
18
+ }
19
+ export function stateSessionRecordPath(pid) {
20
+ return path.join(getRuntimeStateDir(), 'sessions', `${pid}.json`);
21
+ }
22
+ export function readStateSessionRecord(pid, startedAtMs) {
23
+ if (!pid || pid < 1)
24
+ return undefined;
25
+ let rec;
26
+ try {
27
+ rec = parseSessionRecord(fs.readFileSync(stateSessionRecordPath(pid), 'utf8'));
28
+ }
29
+ catch {
30
+ return undefined;
31
+ }
32
+ if (!rec)
33
+ return undefined;
34
+ if (startedAtMs !== undefined && typeof rec.ts === 'number') {
35
+ if (rec.ts * 1000 < startedAtMs - RECORD_SKEW_MS)
36
+ return undefined;
37
+ }
38
+ return rec;
39
+ }
40
+ function ownSession(entry) {
41
+ const own = readStateSessionRecord(entry.pid, entry.startedAtMs);
42
+ return own && own.pid === entry.pid && entry.sessionId && own.session_id !== entry.sessionId
43
+ ? { ...entry, sessionId: own.session_id }
44
+ : entry;
45
+ }
8
46
  function linuxStartTicks(pid) {
9
47
  try {
10
48
  const stat = fs.readFileSync(`/proc/${pid}/stat`, 'utf8');
@@ -188,7 +226,7 @@ export function readPidSessionEntry(pid) {
188
226
  try {
189
227
  const parsed = JSON.parse(raw);
190
228
  if (parsed && typeof parsed === 'object' && parsed.pid === pid) {
191
- return restoreOwnership(parsed);
229
+ return ownSession(restoreOwnership(parsed));
192
230
  }
193
231
  }
194
232
  catch {
@@ -230,7 +268,7 @@ export function listPidSessionEntries() {
230
268
  try {
231
269
  const parsed = JSON.parse(fs.readFileSync(path.join(pidRegistryDir(), f), 'utf8'));
232
270
  if (parsed && typeof parsed === 'object' && typeof parsed.pid === 'number') {
233
- out.push(restoreOwnership(parsed));
271
+ out.push(ownSession(restoreOwnership(parsed)));
234
272
  }
235
273
  }
236
274
  catch {
@@ -24,6 +24,7 @@ const AGENTS_PRS_ACTIONS = {
24
24
  merge: 'merged',
25
25
  review: 'reviewed',
26
26
  comment: 'commented',
27
+ close: 'closed',
27
28
  };
28
29
  const LINEAR_UPDATE_VALUE_FLAGS = new Set([
29
30
  '--status', '--comment', '--proof', '--label', '--unlabel', '--priority', '--assign', '--delegate',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phnx-labs/agents-cli",
3
- "version": "1.23.35",
3
+ "version": "1.23.37",
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",