@phnx-labs/agents-cli 1.22.122 → 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 +261 -0
- package/README.md +49 -10
- package/dist/bootstrap.js +22 -17
- package/dist/cli/command-registry.d.ts +0 -1
- package/dist/cli/command-registry.js +2 -10
- 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 +6 -0
- 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/models.js +1 -1
- 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.js +1 -1
- package/dist/commands/teams.js +2 -2
- package/dist/commands/testdata/feed-hub.d.ts +1 -0
- 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 -8
- 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 -5
- package/dist/lib/device-config.d.ts +4 -1
- package/dist/lib/device-config.js +57 -7
- 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 +18 -5
- 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 -8
- 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/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/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/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 +2 -0
- package/dist/lib/session/db.js +13 -4
- 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/standalone-tools.js +1 -1
- package/dist/lib/startup/command-registry.js +9 -4
- package/dist/lib/state.d.ts +2 -2
- package/dist/lib/state.js +3 -5
- 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 -1
- 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/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/humans.d.ts +0 -12
- package/dist/lib/humans.js +0 -64
|
@@ -22,21 +22,18 @@ import { loadLocalActiveSessions, readActiveSessionsCache, } from '../lib/sessio
|
|
|
22
22
|
import { gatherRemoteList, gatherRemoteToolProgramCounts, gatherRemoteToolSearch, runOnPeer } from '../lib/session/remote-list.js';
|
|
23
23
|
import { gatherRemoteAgentsJson } from '../lib/remote-agents-json.js';
|
|
24
24
|
import { stringWidth, truncateToWidth, padToWidth, terminalWidth } from '../lib/session/width.js';
|
|
25
|
-
import { inferSessionState } from '@phnx-labs/sessions-cli/reader';
|
|
26
25
|
import { discoverSessions, queryIndexedSessions, countSessionsInScope, resolveSessionById, isCompleteSessionId, looksLikeSessionId, searchContentIndex, getSessionRoots, scopeToManaged } from '../lib/session/discover.js';
|
|
27
|
-
import { findSessionsById, querySessions,
|
|
26
|
+
import { findSessionsById, querySessions, readSessionTimelineAny } from '../lib/session/db.js';
|
|
28
27
|
import { foldTimeline, emptyTimelineState, projectTimeline, projectSessionFiles } from '@phnx-labs/sessions-cli/reader';
|
|
29
28
|
import { readSessionTail } from '@phnx-labs/sessions-cli/reader';
|
|
30
29
|
import { liveSessionMetas, fleetExecutionMachineById, reconcileLiveMetaMachine } from '../lib/session/live-metadata.js';
|
|
31
30
|
import { sessionHeadline } from '../lib/session/title.js';
|
|
32
31
|
import { filterTeamSessions, shouldShowTeamSessions, safeTeamText, groupSessionsByTeam, NO_TEAM_GROUP_KEY, } from '@phnx-labs/sessions-cli/reader';
|
|
33
|
-
import { parseSession } from '@phnx-labs/sessions-cli/reader';
|
|
34
32
|
import { runRemoteSessions, buildForwardedArgs, ensureWholeIndex } from '../lib/session/remote.js';
|
|
35
33
|
import { formatRelativeTime, sessionAgeParts } from '../lib/session/relative-time.js';
|
|
36
|
-
import {
|
|
34
|
+
import { linkPath, linkUrl, shortenModel, formatTokenCount } from '@phnx-labs/sessions-cli/reader';
|
|
37
35
|
import { linearIssueUrl } from '@phnx-labs/sessions-cli/reader';
|
|
38
36
|
import { sessionOwnerDevice, RESUME_PINNED_ENV } from '../lib/session/resume-owner.js';
|
|
39
|
-
import { renderMarkdown } from '../lib/markdown.js';
|
|
40
37
|
import { AGENTS, colorAgent, resolveAgentName } from '../lib/agents.js';
|
|
41
38
|
import { getShimsDir } from '../lib/state.js';
|
|
42
39
|
import { listJobs, listJobsWithRuns, listRuns, getRunDir } from '../lib/scheduling/routines.js';
|
|
@@ -50,7 +47,9 @@ import { sessionAgentSupportsResume, sessionRecoveryRunArgs } from '../lib/sessi
|
|
|
50
47
|
import { isInteractiveTerminal, isPromptCancelled } from './utils.js';
|
|
51
48
|
import { sessionPicker, buildPreview, loadSessionPreviewDigest, transcriptOnPeerOf, formatTodoCompact, } from './sessions-picker.js';
|
|
52
49
|
import { setHelpSections } from '../lib/help.js';
|
|
53
|
-
import { cleanPreview, gatherActiveSessions, indexActiveBySessionId, isAwaitingUser, liveGlyphAndPreview, liveStatusWord, remoteHostsToDial, requestedLiveStatuses, resolveRoutineName, runLiveRoster, shouldIncludeLocal,
|
|
50
|
+
import { cleanPreview, gatherActiveSessions, indexActiveBySessionId, isAwaitingUser, liveGlyphAndPreview, liveStatusWord, remoteHostsToDial, requestedLiveStatuses, resolveRoutineName, runLiveRoster, shouldIncludeLocal, statusColor, } from './ps-roster.js';
|
|
51
|
+
import { buildFilterOptions, hasAnyFilter, metaSignals, renderSession, resolveViewMode, signalBadges, } from '../lib/session/presentation.js';
|
|
52
|
+
export { buildFilterOptions, renderSession, renderSessionLog, renderSessionLogJson, resolveViewMode, } from '../lib/session/presentation.js';
|
|
54
53
|
import { registerSessionsTailCommand } from './sessions-tail.js';
|
|
55
54
|
import { registerSessionsResumeCommand } from './sessions-resume.js';
|
|
56
55
|
import { registerSessionsForkCommand } from './fork.js';
|
|
@@ -1199,7 +1198,8 @@ async function sessionsAction(query, options, limitSource) {
|
|
|
1199
1198
|
return;
|
|
1200
1199
|
}
|
|
1201
1200
|
if (options.cloud) {
|
|
1202
|
-
await
|
|
1201
|
+
const { runCloudTranscripts } = await import('./cloud-transcripts.js');
|
|
1202
|
+
await runCloudTranscripts(query, options);
|
|
1203
1203
|
return;
|
|
1204
1204
|
}
|
|
1205
1205
|
if (isBareBrowserListing(options, query)) {
|
|
@@ -1575,13 +1575,6 @@ function originTag(session) {
|
|
|
1575
1575
|
return '';
|
|
1576
1576
|
return `[routine${session.routineName ? ` · ${session.routineName}` : ''}] `;
|
|
1577
1577
|
}
|
|
1578
|
-
function metaSignals(s) {
|
|
1579
|
-
return {
|
|
1580
|
-
pr: s.prUrl ? { url: s.prUrl, number: s.prNumber } : undefined,
|
|
1581
|
-
worktree: s.worktreeSlug ? { path: s.cwd ?? '', slug: s.worktreeSlug } : undefined,
|
|
1582
|
-
ticket: s.ticketId ? { id: s.ticketId } : undefined,
|
|
1583
|
-
};
|
|
1584
|
-
}
|
|
1585
1578
|
const MIN_TOPIC_W = 16;
|
|
1586
1579
|
function timeCell(age, topicSlack) {
|
|
1587
1580
|
const lastOnly = { plain: age.last, text: chalk.gray(age.last), extraW: 0 };
|
|
@@ -1741,7 +1734,7 @@ function printSessionOverview(pool, hiddenCount, liveIndex, opts) {
|
|
|
1741
1734
|
if (opts.hiddenUnmanaged)
|
|
1742
1735
|
console.log(chalk.gray(formatUnmanagedHiddenFooter(opts.hiddenUnmanaged)));
|
|
1743
1736
|
}
|
|
1744
|
-
function printSessionTable(sessions, hiddenCount = 0, tree = false, liveIndex) {
|
|
1737
|
+
export function printSessionTable(sessions, hiddenCount = 0, tree = false, liveIndex) {
|
|
1745
1738
|
if (tree) {
|
|
1746
1739
|
const byDir = new Map();
|
|
1747
1740
|
for (const s of sessions) {
|
|
@@ -1868,158 +1861,6 @@ function printTeamsView(pool, liveIndex, hiddenUnmanaged = 0) {
|
|
|
1868
1861
|
if (hiddenUnmanaged > 0)
|
|
1869
1862
|
console.log(chalk.gray(formatUnmanagedHiddenFooter(hiddenUnmanaged)));
|
|
1870
1863
|
}
|
|
1871
|
-
function buildFilterOptions(options) {
|
|
1872
|
-
const opts = {};
|
|
1873
|
-
if (options.include)
|
|
1874
|
-
opts.include = parseRoleList(options.include, '--include');
|
|
1875
|
-
if (options.exclude)
|
|
1876
|
-
opts.exclude = parseRoleList(options.exclude, '--exclude');
|
|
1877
|
-
if (opts.include && opts.exclude) {
|
|
1878
|
-
throw new Error('--include and --exclude are mutually exclusive');
|
|
1879
|
-
}
|
|
1880
|
-
const parseCount = (raw, flag) => {
|
|
1881
|
-
const n = Number(raw);
|
|
1882
|
-
if (!Number.isFinite(n) || !Number.isInteger(n) || n <= 0) {
|
|
1883
|
-
throw new Error(`${flag} expects a positive integer, got "${raw}"`);
|
|
1884
|
-
}
|
|
1885
|
-
return n;
|
|
1886
|
-
};
|
|
1887
|
-
if (options.first !== undefined)
|
|
1888
|
-
opts.first = parseCount(options.first, '--first');
|
|
1889
|
-
if (options.last !== undefined)
|
|
1890
|
-
opts.last = parseCount(options.last, '--last');
|
|
1891
|
-
if (opts.first !== undefined && opts.last !== undefined) {
|
|
1892
|
-
throw new Error('--first and --last are mutually exclusive');
|
|
1893
|
-
}
|
|
1894
|
-
return opts;
|
|
1895
|
-
}
|
|
1896
|
-
function hasAnyFilter(opts) {
|
|
1897
|
-
return !!(opts.include?.length || opts.exclude?.length || opts.first !== undefined || opts.last !== undefined);
|
|
1898
|
-
}
|
|
1899
|
-
function resolveViewMode(options, filters) {
|
|
1900
|
-
if (options.markdown)
|
|
1901
|
-
return 'markdown';
|
|
1902
|
-
if (options.json)
|
|
1903
|
-
return 'json';
|
|
1904
|
-
if (hasAnyFilter(filters))
|
|
1905
|
-
return 'markdown';
|
|
1906
|
-
return 'summary';
|
|
1907
|
-
}
|
|
1908
|
-
export async function renderSessionLog(session, mode = 'summary') {
|
|
1909
|
-
await renderSession(session, mode, {});
|
|
1910
|
-
}
|
|
1911
|
-
export async function renderSessionLogJson(session) {
|
|
1912
|
-
await renderSession(session, 'json', {});
|
|
1913
|
-
}
|
|
1914
|
-
function renderArchivedSession(session, mode, options = {}) {
|
|
1915
|
-
const redact = (text) => options.redact !== false ? redactSecrets(text) : text;
|
|
1916
|
-
const content = redact((readSessionContent(session.id) ?? '').trim());
|
|
1917
|
-
const digestRaw = readArchivedSessionPreview(session.id);
|
|
1918
|
-
const digest = digestRaw
|
|
1919
|
-
? { ...digestRaw, lastAssistant: redact(digestRaw.lastAssistant ?? '') }
|
|
1920
|
-
: undefined;
|
|
1921
|
-
if (mode === 'json') {
|
|
1922
|
-
console.log(JSON.stringify({
|
|
1923
|
-
session: {
|
|
1924
|
-
...session,
|
|
1925
|
-
topic: session.topic != null ? redact(session.topic) : session.topic,
|
|
1926
|
-
label: session.label != null ? redact(session.label) : session.label,
|
|
1927
|
-
plan: session.plan != null ? redact(session.plan) : session.plan,
|
|
1928
|
-
archived: true,
|
|
1929
|
-
},
|
|
1930
|
-
archived: true,
|
|
1931
|
-
userContent: content,
|
|
1932
|
-
preview: digest ?? null,
|
|
1933
|
-
}, null, 2));
|
|
1934
|
-
return;
|
|
1935
|
-
}
|
|
1936
|
-
const shown = sessionDisplayAgent(session);
|
|
1937
|
-
const agentColor = colorAgent(shown);
|
|
1938
|
-
const absTime = formatAbsoluteTime(session.timestamp);
|
|
1939
|
-
const title = sessionHeadline(session);
|
|
1940
|
-
console.log('');
|
|
1941
|
-
if (title)
|
|
1942
|
-
console.log(chalk.bold.white(title));
|
|
1943
|
-
console.log(agentColor(shown) +
|
|
1944
|
-
(session.version ? chalk.yellow(` ${session.version}`) : '') +
|
|
1945
|
-
(session.project ? chalk.cyan(` ${session.project}`) : '') +
|
|
1946
|
-
chalk.gray(` ${absTime} (${formatRelativeTime(session.timestamp)})`) +
|
|
1947
|
-
(session.account ? chalk.gray(` · ${session.account}`) : ''));
|
|
1948
|
-
console.log(chalk.yellow('archived — transcript file removed; user turns served from the local DB'));
|
|
1949
|
-
console.log(chalk.gray('─'.repeat(60)));
|
|
1950
|
-
console.log(chalk.cyan('User:'));
|
|
1951
|
-
console.log(content);
|
|
1952
|
-
if (digest?.lastAssistant?.trim()) {
|
|
1953
|
-
console.log('');
|
|
1954
|
-
console.log(chalk.magenta('Last assistant:'));
|
|
1955
|
-
console.log(digest.lastAssistant.trim());
|
|
1956
|
-
}
|
|
1957
|
-
}
|
|
1958
|
-
async function renderSession(session, mode, filters, options = {}) {
|
|
1959
|
-
const { hydrateSessionTranscript, findLocalSessionTranscripts } = await import('../lib/session/discover.js');
|
|
1960
|
-
session = await hydrateSessionTranscript(session);
|
|
1961
|
-
const realPath = session.filePath.split('#')[0];
|
|
1962
|
-
if (!fs.existsSync(realPath)) {
|
|
1963
|
-
const archivedContent = readSessionContent(session.id);
|
|
1964
|
-
if (archivedContent && archivedContent.trim() !== '') {
|
|
1965
|
-
renderArchivedSession(session, mode, options);
|
|
1966
|
-
return;
|
|
1967
|
-
}
|
|
1968
|
-
process.exitCode = 1;
|
|
1969
|
-
console.log(chalk.yellow('Session transcript is unavailable after checking its recorded home and the session index.'));
|
|
1970
|
-
console.log(chalk.gray(`Path: ${session.filePath}`));
|
|
1971
|
-
if (session.version)
|
|
1972
|
-
console.log(chalk.gray(`Version: ${sessionDisplayAgent(session)} ${session.version}`));
|
|
1973
|
-
if (session.project)
|
|
1974
|
-
console.log(chalk.gray(`Project: ${session.project}`));
|
|
1975
|
-
if (session.account)
|
|
1976
|
-
console.log(chalk.gray(`Account: ${session.account}`));
|
|
1977
|
-
console.log(chalk.gray(`Time: ${session.timestamp}`));
|
|
1978
|
-
return;
|
|
1979
|
-
}
|
|
1980
|
-
const spinner = ora(`Parsing ${sessionDisplayAgent(session)} session...`).start();
|
|
1981
|
-
const parsedEvents = parseSession(session.filePath, session.agent);
|
|
1982
|
-
spinner.stop();
|
|
1983
|
-
let events = filterEvents(parsedEvents, filters);
|
|
1984
|
-
const shown = sessionDisplayAgent(session);
|
|
1985
|
-
const agentColor = colorAgent(shown);
|
|
1986
|
-
console.log('');
|
|
1987
|
-
if (mode === 'summary') {
|
|
1988
|
-
const stats = computeSummaryStats(events);
|
|
1989
|
-
const modelStr = stats.models.length > 0 ? chalk.yellow(` ${stats.models.join(', ')}`) : '';
|
|
1990
|
-
const branchStr = session.gitBranch ? chalk.gray(` (${session.gitBranch})`) : '';
|
|
1991
|
-
const absTime = formatAbsoluteTime(session.timestamp);
|
|
1992
|
-
const title = sessionHeadline(session);
|
|
1993
|
-
if (title) {
|
|
1994
|
-
const badges = signalBadges(metaSignals(session));
|
|
1995
|
-
console.log(chalk.bold.white(title) + (badges ? ' ' + badges : ''));
|
|
1996
|
-
}
|
|
1997
|
-
console.log(agentColor(shown) +
|
|
1998
|
-
(session.version ? chalk.yellow(` ${session.version}`) : '') +
|
|
1999
|
-
modelStr +
|
|
2000
|
-
(session.project ? chalk.cyan(` ${session.project}`) + branchStr : branchStr) +
|
|
2001
|
-
chalk.gray(` ${absTime} (${formatRelativeTime(session.timestamp)})`) +
|
|
2002
|
-
(session.account ? chalk.gray(` · ${session.account}`) : ''));
|
|
2003
|
-
const statsLine = renderSummaryHeader(stats);
|
|
2004
|
-
if (statsLine)
|
|
2005
|
-
console.log(chalk.gray(statsLine));
|
|
2006
|
-
console.log(chalk.gray('─'.repeat(60)));
|
|
2007
|
-
process.stdout.write(renderSummary(events, session.cwd));
|
|
2008
|
-
return;
|
|
2009
|
-
}
|
|
2010
|
-
if (mode === 'markdown') {
|
|
2011
|
-
console.log(agentColor(shown) +
|
|
2012
|
-
(session.version ? chalk.yellow(` ${session.version}`) : '') +
|
|
2013
|
-
(session.project ? chalk.cyan(` ${session.project}`) : '') +
|
|
2014
|
-
chalk.gray(` ${formatRelativeTime(session.timestamp)}`) +
|
|
2015
|
-
(session.account ? chalk.gray(` (${session.account})`) : ''));
|
|
2016
|
-
console.log(chalk.gray('─'.repeat(60)));
|
|
2017
|
-
process.stdout.write(renderMarkdown(renderConversationMarkdown(events, { redact: options.redact !== false })));
|
|
2018
|
-
return;
|
|
2019
|
-
}
|
|
2020
|
-
const todos = inferSessionState(parsedEvents, { cwd: session.cwd }).todos;
|
|
2021
|
-
process.stdout.write(renderJson(events, todos ? { ...session, todos } : session, { redact: options.redact !== false }));
|
|
2022
|
-
}
|
|
2023
1864
|
function renderTopicCell(label, topic, query, visibleWidth, paddedWidth) {
|
|
2024
1865
|
const lbl = (label ?? '').trim();
|
|
2025
1866
|
const tpc = (topic ?? '').trim();
|
|
@@ -2346,66 +2187,6 @@ export function buildResumeCommand(session) {
|
|
|
2346
2187
|
return null;
|
|
2347
2188
|
}
|
|
2348
2189
|
}
|
|
2349
|
-
async function runCloudSessions(query, options) {
|
|
2350
|
-
const { discoverCloudSessions, ensureCloudSessionCached } = await import('../lib/session/cloud.js');
|
|
2351
|
-
let filterOpts;
|
|
2352
|
-
try {
|
|
2353
|
-
filterOpts = buildFilterOptions(options);
|
|
2354
|
-
}
|
|
2355
|
-
catch (err) {
|
|
2356
|
-
console.error(chalk.red(err.message));
|
|
2357
|
-
process.exit(1);
|
|
2358
|
-
}
|
|
2359
|
-
const mode = resolveViewMode(options, filterOpts);
|
|
2360
|
-
const spinner = options.json ? null : interruptibleSpinner('Loading cloud sessions...').start();
|
|
2361
|
-
let sessions;
|
|
2362
|
-
try {
|
|
2363
|
-
sessions = await discoverCloudSessions({ limit: parseInt(options.limit || '50', 10) });
|
|
2364
|
-
}
|
|
2365
|
-
catch (err) {
|
|
2366
|
-
spinner?.stop();
|
|
2367
|
-
console.error(chalk.red(`Failed to list cloud sessions: ${err?.message || err}`));
|
|
2368
|
-
process.exit(1);
|
|
2369
|
-
}
|
|
2370
|
-
spinner?.stop();
|
|
2371
|
-
if (!query) {
|
|
2372
|
-
if (options.json) {
|
|
2373
|
-
process.stdout.write(JSON.stringify(sessions, null, 2) + '\n');
|
|
2374
|
-
return;
|
|
2375
|
-
}
|
|
2376
|
-
if (sessions.length === 0) {
|
|
2377
|
-
console.log(chalk.gray('No cloud sessions captured yet.'));
|
|
2378
|
-
return;
|
|
2379
|
-
}
|
|
2380
|
-
printSessionTable(sessions);
|
|
2381
|
-
return;
|
|
2382
|
-
}
|
|
2383
|
-
const matches = sessions.filter((s) => s.id === query || s.shortId === query || s.id.startsWith(query));
|
|
2384
|
-
if (matches.length === 0) {
|
|
2385
|
-
console.error(chalk.red(`No cloud session matching: ${query}`));
|
|
2386
|
-
process.exit(1);
|
|
2387
|
-
}
|
|
2388
|
-
if (matches.length > 1) {
|
|
2389
|
-
console.error(chalk.red(`Multiple cloud sessions match "${query}":`));
|
|
2390
|
-
for (const m of matches.slice(0, 10)) {
|
|
2391
|
-
console.error(chalk.cyan(` ${m.shortId} ${m.id}`));
|
|
2392
|
-
}
|
|
2393
|
-
process.exit(1);
|
|
2394
|
-
}
|
|
2395
|
-
const meta = matches[0];
|
|
2396
|
-
const cachedSpinner = options.json ? null : interruptibleSpinner('Fetching session...').start();
|
|
2397
|
-
let cachedPath;
|
|
2398
|
-
try {
|
|
2399
|
-
cachedPath = await ensureCloudSessionCached(meta.id);
|
|
2400
|
-
}
|
|
2401
|
-
catch (err) {
|
|
2402
|
-
cachedSpinner?.stop();
|
|
2403
|
-
console.error(chalk.red(`Failed to fetch session: ${err?.message || err}`));
|
|
2404
|
-
process.exit(1);
|
|
2405
|
-
}
|
|
2406
|
-
cachedSpinner?.stop();
|
|
2407
|
-
await renderSession({ ...meta, filePath: cachedPath }, mode, filterOpts, options);
|
|
2408
|
-
}
|
|
2409
2190
|
export function resolveSessionAgentName(name) {
|
|
2410
2191
|
const normalized = name.toLowerCase();
|
|
2411
2192
|
if (SESSION_AGENTS.includes(normalized)) {
|
|
@@ -3510,12 +3291,3 @@ function sessionDistance(session, historyEntry) {
|
|
|
3510
3291
|
return Number.MAX_SAFE_INTEGER;
|
|
3511
3292
|
return Math.abs(sessionTime - historyEntry.timestampMs);
|
|
3512
3293
|
}
|
|
3513
|
-
function formatAbsoluteTime(isoTimestamp) {
|
|
3514
|
-
const d = new Date(isoTimestamp);
|
|
3515
|
-
if (isNaN(d.getTime()))
|
|
3516
|
-
return isoTimestamp;
|
|
3517
|
-
const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
3518
|
-
const hh = String(d.getHours()).padStart(2, '0');
|
|
3519
|
-
const mm = String(d.getMinutes()).padStart(2, '0');
|
|
3520
|
-
return `${months[d.getMonth()]} ${d.getDate()} ${hh}:${mm}`;
|
|
3521
|
-
}
|
|
@@ -2,8 +2,7 @@ import { openSetupTerminal } from './setup-terminal.js';
|
|
|
2
2
|
import os from 'node:os';
|
|
3
3
|
import { execFileSync } from 'node:child_process';
|
|
4
4
|
import chalk from 'chalk';
|
|
5
|
-
import { installComputerHelperMacLocal, activateComputerHelperMacLocal, probeComputerTrust, } from '
|
|
6
|
-
import { resolveComputerBin, ComputerClientError } from '../lib/computer-client.js';
|
|
5
|
+
import { installComputerHelperMacLocal, activateComputerHelperMacLocal, probeComputerTrust, resolveComputerBin, ComputerClientError, } from '../lib/computer-client.js';
|
|
7
6
|
import { isInteractiveTerminal, isPromptCancelled } from './utils.js';
|
|
8
7
|
import { installSetupTool } from '../lib/setup-tool-install.js';
|
|
9
8
|
import { refreshToolSetup } from '../lib/setup-tool-status.js';
|
package/dist/commands/setup.js
CHANGED
|
@@ -27,7 +27,7 @@ import { registerBetaCommands } from './beta.js';
|
|
|
27
27
|
import { addUrlSchemeSubcommands } from './open.js';
|
|
28
28
|
import { runPreferencesStep } from './setup-preferences.js';
|
|
29
29
|
import { browserInstalled } from '../lib/browser-client.js';
|
|
30
|
-
import { probeComputerTrust } from '
|
|
30
|
+
import { probeComputerTrust } from '../lib/computer-client.js';
|
|
31
31
|
import { loadDevices } from '../lib/devices/registry.js';
|
|
32
32
|
import { getConfigValue } from '../lib/device-config.js';
|
|
33
33
|
import { setupSecretsPrefsPath } from './setup-secrets.js';
|
package/dist/commands/teams.js
CHANGED
|
@@ -30,7 +30,7 @@ import { machineId } from '../lib/session/sync/config.js';
|
|
|
30
30
|
import { isVersionInstalled, resolveVersionAlias, resolveVersionAliasLoose } from '../lib/installations/versions.js';
|
|
31
31
|
import { AGENTS, warnAgentDeprecated } from '../lib/agents.js';
|
|
32
32
|
import { discoverSessions, parseTimeFilter, resolveSessionById } from '../lib/session/discover.js';
|
|
33
|
-
import { renderSessionLog } from '
|
|
33
|
+
import { renderSessionLog } from '../lib/session/presentation.js';
|
|
34
34
|
import { buildPreview as buildSessionPreview } from './sessions-picker.js';
|
|
35
35
|
import { parseExecEnv } from '../lib/exec.js';
|
|
36
36
|
import { checkRunAccountReadiness } from '../lib/accounting/rotate.js';
|
|
@@ -1268,7 +1268,7 @@ export function registerTeamsCommands(program) {
|
|
|
1268
1268
|
.alias('a')
|
|
1269
1269
|
.description("Add a teammate to work on a task. Runs in background; returns immediately. Use 'status' to check in.")
|
|
1270
1270
|
.option('-n, --name <name>', 'Friendly name for this teammate (e.g. alice). Required if using --after. Unique within team.')
|
|
1271
|
-
.option('-m, --mode <mode>', `Permissions: plan (read-only) | edit (can write files) | auto (more autonomous than edit, mechanism per-harness — see 'agents
|
|
1271
|
+
.option('-m, --mode <mode>', `Permissions: plan (read-only) | edit (can write files) | auto (more autonomous than edit, mechanism per-harness — see 'agents run --help') | skip (bypass all permission prompts). 'full' accepted as alias for skip. Teammates run headless: plan works headless on claude/codex/cursor/droid/opencode; kimi/grok/antigravity have no headless plan mode and auto-downgrade a plan request to auto.`, 'edit')
|
|
1272
1272
|
.option('-e, --effort <effort>', `Reasoning intensity: ${VALID_EFFORTS.join('|')}`, 'medium')
|
|
1273
1273
|
.option('--model <model>', 'Cost tier (cheap|default|best|ultra) or a concrete id (e.g. claude-opus-4-8); tiers resolve per harness+version to a supported model')
|
|
1274
1274
|
.option('--env <key=value>', 'Set an environment variable for this teammate (repeatable for multiple vars)', (val, prev) => [...prev, val], [])
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { FeedHub } from '../../lib/feed/hub.js';
|
|
2
|
+
import { FeedHubServer } from '../../lib/feed/hub-server.js';
|
|
3
|
+
import { watchFleetFeed, watchLocalFeed } from '../../lib/feed/watch.js';
|
|
4
|
+
import { machineId } from '../../lib/machine-id.js';
|
|
5
|
+
const local = new FeedHub({
|
|
6
|
+
watch: ({ signal, emit }) => watchLocalFeed({ scope: machineId(), signal, emit, sessions: { heartbeatMs: 200 } }),
|
|
7
|
+
});
|
|
8
|
+
const server = new FeedHubServer(new FeedHub({ watch: watchFleetFeed }), undefined, local);
|
|
9
|
+
await server.start();
|
|
10
|
+
process.stdout.write('ready\n');
|
|
11
|
+
process.once('SIGTERM', () => { void server.stop().then(() => process.exit(0)); });
|
package/dist/commands/trash.d.ts
CHANGED
package/dist/commands/trash.js
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
2
|
import * as fs from 'fs';
|
|
3
3
|
import * as path from 'path';
|
|
4
|
+
import { confirm } from '@inquirer/prompts';
|
|
4
5
|
import { resolveAgentName, agentLabel } from '../lib/agents.js';
|
|
5
|
-
import { getTrashVersionsDir } from '../lib/state.js';
|
|
6
|
+
import { getTrashDir, getTrashVersionsDir } from '../lib/state.js';
|
|
6
7
|
import { getVersionDir } from '../lib/installations/versions.js';
|
|
8
|
+
import { parseDuration } from '../lib/hooks/cache.js';
|
|
9
|
+
import { emptyTrash, listTrashItems } from '../lib/trash.js';
|
|
10
|
+
import { setHelpSections } from '../lib/help.js';
|
|
11
|
+
import { isInteractiveTerminal, isPromptCancelled } from './utils.js';
|
|
7
12
|
function listTrashEntries(filterAgent) {
|
|
8
13
|
const root = getTrashVersionsDir();
|
|
9
14
|
if (!fs.existsSync(root))
|
|
@@ -127,7 +132,7 @@ export function restoreVersion(target) {
|
|
|
127
132
|
const dest = getVersionDir(agent, version);
|
|
128
133
|
if (fs.existsSync(dest)) {
|
|
129
134
|
console.error(chalk.red(`Cannot restore: ${dest} already exists.`));
|
|
130
|
-
console.error(chalk.gray('Move or remove the existing dir first, then re-run restore.'));
|
|
135
|
+
console.error(chalk.gray('Move or remove the existing dir first, then re-run agents trash restore.'));
|
|
131
136
|
process.exit(1);
|
|
132
137
|
}
|
|
133
138
|
try {
|
|
@@ -149,16 +154,10 @@ export function restoreVersion(target) {
|
|
|
149
154
|
catch { }
|
|
150
155
|
console.log(chalk.green(`Restored ${agentLabel(agent)}@${version} to ${dest}`));
|
|
151
156
|
}
|
|
152
|
-
export function registerRestoreCommand(program) {
|
|
153
|
-
program
|
|
154
|
-
.command('restore <target>')
|
|
155
|
-
.description('Restore a soft-deleted agent version (e.g. "codex@0.141.0") removed via prune/remove')
|
|
156
|
-
.action((target) => restoreVersion(target));
|
|
157
|
-
}
|
|
158
157
|
export function registerTrashCommands(program) {
|
|
159
158
|
const trash = program
|
|
160
159
|
.command('trash')
|
|
161
|
-
.description('Inspect and
|
|
160
|
+
.description('Inspect, restore, and empty soft-deleted agent versions and resources');
|
|
162
161
|
trash
|
|
163
162
|
.command('list [agent]')
|
|
164
163
|
.description('List soft-deleted version directories (optionally filtered to one agent)')
|
|
@@ -184,6 +183,71 @@ export function registerTrashCommands(program) {
|
|
|
184
183
|
chalk.gray(`${e.stamp} ${size} ${e.trashPath}`));
|
|
185
184
|
}
|
|
186
185
|
console.log();
|
|
187
|
-
console.log(chalk.gray('Restore with: agents restore <agent>@<version>'));
|
|
186
|
+
console.log(chalk.gray('Restore with: agents trash restore <agent>@<version>'));
|
|
187
|
+
});
|
|
188
|
+
trash
|
|
189
|
+
.command('restore <target>')
|
|
190
|
+
.description('Restore the newest soft-deleted copy of an agent version (e.g. "codex@0.141.0")')
|
|
191
|
+
.action((target) => restoreVersion(target));
|
|
192
|
+
const empty = trash
|
|
193
|
+
.command('empty')
|
|
194
|
+
.description('Permanently delete trashed items, optionally only those trashed before a cutoff')
|
|
195
|
+
.option('--older-than <duration>', 'only items trashed at least this long ago (e.g. 30d, 12h)')
|
|
196
|
+
.option('-y, --yes', 'skip the confirmation prompt')
|
|
197
|
+
.action(async (opts) => runTrashEmpty(opts));
|
|
198
|
+
setHelpSections(empty, {
|
|
199
|
+
examples: `
|
|
200
|
+
agents trash list
|
|
201
|
+
agents trash empty --older-than 30d
|
|
202
|
+
agents trash empty --yes
|
|
203
|
+
`,
|
|
204
|
+
notes: `
|
|
205
|
+
Removes items from ~/.agents/.history/trash for good; they cannot be
|
|
206
|
+
restored afterwards. An item's age is the time it was moved to trash.
|
|
207
|
+
Without --yes, a terminal asks first and a non-interactive shell refuses.
|
|
208
|
+
`,
|
|
188
209
|
});
|
|
189
210
|
}
|
|
211
|
+
async function runTrashEmpty(opts) {
|
|
212
|
+
let olderThanMs;
|
|
213
|
+
if (opts.olderThan !== undefined) {
|
|
214
|
+
const seconds = parseDuration(opts.olderThan);
|
|
215
|
+
if (seconds === null) {
|
|
216
|
+
console.error(chalk.red(`Invalid --older-than '${opts.olderThan}'. Use a number with s, m, h or d (e.g. 30d).`));
|
|
217
|
+
process.exit(1);
|
|
218
|
+
}
|
|
219
|
+
olderThanMs = seconds * 1000;
|
|
220
|
+
}
|
|
221
|
+
const now = Date.now();
|
|
222
|
+
const due = listTrashItems().filter((item) => olderThanMs === undefined || now - item.trashedAtMs >= olderThanMs);
|
|
223
|
+
if (due.length === 0) {
|
|
224
|
+
console.log(chalk.gray(opts.olderThan ? `Nothing in trash is older than ${opts.olderThan}.` : 'Trash is empty.'));
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
const bytes = due.reduce((sum, item) => sum + dirSizeBytes(item.path), 0);
|
|
228
|
+
if (!opts.yes) {
|
|
229
|
+
if (!isInteractiveTerminal()) {
|
|
230
|
+
console.error(chalk.yellow(`Would permanently delete ${due.length} trashed item(s) (${humanSize(bytes)}). Pass --yes to confirm.`));
|
|
231
|
+
process.exit(1);
|
|
232
|
+
}
|
|
233
|
+
let ok = false;
|
|
234
|
+
try {
|
|
235
|
+
ok = await confirm({ message: `Permanently delete ${due.length} trashed item(s) (${humanSize(bytes)})?`, default: false });
|
|
236
|
+
}
|
|
237
|
+
catch (err) {
|
|
238
|
+
if (isPromptCancelled(err)) {
|
|
239
|
+
console.log(chalk.gray('Cancelled'));
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
throw err;
|
|
243
|
+
}
|
|
244
|
+
if (!ok) {
|
|
245
|
+
console.log(chalk.gray('Cancelled'));
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
const { removed, kept } = emptyTrash({ olderThanMs, now });
|
|
250
|
+
console.log(chalk.green(`Deleted ${removed.length} trashed item(s) (${humanSize(bytes)}) from ${getTrashDir()}.`));
|
|
251
|
+
if (kept > 0)
|
|
252
|
+
console.log(chalk.gray(`${kept} newer item(s) kept.`));
|
|
253
|
+
}
|
|
@@ -118,6 +118,13 @@ export async function publishOwnFleetState(options = {}) {
|
|
|
118
118
|
}
|
|
119
119
|
if (auth.error)
|
|
120
120
|
errors.push(`auth: ${auth.error}`);
|
|
121
|
+
try {
|
|
122
|
+
const { publishOwnerNotifyState } = await import('../owner-notify-tokens.js');
|
|
123
|
+
await publishOwnerNotifyState({ userAgentsDir: options.userAgentsDir, device: options.device });
|
|
124
|
+
}
|
|
125
|
+
catch (err) {
|
|
126
|
+
errors.push(`owner-notify: ${err.message}`);
|
|
127
|
+
}
|
|
121
128
|
return { usage, mirror, auth, errors };
|
|
122
129
|
}
|
|
123
130
|
// Workers never initiate or poll OAuth usage; only headed peers publish the usage rows they own.
|
|
@@ -17,4 +17,4 @@ export interface AgentModesCatalog {
|
|
|
17
17
|
notes: string[];
|
|
18
18
|
}
|
|
19
19
|
export declare function getAgentModesCatalog(agent: AgentId, version?: string | null, cwd?: string): AgentModesCatalog;
|
|
20
|
-
export declare function
|
|
20
|
+
export declare function formatModeSupportTable(): string;
|
package/dist/lib/agent-modes.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ALL_MODES } from './types.js';
|
|
2
|
-
import { AGENTS } from './agents.js';
|
|
2
|
+
import { AGENTS, ALL_AGENT_IDS } from './agents.js';
|
|
3
3
|
import { AGENT_COMMANDS, defaultModeFor } from './exec.js';
|
|
4
4
|
import { resolveRunDefaults } from './run-defaults.js';
|
|
5
5
|
export const MODE_DESCRIPTIONS = {
|
|
@@ -60,8 +60,14 @@ export function getAgentModesCatalog(agent, version, cwd = process.cwd()) {
|
|
|
60
60
|
notes,
|
|
61
61
|
};
|
|
62
62
|
}
|
|
63
|
-
export function
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
return
|
|
63
|
+
export function formatModeSupportTable() {
|
|
64
|
+
const agents = ALL_AGENT_IDS.filter((id) => !AGENTS[id].deprecated?.hard);
|
|
65
|
+
const width = Math.max(...agents.map((id) => id.length));
|
|
66
|
+
return agents
|
|
67
|
+
.map((agent) => {
|
|
68
|
+
const defaultMode = defaultModeFor(agent);
|
|
69
|
+
const modes = AGENTS[agent].capabilities.modes.map((mode) => (mode === defaultMode ? `${mode}*` : mode));
|
|
70
|
+
return `${agent.padEnd(width)} ${modes.join(' ')}`;
|
|
71
|
+
})
|
|
72
|
+
.join('\n');
|
|
67
73
|
}
|
package/dist/lib/auth-mint.d.ts
CHANGED
|
@@ -55,6 +55,10 @@ export declare function seedReservedStoreKey(harness: AgentId, kind: StorableCre
|
|
|
55
55
|
bundle: string;
|
|
56
56
|
key: string;
|
|
57
57
|
};
|
|
58
|
+
export declare function writeReservedStoreItem(name: string, key: string, value: string, description: string): {
|
|
59
|
+
bundle: string;
|
|
60
|
+
key: string;
|
|
61
|
+
};
|
|
58
62
|
export interface AdoptLegacyReservedItemsResult {
|
|
59
63
|
adopted: Array<{
|
|
60
64
|
bundle: string;
|
package/dist/lib/auth-mint.js
CHANGED
|
@@ -204,10 +204,12 @@ export function workerCredentialStoreKey(harness, accountId) {
|
|
|
204
204
|
export function seedReservedStoreKey(harness, kind, key, value) {
|
|
205
205
|
// Reserved worker bundles are real file-backed policy-never stores, never rotating OAuth/session credentials.
|
|
206
206
|
assertStorableCredentialKind(kind, harness);
|
|
207
|
-
|
|
207
|
+
return writeReservedStoreItem(reservedStoreName(harness), key, value, `Reserved ${harness} worker credentials (${kind}), one key per account; pushed to worker devices by the daemon. Never a native OAuth session.`);
|
|
208
|
+
}
|
|
209
|
+
export function writeReservedStoreItem(name, key, value, description) {
|
|
208
210
|
const cleaned = value.trim();
|
|
209
211
|
if (!cleaned)
|
|
210
|
-
throw new Error(`Empty
|
|
212
|
+
throw new Error(`Empty value for reserved store '${name}' key ${key}.`);
|
|
211
213
|
const item = secretsKeychainItem(name, key);
|
|
212
214
|
try {
|
|
213
215
|
if (bundleExistsSync(name)) {
|
|
@@ -231,7 +233,7 @@ export function seedReservedStoreKey(harness, kind, key, value) {
|
|
|
231
233
|
name,
|
|
232
234
|
backend: 'file',
|
|
233
235
|
policy: 'never',
|
|
234
|
-
description
|
|
236
|
+
description,
|
|
235
237
|
vars: { [key]: keychainRef(key) },
|
|
236
238
|
meta: { [key]: { type: 'token' } },
|
|
237
239
|
};
|
|
@@ -240,7 +242,7 @@ export function seedReservedStoreKey(harness, kind, key, value) {
|
|
|
240
242
|
}
|
|
241
243
|
catch (err) {
|
|
242
244
|
if (isSecretsClientError(err, 'OPERATION_FAILED')) {
|
|
243
|
-
throw new Error(`Could not write the reserved store '${name}' as a bundle: ${err.message}. agents-cli needs @phnx-labs/secrets-cli 0.1.1 or newer, which accepts the __<
|
|
245
|
+
throw new Error(`Could not write the reserved store '${name}' as a bundle: ${err.message}. agents-cli needs @phnx-labs/secrets-cli 0.1.1 or newer, which accepts the __<name>__ bundle name: npm i -g @phnx-labs/secrets-cli@latest`);
|
|
244
246
|
}
|
|
245
247
|
throw err;
|
|
246
248
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { BrowserTaskSummary } from './sessions-list.js';
|
|
2
|
+
export declare class NativeHistoryWriter {
|
|
3
|
+
readonly file: string;
|
|
4
|
+
private readonly db;
|
|
5
|
+
constructor(file: string);
|
|
6
|
+
put(record: Omit<BrowserTaskSummary, 'counts'> & {
|
|
7
|
+
counts?: BrowserTaskSummary['counts'];
|
|
8
|
+
}): void;
|
|
9
|
+
putMany(records: Parameters<NativeHistoryWriter['put']>[0][]): void;
|
|
10
|
+
rawRecord(profile: string, task: string, record: string, lastActivity: number): void;
|
|
11
|
+
close(): void;
|
|
12
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
import Database from '../sqlite.js';
|
|
4
|
+
export class NativeHistoryWriter {
|
|
5
|
+
file;
|
|
6
|
+
db;
|
|
7
|
+
constructor(file) {
|
|
8
|
+
this.file = file;
|
|
9
|
+
fs.mkdirSync(path.dirname(file), { recursive: true, mode: 0o700 });
|
|
10
|
+
this.db = new Database(file);
|
|
11
|
+
this.db.exec(`PRAGMA busy_timeout=5000;
|
|
12
|
+
PRAGMA journal_mode=WAL;
|
|
13
|
+
PRAGMA wal_autocheckpoint=0;
|
|
14
|
+
CREATE TABLE IF NOT EXISTS tasks (
|
|
15
|
+
profile TEXT NOT NULL, task TEXT NOT NULL, last_activity INTEGER NOT NULL,
|
|
16
|
+
record TEXT NOT NULL, native INTEGER NOT NULL DEFAULT 1, PRIMARY KEY(profile, task));
|
|
17
|
+
CREATE INDEX IF NOT EXISTS tasks_activity ON tasks(last_activity DESC);
|
|
18
|
+
CREATE TABLE IF NOT EXISTS migrations (name TEXT PRIMARY KEY);`);
|
|
19
|
+
this.db.exec('PRAGMA user_version=1');
|
|
20
|
+
}
|
|
21
|
+
put(record) {
|
|
22
|
+
this.db.prepare(`INSERT INTO tasks(profile,task,last_activity,record,native) VALUES(?,?,?,?,1)
|
|
23
|
+
ON CONFLICT(profile,task) DO UPDATE SET
|
|
24
|
+
last_activity=MAX(tasks.last_activity,excluded.last_activity), native=excluded.native,
|
|
25
|
+
record=json_set(
|
|
26
|
+
CASE WHEN excluded.last_activity >= tasks.last_activity
|
|
27
|
+
THEN json_patch(tasks.record,excluded.record)
|
|
28
|
+
ELSE json_patch(excluded.record,tasks.record) END,
|
|
29
|
+
'$.lastActivity', MAX(tasks.last_activity,excluded.last_activity),
|
|
30
|
+
'$.startedAt', MIN(json_extract(tasks.record,'$.startedAt'),json_extract(excluded.record,'$.startedAt')))`).run(record.profile, record.task, record.lastActivity, JSON.stringify(record));
|
|
31
|
+
}
|
|
32
|
+
putMany(records) {
|
|
33
|
+
this.db.transaction(() => { for (const record of records)
|
|
34
|
+
this.put(record); })();
|
|
35
|
+
}
|
|
36
|
+
rawRecord(profile, task, record, lastActivity) {
|
|
37
|
+
this.db.prepare('INSERT OR REPLACE INTO tasks(profile,task,last_activity,record,native) VALUES(?,?,?,?,1)')
|
|
38
|
+
.run(profile, task, lastActivity, record);
|
|
39
|
+
}
|
|
40
|
+
close() {
|
|
41
|
+
this.db.close();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
export { getBrowserDurableDir } from '../state.js';
|
|
2
2
|
export declare function getBrowserRuntimeDir(): string;
|
|
3
3
|
export declare function getProfileRuntimeDir(name: string): string;
|
|
4
|
+
export declare function profileOfCacheKey(key: string): string;
|
|
5
|
+
export declare function profileScopeSql(column: string, profile: string): {
|
|
6
|
+
sql: string;
|
|
7
|
+
params: string[];
|
|
8
|
+
};
|
|
4
9
|
export declare function listProfileCacheDirs(profileName: string): string[];
|