@phnx-labs/agents-cli 1.22.121 → 1.22.123
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 +316 -0
- package/README.md +53 -53
- package/dist/bootstrap.js +22 -17
- package/dist/cli/command-registry.d.ts +0 -1
- package/dist/cli/command-registry.js +2 -12
- package/dist/commands/auth.js +13 -4
- package/dist/commands/browser.js +3 -4
- package/dist/commands/cloud-transcripts.d.ts +7 -0
- package/dist/commands/cloud-transcripts.js +100 -0
- package/dist/commands/cloud.js +5 -0
- package/dist/commands/computer.d.ts +0 -12
- package/dist/commands/computer.js +14 -124
- package/dist/commands/config.js +5 -4
- package/dist/commands/daemon-index.d.ts +2 -0
- package/dist/commands/daemon-index.js +44 -0
- package/dist/commands/daemon.js +13 -8
- package/dist/commands/doctor.js +3 -4
- package/dist/commands/exec.d.ts +5 -0
- package/dist/commands/exec.js +35 -7
- package/dist/commands/feed-watch.js +12 -0
- package/dist/commands/feed.d.ts +1 -1
- package/dist/commands/feed.js +7 -4
- package/dist/commands/insights.js +3 -1
- package/dist/commands/inspect.js +1 -1
- package/dist/commands/logs.js +2 -1
- package/dist/commands/mailboxes.js +1 -1
- package/dist/commands/models.js +1 -1
- package/dist/commands/projects.js +3 -3
- package/dist/commands/prune.js +6 -28
- package/dist/commands/ps-roster.d.ts +0 -1
- package/dist/commands/ps-roster.js +2 -21
- package/dist/commands/ps.js +13 -1
- package/dist/commands/recordings.d.ts +2 -0
- package/dist/commands/recordings.js +117 -0
- package/dist/commands/routines.js +1 -1
- package/dist/commands/secrets-passthrough.js +3 -3
- package/dist/commands/send.js +33 -20
- package/dist/commands/sessions-backfill.d.ts +1 -0
- package/dist/commands/sessions-backfill.js +48 -13
- package/dist/commands/sessions-migrate.d.ts +1 -1
- package/dist/commands/sessions-migrate.js +11 -10
- package/dist/commands/sessions-optimize.d.ts +1 -0
- package/dist/commands/sessions-optimize.js +7 -4
- package/dist/commands/sessions-resume.js +8 -1
- package/dist/commands/sessions-stats.d.ts +2 -0
- package/dist/commands/sessions-stats.js +24 -7
- package/dist/commands/sessions.d.ts +5 -11
- package/dist/commands/sessions.js +8 -236
- package/dist/commands/setup-computer.js +1 -2
- package/dist/commands/setup-mine.js +0 -1
- package/dist/commands/setup.js +1 -1
- package/dist/commands/sync.js +101 -1
- package/dist/commands/teams.js +2 -2
- package/dist/commands/testdata/feed-hub.js +11 -0
- package/dist/commands/trash.d.ts +0 -1
- package/dist/commands/trash.js +74 -10
- package/dist/lib/accounting/usage-sync.js +7 -0
- package/dist/lib/agent-modes.d.ts +1 -1
- package/dist/lib/agent-modes.js +11 -5
- package/dist/lib/auth-mint.d.ts +4 -0
- package/dist/lib/auth-mint.js +6 -4
- package/dist/lib/browser/native-history.test-fixture.d.ts +12 -0
- package/dist/lib/browser/native-history.test-fixture.js +43 -0
- package/dist/lib/browser/paths.d.ts +5 -0
- package/dist/lib/browser/paths.js +7 -1
- package/dist/lib/browser/sessions-list.d.ts +28 -1
- package/dist/lib/browser/sessions-list.js +137 -25
- package/dist/lib/channels/providers/rush.d.ts +2 -1
- package/dist/lib/channels/providers/rush.js +2 -2
- package/dist/lib/channels/providers/session.d.ts +1 -0
- package/dist/lib/channels/providers/session.js +23 -12
- package/dist/lib/channels/registry.d.ts +9 -2
- package/dist/lib/channels/send.d.ts +5 -10
- package/dist/lib/channels/send.js +88 -50
- package/dist/lib/cloud/rush.d.ts +6 -0
- package/dist/lib/cloud/rush.js +18 -3
- package/dist/lib/computer-client.d.ts +19 -0
- package/dist/lib/computer-client.js +104 -0
- package/dist/lib/config-keys.d.ts +5 -1
- package/dist/lib/config-keys.js +14 -11
- package/dist/lib/daemon/auth-sync-service.js +13 -0
- package/dist/lib/daemon/daemon.js +20 -23
- package/dist/lib/daemon/owner-device-delivery-service.d.ts +10 -0
- package/dist/lib/daemon/owner-device-delivery-service.js +28 -0
- package/dist/lib/daemon-services.d.ts +2 -1
- package/dist/lib/daemon-services.js +17 -10
- package/dist/lib/daemon-webhooks.d.ts +1 -1
- package/dist/lib/daemon-webhooks.js +1 -1
- package/dist/lib/device-config.d.ts +4 -1
- package/dist/lib/device-config.js +58 -8
- package/dist/lib/devices/doctor-findings.d.ts +2 -3
- package/dist/lib/devices/doctor-findings.js +10 -19
- package/dist/lib/event-provenance.d.ts +1 -0
- package/dist/lib/event-provenance.js +2 -0
- package/dist/lib/exec.d.ts +1 -0
- package/dist/lib/exec.js +20 -15
- package/dist/lib/feed/pr-status.d.ts +5 -1
- package/dist/lib/feed/pr-status.js +44 -3
- package/dist/lib/feed/tool-activity.js +9 -6
- package/dist/lib/feed/tools.d.ts +4 -1
- package/dist/lib/feed/tools.js +8 -11
- package/dist/lib/feed-broadcast.d.ts +5 -3
- package/dist/lib/feed-broadcast.js +47 -36
- package/dist/lib/fleet-shared-state.d.ts +5 -0
- package/dist/lib/fleet-shared-state.js +8 -0
- package/dist/lib/github/project-prs.d.ts +4 -1
- package/dist/lib/github/project-prs.js +20 -7
- package/dist/lib/help.d.ts +1 -0
- package/dist/lib/help.js +8 -0
- package/dist/lib/helper-versions.js +1 -1
- package/dist/lib/hosts/passthrough.js +5 -9
- package/dist/lib/hosts/remote-cmd.d.ts +2 -7
- package/dist/lib/hosts/remote-cmd.js +14 -22
- package/dist/lib/hosts/routing-flag.d.ts +22 -0
- package/dist/lib/hosts/routing-flag.js +127 -14
- package/dist/lib/identity/index.d.ts +22 -0
- package/dist/lib/identity/index.js +3 -0
- package/dist/lib/installations/migrate.d.ts +7 -0
- package/dist/lib/installations/migrate.js +99 -88
- package/dist/lib/installations/versions.js +2 -2
- package/dist/lib/launch-identity.d.ts +6 -1
- package/dist/lib/launch-identity.js +12 -2
- package/dist/lib/menubar/install-menubar.d.ts +1 -0
- package/dist/lib/menubar/install-menubar.js +8 -5
- package/dist/lib/menubar/snapshot.js +2 -3
- package/dist/lib/notify.d.ts +7 -14
- package/dist/lib/notify.js +29 -75
- package/dist/lib/owner-message.d.ts +4 -6
- package/dist/lib/owner-message.js +12 -11
- package/dist/lib/owner-notify-tokens.d.ts +49 -0
- package/dist/lib/owner-notify-tokens.js +214 -0
- package/dist/lib/owner-notify.d.ts +75 -0
- package/dist/lib/owner-notify.js +144 -0
- package/dist/lib/plugins/plugins.d.ts +7 -1
- package/dist/lib/plugins/plugins.js +26 -5
- package/dist/lib/pr-land-detach.js +2 -2
- package/dist/lib/recordings/config.d.ts +11 -0
- package/dist/lib/recordings/config.js +54 -0
- package/dist/lib/recordings/identity.d.ts +12 -0
- package/dist/lib/recordings/identity.js +57 -0
- package/dist/lib/recordings/ledger.d.ts +16 -0
- package/dist/lib/recordings/ledger.js +141 -0
- package/dist/lib/recordings/model.d.ts +29 -0
- package/dist/lib/recordings/model.js +28 -0
- package/dist/lib/recordings/pipeline.d.ts +44 -0
- package/dist/lib/recordings/pipeline.js +272 -0
- package/dist/lib/recordings/process.d.ts +17 -0
- package/dist/lib/recordings/process.js +94 -0
- package/dist/lib/recordings/service.d.ts +15 -0
- package/dist/lib/recordings/service.js +45 -0
- package/dist/lib/recordings/settle.d.ts +21 -0
- package/dist/lib/recordings/settle.js +92 -0
- package/dist/lib/recordings/transcode.d.ts +13 -0
- package/dist/lib/recordings/transcode.js +44 -0
- package/dist/lib/refresh.js +4 -1
- package/dist/lib/reminders.d.ts +0 -1
- package/dist/lib/reminders.js +1 -1
- package/dist/lib/reserved-stores.d.ts +3 -0
- package/dist/lib/reserved-stores.js +13 -0
- package/dist/lib/routine-notify-owner.d.ts +3 -23
- package/dist/lib/routine-notify-owner.js +26 -107
- package/dist/lib/rush-api.d.ts +1 -0
- package/dist/lib/rush-api.js +1 -0
- package/dist/lib/scheduling/routines.d.ts +1 -1
- package/dist/lib/scheduling/routines.js +1 -1
- package/dist/lib/session/active.d.ts +18 -2
- package/dist/lib/session/active.js +47 -37
- package/dist/lib/session/cloud.js +18 -45
- package/dist/lib/session/db.d.ts +3 -1
- package/dist/lib/session/db.js +64 -32
- package/dist/lib/session/glance-files.d.ts +4 -3
- package/dist/lib/session/glance-files.js +31 -0
- package/dist/lib/session/inject-target.js +12 -2
- package/dist/lib/session/pid-registry.d.ts +2 -0
- package/dist/lib/session/pid-registry.js +6 -2
- package/dist/lib/session/presentation.d.ts +21 -0
- package/dist/lib/session/presentation.js +198 -0
- package/dist/lib/session/projection.js +9 -2
- package/dist/lib/sqlite.d.ts +3 -1
- package/dist/lib/sqlite.js +7 -3
- package/dist/lib/staleness/index.js +12 -0
- package/dist/lib/staleness/types.d.ts +5 -0
- package/dist/lib/standalone-tools.js +1 -1
- package/dist/lib/startup/command-registry.js +10 -5
- package/dist/lib/state.d.ts +2 -5
- package/dist/lib/state.js +3 -11
- package/dist/lib/sync-delete.d.ts +21 -0
- package/dist/lib/sync-delete.js +113 -0
- package/dist/lib/terminal/inject.js +1 -1
- package/dist/lib/testdata/owner-notify-api.d.ts +36 -0
- package/dist/lib/testdata/owner-notify-api.js +102 -0
- package/dist/lib/trash.d.ts +14 -0
- package/dist/lib/trash.js +75 -0
- package/dist/lib/types.d.ts +0 -34
- package/package.json +1 -3
- package/dist/commands/feedback.d.ts +0 -2
- package/dist/commands/feedback.js +0 -68
- package/dist/commands/humans.d.ts +0 -2
- package/dist/commands/humans.js +0 -83
- package/dist/commands/modes.d.ts +0 -2
- package/dist/commands/modes.js +0 -134
- package/dist/commands/monitors.d.ts +0 -2
- package/dist/commands/monitors.js +0 -1070
- package/dist/commands/reminders.d.ts +0 -2
- package/dist/commands/reminders.js +0 -49
- package/dist/lib/channels/owner-forward.d.ts +0 -25
- package/dist/lib/channels/owner-forward.js +0 -78
- package/dist/lib/channels/owner-sink.d.ts +0 -10
- package/dist/lib/channels/owner-sink.js +0 -26
- package/dist/lib/daemon/monitor-engine-service.d.ts +0 -13
- package/dist/lib/daemon/monitor-engine-service.js +0 -25
- package/dist/lib/humans.d.ts +0 -12
- package/dist/lib/humans.js +0 -64
- package/dist/lib/monitors/config.d.ts +0 -77
- package/dist/lib/monitors/config.js +0 -405
- package/dist/lib/monitors/dispatch.d.ts +0 -10
- package/dist/lib/monitors/dispatch.js +0 -72
- package/dist/lib/monitors/engine.d.ts +0 -45
- package/dist/lib/monitors/engine.js +0 -243
- package/dist/lib/monitors/fingerprint.d.ts +0 -3
- package/dist/lib/monitors/fingerprint.js +0 -43
- package/dist/lib/monitors/pid-watch.d.ts +0 -4
- package/dist/lib/monitors/pid-watch.js +0 -14
- package/dist/lib/monitors/remote.d.ts +0 -31
- package/dist/lib/monitors/remote.js +0 -63
- package/dist/lib/monitors/sources/command.d.ts +0 -4
- package/dist/lib/monitors/sources/command.js +0 -20
- package/dist/lib/monitors/sources/device.d.ts +0 -3
- package/dist/lib/monitors/sources/device.js +0 -31
- package/dist/lib/monitors/sources/failure.d.ts +0 -5
- package/dist/lib/monitors/sources/failure.js +0 -25
- package/dist/lib/monitors/sources/file.d.ts +0 -4
- package/dist/lib/monitors/sources/file.js +0 -46
- package/dist/lib/monitors/sources/http.d.ts +0 -3
- package/dist/lib/monitors/sources/http.js +0 -25
- package/dist/lib/monitors/sources/index.d.ts +0 -5
- package/dist/lib/monitors/sources/index.js +0 -22
- package/dist/lib/monitors/sources/poll.d.ts +0 -1
- package/dist/lib/monitors/sources/poll.js +0 -1
- package/dist/lib/monitors/sources/types.d.ts +0 -9
- package/dist/lib/monitors/sources/webhook.d.ts +0 -3
- package/dist/lib/monitors/sources/webhook.js +0 -3
- package/dist/lib/monitors/sources/ws.d.ts +0 -4
- package/dist/lib/monitors/sources/ws.js +0 -35
- package/dist/lib/monitors/state.d.ts +0 -51
- package/dist/lib/monitors/state.js +0 -221
- /package/dist/{lib/monitors/sources/types.js → commands/testdata/feed-hub.d.ts} +0 -0
package/dist/lib/session/db.js
CHANGED
|
@@ -17,11 +17,12 @@ import { discoverPlugins } from '../plugins/plugins.js';
|
|
|
17
17
|
import { machineId } from '../machine-id.js';
|
|
18
18
|
import { firstUserMessageFromEvents, lastUserMessageFromEvents } from '@phnx-labs/sessions-cli/reader';
|
|
19
19
|
import { emptyTimelineState, TIMELINE_EXTRACTOR_VERSION } from '@phnx-labs/sessions-cli/reader';
|
|
20
|
+
import { profileScopeSql } from '../browser/paths.js';
|
|
20
21
|
const SESSIONS_DIR = getSessionsDir();
|
|
21
22
|
const DB_PATH = getSessionsDbPath();
|
|
22
|
-
export const SCHEMA_VERSION =
|
|
23
|
+
export const SCHEMA_VERSION = 52;
|
|
23
24
|
export const CONTENT_INDEX_VERSION = 6;
|
|
24
|
-
const RESOURCE_INDEX_VERSION =
|
|
25
|
+
const RESOURCE_INDEX_VERSION = 2;
|
|
25
26
|
function canonicalLedgerKey(filePath) {
|
|
26
27
|
if (!filePath)
|
|
27
28
|
return filePath;
|
|
@@ -1055,6 +1056,16 @@ function migrateSchema(db, fromVersion) {
|
|
|
1055
1056
|
`);
|
|
1056
1057
|
db.exec(`DROP TABLE session_text_v50`);
|
|
1057
1058
|
}
|
|
1059
|
+
if (fromVersion < 52) {
|
|
1060
|
+
db.exec(`
|
|
1061
|
+
INSERT INTO session_resource_usage (session_id, kind, name, plugin, source, repo_root, snapshot_sha, count)
|
|
1062
|
+
SELECT session_id, kind, plugin || ':' || name, plugin, source, repo_root, snapshot_sha, count
|
|
1063
|
+
FROM session_resource_usage
|
|
1064
|
+
WHERE plugin IS NOT NULL AND plugin <> '' AND instr(name, ':') = 0
|
|
1065
|
+
ON CONFLICT(session_id, kind, name) DO UPDATE SET count = session_resource_usage.count + excluded.count
|
|
1066
|
+
`);
|
|
1067
|
+
db.exec(`DELETE FROM session_resource_usage WHERE plugin IS NOT NULL AND plugin <> '' AND instr(name, ':') = 0`);
|
|
1068
|
+
}
|
|
1058
1069
|
}
|
|
1059
1070
|
function backfillClaudeAccounts(db, scope = 'all') {
|
|
1060
1071
|
const where = scope === 'all'
|
|
@@ -1600,24 +1611,35 @@ const insertResourceUsageStmt = (db) => db.prepare(`
|
|
|
1600
1611
|
INSERT INTO session_resource_usage (session_id, kind, name, plugin, source, repo_root, snapshot_sha, count)
|
|
1601
1612
|
VALUES (@session_id, @kind, @name, @plugin, @source, @repo_root, @snapshot_sha, @count)
|
|
1602
1613
|
`);
|
|
1603
|
-
function
|
|
1614
|
+
function resolveInstalled(kind, name, cwd, plugins) {
|
|
1604
1615
|
const listOf = (p) => (kind === 'skills' ? p.skills : p.commands);
|
|
1616
|
+
const fromPlugin = (p, shortName) => ({
|
|
1617
|
+
name: `${p.name}:${shortName}`,
|
|
1618
|
+
plugin: p.name, source: p.marketplace, repoRoot: p.repoRoot, snapshotSha: p.snapshotSha,
|
|
1619
|
+
});
|
|
1605
1620
|
const colonIdx = name.indexOf(':');
|
|
1606
1621
|
if (colonIdx > 0) {
|
|
1607
1622
|
const pluginName = name.slice(0, colonIdx);
|
|
1608
1623
|
const shortName = name.slice(colonIdx + 1);
|
|
1609
1624
|
const plugin = plugins.find((p) => p.name === pluginName && listOf(p).includes(shortName));
|
|
1610
|
-
|
|
1611
|
-
return {};
|
|
1612
|
-
return { plugin: plugin.name, source: plugin.marketplace, repoRoot: plugin.repoRoot, snapshotSha: plugin.snapshotSha };
|
|
1625
|
+
return plugin ? fromPlugin(plugin, shortName) : null;
|
|
1613
1626
|
}
|
|
1614
1627
|
const resolved = resolveResource(kind, name, cwd);
|
|
1615
1628
|
if (resolved)
|
|
1616
|
-
return { source: resolved.source, repoRoot: resolved.repoRoot, snapshotSha: resolved.snapshotSha };
|
|
1629
|
+
return { name: resolved.name, source: resolved.source, repoRoot: resolved.repoRoot, snapshotSha: resolved.snapshotSha };
|
|
1617
1630
|
const plugin = plugins.find((p) => listOf(p).includes(name));
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1631
|
+
return plugin ? fromPlugin(plugin, name) : null;
|
|
1632
|
+
}
|
|
1633
|
+
function canonicalResource(kind, name, cwd, plugins) {
|
|
1634
|
+
const own = resolveInstalled(kind === 'skill' ? 'skills' : 'commands', name, cwd, plugins);
|
|
1635
|
+
if (own)
|
|
1636
|
+
return { kind, ...own };
|
|
1637
|
+
if (kind === 'command') {
|
|
1638
|
+
const skill = resolveInstalled('skills', name, cwd, plugins);
|
|
1639
|
+
if (skill)
|
|
1640
|
+
return { kind: 'skill', ...skill };
|
|
1641
|
+
}
|
|
1642
|
+
return { kind, name };
|
|
1621
1643
|
}
|
|
1622
1644
|
function writeResourceUsageFromTallies(sessionId, skills, commands, cwd) {
|
|
1623
1645
|
const db = getDB();
|
|
@@ -1627,25 +1649,27 @@ function writeResourceUsageFromTallies(sessionId, skills, commands, cwd) {
|
|
|
1627
1649
|
if (skills.length === 0 && commands.length === 0)
|
|
1628
1650
|
return;
|
|
1629
1651
|
const plugins = discoverPlugins({ cwd });
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
const
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1652
|
+
const rows = new Map();
|
|
1653
|
+
const tally = (kind, name, count) => {
|
|
1654
|
+
const c = canonicalResource(kind, name, cwd, plugins);
|
|
1655
|
+
const key = `${c.kind}\0${c.name}`;
|
|
1656
|
+
const existing = rows.get(key);
|
|
1657
|
+
if (existing) {
|
|
1658
|
+
existing.count += count;
|
|
1659
|
+
return;
|
|
1660
|
+
}
|
|
1661
|
+
rows.set(key, {
|
|
1662
|
+
session_id: sessionId, kind: c.kind, name: c.name, count,
|
|
1663
|
+
plugin: c.plugin ?? null, source: c.source ?? null,
|
|
1664
|
+
repo_root: c.repoRoot ?? null, snapshot_sha: c.snapshotSha ?? null,
|
|
1665
|
+
});
|
|
1666
|
+
};
|
|
1667
|
+
for (const { name, count } of skills)
|
|
1668
|
+
tally('skill', name, count);
|
|
1669
|
+
for (const { name, count } of commands)
|
|
1670
|
+
tally('command', name.replace(/^\//, ''), count);
|
|
1671
|
+
for (const bind of rows.values())
|
|
1647
1672
|
ins.run(bind);
|
|
1648
|
-
}
|
|
1649
1673
|
}
|
|
1650
1674
|
function writeResourceUsage(sessionId, events, cwd) {
|
|
1651
1675
|
writeResourceUsageFromTallies(sessionId, extractSkills(events), extractSlashCommands(events), cwd);
|
|
@@ -2206,6 +2230,14 @@ export function latestSessionFileForCwd(agent, cwd, options) {
|
|
|
2206
2230
|
}
|
|
2207
2231
|
return row.file_path;
|
|
2208
2232
|
}
|
|
2233
|
+
export function indexedSessionIdForFile(agent, filePath) {
|
|
2234
|
+
if (!filePath)
|
|
2235
|
+
return undefined;
|
|
2236
|
+
const row = getDB()
|
|
2237
|
+
.prepare(`SELECT id FROM sessions WHERE file_path = ? AND agent = ? LIMIT 1`)
|
|
2238
|
+
.get(filePath, agent);
|
|
2239
|
+
return row?.id;
|
|
2240
|
+
}
|
|
2209
2241
|
function buildSessionWhere(options) {
|
|
2210
2242
|
const where = [];
|
|
2211
2243
|
const params = [];
|
|
@@ -3546,10 +3578,10 @@ function toStoredBrowserSession(row) {
|
|
|
3546
3578
|
}
|
|
3547
3579
|
export function listBrowserSessionRecords(profile, opts = {}) {
|
|
3548
3580
|
const db = getDB();
|
|
3549
|
-
const
|
|
3550
|
-
?
|
|
3551
|
-
|
|
3552
|
-
|
|
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]));
|
|
3553
3585
|
return rows.map(toStoredBrowserSession);
|
|
3554
3586
|
}
|
|
3555
3587
|
export function getBrowserSessionRecord(profile, task) {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { SessionEvent
|
|
2
|
-
import type { ActiveSession } from './active.js';
|
|
1
|
+
import type { SessionEvent } from '@phnx-labs/sessions-cli/reader';
|
|
2
|
+
import type { ActiveSession, WatchSubagent } from './active.js';
|
|
3
|
+
export declare const SUBAGENT_PROMPT_MAX_CHARS = 400;
|
|
3
4
|
export declare function resolvedSubAgentCount(children: readonly string[] | undefined, toolCount: number): number;
|
|
4
5
|
export declare function claudeSubagentFiles(sessionFile: string): string[] | undefined;
|
|
5
|
-
export declare function readSessionSubagents(sessionFile: string, parentLive: boolean, failedCalls?: readonly string[], nowMs?: number):
|
|
6
|
+
export declare function readSessionSubagents(sessionFile: string, parentLive: boolean, failedCalls?: readonly string[], nowMs?: number): WatchSubagent[] | undefined;
|
|
6
7
|
export declare function hasOpenInlineImage(sessionId: string): boolean;
|
|
7
8
|
export declare function dropOpenInlineImage(sessionId: string): void;
|
|
8
9
|
export declare function appendInlineImage(sessionId: string, chunk: string, mediaType: string): void;
|
|
@@ -3,6 +3,7 @@ import * as path from 'node:path';
|
|
|
3
3
|
import { createHash } from 'node:crypto';
|
|
4
4
|
import { getUserAgentsDir } from '../state.js';
|
|
5
5
|
import { indexArtifactSidecars, mergeArtifacts, parseClaudeContent, sanitizeEvents } from '@phnx-labs/sessions-cli/reader';
|
|
6
|
+
export const SUBAGENT_PROMPT_MAX_CHARS = 400;
|
|
6
7
|
const directoryCache = new Map();
|
|
7
8
|
const childFolds = new Map();
|
|
8
9
|
const MAX_CHILD_BYTES_PER_READ = 256 * 1024;
|
|
@@ -39,11 +40,31 @@ function foldChildEvents(fold, events) {
|
|
|
39
40
|
}
|
|
40
41
|
if (event.type === 'tool_use' && !event._local)
|
|
41
42
|
fold.toolCount++;
|
|
43
|
+
if (event.role === 'assistant' && event.model && (event.type === 'message' || event.type === 'usage'))
|
|
44
|
+
fold.model = event.model;
|
|
42
45
|
if (event.type === 'message' && event.role === 'assistant' && event.content) {
|
|
43
46
|
fold.resultExcerpt = event.content.slice(0, 200);
|
|
44
47
|
}
|
|
48
|
+
if (event.type === 'message' && event.role === 'user' && !fold.promptDone)
|
|
49
|
+
foldPrompt(fold, event);
|
|
45
50
|
}
|
|
46
51
|
}
|
|
52
|
+
function foldPrompt(fold, event) {
|
|
53
|
+
if (fold.prompt !== undefined && event._turnId !== fold.promptTurnId) {
|
|
54
|
+
fold.promptDone = true;
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (event._synthetic || event._meta)
|
|
58
|
+
return;
|
|
59
|
+
const text = (event.content ?? '').replace(/\s+/g, ' ').trim();
|
|
60
|
+
if (!text)
|
|
61
|
+
return;
|
|
62
|
+
const joined = fold.prompt ? `${fold.prompt} ${text}` : text;
|
|
63
|
+
fold.prompt = joined.length > SUBAGENT_PROMPT_MAX_CHARS ? joined.slice(0, SUBAGENT_PROMPT_MAX_CHARS) : joined;
|
|
64
|
+
fold.promptTurnId = event._turnId;
|
|
65
|
+
if (event._turnId === undefined || joined.length >= SUBAGENT_PROMPT_MAX_CHARS)
|
|
66
|
+
fold.promptDone = true;
|
|
67
|
+
}
|
|
47
68
|
function advanceChild(file, fold, size) {
|
|
48
69
|
if (size < fold.offset) {
|
|
49
70
|
fold.offset = 0;
|
|
@@ -52,6 +73,10 @@ function advanceChild(file, fold, size) {
|
|
|
52
73
|
fold.startedAtMs = undefined;
|
|
53
74
|
fold.endedAtMs = undefined;
|
|
54
75
|
fold.resultExcerpt = undefined;
|
|
76
|
+
fold.model = undefined;
|
|
77
|
+
fold.prompt = undefined;
|
|
78
|
+
fold.promptTurnId = undefined;
|
|
79
|
+
fold.promptDone = undefined;
|
|
55
80
|
}
|
|
56
81
|
const end = Math.min(size, fold.offset + MAX_CHILD_BYTES_PER_READ);
|
|
57
82
|
if (end <= fold.offset)
|
|
@@ -111,6 +136,10 @@ export function readSessionSubagents(sessionFile, parentLive, failedCalls = [],
|
|
|
111
136
|
startedAtMs: fold?.startedAtMs,
|
|
112
137
|
endedAtMs: fold?.endedAtMs,
|
|
113
138
|
resultExcerpt: fold?.resultExcerpt,
|
|
139
|
+
model: fold?.model,
|
|
140
|
+
prompt: fold?.prompt,
|
|
141
|
+
promptTurnId: fold?.promptTurnId,
|
|
142
|
+
promptDone: fold?.promptDone,
|
|
114
143
|
agentType: typeof meta.agentType === 'string' ? meta.agentType : '',
|
|
115
144
|
description: typeof meta.description === 'string' ? meta.description : '',
|
|
116
145
|
toolUseId: typeof meta.toolUseId === 'string' ? meta.toolUseId : undefined,
|
|
@@ -135,6 +164,8 @@ export function readSessionSubagents(sessionFile, parentLive, failedCalls = [],
|
|
|
135
164
|
...(fold.startedAtMs !== undefined ? { startedAtMs: fold.startedAtMs, endedAtMs: fold.endedAtMs } : {}),
|
|
136
165
|
toolCount: fold.toolCount,
|
|
137
166
|
...(fold.resultExcerpt ? { resultExcerpt: fold.resultExcerpt } : {}),
|
|
167
|
+
...(fold.model ? { model: fold.model } : {}),
|
|
168
|
+
...(fold.prompt ? { prompt: fold.prompt } : {}),
|
|
138
169
|
transcriptPath: file,
|
|
139
170
|
});
|
|
140
171
|
}
|
|
@@ -17,9 +17,19 @@ export function matchInjectSelector(session, token) {
|
|
|
17
17
|
}
|
|
18
18
|
export async function resolveLiveInjectTarget(selector) {
|
|
19
19
|
const sessions = await getActiveSessions();
|
|
20
|
-
const
|
|
21
|
-
if (
|
|
20
|
+
const matches = sessions.filter((s) => matchInjectSelector(s, selector));
|
|
21
|
+
if (matches.length === 0)
|
|
22
22
|
return { target: null, reason: `No active session matches "${selector}".` };
|
|
23
|
+
const exact = matches.filter((s) => [s.sessionId, s.tmuxName, s.paneId, s.tmuxName && shortIdFromName(s.tmuxName)].includes(selector));
|
|
24
|
+
const candidates = exact.length > 0 ? exact : matches;
|
|
25
|
+
if (candidates.length > 1) {
|
|
26
|
+
const names = candidates.map((s) => s.tmuxName ?? s.sessionId ?? s.paneId).join(', ');
|
|
27
|
+
return {
|
|
28
|
+
target: null,
|
|
29
|
+
reason: `"${selector}" matches ${candidates.length} live sessions (${names}); pass a longer id.`,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
const [match] = candidates;
|
|
23
33
|
const resolution = resolveInjectTargetForSession(match);
|
|
24
34
|
if (!resolution.addressable) {
|
|
25
35
|
return {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { LaunchOrigin } from '../launch-identity.js';
|
|
1
2
|
export interface PidSessionEntry {
|
|
2
3
|
pid: number;
|
|
3
4
|
agent: string;
|
|
@@ -8,6 +9,7 @@ export interface PidSessionEntry {
|
|
|
8
9
|
initiatedBy?: 'human' | 'agent';
|
|
9
10
|
launchId?: string;
|
|
10
11
|
terminalId?: string;
|
|
12
|
+
originTerminal?: LaunchOrigin;
|
|
11
13
|
tmuxPane?: string;
|
|
12
14
|
startedAtMs: number;
|
|
13
15
|
processIdentity?: {
|
|
@@ -139,12 +139,16 @@ function persistOwnership(entry) {
|
|
|
139
139
|
atomicWriteFileSync(ownershipPath(entry.pid), JSON.stringify(entry), 'utf8');
|
|
140
140
|
}
|
|
141
141
|
function restoreOwnership(entry) {
|
|
142
|
-
if (entry.processIdentity)
|
|
142
|
+
if (entry.processIdentity && (entry.originTerminal || !entry.terminalId || !entry.launchId))
|
|
143
143
|
return entry;
|
|
144
144
|
try {
|
|
145
145
|
const owner = JSON.parse(fs.readFileSync(ownershipPath(entry.pid), 'utf8'));
|
|
146
146
|
if (owner.pid === entry.pid && owner.launchId === entry.launchId && owner.startedAtMs === entry.startedAtMs) {
|
|
147
|
-
return {
|
|
147
|
+
return {
|
|
148
|
+
...entry,
|
|
149
|
+
processIdentity: entry.processIdentity ?? owner.processIdentity,
|
|
150
|
+
...(entry.originTerminal ?? owner.originTerminal ? { originTerminal: entry.originTerminal ?? owner.originTerminal } : {}),
|
|
151
|
+
};
|
|
148
152
|
}
|
|
149
153
|
}
|
|
150
154
|
catch { }
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type FilterOptions, type SessionMeta, type ViewMode } from '@phnx-labs/sessions-cli/reader';
|
|
2
|
+
import type { ActiveSession } from './active.js';
|
|
3
|
+
export declare function signalBadges(s: Pick<ActiveSession, 'awaitingReason' | 'pr' | 'worktree' | 'ticket'>): string;
|
|
4
|
+
export interface TranscriptRenderOptions {
|
|
5
|
+
json?: boolean;
|
|
6
|
+
markdown?: boolean;
|
|
7
|
+
redact?: boolean;
|
|
8
|
+
include?: string;
|
|
9
|
+
exclude?: string;
|
|
10
|
+
first?: string;
|
|
11
|
+
last?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare function metaSignals(s: SessionMeta): Parameters<typeof signalBadges>[0];
|
|
14
|
+
export declare function buildFilterOptions(options: TranscriptRenderOptions): FilterOptions;
|
|
15
|
+
export declare function hasAnyFilter(opts: FilterOptions): boolean;
|
|
16
|
+
export declare function resolveViewMode(options: TranscriptRenderOptions, filters: FilterOptions): ViewMode;
|
|
17
|
+
export declare function renderSessionLog(session: SessionMeta, mode?: ViewMode): Promise<void>;
|
|
18
|
+
export declare function renderSessionLogJson(session: SessionMeta): Promise<void>;
|
|
19
|
+
export declare function renderSession(session: SessionMeta, mode: ViewMode, filters: FilterOptions, options?: {
|
|
20
|
+
redact?: boolean;
|
|
21
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import ora from 'ora';
|
|
4
|
+
import { computeSummaryStats, filterEvents, inferSessionState, linearIssueUrl, linkUrl, parseRoleList, parseSession, renderConversationMarkdown, renderJson, renderSummary, renderSummaryHeader, sessionDisplayAgent, } from '@phnx-labs/sessions-cli/reader';
|
|
5
|
+
import { colorAgent } from '../agents.js';
|
|
6
|
+
import { renderMarkdown } from '../markdown.js';
|
|
7
|
+
import { redactSecrets } from '../redact.js';
|
|
8
|
+
import { readArchivedSessionPreview, readSessionContent } from './db.js';
|
|
9
|
+
import { formatRelativeTime } from './relative-time.js';
|
|
10
|
+
import { sessionHeadline } from './title.js';
|
|
11
|
+
export function signalBadges(s) {
|
|
12
|
+
const parts = [];
|
|
13
|
+
if (s.awaitingReason === 'plan_review')
|
|
14
|
+
parts.push(chalk.yellow('plan'));
|
|
15
|
+
else if (s.awaitingReason === 'question')
|
|
16
|
+
parts.push(chalk.yellow('ask'));
|
|
17
|
+
else if (s.awaitingReason === 'permission')
|
|
18
|
+
parts.push(chalk.yellow('perm'));
|
|
19
|
+
if (s.ticket) {
|
|
20
|
+
const url = linearIssueUrl(s.ticket.id);
|
|
21
|
+
parts.push(chalk.cyan(url ? linkUrl(url, s.ticket.id) : s.ticket.id));
|
|
22
|
+
}
|
|
23
|
+
if (s.pr) {
|
|
24
|
+
const label = `PR#${s.pr.number ?? '?'}`;
|
|
25
|
+
parts.push(chalk.blue(s.pr.url ? linkUrl(s.pr.url, label) : label));
|
|
26
|
+
}
|
|
27
|
+
if (s.worktree)
|
|
28
|
+
parts.push(chalk.magenta(`wt:${s.worktree.slug}`));
|
|
29
|
+
return parts.join(' ');
|
|
30
|
+
}
|
|
31
|
+
export function metaSignals(s) {
|
|
32
|
+
return {
|
|
33
|
+
pr: s.prUrl ? { url: s.prUrl, number: s.prNumber } : undefined,
|
|
34
|
+
worktree: s.worktreeSlug ? { path: s.cwd ?? '', slug: s.worktreeSlug } : undefined,
|
|
35
|
+
ticket: s.ticketId ? { id: s.ticketId } : undefined,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export function buildFilterOptions(options) {
|
|
39
|
+
const opts = {};
|
|
40
|
+
if (options.include)
|
|
41
|
+
opts.include = parseRoleList(options.include, '--include');
|
|
42
|
+
if (options.exclude)
|
|
43
|
+
opts.exclude = parseRoleList(options.exclude, '--exclude');
|
|
44
|
+
if (opts.include && opts.exclude) {
|
|
45
|
+
throw new Error('--include and --exclude are mutually exclusive');
|
|
46
|
+
}
|
|
47
|
+
const parseCount = (raw, flag) => {
|
|
48
|
+
const n = Number(raw);
|
|
49
|
+
if (!Number.isFinite(n) || !Number.isInteger(n) || n <= 0) {
|
|
50
|
+
throw new Error(`${flag} expects a positive integer, got "${raw}"`);
|
|
51
|
+
}
|
|
52
|
+
return n;
|
|
53
|
+
};
|
|
54
|
+
if (options.first !== undefined)
|
|
55
|
+
opts.first = parseCount(options.first, '--first');
|
|
56
|
+
if (options.last !== undefined)
|
|
57
|
+
opts.last = parseCount(options.last, '--last');
|
|
58
|
+
if (opts.first !== undefined && opts.last !== undefined) {
|
|
59
|
+
throw new Error('--first and --last are mutually exclusive');
|
|
60
|
+
}
|
|
61
|
+
return opts;
|
|
62
|
+
}
|
|
63
|
+
export function hasAnyFilter(opts) {
|
|
64
|
+
return !!(opts.include?.length || opts.exclude?.length || opts.first !== undefined || opts.last !== undefined);
|
|
65
|
+
}
|
|
66
|
+
export function resolveViewMode(options, filters) {
|
|
67
|
+
if (options.markdown)
|
|
68
|
+
return 'markdown';
|
|
69
|
+
if (options.json)
|
|
70
|
+
return 'json';
|
|
71
|
+
if (hasAnyFilter(filters))
|
|
72
|
+
return 'markdown';
|
|
73
|
+
return 'summary';
|
|
74
|
+
}
|
|
75
|
+
export async function renderSessionLog(session, mode = 'summary') {
|
|
76
|
+
await renderSession(session, mode, {});
|
|
77
|
+
}
|
|
78
|
+
export async function renderSessionLogJson(session) {
|
|
79
|
+
await renderSession(session, 'json', {});
|
|
80
|
+
}
|
|
81
|
+
function renderArchivedSession(session, mode, options = {}) {
|
|
82
|
+
const redact = (text) => options.redact !== false ? redactSecrets(text) : text;
|
|
83
|
+
const content = redact((readSessionContent(session.id) ?? '').trim());
|
|
84
|
+
const digestRaw = readArchivedSessionPreview(session.id);
|
|
85
|
+
const digest = digestRaw
|
|
86
|
+
? { ...digestRaw, lastAssistant: redact(digestRaw.lastAssistant ?? '') }
|
|
87
|
+
: undefined;
|
|
88
|
+
if (mode === 'json') {
|
|
89
|
+
console.log(JSON.stringify({
|
|
90
|
+
session: {
|
|
91
|
+
...session,
|
|
92
|
+
topic: session.topic != null ? redact(session.topic) : session.topic,
|
|
93
|
+
label: session.label != null ? redact(session.label) : session.label,
|
|
94
|
+
plan: session.plan != null ? redact(session.plan) : session.plan,
|
|
95
|
+
archived: true,
|
|
96
|
+
},
|
|
97
|
+
archived: true,
|
|
98
|
+
userContent: content,
|
|
99
|
+
preview: digest ?? null,
|
|
100
|
+
}, null, 2));
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
const shown = sessionDisplayAgent(session);
|
|
104
|
+
const agentColor = colorAgent(shown);
|
|
105
|
+
const absTime = formatAbsoluteTime(session.timestamp);
|
|
106
|
+
const title = sessionHeadline(session);
|
|
107
|
+
console.log('');
|
|
108
|
+
if (title)
|
|
109
|
+
console.log(chalk.bold.white(title));
|
|
110
|
+
console.log(agentColor(shown) +
|
|
111
|
+
(session.version ? chalk.yellow(` ${session.version}`) : '') +
|
|
112
|
+
(session.project ? chalk.cyan(` ${session.project}`) : '') +
|
|
113
|
+
chalk.gray(` ${absTime} (${formatRelativeTime(session.timestamp)})`) +
|
|
114
|
+
(session.account ? chalk.gray(` · ${session.account}`) : ''));
|
|
115
|
+
console.log(chalk.yellow('archived — transcript file removed; user turns served from the local DB'));
|
|
116
|
+
console.log(chalk.gray('─'.repeat(60)));
|
|
117
|
+
console.log(chalk.cyan('User:'));
|
|
118
|
+
console.log(content);
|
|
119
|
+
if (digest?.lastAssistant?.trim()) {
|
|
120
|
+
console.log('');
|
|
121
|
+
console.log(chalk.magenta('Last assistant:'));
|
|
122
|
+
console.log(digest.lastAssistant.trim());
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
export async function renderSession(session, mode, filters, options = {}) {
|
|
126
|
+
const { hydrateSessionTranscript } = await import('./discover.js');
|
|
127
|
+
session = await hydrateSessionTranscript(session);
|
|
128
|
+
const realPath = session.filePath.split('#')[0];
|
|
129
|
+
if (!fs.existsSync(realPath)) {
|
|
130
|
+
const archivedContent = readSessionContent(session.id);
|
|
131
|
+
if (archivedContent && archivedContent.trim() !== '') {
|
|
132
|
+
renderArchivedSession(session, mode, options);
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
process.exitCode = 1;
|
|
136
|
+
console.log(chalk.yellow('Session transcript is unavailable after checking its recorded home and the session index.'));
|
|
137
|
+
console.log(chalk.gray(`Path: ${session.filePath}`));
|
|
138
|
+
if (session.version)
|
|
139
|
+
console.log(chalk.gray(`Version: ${sessionDisplayAgent(session)} ${session.version}`));
|
|
140
|
+
if (session.project)
|
|
141
|
+
console.log(chalk.gray(`Project: ${session.project}`));
|
|
142
|
+
if (session.account)
|
|
143
|
+
console.log(chalk.gray(`Account: ${session.account}`));
|
|
144
|
+
console.log(chalk.gray(`Time: ${session.timestamp}`));
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
const spinner = ora(`Parsing ${sessionDisplayAgent(session)} session...`).start();
|
|
148
|
+
const parsedEvents = parseSession(session.filePath, session.agent);
|
|
149
|
+
spinner.stop();
|
|
150
|
+
let events = filterEvents(parsedEvents, filters);
|
|
151
|
+
const shown = sessionDisplayAgent(session);
|
|
152
|
+
const agentColor = colorAgent(shown);
|
|
153
|
+
console.log('');
|
|
154
|
+
if (mode === 'summary') {
|
|
155
|
+
const stats = computeSummaryStats(events);
|
|
156
|
+
const modelStr = stats.models.length > 0 ? chalk.yellow(` ${stats.models.join(', ')}`) : '';
|
|
157
|
+
const branchStr = session.gitBranch ? chalk.gray(` (${session.gitBranch})`) : '';
|
|
158
|
+
const absTime = formatAbsoluteTime(session.timestamp);
|
|
159
|
+
const title = sessionHeadline(session);
|
|
160
|
+
if (title) {
|
|
161
|
+
const badges = signalBadges(metaSignals(session));
|
|
162
|
+
console.log(chalk.bold.white(title) + (badges ? ' ' + badges : ''));
|
|
163
|
+
}
|
|
164
|
+
console.log(agentColor(shown) +
|
|
165
|
+
(session.version ? chalk.yellow(` ${session.version}`) : '') +
|
|
166
|
+
modelStr +
|
|
167
|
+
(session.project ? chalk.cyan(` ${session.project}`) + branchStr : branchStr) +
|
|
168
|
+
chalk.gray(` ${absTime} (${formatRelativeTime(session.timestamp)})`) +
|
|
169
|
+
(session.account ? chalk.gray(` · ${session.account}`) : ''));
|
|
170
|
+
const statsLine = renderSummaryHeader(stats);
|
|
171
|
+
if (statsLine)
|
|
172
|
+
console.log(chalk.gray(statsLine));
|
|
173
|
+
console.log(chalk.gray('─'.repeat(60)));
|
|
174
|
+
process.stdout.write(renderSummary(events, session.cwd));
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
if (mode === 'markdown') {
|
|
178
|
+
console.log(agentColor(shown) +
|
|
179
|
+
(session.version ? chalk.yellow(` ${session.version}`) : '') +
|
|
180
|
+
(session.project ? chalk.cyan(` ${session.project}`) : '') +
|
|
181
|
+
chalk.gray(` ${formatRelativeTime(session.timestamp)}`) +
|
|
182
|
+
(session.account ? chalk.gray(` (${session.account})`) : ''));
|
|
183
|
+
console.log(chalk.gray('─'.repeat(60)));
|
|
184
|
+
process.stdout.write(renderMarkdown(renderConversationMarkdown(events, { redact: options.redact !== false })));
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
const todos = inferSessionState(parsedEvents, { cwd: session.cwd }).todos;
|
|
188
|
+
process.stdout.write(renderJson(events, todos ? { ...session, todos } : session, { redact: options.redact !== false }));
|
|
189
|
+
}
|
|
190
|
+
function formatAbsoluteTime(isoTimestamp) {
|
|
191
|
+
const d = new Date(isoTimestamp);
|
|
192
|
+
if (isNaN(d.getTime()))
|
|
193
|
+
return isoTimestamp;
|
|
194
|
+
const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
195
|
+
const hh = String(d.getHours()).padStart(2, '0');
|
|
196
|
+
const mm = String(d.getMinutes()).padStart(2, '0');
|
|
197
|
+
return `${months[d.getMonth()]} ${d.getDate()} ${hh}:${mm}`;
|
|
198
|
+
}
|
|
@@ -63,8 +63,15 @@ 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 }))
|
|
67
|
-
|
|
66
|
+
.map(({ scope: device, row }) => ({ device, terminalId: row.terminalId, launchId: row.launchId, viewingIn: row.viewingIn, provenance: row.provenance }));
|
|
67
|
+
const origin = chosen.originTerminal;
|
|
68
|
+
if (!chosen.previous && origin && normalizeHost(origin.device) !== owner) {
|
|
69
|
+
const device = normalizeHost(origin.device);
|
|
70
|
+
if (!observerTerminals.some(item => item.device === device && item.terminalId === origin.terminalId)) {
|
|
71
|
+
observerTerminals.push({ device, terminalId: origin.terminalId, launchId: chosen.launchId, viewingIn: null });
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
observerTerminals.sort((a, b) => a.device.localeCompare(b.device) || (a.terminalId ?? '').localeCompare(b.terminalId ?? ''));
|
|
68
75
|
next.set(rowKey, {
|
|
69
76
|
...chosen, rowKey, sourceDevice: owner, machine: owner,
|
|
70
77
|
observerTerminals,
|
package/dist/lib/sqlite.d.ts
CHANGED
|
@@ -16,7 +16,9 @@ declare class StatementImpl<_T = unknown> {
|
|
|
16
16
|
}
|
|
17
17
|
declare class Database {
|
|
18
18
|
private readonly inner;
|
|
19
|
-
constructor(filename: string
|
|
19
|
+
constructor(filename: string, options?: {
|
|
20
|
+
readOnly?: boolean;
|
|
21
|
+
});
|
|
20
22
|
prepare<T = unknown>(sql: string): StatementImpl<T>;
|
|
21
23
|
exec(sql: string): void;
|
|
22
24
|
pragma(stmt: string): void;
|
package/dist/lib/sqlite.js
CHANGED
|
@@ -29,7 +29,11 @@ const sqliteMod = isBun
|
|
|
29
29
|
: loadNodeSqlite();
|
|
30
30
|
const NativeDatabase = sqliteMod.Database
|
|
31
31
|
?? sqliteMod.DatabaseSync;
|
|
32
|
-
|
|
32
|
+
function nativeOptions(readOnly) {
|
|
33
|
+
if (isBun)
|
|
34
|
+
return readOnly ? { strict: true, readonly: true } : { strict: true };
|
|
35
|
+
return readOnly ? { readOnly: true } : {};
|
|
36
|
+
}
|
|
33
37
|
function bindArgs(params) {
|
|
34
38
|
if (params.length === 1 &&
|
|
35
39
|
params[0] !== null &&
|
|
@@ -57,8 +61,8 @@ class StatementImpl {
|
|
|
57
61
|
}
|
|
58
62
|
class Database {
|
|
59
63
|
inner;
|
|
60
|
-
constructor(filename) {
|
|
61
|
-
this.inner = new NativeDatabase(filename,
|
|
64
|
+
constructor(filename, options = {}) {
|
|
65
|
+
this.inner = new NativeDatabase(filename, nativeOptions(options.readOnly === true));
|
|
62
66
|
}
|
|
63
67
|
prepare(sql) {
|
|
64
68
|
return new StatementImpl(this.inner.prepare(sql));
|
|
@@ -81,6 +81,10 @@ export function buildManifest(agent, version, cwd, previous) {
|
|
|
81
81
|
target[name] = entry;
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
+
manifest.retired = {
|
|
85
|
+
commands: retireRemoved(manifest.commands, previous?.commands, previous?.retired?.commands),
|
|
86
|
+
skills: retireRemoved(manifest.skills, previous?.skills, previous?.retired?.skills),
|
|
87
|
+
};
|
|
84
88
|
if (previous?.rules && !isRulesStale(previous.rules, agent, version, cwd)) {
|
|
85
89
|
manifest.rules = previous.rules;
|
|
86
90
|
}
|
|
@@ -95,6 +99,14 @@ export function buildManifest(agent, version, cwd, previous) {
|
|
|
95
99
|
}
|
|
96
100
|
return manifest;
|
|
97
101
|
}
|
|
102
|
+
function retireRemoved(current, previous, previouslyRetired) {
|
|
103
|
+
const retired = {};
|
|
104
|
+
for (const [name, entry] of Object.entries({ ...previouslyRetired, ...previous })) {
|
|
105
|
+
if (!(name in current))
|
|
106
|
+
retired[name] = entry;
|
|
107
|
+
}
|
|
108
|
+
return retired;
|
|
109
|
+
}
|
|
98
110
|
export function isStale(manifest, agent, version, cwd) {
|
|
99
111
|
for (const { checker, field } of STANDARD_CHECKERS) {
|
|
100
112
|
const storedMap = (manifest[field] ?? {});
|
|
@@ -29,4 +29,9 @@ export interface SyncManifest {
|
|
|
29
29
|
workflows?: Record<string, DirEntry>;
|
|
30
30
|
plugins?: Record<string, PluginEntry>;
|
|
31
31
|
writtenTargets?: string[];
|
|
32
|
+
retired?: RetiredEntries;
|
|
33
|
+
}
|
|
34
|
+
export interface RetiredEntries {
|
|
35
|
+
commands: Record<string, FileEntry>;
|
|
36
|
+
skills: Record<string, DirEntry>;
|
|
32
37
|
}
|
|
@@ -4,7 +4,7 @@ import { SECRETS_CLI_PACKAGE, SECRETS_CLI_VERSION } from './secrets-cli.js';
|
|
|
4
4
|
export const STANDALONE_TOOLS = ['sessions', 'browser', 'secrets', 'computer', 'term'];
|
|
5
5
|
export const STANDALONE_TOOL_PINS = {
|
|
6
6
|
sessions: { tool: 'sessions', pkg: '@phnx-labs/sessions-cli', floor: '0.5.0' },
|
|
7
|
-
browser: { tool: 'browser', pkg: '@phnx-labs/browser-cli', floor: '0.1.
|
|
7
|
+
browser: { tool: 'browser', pkg: '@phnx-labs/browser-cli', floor: '0.1.16' },
|
|
8
8
|
secrets: { tool: 'secrets', pkg: SECRETS_CLI_PACKAGE, floor: SECRETS_CLI_VERSION },
|
|
9
9
|
computer: { tool: 'computer', pkg: '@phnx-labs/computer-cli', floor: '0.1.5' },
|
|
10
10
|
term: { tool: 'term', pkg: '@phnx-labs/term-cli', floor: '0.1.0' },
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
const LOADED_COMMAND_NAMES = [
|
|
2
|
-
'accounts', 'auth', 'view', 'inspect', '
|
|
2
|
+
'accounts', 'auth', 'view', 'inspect', 'commands', 'hooks', 'skills', 'rules', 'memory',
|
|
3
3
|
'permissions', 'mcp', 'clis', 'subagents', 'plugins', 'workflows', 'add', 'use',
|
|
4
4
|
'remove', 'rm', 'purge', 'update', 'prune', 'import', 'registry', 'search', 'install', 'packages',
|
|
5
|
-
'routines', '
|
|
6
|
-
'models', '
|
|
5
|
+
'routines', 'projects', 'run', '_callback', 'open', 'fork', 'config',
|
|
6
|
+
'models', 'trash', 'doctor',
|
|
7
7
|
'route', 'routes', 'harness', 'harnesses', 'secrets', 'menubar', 'sync',
|
|
8
|
-
'refresh-rules', 'factory', 'insights', 'trace',
|
|
8
|
+
'refresh-rules', 'factory', 'insights', 'trace',
|
|
9
9
|
'tmux', 'watchdog', 'browser', 'computer', 'logs', 'events',
|
|
10
10
|
'ssh', 'devices', 'fleet', 'repos', 'repo', 'setup', 'uninstall', 'upgrade', 'sessions',
|
|
11
11
|
'teams', 'cloud', 'message', 'ps', 'send', 'feed',
|
|
12
12
|
'mailboxes', 'mailbox', 'webhooks',
|
|
13
|
-
'
|
|
13
|
+
'daemon', 'traces', 'recordings',
|
|
14
14
|
];
|
|
15
15
|
const INLINE_COMMAND_NAMES = [
|
|
16
16
|
'perms', 'exec', 'jobs', 'cron', 'check', 'resources', 'hq', '_internal',
|
|
@@ -51,6 +51,11 @@ export const RETIRED_TOP_LEVEL_COMMANDS = new Set([
|
|
|
51
51
|
'beta',
|
|
52
52
|
'perf',
|
|
53
53
|
'list',
|
|
54
|
+
'humans',
|
|
55
|
+
'reminders',
|
|
56
|
+
'modes',
|
|
57
|
+
'feedback',
|
|
58
|
+
'restore',
|
|
54
59
|
]);
|
|
55
60
|
export function isKnownTopLevelCommand(name) {
|
|
56
61
|
return KNOWN_TOP_LEVEL_COMMANDS.has(name);
|