@phnx-labs/agents-cli 1.22.127 → 1.23.1
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 +108 -0
- package/README.md +15 -16
- package/dist/bootstrap.js +4 -3
- package/dist/commands/browser.js +4 -19
- package/dist/commands/cloud-transcripts.js +1 -2
- package/dist/commands/computer.d.ts +2 -6
- package/dist/commands/computer.js +12 -18
- package/dist/commands/daemon.js +70 -11
- package/dist/commands/exec.js +1 -1
- package/dist/commands/feed.js +1 -2
- package/dist/commands/focus.js +4 -1
- package/dist/commands/go.js +3 -2
- package/dist/commands/logs.js +3 -7
- package/dist/commands/menubar.js +55 -3
- package/dist/commands/projects.js +103 -40
- package/dist/commands/ps-roster.d.ts +0 -11
- package/dist/commands/ps-roster.js +3 -116
- package/dist/commands/ps.d.ts +10 -0
- package/dist/commands/ps.js +182 -1
- package/dist/commands/resume.js +1 -1
- package/dist/commands/sessions-browser.d.ts +0 -1
- package/dist/commands/sessions-browser.js +6 -23
- package/dist/commands/sessions-export.js +1 -1
- package/dist/commands/sessions-migrate.js +1 -1
- package/dist/commands/sessions-picker.d.ts +6 -32
- package/dist/commands/sessions-picker.js +81 -8
- package/dist/commands/sessions-render.js +1 -1
- package/dist/commands/sessions-resume.js +2 -2
- package/dist/commands/sessions-share.js +1 -1
- package/dist/commands/sessions-trace.js +1 -1
- package/dist/commands/sessions.d.ts +2 -176
- package/dist/commands/sessions.js +44 -1577
- package/dist/index.js +10 -11
- package/dist/lib/browser-client.d.ts +0 -21
- package/dist/lib/browser-client.js +1 -44
- package/dist/lib/computer/record.d.ts +1 -0
- package/dist/lib/computer/record.js +2 -16
- package/dist/lib/config-keys.d.ts +2 -2
- package/dist/lib/config-keys.js +8 -2
- package/dist/lib/daemon/account-state-daemon-service.d.ts +2 -2
- package/dist/lib/daemon/account-state-daemon-service.js +2 -2
- package/dist/lib/daemon/attention-notify-service.js +8 -4
- package/dist/lib/daemon/daemon.d.ts +5 -1
- package/dist/lib/daemon/daemon.js +54 -14
- package/dist/lib/daemon/diagnostics.d.ts +70 -0
- package/dist/lib/daemon/diagnostics.js +185 -0
- package/dist/lib/daemon/runner.js +3 -2
- package/dist/lib/daemon/service.d.ts +1 -1
- package/dist/lib/daemon/session-state-service.d.ts +1 -1
- package/dist/lib/daemon/session-state-service.js +2 -2
- package/dist/lib/daemon/supervisor.d.ts +8 -0
- package/dist/lib/daemon/supervisor.js +47 -6
- package/dist/lib/daemon-services.d.ts +4 -1
- package/dist/lib/daemon-services.js +36 -5
- package/dist/lib/daemon-ticks.d.ts +3 -1
- package/dist/lib/daemon-ticks.js +18 -12
- package/dist/lib/device-config.d.ts +1 -1
- package/dist/lib/device-config.js +48 -7
- package/dist/lib/feed/tool-activity.d.ts +22 -10
- package/dist/lib/feed/tool-activity.js +168 -32
- package/dist/lib/feed/tools.d.ts +55 -2
- package/dist/lib/feed/tools.js +22 -28
- package/dist/lib/feed/watch.js +12 -8
- package/dist/lib/github/open-prs.d.ts +41 -0
- package/dist/lib/github/open-prs.js +157 -0
- package/dist/lib/github/project-prs.d.ts +20 -1
- package/dist/lib/github/project-prs.js +8 -7
- package/dist/lib/helper-versions.js +1 -1
- package/dist/lib/menubar/install-menubar.d.ts +23 -7
- package/dist/lib/menubar/install-menubar.js +179 -30
- package/dist/lib/menubar/resolve-version.d.ts +1 -0
- package/dist/lib/menubar/resolve-version.js +4 -2
- package/dist/lib/menubar/snapshot.d.ts +2 -0
- package/dist/lib/menubar/snapshot.js +2 -0
- package/dist/lib/menubar/update-state.d.ts +15 -0
- package/dist/lib/menubar/update-state.js +36 -0
- package/dist/lib/owner-notify.d.ts +0 -12
- package/dist/lib/owner-notify.js +1 -10
- package/dist/lib/self-heal/checks/menubar-helper.js +1 -0
- package/dist/lib/session/active.js +18 -14
- package/dist/lib/session/cloud.d.ts +0 -1
- package/dist/lib/session/cloud.js +0 -5
- package/dist/lib/session/db.d.ts +0 -64
- package/dist/lib/session/db.js +0 -116
- package/dist/lib/session/pid-registry.js +9 -6
- package/dist/lib/session/presentation.d.ts +107 -1
- package/dist/lib/session/presentation.js +543 -4
- package/dist/lib/session/remote/remote-list.d.ts +5 -36
- package/dist/lib/session/remote/remote-list.js +16 -320
- package/dist/lib/session/resume-command.d.ts +9 -0
- package/dist/lib/session/resume-command.js +107 -0
- package/dist/lib/session/selection.d.ts +102 -0
- package/dist/lib/session/selection.js +443 -0
- package/dist/lib/session/tool-index.d.ts +0 -62
- package/dist/lib/session/tool-index.js +1 -537
- package/dist/lib/sessions-client.d.ts +1 -0
- package/dist/lib/sessions-client.js +17 -1
- package/dist/lib/standalone-tools.js +2 -2
- package/dist/lib/testdata/owner-notify-api.d.ts +0 -13
- package/dist/lib/testdata/owner-notify-api.js +3 -23
- package/package.json +1 -1
- package/dist/commands/browser-sessions-picker.d.ts +0 -9
- package/dist/commands/browser-sessions-picker.js +0 -136
- package/dist/commands/computer-sessions-picker.d.ts +0 -11
- package/dist/commands/computer-sessions-picker.js +0 -90
- package/dist/commands/sessions-tail.d.ts +0 -13
- package/dist/commands/sessions-tail.js +0 -222
- package/dist/lib/browser/native-history.test-fixture.d.ts +0 -12
- package/dist/lib/browser/native-history.test-fixture.js +0 -43
- package/dist/lib/browser/paths.d.ts +0 -9
- package/dist/lib/browser/paths.js +0 -31
- package/dist/lib/browser/record.d.ts +0 -4
- package/dist/lib/browser/record.js +0 -19
- package/dist/lib/browser/sessions-list.d.ts +0 -79
- package/dist/lib/browser/sessions-list.js +0 -415
- package/dist/lib/computer/sessions-list.d.ts +0 -78
- package/dist/lib/computer/sessions-list.js +0 -372
- package/dist/lib/daemon/owner-device-delivery-service.d.ts +0 -10
- package/dist/lib/daemon/owner-device-delivery-service.js +0 -28
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getMenubarUpdateStatus } from './install-menubar.js';
|
|
1
2
|
import * as fs from 'fs';
|
|
2
3
|
import * as path from 'path';
|
|
3
4
|
import { httpsUrl } from '../actor.js';
|
|
@@ -132,6 +133,7 @@ export async function computeMenubarSnapshot() {
|
|
|
132
133
|
version: 1,
|
|
133
134
|
capturedAt: new Date().toISOString(),
|
|
134
135
|
cliVersion: getCliVersion(),
|
|
136
|
+
menubarUpdate: getMenubarUpdateStatus(),
|
|
135
137
|
routines,
|
|
136
138
|
recentSessions: JSON.parse(serializeSessionsJson(recent)),
|
|
137
139
|
activeSessions: serializeActiveSessionsForJson(activeSessions),
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const MENUBAR_AUTO_UPDATE_INTERVAL_MS: number;
|
|
2
|
+
export declare const menubarAutoUpdateEnabled: () => boolean;
|
|
3
|
+
export declare const updateStatePath: () => string;
|
|
4
|
+
export interface MenubarUpdateState {
|
|
5
|
+
outcome: 'unknown' | 'available' | 'updated' | 'current' | 'skipped' | 'failed';
|
|
6
|
+
installed: string | null;
|
|
7
|
+
available: string | null;
|
|
8
|
+
checkedAt: string | null;
|
|
9
|
+
nextCheckAt: string | null;
|
|
10
|
+
autoUpdate: boolean;
|
|
11
|
+
detail: string;
|
|
12
|
+
}
|
|
13
|
+
export declare function readUpdateState(): Partial<MenubarUpdateState>;
|
|
14
|
+
export declare function saveUpdateState(status: MenubarUpdateState): MenubarUpdateState;
|
|
15
|
+
export declare function menubarAutomaticUpdateDue(checkedAt: string | null, now?: number): boolean;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
import { getRuntimeStateDir } from '../state.js';
|
|
4
|
+
import { getConfigValue } from '../device-config.js';
|
|
5
|
+
export const MENUBAR_AUTO_UPDATE_INTERVAL_MS = 12 * 60 * 60 * 1000;
|
|
6
|
+
export const menubarAutoUpdateEnabled = () => getConfigValue('menubar.autoUpdate').value !== false;
|
|
7
|
+
export const updateStatePath = () => path.join(getRuntimeStateDir(), 'menubar-update.json');
|
|
8
|
+
export function readUpdateState() {
|
|
9
|
+
try {
|
|
10
|
+
const state = JSON.parse(fs.readFileSync(updateStatePath(), 'utf8'));
|
|
11
|
+
if (!state || typeof state !== 'object')
|
|
12
|
+
return {};
|
|
13
|
+
if (state.checkedAt != null && (typeof state.checkedAt !== 'string' || !Number.isFinite(Date.parse(state.checkedAt))))
|
|
14
|
+
return {};
|
|
15
|
+
if (!['unknown', 'available', 'updated', 'current', 'skipped', 'failed'].includes(state.outcome))
|
|
16
|
+
return {};
|
|
17
|
+
if (state.available != null && (typeof state.available !== 'string' || !/^\d+\.\d+\.\d+$/.test(state.available)))
|
|
18
|
+
return {};
|
|
19
|
+
if (typeof state.detail !== 'string')
|
|
20
|
+
return {};
|
|
21
|
+
return state;
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
return {};
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export function saveUpdateState(status) {
|
|
28
|
+
fs.mkdirSync(path.dirname(updateStatePath()), { recursive: true });
|
|
29
|
+
const tmp = `${updateStatePath()}.${process.pid}.tmp`;
|
|
30
|
+
fs.writeFileSync(tmp, JSON.stringify(status));
|
|
31
|
+
fs.renameSync(tmp, updateStatePath());
|
|
32
|
+
return status;
|
|
33
|
+
}
|
|
34
|
+
export function menubarAutomaticUpdateDue(checkedAt, now = Date.now()) {
|
|
35
|
+
return checkedAt === null || now - Date.parse(checkedAt) >= MENUBAR_AUTO_UPDATE_INTERVAL_MS;
|
|
36
|
+
}
|
|
@@ -24,13 +24,6 @@ export interface OwnerNotifyResult {
|
|
|
24
24
|
}>;
|
|
25
25
|
suppressed: null | 'duplicate' | 'quiet_hours';
|
|
26
26
|
}
|
|
27
|
-
export interface DeviceDelivery {
|
|
28
|
-
id: string;
|
|
29
|
-
channel: 'imessage';
|
|
30
|
-
address: string;
|
|
31
|
-
body: string;
|
|
32
|
-
createdAt: string;
|
|
33
|
-
}
|
|
34
27
|
export interface OwnerPreferencesPatch {
|
|
35
28
|
preferences?: Array<{
|
|
36
29
|
event: OwnerEvent;
|
|
@@ -66,10 +59,5 @@ export declare function resolveOwnerCredential(): OwnerCredential | null;
|
|
|
66
59
|
export declare const OWNER_DEDUP_PREFIX = "owner:";
|
|
67
60
|
export declare function hasUsableDeviceToken(device: string, cacheDir?: string): boolean;
|
|
68
61
|
export declare function postOwnerNotification(notification: OwnerNotification): Promise<OwnerNotifyResult>;
|
|
69
|
-
export declare function claimDeviceDeliveries(device: string, limit?: number): Promise<DeviceDelivery[]>;
|
|
70
|
-
export declare function reportDeviceDelivery(id: string, result: {
|
|
71
|
-
ok: boolean;
|
|
72
|
-
error?: string;
|
|
73
|
-
}): Promise<void>;
|
|
74
62
|
export declare function putOwnerPreferences(patch: OwnerPreferencesPatch): Promise<void>;
|
|
75
63
|
export declare function describeOwnerResult(result: OwnerNotifyResult): string;
|
package/dist/lib/owner-notify.js
CHANGED
|
@@ -87,8 +87,6 @@ async function rushRequest(method, route, body) {
|
|
|
87
87
|
}
|
|
88
88
|
if (response.ok && credential.kind === 'device')
|
|
89
89
|
fs.rmSync(rejectedTokenPath(getCacheDir()), { force: true });
|
|
90
|
-
if (response.status === 204)
|
|
91
|
-
return undefined;
|
|
92
90
|
const text = await response.text();
|
|
93
91
|
let payload = null;
|
|
94
92
|
try {
|
|
@@ -118,13 +116,6 @@ export function postOwnerNotification(notification) {
|
|
|
118
116
|
dedupKey: `${OWNER_DEDUP_PREFIX}${notification.dedupKey}`,
|
|
119
117
|
});
|
|
120
118
|
}
|
|
121
|
-
export async function claimDeviceDeliveries(device, limit = 10) {
|
|
122
|
-
const out = await rushRequest('POST', '/me/device-deliveries/claim', { device, limit });
|
|
123
|
-
return out.deliveries;
|
|
124
|
-
}
|
|
125
|
-
export async function reportDeviceDelivery(id, result) {
|
|
126
|
-
await rushRequest('POST', `/me/device-deliveries/${encodeURIComponent(id)}/result`, result);
|
|
127
|
-
}
|
|
128
119
|
export async function putOwnerPreferences(patch) {
|
|
129
120
|
await rushRequest('PUT', '/me/preferences', patch);
|
|
130
121
|
}
|
|
@@ -137,7 +128,7 @@ export function describeOwnerResult(result) {
|
|
|
137
128
|
if (result.delivered.length)
|
|
138
129
|
parts.push(`delivered ${result.delivered.join(', ')}`);
|
|
139
130
|
if (result.queued.length)
|
|
140
|
-
parts.push(`
|
|
131
|
+
parts.push(`Rush is sending ${result.queued.join(', ')}`);
|
|
141
132
|
for (const s of result.skipped)
|
|
142
133
|
parts.push(`skipped ${s.channel} (${s.reason})`);
|
|
143
134
|
return parts.join('; ') || 'no channel enabled for this event';
|
|
@@ -8,6 +8,7 @@ export const menubarHelperCheck = {
|
|
|
8
8
|
const { updateMenubarHelperIfNewer } = await import('../../menubar/install-menubar.js');
|
|
9
9
|
const r = await updateMenubarHelperIfNewer({ dryRun: ctx.dryRun });
|
|
10
10
|
switch (r.outcome) {
|
|
11
|
+
case 'available':
|
|
11
12
|
case 'updated': return resultOf([r.detail], []);
|
|
12
13
|
case 'failed': return resultOf([], [`AGI Menu ${r.installed ?? '?'} → ${r.available}: ${r.detail}`]);
|
|
13
14
|
default: return resultOf([], []);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { writerProcessView } from './process-view.js';
|
|
2
|
+
import { span, spanSync } from '../daemon/diagnostics.js';
|
|
2
3
|
import * as fs from 'fs';
|
|
3
4
|
import * as path from 'path';
|
|
4
5
|
import * as os from 'os';
|
|
@@ -1249,11 +1250,12 @@ export async function getActiveSessions(opts = {}) {
|
|
|
1249
1250
|
const { loadLocalActiveSessions } = await import('./session-cache.js');
|
|
1250
1251
|
return (await loadLocalActiveSessions()).sessions;
|
|
1251
1252
|
}
|
|
1253
|
+
const count = (rows) => () => ({ rows: rows.length });
|
|
1252
1254
|
const [tmuxAgents, teams, terminals, cloud] = await Promise.all([
|
|
1253
|
-
listTmuxAgentSessions().catch(() => []),
|
|
1254
|
-
listTeamsActive({ localOnly: opts.localOnly }).catch(() => []),
|
|
1255
|
-
listTerminalsActive().catch(() => []),
|
|
1256
|
-
Promise.resolve(listCloudActive()),
|
|
1255
|
+
span('active.tmux', () => listTmuxAgentSessions().catch(() => [])),
|
|
1256
|
+
span('active.teams', () => listTeamsActive({ localOnly: opts.localOnly }).catch(() => [])),
|
|
1257
|
+
span('active.terminals', () => listTerminalsActive().catch(() => [])),
|
|
1258
|
+
Promise.resolve(spanSync('active.cloud', () => listCloudActive())),
|
|
1257
1259
|
]);
|
|
1258
1260
|
const knownPids = new Set();
|
|
1259
1261
|
for (const s of tmuxAgents)
|
|
@@ -1265,17 +1267,19 @@ export async function getActiveSessions(opts = {}) {
|
|
|
1265
1267
|
for (const s of terminals)
|
|
1266
1268
|
if (s.pid)
|
|
1267
1269
|
knownPids.add(s.pid);
|
|
1268
|
-
const unattributed = opts.skipHeadless ? [] : await listUnattributedActive(knownPids);
|
|
1270
|
+
const unattributed = opts.skipHeadless ? [] : await span('active.unattributed', () => listUnattributedActive(knownPids));
|
|
1269
1271
|
const merged = dedupeBySession([...tmuxAgents, ...teams, ...terminals, ...cloud, ...unattributed]);
|
|
1270
|
-
await enrichProvenance(merged);
|
|
1271
|
-
await resolveOrigins(merged);
|
|
1272
|
-
foldPresence(merged);
|
|
1273
|
-
await foldTmuxClients(merged);
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1272
|
+
await span('active.provenance', () => enrichProvenance(merged), count(merged));
|
|
1273
|
+
await span('active.origins', () => resolveOrigins(merged), count(merged));
|
|
1274
|
+
spanSync('active.fold-presence', () => foldPresence(merged), count(merged));
|
|
1275
|
+
await span('active.tmux-clients', () => foldTmuxClients(merged));
|
|
1276
|
+
spanSync('active.fold', () => {
|
|
1277
|
+
foldHostLink(merged);
|
|
1278
|
+
foldExecutionMachine(merged, recordedMachineLookup(merged), machineId());
|
|
1279
|
+
annotateOrchestratorLabels(merged);
|
|
1280
|
+
foldRecap(merged);
|
|
1281
|
+
foldPhase(merged);
|
|
1282
|
+
}, count(merged));
|
|
1279
1283
|
return merged;
|
|
1280
1284
|
}
|
|
1281
1285
|
export async function describeActiveDiscoveryHealth() {
|
|
@@ -3,4 +3,3 @@ export declare function discoverCloudSessions(options?: {
|
|
|
3
3
|
limit?: number;
|
|
4
4
|
}): Promise<SessionMeta[]>;
|
|
5
5
|
export declare function ensureCloudSessionCached(executionId: string, destPath?: string): Promise<string>;
|
|
6
|
-
export declare function isCloudSessionPath(filePath: string): boolean;
|
|
@@ -87,8 +87,3 @@ export async function ensureCloudSessionCached(executionId, destPath) {
|
|
|
87
87
|
fs.writeFileSync(finalPath, body);
|
|
88
88
|
return finalPath;
|
|
89
89
|
}
|
|
90
|
-
export function isCloudSessionPath(filePath) {
|
|
91
|
-
const root = path.resolve(CLOUD_CACHE_DIR);
|
|
92
|
-
const resolved = path.resolve(filePath);
|
|
93
|
-
return resolved.startsWith(root + path.sep);
|
|
94
|
-
}
|
package/dist/lib/session/db.d.ts
CHANGED
|
@@ -356,68 +356,4 @@ export declare function reindexMovedSessionPaths(moves: ReadonlyArray<{
|
|
|
356
356
|
}>): number;
|
|
357
357
|
export declare function updateSessionFilePaths(oldPrefix: string, newPrefix: string): number;
|
|
358
358
|
export declare function countSessionsWithFilePrefix(prefix: string): number;
|
|
359
|
-
interface BrowserCaptureCounts {
|
|
360
|
-
screenshot: number;
|
|
361
|
-
pdf: number;
|
|
362
|
-
recording: number;
|
|
363
|
-
download: number;
|
|
364
|
-
}
|
|
365
|
-
interface BrowserSessionRecord {
|
|
366
|
-
task: string;
|
|
367
|
-
profile: string;
|
|
368
|
-
sessionId?: string;
|
|
369
|
-
launchId?: string;
|
|
370
|
-
actor?: string;
|
|
371
|
-
machine?: string;
|
|
372
|
-
startedAt?: number;
|
|
373
|
-
lastActivity?: number;
|
|
374
|
-
counts?: Partial<BrowserCaptureCounts>;
|
|
375
|
-
captureDir?: string;
|
|
376
|
-
capturesRemote?: string;
|
|
377
|
-
}
|
|
378
|
-
interface ComputerSessionRecord {
|
|
379
|
-
invocationId: string;
|
|
380
|
-
sessionId?: string;
|
|
381
|
-
launchId?: string;
|
|
382
|
-
actor?: string;
|
|
383
|
-
machine?: string;
|
|
384
|
-
startedAt?: number;
|
|
385
|
-
lastActivity?: number;
|
|
386
|
-
actionCount?: number;
|
|
387
|
-
taskPreview?: string;
|
|
388
|
-
}
|
|
389
|
-
export declare function recordBrowserSession(record: BrowserSessionRecord): void;
|
|
390
|
-
export declare function recordComputerSession(record: ComputerSessionRecord): void;
|
|
391
|
-
interface StoredBrowserSession extends Required<Pick<BrowserSessionRecord, 'task' | 'profile'>> {
|
|
392
|
-
sessionId?: string;
|
|
393
|
-
launchId?: string;
|
|
394
|
-
actor?: string;
|
|
395
|
-
machine: string;
|
|
396
|
-
startedAt: number;
|
|
397
|
-
lastActivity?: number;
|
|
398
|
-
counts: BrowserCaptureCounts;
|
|
399
|
-
captureDir?: string;
|
|
400
|
-
capturesRemote?: string;
|
|
401
|
-
}
|
|
402
|
-
export declare function listBrowserSessionRecords(profile?: string, opts?: {
|
|
403
|
-
limit?: number;
|
|
404
|
-
deviceKeys?: boolean;
|
|
405
|
-
}): StoredBrowserSession[];
|
|
406
|
-
export declare function getBrowserSessionRecord(profile: string, task: string): StoredBrowserSession | null;
|
|
407
|
-
interface StoredComputerSession {
|
|
408
|
-
invocationId: string;
|
|
409
|
-
sessionId?: string;
|
|
410
|
-
launchId?: string;
|
|
411
|
-
actor?: string;
|
|
412
|
-
machine: string;
|
|
413
|
-
startedAt: number;
|
|
414
|
-
lastActivity?: number;
|
|
415
|
-
actionCount: number;
|
|
416
|
-
taskPreview?: string;
|
|
417
|
-
}
|
|
418
|
-
export declare function pruneToolSessions(maxAgeDays?: number): number;
|
|
419
|
-
export declare function listComputerSessionRecords(opts?: {
|
|
420
|
-
limit?: number;
|
|
421
|
-
startedBeforeMs?: number;
|
|
422
|
-
}): StoredComputerSession[];
|
|
423
359
|
export {};
|
package/dist/lib/session/db.js
CHANGED
|
@@ -14,10 +14,8 @@ import { buildClaudeAccountIndex, resolveClaudeAccount } from './claude-accounts
|
|
|
14
14
|
import { extractBackgroundShells, extractSkills, extractSlashCommands, harnessTracksBackgroundShells, isSubAgentTool, } from '@phnx-labs/sessions-cli/reader';
|
|
15
15
|
import { resolveResource } from '../resources.js';
|
|
16
16
|
import { discoverPlugins } from '../plugins/plugins.js';
|
|
17
|
-
import { machineId } from '../machine-id.js';
|
|
18
17
|
import { firstUserMessageFromEvents, lastUserMessageFromEvents } from '@phnx-labs/sessions-cli/reader';
|
|
19
18
|
import { emptyTimelineState, TIMELINE_EXTRACTOR_VERSION } from '@phnx-labs/sessions-cli/reader';
|
|
20
|
-
import { profileScopeSql } from '../browser/paths.js';
|
|
21
19
|
const SESSIONS_DIR = getSessionsDir();
|
|
22
20
|
const DB_PATH = getSessionsDbPath();
|
|
23
21
|
export const SCHEMA_VERSION = 52;
|
|
@@ -3516,117 +3514,3 @@ export function countSessionsWithFilePrefix(prefix) {
|
|
|
3516
3514
|
.get(prefix + '%');
|
|
3517
3515
|
return row.c;
|
|
3518
3516
|
}
|
|
3519
|
-
export function recordBrowserSession(record) {
|
|
3520
|
-
const db = getDB();
|
|
3521
|
-
const now = Date.now();
|
|
3522
|
-
db.prepare(`
|
|
3523
|
-
INSERT INTO browser_sessions (
|
|
3524
|
-
task, profile, session_id, launch_id, actor, machine,
|
|
3525
|
-
started_at, last_activity,
|
|
3526
|
-
screenshot_count, pdf_count, recording_count, download_count,
|
|
3527
|
-
capture_dir, captures_remote
|
|
3528
|
-
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
3529
|
-
ON CONFLICT(profile, task) DO UPDATE SET
|
|
3530
|
-
session_id = COALESCE(excluded.session_id, browser_sessions.session_id),
|
|
3531
|
-
launch_id = COALESCE(excluded.launch_id, browser_sessions.launch_id),
|
|
3532
|
-
actor = COALESCE(excluded.actor, browser_sessions.actor),
|
|
3533
|
-
last_activity = excluded.last_activity,
|
|
3534
|
-
screenshot_count = excluded.screenshot_count,
|
|
3535
|
-
pdf_count = excluded.pdf_count,
|
|
3536
|
-
recording_count = excluded.recording_count,
|
|
3537
|
-
download_count = excluded.download_count,
|
|
3538
|
-
capture_dir = COALESCE(excluded.capture_dir, browser_sessions.capture_dir),
|
|
3539
|
-
captures_remote = COALESCE(excluded.captures_remote, browser_sessions.captures_remote)
|
|
3540
|
-
`).run(record.task, record.profile, record.sessionId ?? null, record.launchId ?? null, record.actor ?? null, record.machine ?? machineId(), record.startedAt ?? now, record.lastActivity ?? now, record.counts?.screenshot ?? 0, record.counts?.pdf ?? 0, record.counts?.recording ?? 0, record.counts?.download ?? 0, record.captureDir ?? null, record.capturesRemote ?? null);
|
|
3541
|
-
}
|
|
3542
|
-
export function recordComputerSession(record) {
|
|
3543
|
-
const db = getDB();
|
|
3544
|
-
const now = Date.now();
|
|
3545
|
-
db.prepare(`
|
|
3546
|
-
INSERT INTO computer_sessions (
|
|
3547
|
-
invocation_id, session_id, launch_id, actor, machine,
|
|
3548
|
-
started_at, last_activity, action_count, task_preview
|
|
3549
|
-
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
3550
|
-
ON CONFLICT(invocation_id) DO UPDATE SET
|
|
3551
|
-
session_id = COALESCE(excluded.session_id, computer_sessions.session_id),
|
|
3552
|
-
launch_id = COALESCE(excluded.launch_id, computer_sessions.launch_id),
|
|
3553
|
-
actor = COALESCE(excluded.actor, computer_sessions.actor),
|
|
3554
|
-
last_activity = excluded.last_activity,
|
|
3555
|
-
action_count = computer_sessions.action_count + excluded.action_count,
|
|
3556
|
-
task_preview = COALESCE(excluded.task_preview, computer_sessions.task_preview)
|
|
3557
|
-
`).run(record.invocationId, record.sessionId ?? null, record.launchId ?? null, record.actor ?? null, record.machine ?? machineId(), record.startedAt ?? now, record.lastActivity ?? now, record.actionCount ?? 1, record.taskPreview ?? null);
|
|
3558
|
-
}
|
|
3559
|
-
function toStoredBrowserSession(row) {
|
|
3560
|
-
return {
|
|
3561
|
-
task: row.task,
|
|
3562
|
-
profile: row.profile,
|
|
3563
|
-
sessionId: row.session_id ?? undefined,
|
|
3564
|
-
launchId: row.launch_id ?? undefined,
|
|
3565
|
-
actor: row.actor ?? undefined,
|
|
3566
|
-
machine: row.machine,
|
|
3567
|
-
startedAt: row.started_at,
|
|
3568
|
-
lastActivity: row.last_activity ?? undefined,
|
|
3569
|
-
counts: {
|
|
3570
|
-
screenshot: row.screenshot_count,
|
|
3571
|
-
pdf: row.pdf_count,
|
|
3572
|
-
recording: row.recording_count,
|
|
3573
|
-
download: row.download_count,
|
|
3574
|
-
},
|
|
3575
|
-
captureDir: row.capture_dir ?? undefined,
|
|
3576
|
-
capturesRemote: row.captures_remote ?? undefined,
|
|
3577
|
-
};
|
|
3578
|
-
}
|
|
3579
|
-
export function listBrowserSessionRecords(profile, opts = {}) {
|
|
3580
|
-
const db = getDB();
|
|
3581
|
-
const where = !profile ? undefined
|
|
3582
|
-
: opts.deviceKeys ? profileScopeSql('profile', profile) : { sql: 'profile = ?', params: [profile] };
|
|
3583
|
-
const limit = profile ? opts.limit : opts.limit ?? TOOL_SESSION_LIST_LIMIT;
|
|
3584
|
-
const rows = db.prepare(`SELECT * FROM browser_sessions${where ? ` WHERE ${where.sql}` : ''} ORDER BY started_at DESC${limit === undefined ? '' : ' LIMIT ?'}`).all(...(where?.params ?? []), ...(limit === undefined ? [] : [limit]));
|
|
3585
|
-
return rows.map(toStoredBrowserSession);
|
|
3586
|
-
}
|
|
3587
|
-
export function getBrowserSessionRecord(profile, task) {
|
|
3588
|
-
const db = getDB();
|
|
3589
|
-
const row = db
|
|
3590
|
-
.prepare(`SELECT * FROM browser_sessions WHERE profile = ? AND task = ?`)
|
|
3591
|
-
.get(profile, task);
|
|
3592
|
-
return row ? toStoredBrowserSession(row) : null;
|
|
3593
|
-
}
|
|
3594
|
-
const TOOL_SESSION_MAX_AGE_DAYS = 365;
|
|
3595
|
-
const TOOL_SESSION_LIST_LIMIT = 2000;
|
|
3596
|
-
export function pruneToolSessions(maxAgeDays = TOOL_SESSION_MAX_AGE_DAYS) {
|
|
3597
|
-
const db = getDB();
|
|
3598
|
-
const cutoff = Date.now() - maxAgeDays * 24 * 60 * 60 * 1000;
|
|
3599
|
-
const stale = db.prepare(`
|
|
3600
|
-
SELECT 1 FROM computer_sessions WHERE started_at < ?
|
|
3601
|
-
UNION ALL
|
|
3602
|
-
SELECT 1 FROM browser_sessions WHERE started_at < ?
|
|
3603
|
-
LIMIT 1
|
|
3604
|
-
`).get(cutoff, cutoff);
|
|
3605
|
-
if (!stale)
|
|
3606
|
-
return 0;
|
|
3607
|
-
const computer = db.prepare(`DELETE FROM computer_sessions WHERE started_at < ?`).run(cutoff);
|
|
3608
|
-
const browser = db.prepare(`DELETE FROM browser_sessions WHERE started_at < ?`).run(cutoff);
|
|
3609
|
-
return Number(computer.changes ?? 0) + Number(browser.changes ?? 0);
|
|
3610
|
-
}
|
|
3611
|
-
export function listComputerSessionRecords(opts = {}) {
|
|
3612
|
-
const db = getDB();
|
|
3613
|
-
const limit = opts.limit ?? TOOL_SESSION_LIST_LIMIT;
|
|
3614
|
-
const rows = (opts.startedBeforeMs === undefined
|
|
3615
|
-
? db
|
|
3616
|
-
.prepare(`SELECT * FROM computer_sessions ORDER BY started_at DESC LIMIT ?`)
|
|
3617
|
-
.all(limit)
|
|
3618
|
-
: db
|
|
3619
|
-
.prepare(`SELECT * FROM computer_sessions WHERE started_at < ? ORDER BY started_at DESC LIMIT ?`)
|
|
3620
|
-
.all(opts.startedBeforeMs, limit));
|
|
3621
|
-
return rows.map((row) => ({
|
|
3622
|
-
invocationId: row.invocation_id,
|
|
3623
|
-
sessionId: row.session_id ?? undefined,
|
|
3624
|
-
launchId: row.launch_id ?? undefined,
|
|
3625
|
-
actor: row.actor ?? undefined,
|
|
3626
|
-
machine: row.machine,
|
|
3627
|
-
startedAt: row.started_at,
|
|
3628
|
-
lastActivity: row.last_activity ?? undefined,
|
|
3629
|
-
actionCount: row.action_count,
|
|
3630
|
-
taskPreview: row.task_preview ?? undefined,
|
|
3631
|
-
}));
|
|
3632
|
-
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
|
+
import { spanSync } from '../daemon/diagnostics.js';
|
|
2
3
|
import path from 'path';
|
|
3
4
|
import { execFileSync } from 'child_process';
|
|
4
5
|
import { hostProcessView, writerProcessView } from './process-view.js';
|
|
@@ -29,12 +30,14 @@ function pidExists(pid) {
|
|
|
29
30
|
}
|
|
30
31
|
}
|
|
31
32
|
function darwinStartTime(pid) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
return spanSync('proc.ps-start-time', () => {
|
|
34
|
+
try {
|
|
35
|
+
return execFileSync('ps', ['-p', String(pid), '-o', 'lstart='], { encoding: 'utf8', timeout: 2000, stdio: ['ignore', 'pipe', 'ignore'] }).trim() || undefined;
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
});
|
|
38
41
|
}
|
|
39
42
|
function processStartTimeMs(value) {
|
|
40
43
|
return typeof value === 'string' ? Date.parse(value.trim().replace(/\s+/g, ' ')) : NaN;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { type FilterOptions, type SessionMeta, type ViewMode } from '@phnx-labs/sessions-cli/reader';
|
|
1
|
+
import { type FileChange, type FilterOptions, type SessionEvent, type SessionMeta, type TodoProgress, type ViewMode } from '@phnx-labs/sessions-cli/reader';
|
|
2
|
+
import type { changeCounts, detectTestResult, extractArtifacts, extractHooks, extractLinks, extractSkills, toolHistogram } from '@phnx-labs/sessions-cli/reader';
|
|
2
3
|
import type { ActiveSession } from './active.js';
|
|
4
|
+
import { type SessionAgeParts } from './relative-time.js';
|
|
3
5
|
export declare function signalBadges(s: Pick<ActiveSession, 'awaitingReason' | 'pr' | 'worktree' | 'ticket'>): string;
|
|
4
6
|
export interface TranscriptRenderOptions {
|
|
5
7
|
json?: boolean;
|
|
@@ -19,3 +21,107 @@ export declare function renderSessionLogJson(session: SessionMeta): Promise<void
|
|
|
19
21
|
export declare function renderSession(session: SessionMeta, mode: ViewMode, filters: FilterOptions, options?: {
|
|
20
22
|
redact?: boolean;
|
|
21
23
|
}): Promise<void>;
|
|
24
|
+
export declare function formatTodoCompact(todos?: Pick<TodoProgress, 'done' | 'total' | 'activeForm'> | null): string;
|
|
25
|
+
export declare function statusColor(status: ActiveSession['status']): (s: string) => string;
|
|
26
|
+
export declare function cleanPreview(text: string): string;
|
|
27
|
+
export declare function buildSessionDescription(s: ActiveSession): string;
|
|
28
|
+
export declare function liveGlyphAndPreview(a: ActiveSession | undefined): {
|
|
29
|
+
glyph: string;
|
|
30
|
+
preview: string;
|
|
31
|
+
};
|
|
32
|
+
export declare function liveStatusWord(a: ActiveSession | undefined): string;
|
|
33
|
+
export declare function isAwaitingUser(s: ActiveSession): boolean;
|
|
34
|
+
export declare function shortCwd(cwd?: string): string;
|
|
35
|
+
export declare const LIVE_STATUS_W = 8;
|
|
36
|
+
export declare function liveStatusCell(live: ActiveSession | undefined): {
|
|
37
|
+
cell: string;
|
|
38
|
+
width: number;
|
|
39
|
+
};
|
|
40
|
+
export declare function linkTicketCell(s: Pick<SessionMeta, 'ticketId' | 'prNumber' | 'prUrl'>, label: string): string;
|
|
41
|
+
export declare function linkCwdCell(s: Pick<SessionMeta, 'cwd' | '_remote'>, label: string): string;
|
|
42
|
+
export declare function formatLiveStatusHeadline(live: ActiveSession | undefined, bookmarked?: boolean): string;
|
|
43
|
+
export declare function teamTag(session: SessionMeta): string;
|
|
44
|
+
export declare function teamBadge(session: SessionMeta): {
|
|
45
|
+
plain: string;
|
|
46
|
+
width: number;
|
|
47
|
+
};
|
|
48
|
+
export declare function originTag(session: SessionMeta): string;
|
|
49
|
+
export declare function timeCell(age: SessionAgeParts, topicSlack: number): {
|
|
50
|
+
plain: string;
|
|
51
|
+
text: string;
|
|
52
|
+
extraW: number;
|
|
53
|
+
};
|
|
54
|
+
export declare function flatSessionRow(session: SessionMeta, live?: ActiveSession, showTicket?: boolean, cols?: PickerColumns, bookmarked?: boolean): string;
|
|
55
|
+
export declare function treeSessionRow(session: SessionMeta, live?: ActiveSession): string;
|
|
56
|
+
export declare function printSessionTable(sessions: SessionMeta[], hiddenCount?: number, tree?: boolean, liveIndex?: Map<string, ActiveSession>): void;
|
|
57
|
+
export declare function renderTopicCell(label: string | undefined | null, topic: string | undefined | null, query: string, visibleWidth: number, paddedWidth: number): string;
|
|
58
|
+
export interface SshOriginTag {
|
|
59
|
+
device?: string;
|
|
60
|
+
}
|
|
61
|
+
export interface PickerColumns {
|
|
62
|
+
showMachine?: boolean;
|
|
63
|
+
machineLabel?: (m: string) => string;
|
|
64
|
+
machineWidth?: number;
|
|
65
|
+
showModel?: boolean;
|
|
66
|
+
modelWidth?: number;
|
|
67
|
+
showTicket?: boolean;
|
|
68
|
+
showHost?: boolean;
|
|
69
|
+
showBookmark?: boolean;
|
|
70
|
+
showStatus?: boolean;
|
|
71
|
+
gutter?: number;
|
|
72
|
+
}
|
|
73
|
+
export declare function machineLabeler(machines: string[]): (m: string) => string;
|
|
74
|
+
export declare function pickerColumnsFor(sessions: SessionMeta[]): PickerColumns;
|
|
75
|
+
export declare function liveHostLabel(a: ActiveSession | undefined): string;
|
|
76
|
+
export declare function formatPickerLabel(s: SessionMeta, query: string, cols?: PickerColumns, ssh?: SshOriginTag, host?: string, bookmarked?: boolean, live?: ActiveSession): string;
|
|
77
|
+
export declare function formatPickerTip(sessions: SessionMeta[]): string;
|
|
78
|
+
export declare function formatTeamHiddenFooter(hiddenCount: number): string;
|
|
79
|
+
export declare function notFoundByIdMessage(query: string): string[];
|
|
80
|
+
export interface SessionPreviewDigest {
|
|
81
|
+
schemaVersion: 1;
|
|
82
|
+
firstUser: string;
|
|
83
|
+
lastAssistant: string;
|
|
84
|
+
filesRead: number;
|
|
85
|
+
toolCalls: number;
|
|
86
|
+
planFile: string;
|
|
87
|
+
todos?: TodoProgress;
|
|
88
|
+
subAgentCount: number;
|
|
89
|
+
backgroundShellCount?: number;
|
|
90
|
+
toolTags: string[];
|
|
91
|
+
changes: ReturnType<typeof changeCounts>;
|
|
92
|
+
changedFiles: FileChange[];
|
|
93
|
+
dirs: string[];
|
|
94
|
+
repos: string[];
|
|
95
|
+
artifacts: ReturnType<typeof extractArtifacts>;
|
|
96
|
+
skills: ReturnType<typeof extractSkills>;
|
|
97
|
+
plugins: string[];
|
|
98
|
+
hooks: ReturnType<typeof extractHooks>;
|
|
99
|
+
links: ReturnType<typeof extractLinks>;
|
|
100
|
+
errorCount: number;
|
|
101
|
+
firstError?: string;
|
|
102
|
+
toolHistogram: ReturnType<typeof toolHistogram>;
|
|
103
|
+
test: ReturnType<typeof detectTestResult>;
|
|
104
|
+
partial?: boolean;
|
|
105
|
+
partialReason?: string;
|
|
106
|
+
}
|
|
107
|
+
export interface SessionDetailMessage {
|
|
108
|
+
role: 'user' | 'assistant';
|
|
109
|
+
text: string;
|
|
110
|
+
at: string | null;
|
|
111
|
+
}
|
|
112
|
+
export declare function sessionTranscriptStamp(session: SessionMeta): {
|
|
113
|
+
fileMtimeMs: number;
|
|
114
|
+
fileSize: number;
|
|
115
|
+
} | undefined;
|
|
116
|
+
export declare function buildSessionDetailBlock(session: SessionMeta, digest: SessionPreviewDigest | undefined, events: SessionEvent[], sourceStamp?: {
|
|
117
|
+
fileMtimeMs: number;
|
|
118
|
+
fileSize: number;
|
|
119
|
+
}): {
|
|
120
|
+
request: unknown;
|
|
121
|
+
timeline: unknown;
|
|
122
|
+
files: unknown;
|
|
123
|
+
messages: SessionDetailMessage[];
|
|
124
|
+
sourceRevision: string | null;
|
|
125
|
+
partial: boolean;
|
|
126
|
+
reason: string | null;
|
|
127
|
+
};
|