@phnx-labs/agents-cli 1.23.17 → 1.23.19
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 +239 -0
- package/README.md +140 -165
- package/dist/bootstrap.js +11 -17
- package/dist/cli/command-registry.d.ts +1 -2
- package/dist/cli/command-registry.js +1 -10
- package/dist/commands/accounts.js +7 -7
- package/dist/commands/cloud-transcripts.d.ts +0 -1
- package/dist/commands/cloud-transcripts.js +2 -2
- package/dist/commands/cloud.js +2 -2
- package/dist/commands/config.js +1 -5
- package/dist/commands/cost.js +1 -1
- package/dist/commands/daemon-index.js +0 -1
- package/dist/commands/detach.d.ts +1 -1
- package/dist/commands/detach.js +10 -6
- package/dist/commands/doctor.js +11 -7
- package/dist/commands/exec.d.ts +0 -17
- package/dist/commands/exec.js +26 -72
- package/dist/commands/feed.d.ts +1 -1
- package/dist/commands/feed.js +3 -3
- package/dist/commands/focus.d.ts +11 -6
- package/dist/commands/focus.js +91 -31
- package/dist/commands/fork.d.ts +0 -1
- package/dist/commands/fork.js +7 -16
- package/dist/commands/harness-wizard.js +1 -1
- package/dist/commands/harness.js +1 -1
- package/dist/commands/insights.d.ts +0 -1
- package/dist/commands/insights.js +3 -7
- package/dist/commands/open.js +1 -1
- package/dist/commands/output.js +1 -1
- package/dist/commands/profiles.d.ts +1 -1
- package/dist/commands/profiles.js +2 -2
- package/dist/commands/projects-todo.js +10 -5
- package/dist/commands/projects.js +1 -1
- package/dist/commands/prune.js +1 -1
- package/dist/commands/ps.d.ts +8 -3
- package/dist/commands/ps.js +238 -110
- package/dist/commands/routines.js +1 -1
- package/dist/commands/send.js +1 -1
- package/dist/commands/sessions-backfill.d.ts +0 -1
- package/dist/commands/sessions-backfill.js +3 -6
- package/dist/commands/sessions-browser.d.ts +0 -10
- package/dist/commands/sessions-browser.js +19 -25
- package/dist/commands/sessions-migrate.d.ts +2 -2
- package/dist/commands/sessions-migrate.js +13 -13
- package/dist/commands/sessions-optimize.d.ts +0 -1
- package/dist/commands/sessions-optimize.js +0 -3
- package/dist/commands/sessions-picker.d.ts +0 -7
- package/dist/commands/sessions-picker.js +16 -310
- package/dist/commands/sessions-resume.d.ts +16 -15
- package/dist/commands/sessions-resume.js +101 -269
- package/dist/commands/sessions-stats.d.ts +0 -1
- package/dist/commands/sessions-stats.js +5 -8
- package/dist/commands/sessions-stop.d.ts +1 -1
- package/dist/commands/sessions-stop.js +8 -8
- package/dist/commands/sessions-trace.d.ts +1 -1
- package/dist/commands/sessions-trace.js +40 -17
- package/dist/commands/sessions-watch.js +2 -2
- package/dist/commands/sessions.test-fixture.d.ts +1 -0
- package/dist/commands/sessions.test-fixture.js +14 -0
- package/dist/commands/setup-browser.js +4 -4
- package/dist/commands/setup-computer.js +4 -4
- package/dist/commands/setup-fleet.js +1 -1
- package/dist/commands/setup-preferences.js +1 -1
- package/dist/commands/{sessions-backup-setup.d.ts → setup-session-backup.d.ts} +2 -2
- package/dist/commands/{sessions-backup-setup.js → setup-session-backup.js} +8 -8
- package/dist/commands/setup.js +3 -1
- package/dist/commands/ssh.js +4 -5
- package/dist/commands/sync.js +1 -1
- package/dist/commands/teams.js +2 -2
- package/dist/commands/utils.d.ts +0 -1
- package/dist/commands/utils.js +0 -10
- package/dist/index.js +0 -71
- package/dist/lib/account-registry.d.ts +3 -0
- package/dist/lib/account-registry.js +40 -0
- package/dist/lib/accounting/usage-sync.d.ts +1 -0
- package/dist/lib/accounting/usage-sync.js +20 -3
- package/dist/lib/accounting/usage.d.ts +4 -1
- package/dist/lib/accounting/usage.js +38 -6
- package/dist/lib/agent-spec/agents.js +12 -11
- package/dist/lib/analytics/mix-commands.js +1 -1
- package/dist/lib/auth-mint.js +2 -2
- package/dist/lib/browser-client.d.ts +0 -1
- package/dist/lib/browser-client.js +0 -3
- package/dist/lib/cloud/antigravity.js +1 -1
- package/dist/lib/cloud/cursor.js +3 -3
- package/dist/lib/cloud/store.d.ts +5 -1
- package/dist/lib/cloud/store.js +10 -3
- package/dist/lib/cloudflare/creds.js +2 -2
- package/dist/lib/computer/context.d.ts +4 -21
- package/dist/lib/computer/context.js +3 -24
- package/dist/lib/computer/policy.d.ts +0 -10
- package/dist/lib/computer/policy.js +0 -28
- package/dist/lib/computer-client.d.ts +0 -44
- package/dist/lib/computer-client.js +17 -121
- package/dist/lib/config-keys.d.ts +2 -2
- package/dist/lib/config-keys.js +1 -3
- package/dist/lib/crabbox/cli.js +1 -1
- package/dist/lib/daemon/account-state-daemon-service.js +9 -2
- package/dist/lib/daemon/self-update-service.js +1 -1
- package/dist/lib/device-config.d.ts +2 -1
- package/dist/lib/device-config.js +26 -39
- package/dist/lib/devices/connect.d.ts +1 -1
- package/dist/lib/devices/connect.js +3 -6
- package/dist/lib/devices/doctor-findings.d.ts +2 -1
- package/dist/lib/devices/doctor-findings.js +4 -4
- package/dist/lib/devices/health.d.ts +6 -0
- package/dist/lib/devices/health.js +11 -4
- package/dist/lib/exec.js +1 -1
- package/dist/lib/feed/activity.js +1 -1
- package/dist/lib/feed/watch.js +2 -1
- package/dist/lib/fleet/apply.d.ts +1 -1
- package/dist/lib/fleet/apply.js +6 -3
- package/dist/lib/fleet-shared-state.d.ts +2 -0
- package/dist/lib/fleet-shared-state.js +3 -1
- package/dist/lib/github/project-prs.js +14 -1
- package/dist/lib/help.d.ts +0 -1
- package/dist/lib/help.js +2 -10
- package/dist/lib/helper-versions.js +1 -1
- package/dist/lib/hosts/option.js +1 -1
- package/dist/lib/hosts/passthrough.d.ts +0 -1
- package/dist/lib/hosts/passthrough.js +2 -26
- package/dist/lib/hosts/reconnect.js +5 -5
- package/dist/lib/hosts/remote-cmd.d.ts +3 -5
- package/dist/lib/hosts/remote-cmd.js +15 -20
- package/dist/lib/hosts/remote-session-id.js +1 -1
- package/dist/lib/installations/active-check.js +1 -1
- package/dist/lib/installations/migrate.js +4 -15
- package/dist/lib/installations/versions.js +5 -4
- package/dist/lib/launch-log.js +3 -6
- package/dist/lib/owner-notify.d.ts +1 -6
- package/dist/lib/owner-notify.js +0 -2
- package/dist/lib/paths.d.ts +0 -1
- package/dist/lib/paths.js +0 -8
- package/dist/lib/permissions.js +1 -1
- package/dist/lib/project-root.d.ts +1 -0
- package/dist/lib/project-root.js +11 -3
- package/dist/lib/projects.js +2 -2
- package/dist/lib/quick-todo.d.ts +5 -1
- package/dist/lib/quick-todo.js +14 -1
- package/dist/lib/redact.d.ts +0 -1
- package/dist/lib/redact.js +0 -4
- package/dist/lib/remote-agents-json.d.ts +3 -1
- package/dist/lib/remote-agents-json.js +12 -8
- package/dist/lib/reserved-stores.js +1 -1
- package/dist/lib/scheduling/routines.d.ts +0 -1
- package/dist/lib/scheduling/routines.js +1 -1
- package/dist/lib/self-update.d.ts +1 -1
- package/dist/lib/self-update.js +59 -2
- package/dist/lib/session/active.d.ts +1 -1
- package/dist/lib/session/db.js +4 -4
- package/dist/lib/session/detached.d.ts +0 -1
- package/dist/lib/session/detached.js +0 -23
- package/dist/lib/session/discover.d.ts +2 -2
- package/dist/lib/session/glance-files.d.ts +21 -0
- package/dist/lib/session/glance-files.js +123 -0
- package/dist/lib/session/presentation.d.ts +3 -7
- package/dist/lib/session/presentation.js +4 -4
- package/dist/lib/session/preview-digest.d.ts +13 -0
- package/dist/lib/session/preview-digest.js +328 -0
- package/dist/lib/session/projection.js +1 -1
- package/dist/lib/session/remote/remote-list.d.ts +5 -2
- package/dist/lib/session/remote/remote-list.js +15 -8
- package/dist/lib/session/remote/watch.d.ts +2 -0
- package/dist/lib/session/remote/watch.js +90 -10
- package/dist/lib/session/remote-active.js +1 -1
- package/dist/lib/session/resume-command.d.ts +0 -1
- package/dist/lib/session/resume-command.js +1 -4
- package/dist/lib/session/resume-owner.d.ts +0 -2
- package/dist/lib/session/resume-owner.js +0 -6
- package/dist/lib/session/selection.d.ts +4 -5
- package/dist/lib/session/selection.js +2 -2
- package/dist/lib/session/sync/config.d.ts +0 -25
- package/dist/lib/session/sync/config.js +0 -62
- package/dist/lib/session/sync/managed-config.d.ts +0 -1
- package/dist/lib/session/sync/managed-config.js +0 -3
- package/dist/lib/session/sync/worker-template.js +1 -1
- package/dist/lib/sessions-client.d.ts +0 -16
- package/dist/lib/sessions-client.js +1 -187
- package/dist/lib/smart-launch.js +6 -1
- package/dist/lib/startup/command-registry.d.ts +2 -0
- package/dist/lib/startup/command-registry.js +36 -3
- package/dist/lib/startup/root-command.d.ts +0 -1
- package/dist/lib/startup/root-command.js +0 -21
- package/dist/lib/sync-umbrella.js +1 -1
- package/dist/lib/teams/placement-probe.d.ts +2 -0
- package/dist/lib/teams/placement-probe.js +8 -3
- package/dist/lib/terminal/engine.d.ts +2 -0
- package/dist/lib/terminal/engine.js +5 -3
- package/dist/lib/terminal/index.d.ts +1 -1
- package/dist/lib/terminal/index.js +1 -1
- package/dist/lib/terminal/resolve.js +1 -1
- package/dist/lib/terminal/run-surface.d.ts +1 -0
- package/dist/lib/terminal/run-surface.js +9 -0
- package/dist/lib/watchdog/rotate.js +1 -1
- package/dist/lib/watchdog/watchdog.d.ts +1 -1
- package/dist/lib/watchdog/watchdog.js +2 -2
- package/package.json +1 -1
- package/dist/commands/browser.d.ts +0 -7
- package/dist/commands/browser.js +0 -139
- package/dist/commands/computer.d.ts +0 -48
- package/dist/commands/computer.js +0 -244
- package/dist/commands/resume.d.ts +0 -23
- package/dist/commands/resume.js +0 -158
- package/dist/commands/secrets-passthrough.d.ts +0 -3
- package/dist/commands/secrets-passthrough.js +0 -52
- package/dist/commands/sessions-bookmark.d.ts +0 -2
- package/dist/commands/sessions-bookmark.js +0 -92
- package/dist/commands/sessions-export.d.ts +0 -31
- package/dist/commands/sessions-export.js +0 -409
- package/dist/commands/sessions-import.d.ts +0 -6
- package/dist/commands/sessions-import.js +0 -343
- package/dist/commands/sessions-inject.d.ts +0 -14
- package/dist/commands/sessions-inject.js +0 -143
- package/dist/commands/sessions-picker-factory.d.ts +0 -24
- package/dist/commands/sessions-picker-factory.js +0 -59
- package/dist/commands/sessions-render.d.ts +0 -11
- package/dist/commands/sessions-render.js +0 -119
- package/dist/commands/sessions-share.d.ts +0 -15
- package/dist/commands/sessions-share.js +0 -171
- package/dist/commands/sessions.d.ts +0 -122
- package/dist/commands/sessions.js +0 -1760
- package/dist/lib/address.d.ts +0 -39
- package/dist/lib/address.js +0 -128
- package/dist/lib/computer/record.d.ts +0 -6
- package/dist/lib/computer/record.js +0 -25
- package/dist/lib/onepassword.d.ts +0 -57
- package/dist/lib/onepassword.js +0 -140
- package/dist/lib/openclaw-keychain.d.ts +0 -43
- package/dist/lib/openclaw-keychain.js +0 -227
- package/dist/lib/session/bundle.d.ts +0 -76
- package/dist/lib/session/bundle.js +0 -146
- package/dist/lib/session/remote/remote-bundle.d.ts +0 -7
- package/dist/lib/session/remote/remote-bundle.js +0 -40
- package/dist/lib/session/remote/remote.d.ts +0 -35
- package/dist/lib/session/remote/remote.js +0 -198
- package/dist/lib/session/remote-bundle.d.ts +0 -1
- package/dist/lib/session/remote-bundle.js +0 -1
- package/dist/lib/session/remote.d.ts +0 -1
- package/dist/lib/session/remote.js +0 -1
- package/dist/lib/session/sync/agents.d.ts +0 -24
- package/dist/lib/session/sync/agents.js +0 -0
- package/dist/lib/session/sync/backend.d.ts +0 -22
- package/dist/lib/session/sync/backend.js +0 -44
- package/dist/lib/session/sync/managed-key.d.ts +0 -5
- package/dist/lib/session/sync/managed-key.js +0 -87
- package/dist/lib/session/sync/net-client.d.ts +0 -29
- package/dist/lib/session/sync/net-client.js +0 -87
- package/dist/lib/session/sync/r2.d.ts +0 -20
- package/dist/lib/session/sync/r2.js +0 -103
- package/dist/lib/session/sync/transcript-crypto.d.ts +0 -41
- package/dist/lib/session/sync/transcript-crypto.js +0 -115
|
@@ -14,8 +14,34 @@ import { diffTrajectories } from '@phnx-labs/sessions-cli/reader';
|
|
|
14
14
|
import { buildLineage } from '@phnx-labs/sessions-cli/reader';
|
|
15
15
|
import { renderTrajectoryHtml, renderTrajectoryCompareHtml, renderLineageHtml } from '@phnx-labs/sessions-cli/reader';
|
|
16
16
|
import { renderTrajectoryText, renderTrajectoryCompareText, renderLineageText } from '@phnx-labs/sessions-cli/reader';
|
|
17
|
-
import { parseAgentFilter } from '../lib/session/selection.js';
|
|
18
|
-
import {
|
|
17
|
+
import { filterSessionsByQuery, parseAgentFilter } from '../lib/session/selection.js';
|
|
18
|
+
import { looksLikeSessionId, resolveSessionById } from '../lib/session/discover.js';
|
|
19
|
+
import { findSessionsById } from '../lib/session/db.js';
|
|
20
|
+
export function selectSessions(metas, selectors) {
|
|
21
|
+
if (selectors.length === 0)
|
|
22
|
+
return metas;
|
|
23
|
+
const byId = [];
|
|
24
|
+
const unmatched = [];
|
|
25
|
+
for (const sel of selectors) {
|
|
26
|
+
const trimmed = sel.trim();
|
|
27
|
+
const hits = resolveSessionById(metas, trimmed);
|
|
28
|
+
const resolved = hits.length > 0 || !looksLikeSessionId(trimmed) ? hits : findSessionsById(trimmed);
|
|
29
|
+
if (resolved.length > 0)
|
|
30
|
+
byId.push(...resolved);
|
|
31
|
+
else
|
|
32
|
+
unmatched.push(trimmed);
|
|
33
|
+
}
|
|
34
|
+
if (byId.length > 0 && unmatched.length === 0) {
|
|
35
|
+
const seen = new Set();
|
|
36
|
+
return byId.filter(s => (seen.has(s.id) ? false : (seen.add(s.id), true)));
|
|
37
|
+
}
|
|
38
|
+
const missingIds = unmatched.filter(looksLikeSessionId);
|
|
39
|
+
if (missingIds.length > 0) {
|
|
40
|
+
process.stderr.write(chalk.red(`No session with id ${missingIds.join(', ')} on this machine.\n`));
|
|
41
|
+
return [];
|
|
42
|
+
}
|
|
43
|
+
return filterSessionsByQuery(metas, selectors.join(' '));
|
|
44
|
+
}
|
|
19
45
|
export const SESSIONS_TRACE_SCHEMA_VERSION = 1;
|
|
20
46
|
export function buildTraceEnvelope(models) {
|
|
21
47
|
return {
|
|
@@ -159,37 +185,37 @@ function configureTraceCommand(cmd) {
|
|
|
159
185
|
.option('-a, --agent <agent>', 'Filter by agent type (e.g. claude, codex)');
|
|
160
186
|
setHelpSections(cmd, {
|
|
161
187
|
examples: `# Open one session's trajectory in a browser (a person at a terminal)
|
|
162
|
-
agents
|
|
188
|
+
agents trace a1b2c3d4
|
|
163
189
|
|
|
164
|
-
# The compact text trajectory an agent reads in-context
|
|
165
|
-
|
|
190
|
+
# The compact text trajectory an agent reads in-context (standalone sessions CLI)
|
|
191
|
+
sessions trace a1b2c3d4
|
|
166
192
|
|
|
167
193
|
# Just the failures and their neighbours — for a triaging agent
|
|
168
|
-
|
|
194
|
+
sessions trace a1b2c3d4 --errors-only
|
|
169
195
|
|
|
170
196
|
# What the agent said it was doing, step by step — the sidebar's timeline as text
|
|
171
|
-
agents
|
|
197
|
+
agents trace a1b2c3d4 --steps
|
|
172
198
|
|
|
173
199
|
# The stable JSON envelope for the AGI EXT Fleet panel or a tool
|
|
174
|
-
agents
|
|
200
|
+
agents trace a1b2c3d4 --json
|
|
175
201
|
|
|
176
202
|
# Write the self-contained HTML to a file without opening it
|
|
177
|
-
agents
|
|
203
|
+
agents trace a1b2c3d4 --html -o trace.html --no-open
|
|
178
204
|
|
|
179
205
|
# Two selectors — compare where a passing run and a failing one diverge
|
|
180
|
-
agents
|
|
206
|
+
agents trace a1b2c3d4 e5f6a7b8
|
|
181
207
|
|
|
182
208
|
# The compare, as text — for a triaging agent comparing harnesses
|
|
183
|
-
agents
|
|
209
|
+
agents trace a1b2c3d4 e5f6a7b8 --text
|
|
184
210
|
|
|
185
211
|
# The team an orchestrator spawned, as a graph (one selector + --tree)
|
|
186
|
-
agents
|
|
212
|
+
agents trace a1b2c3d4 --tree
|
|
187
213
|
|
|
188
214
|
# The same lineage as an indented tree an agent can read
|
|
189
|
-
agents
|
|
215
|
+
agents trace a1b2c3d4 --tree --text`,
|
|
190
216
|
notes: `Audience auto-select: with no --html/--text/--json, HTML opens on a TTY (a person) and
|
|
191
217
|
the compact text trajectory prints when piped or headless (an agent). The HTML is self-contained
|
|
192
|
-
(no CDN, no external asset) and redacted by default, as safe to share as
|
|
218
|
+
(no CDN, no external asset) and redacted by default, as safe to share as a 'sessions share' page.
|
|
193
219
|
|
|
194
220
|
One selector renders the single trajectory; exactly two selectors compare them (a shared time axis,
|
|
195
221
|
the first divergence point, and the step-level diff); one selector with --tree renders its lineage —
|
|
@@ -375,9 +401,6 @@ Three or more selectors, and --tree with more than one selector, fail loud.`,
|
|
|
375
401
|
});
|
|
376
402
|
return cmd;
|
|
377
403
|
}
|
|
378
|
-
export function registerSessionsTraceCommand(sessionsCmd) {
|
|
379
|
-
configureTraceCommand(sessionsCmd.command('trace <selectors...>'));
|
|
380
|
-
}
|
|
381
404
|
export function registerTraceCommand(program) {
|
|
382
405
|
configureTraceCommand(program.command('trace <selectors...>'));
|
|
383
406
|
}
|
|
@@ -9,10 +9,10 @@ export function registerSessionsWatchCommand(parent) {
|
|
|
9
9
|
setHelpSections(command, {
|
|
10
10
|
examples: `
|
|
11
11
|
# Subscribe to session changes for a long-lived UI consumer
|
|
12
|
-
agents
|
|
12
|
+
agents ps watch --json
|
|
13
13
|
|
|
14
14
|
# Subscribe only to this machine
|
|
15
|
-
agents
|
|
15
|
+
agents ps watch --json --local
|
|
16
16
|
`,
|
|
17
17
|
notes: `
|
|
18
18
|
- Each line is one versioned reset, upsert, remove, scope, or heartbeat envelope.
|
|
@@ -8,6 +8,7 @@ export declare function writeClaudeSession(tempHome: string, projectKey: string,
|
|
|
8
8
|
export declare function writeCodexSession(tempHome: string, sessionId: string, cwd: string, prompt: string, timestamp: string): void;
|
|
9
9
|
export declare function writeOpenClawSetup(tempHome: string, version?: string): string;
|
|
10
10
|
export declare function runAgents(args: string[], cwd: string, home: string, envOverrides?: Record<string, string>): import("node:child_process").SpawnSyncReturns<string>;
|
|
11
|
+
export declare function indexSessions(cwd: string, home: string): import("node:child_process").SpawnSyncReturns<string>;
|
|
11
12
|
export declare function outputOf(result: {
|
|
12
13
|
stdout: string;
|
|
13
14
|
stderr: string;
|
|
@@ -167,6 +167,20 @@ export function runAgents(args, cwd, home, envOverrides = {}) {
|
|
|
167
167
|
encoding: 'utf-8',
|
|
168
168
|
});
|
|
169
169
|
}
|
|
170
|
+
// The daemon tick's incremental scan, the only writer of the index on a peer.
|
|
171
|
+
export function indexSessions(cwd, home) {
|
|
172
|
+
const script = [
|
|
173
|
+
"const { scanSessionsIncremental } = await import('./src/lib/session/discover.ts');",
|
|
174
|
+
"const { closeDB } = await import('./src/lib/session/db.ts');",
|
|
175
|
+
'await scanSessionsIncremental();',
|
|
176
|
+
'closeDB();',
|
|
177
|
+
].join(' ');
|
|
178
|
+
return spawnSync(process.execPath, ['--import', tsxLoaderUrl, '--input-type=module', '--eval', script], {
|
|
179
|
+
cwd: repoRoot,
|
|
180
|
+
env: { ...process.env, HOME: home, USERPROFILE: home, PWD: cwd },
|
|
181
|
+
encoding: 'utf-8',
|
|
182
|
+
});
|
|
183
|
+
}
|
|
170
184
|
export function outputOf(result) {
|
|
171
185
|
return `${result.stdout}${result.stderr}`;
|
|
172
186
|
}
|
|
@@ -39,7 +39,7 @@ export async function runBrowserWizard() {
|
|
|
39
39
|
await runBrowserVerb(['use']);
|
|
40
40
|
const chosen = configuredDefaultProfile();
|
|
41
41
|
if (!chosen) {
|
|
42
|
-
console.log(chalk.dim('No default profile chosen. Run `
|
|
42
|
+
console.log(chalk.dim('No default profile chosen. Run `browser use <name>` later to set one.'));
|
|
43
43
|
return false;
|
|
44
44
|
}
|
|
45
45
|
printOnboardingNextStep(chosen);
|
|
@@ -48,14 +48,14 @@ export async function runBrowserWizard() {
|
|
|
48
48
|
function printOnboardingNextStep(name) {
|
|
49
49
|
console.log(chalk.bold('\nOne manual step left:'));
|
|
50
50
|
console.log(' ' +
|
|
51
|
-
chalk.cyan(`
|
|
51
|
+
chalk.cyan(`browser start --profile ${name}`) +
|
|
52
52
|
chalk.dim(' # finish the browser first-run + sign in to any sites you want automated'));
|
|
53
|
-
console.log(chalk.dim(` Then check it's ready:
|
|
53
|
+
console.log(chalk.dim(` Then check it's ready: browser profiles doctor ${name}`));
|
|
54
54
|
}
|
|
55
55
|
export function registerSetupBrowserCommand(setupCmd) {
|
|
56
56
|
setupCmd
|
|
57
57
|
.command('browser')
|
|
58
|
-
.description('Set up `
|
|
58
|
+
.description('Set up the standalone `browser` CLI — install it, seed profiles, and pick this machine\'s default.')
|
|
59
59
|
.option('--install-only', 'Install the standalone Browser CLI without changing profiles or starting a browser')
|
|
60
60
|
.option('--terminal [backend]', 'Open interactive setup in a detected or selected terminal')
|
|
61
61
|
.action(async (options) => {
|
|
@@ -19,7 +19,7 @@ function openPane(pane) {
|
|
|
19
19
|
export async function runComputerWizard() {
|
|
20
20
|
if (os.platform() !== 'darwin') {
|
|
21
21
|
console.log(chalk.yellow('`agents setup computer` configures the macOS helper (local control).'));
|
|
22
|
-
console.log(chalk.dim('On Windows, provision a remote host from a Mac/Linux box instead: `
|
|
22
|
+
console.log(chalk.dim('On Windows, provision a remote host from a Mac/Linux box instead: `computer setup --device <device>`.'));
|
|
23
23
|
return false;
|
|
24
24
|
}
|
|
25
25
|
try {
|
|
@@ -67,7 +67,7 @@ export async function runComputerWizard() {
|
|
|
67
67
|
openPane(SCREEN_PANE);
|
|
68
68
|
if (!trusted) {
|
|
69
69
|
console.log(chalk.yellow('\nAccessibility not granted yet.'));
|
|
70
|
-
console.log(chalk.dim('Finish both grants in System Settings, then run: ') + chalk.cyan('
|
|
70
|
+
console.log(chalk.dim('Finish both grants in System Settings, then run: ') + chalk.cyan('computer start'));
|
|
71
71
|
console.log(chalk.dim(' Accessibility: System Settings > Privacy & Security > Accessibility'));
|
|
72
72
|
console.log(chalk.dim(' Screen Recording: System Settings > Privacy & Security > Screen Recording'));
|
|
73
73
|
}
|
|
@@ -81,7 +81,7 @@ export async function runComputerWizard() {
|
|
|
81
81
|
console.log(chalk.dim(' allow:'));
|
|
82
82
|
console.log(chalk.dim(' - "Computer(com.apple.finder)"'));
|
|
83
83
|
console.log(chalk.dim(' - "Computer(com.apple.notes)"'));
|
|
84
|
-
console.log(chalk.dim(' Then reload: ') + chalk.cyan('
|
|
84
|
+
console.log(chalk.dim(' Then reload: ') + chalk.cyan('computer reload'));
|
|
85
85
|
return trusted;
|
|
86
86
|
}
|
|
87
87
|
async function pollForTrust() {
|
|
@@ -107,7 +107,7 @@ async function pollForTrust() {
|
|
|
107
107
|
export function registerSetupComputerCommand(setupCmd) {
|
|
108
108
|
setupCmd
|
|
109
109
|
.command('computer')
|
|
110
|
-
.description('Set up `
|
|
110
|
+
.description('Set up `computer` (macOS) — install the signed helper and grant control permissions.')
|
|
111
111
|
.option('--install-only', 'Install the standalone Computer CLI without starting the helper or changing permissions')
|
|
112
112
|
.option('--terminal [backend]', 'Open interactive setup in a detected or selected terminal')
|
|
113
113
|
.action(async (options) => {
|
|
@@ -73,7 +73,7 @@ async function resolveInteractiveChoices(opts) {
|
|
|
73
73
|
default: 'key',
|
|
74
74
|
choices: [
|
|
75
75
|
{ name: 'key — use your SSH agent / on-disk public keys', value: 'key' },
|
|
76
|
-
{ name: 'password — read the login password from an
|
|
76
|
+
{ name: 'password — read the login password from an secrets bundle', value: 'password' },
|
|
77
77
|
],
|
|
78
78
|
});
|
|
79
79
|
return {
|
|
@@ -58,7 +58,7 @@ export async function maybePickBrowserProfile(deps = {}) {
|
|
|
58
58
|
if (!chosen)
|
|
59
59
|
return false;
|
|
60
60
|
console.log(chalk.green(`Browser: '${chosen}'`) +
|
|
61
|
-
chalk.dim(' — this machine\'s default (
|
|
61
|
+
chalk.dim(' — this machine\'s default (browser use to change).'));
|
|
62
62
|
return true;
|
|
63
63
|
}
|
|
64
64
|
export async function runPreferencesStep() {
|
|
@@ -7,6 +7,6 @@ interface BackupSetupOptions {
|
|
|
7
7
|
token?: string;
|
|
8
8
|
domain: string;
|
|
9
9
|
}
|
|
10
|
-
export declare function
|
|
11
|
-
export declare function
|
|
10
|
+
export declare function handleSessionBackupSetup(opts: BackupSetupOptions): Promise<void>;
|
|
11
|
+
export declare function registerSetupSessionBackupCommand(setupCmd: Command): void;
|
|
12
12
|
export {};
|
|
@@ -4,7 +4,7 @@ import { PHOENIX_ID_BASE } from '../lib/identity/client.js';
|
|
|
4
4
|
import { provisionSessions } from '../lib/session/sync/provision.js';
|
|
5
5
|
import { DEFAULT_SESSIONS_BUCKET_NAME, DEFAULT_SESSIONS_DOMAIN, DEFAULT_SESSIONS_WORKER_NAME, } from '../lib/session/sync/managed-config.js';
|
|
6
6
|
import { setHelpSections } from '../lib/help.js';
|
|
7
|
-
export async function
|
|
7
|
+
export async function handleSessionBackupSetup(opts) {
|
|
8
8
|
const { input } = await import('@inquirer/prompts');
|
|
9
9
|
const { apiToken, accountId: bundledAccountId } = readCloudflareCreds(opts.bundle, {
|
|
10
10
|
apiToken: opts.token,
|
|
@@ -22,18 +22,18 @@ export async function handleSessionsBackupSetup(opts) {
|
|
|
22
22
|
phoenixIdBase: PHOENIX_ID_BASE,
|
|
23
23
|
});
|
|
24
24
|
console.log(chalk.green(`Managed session-backup endpoint ready → ${chalk.bold(result.baseUrl)}`));
|
|
25
|
-
console.log(chalk.dim('Signed-in users now back up with `
|
|
25
|
+
console.log(chalk.dim('Signed-in users now back up with `sessions export --to-r2` — no r2.backups bucket.'));
|
|
26
26
|
}
|
|
27
27
|
const BACKUP_SETUP_EXAMPLES = `
|
|
28
|
-
$
|
|
28
|
+
$ secrets exec cloudflare -- agents setup session-backup
|
|
29
29
|
Provision the managed session-backup Worker + R2 bucket (creds from the bundle).
|
|
30
30
|
|
|
31
|
-
$ agents
|
|
31
|
+
$ agents setup session-backup --account <id> --domain sessions.example.com
|
|
32
32
|
Provision against a private account service and custom domain.
|
|
33
33
|
`.trimStart();
|
|
34
|
-
export function
|
|
35
|
-
const cmd =
|
|
36
|
-
.command('backup
|
|
34
|
+
export function registerSetupSessionBackupCommand(setupCmd) {
|
|
35
|
+
const cmd = setupCmd
|
|
36
|
+
.command('session-backup')
|
|
37
37
|
.description('(operator) Provision the managed session-backup Worker + R2 bucket — NOT a per-user step; signing in with `agents auth login` backs sessions up with zero setup')
|
|
38
38
|
.option('--bundle <name>', 'secrets bundle holding the Cloudflare API token', DEFAULT_CF_BUNDLE)
|
|
39
39
|
.option('--worker <name>', 'Worker name', DEFAULT_SESSIONS_WORKER_NAME)
|
|
@@ -43,7 +43,7 @@ export function registerSessionsBackupSetupCommand(sessionsCmd) {
|
|
|
43
43
|
.option('--domain <host>', 'custom domain to map', DEFAULT_SESSIONS_DOMAIN)
|
|
44
44
|
.action(async (opts) => {
|
|
45
45
|
try {
|
|
46
|
-
await
|
|
46
|
+
await handleSessionBackupSetup(opts);
|
|
47
47
|
}
|
|
48
48
|
catch (err) {
|
|
49
49
|
console.error(chalk.red(err.message));
|
package/dist/commands/setup.js
CHANGED
|
@@ -21,6 +21,7 @@ import { registerSetupTermCommand, runTermWizard, isTermCliInstalled } from './s
|
|
|
21
21
|
import { registerSetupFleetCommand } from './setup-fleet.js';
|
|
22
22
|
import { registerSetupAccountsCommand, runAccountsSetupWizard } from './setup-accounts.js';
|
|
23
23
|
import { registerSetupWatchdogCommand, runWatchdogSetupWizard } from './setup-watchdog.js';
|
|
24
|
+
import { registerSetupSessionBackupCommand } from './setup-session-backup.js';
|
|
24
25
|
import { hasMintedSetupToken } from '../lib/auth-mint.js';
|
|
25
26
|
import { registerAliasCommand } from './alias.js';
|
|
26
27
|
import { registerBetaCommands } from './beta.js';
|
|
@@ -184,7 +185,7 @@ export async function runSetup(program, options = {}) {
|
|
|
184
185
|
.map(i => `${agentLabel(i.agentId)} (${sessionCounts[i.agentId] || 0})`)
|
|
185
186
|
.join(', ');
|
|
186
187
|
console.log(chalk.gray(`\n${totalSessions} sessions available across ${breakdown}`));
|
|
187
|
-
console.log(chalk.cyan('
|
|
188
|
+
console.log(chalk.cyan(' sessions') + chalk.gray(' # browse them'));
|
|
188
189
|
}
|
|
189
190
|
}
|
|
190
191
|
}
|
|
@@ -332,6 +333,7 @@ export function registerSetupCommand(program) {
|
|
|
332
333
|
registerSetupAccountsCommand(setupCmd);
|
|
333
334
|
registerSetupFleetCommand(setupCmd);
|
|
334
335
|
registerSetupWatchdogCommand(setupCmd);
|
|
336
|
+
registerSetupSessionBackupCommand(setupCmd);
|
|
335
337
|
registerAliasCommand(setupCmd);
|
|
336
338
|
registerBetaCommands(setupCmd);
|
|
337
339
|
const urlScheme = setupCmd
|
package/dist/commands/ssh.js
CHANGED
|
@@ -23,7 +23,7 @@ import { clearPendingSentinel } from '../lib/devices/pending.js';
|
|
|
23
23
|
import { getDeviceDiscoveryStatus, setDeviceDiscoveryStatus } from '../lib/devices/discovery-policy.js';
|
|
24
24
|
import { isInteractiveTerminal, isPromptCancelled } from './utils.js';
|
|
25
25
|
import { hostNameFor, renderSshConfig } from '../lib/devices/ssh-config.js';
|
|
26
|
-
import { ASKPASS_BUNDLE_ENV, ASKPASS_KEY_ENV, buildSshInvocation, deviceIdentityArgs, fleetDialTarget,
|
|
26
|
+
import { ASKPASS_BUNDLE_ENV, ASKPASS_KEY_ENV, buildSshInvocation, deviceIdentityArgs, fleetDialTarget, isBrowserDrive, markFleetRemote, writeAskpassShim, } from '../lib/devices/connect.js';
|
|
27
27
|
import { ensureManagedKnownHostsDir, isHostPinned } from '../lib/devices/known-hosts.js';
|
|
28
28
|
import { shouldSyncTerminfo, syncTerminfoToDevice, terminfoHostKey } from '../lib/devices/terminfo.js';
|
|
29
29
|
import { fanOutDevices, fleetHealthSkip, planFleetTargets, remoteFleetTargets, runFleet, runOnDevice, runLocalCommand, skipLabel, upgradeCommand, } from '../lib/devices/fleet.js';
|
|
@@ -261,7 +261,7 @@ function trySshLeasedBox(name, cmd) {
|
|
|
261
261
|
process.exit(res.status ?? 1);
|
|
262
262
|
}
|
|
263
263
|
export function leasedBoxRemoteCmd(cmd) {
|
|
264
|
-
return
|
|
264
|
+
return isBrowserDrive(cmd) ? markFleetRemote(cmd, { shell: 'posix' }) : cmd;
|
|
265
265
|
}
|
|
266
266
|
async function mustGetDevice(name) {
|
|
267
267
|
const d = await getDevice(name);
|
|
@@ -2067,9 +2067,8 @@ launched from — 'agents ssh yosemite-s0' from ~/src/app lands in ~/src/app on
|
|
|
2067
2067
|
the target when it exists, else the remote home. Same portable-cwd rule as
|
|
2068
2068
|
'agents run --device'. Passing a command keeps the remote home.
|
|
2069
2069
|
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
gate applies, same as 'agents browser <verb> --device <name>'.
|
|
2070
|
+
A 'browser …' command is stamped AGENTS_FLEET_REMOTE so the target's
|
|
2071
|
+
browser.remote-control consent gate applies, same as 'browser <verb> --device <name>'.
|
|
2073
2072
|
|
|
2074
2073
|
--argv takes a JSON array of strings and delivers each element as exactly ONE
|
|
2075
2074
|
token on the peer, so a token containing a space, '&', '|', '$' or a quote
|
package/dist/commands/sync.js
CHANGED
|
@@ -113,7 +113,7 @@ export function addSelectorOptions(cmd) {
|
|
|
113
113
|
export function registerSyncCommand(program) {
|
|
114
114
|
const cmd = addHostOption(program.command('sync [agentSpec] [repo]'))
|
|
115
115
|
.summary('Make this machine current, or sync resources into one agent')
|
|
116
|
-
.description('With an [agentSpec], syncs resources (commands, skills, hooks, rules, MCPs, plugins, etc.) into that installed agent version — previews changes and lets you pick. e.g. "claude", "claude@2.1.142", a selector: @latest / @oldest / @pinned (= @default), or @all for every installed version.\n\nAppend a [repo] (or pass --repo) to scope the sync to a single DotAgent repo — system / user / project / <alias>. e.g. "agents sync claude@all system" reconciles only the system repo\'s resources into every installed Claude.\n\nGive a DotAgent repo name ALONE — "agents sync system" / "agents sync user" / "agents sync <alias>" — to git-sync that one repo: git pull --rebase against origin when the tree is clean; when it is dirty, fast-forward anyway if no incoming path is uncommitted, else refuse and name what collided. The user repo and extra aliases also push local commits up; the system repo is a pull-only mirror.\n\nWith NO agent, runs the umbrella verb: fetch the config repos then reconcile them into every installed agent. Secrets are opt-in — add --secrets to pull secret bundles. Session transcripts are queryable live via "
|
|
116
|
+
.description('With an [agentSpec], syncs resources (commands, skills, hooks, rules, MCPs, plugins, etc.) into that installed agent version — previews changes and lets you pick. e.g. "claude", "claude@2.1.142", a selector: @latest / @oldest / @pinned (= @default), or @all for every installed version.\n\nAppend a [repo] (or pass --repo) to scope the sync to a single DotAgent repo — system / user / project / <alias>. e.g. "agents sync claude@all system" reconciles only the system repo\'s resources into every installed Claude.\n\nGive a DotAgent repo name ALONE — "agents sync system" / "agents sync user" / "agents sync <alias>" — to git-sync that one repo: git pull --rebase against origin when the tree is clean; when it is dirty, fast-forward anyway if no incoming path is uncommitted, else refuse and name what collided. The user repo and extra aliases also push local commits up; the system repo is a pull-only mirror.\n\nWith NO agent, runs the umbrella verb: fetch the config repos then reconcile them into every installed agent. Secrets are opt-in — add --secrets to pull secret bundles. Session transcripts are queryable live via "sessions --device <machine>", or moved with "sessions export/import". Also: --cloud (fetch only), --local (reconcile only).\n\n`agents sync status` reports fleet drift (what is drifted, missing, or behind) and can reconcile it — the former top-level `agents status`.')
|
|
117
117
|
.option('--agent <agent>', 'Agent identifier (legacy form; prefer the positional spec)')
|
|
118
118
|
.option('--agent-version <version>', 'Version to sync into (legacy form; prefer "agent@version" or --version)')
|
|
119
119
|
.option('--repo <name>', 'Scope the sync to a single DotAgent repo: system / user / project / <alias> (also accepted as a positional)')
|
package/dist/commands/teams.js
CHANGED
|
@@ -1047,7 +1047,7 @@ export function registerTeamsCommands(program) {
|
|
|
1047
1047
|
`,
|
|
1048
1048
|
notes: `
|
|
1049
1049
|
A team is a named group of agents working in the background on a shared task.
|
|
1050
|
-
Teammate sessions show in '
|
|
1050
|
+
Teammate sessions show in 'sessions --teams' tagged [team/name · mode].
|
|
1051
1051
|
|
|
1052
1052
|
Teammate syntax:
|
|
1053
1053
|
'claude' the default Claude version on this machine
|
|
@@ -1708,7 +1708,7 @@ export function registerTeamsCommands(program) {
|
|
|
1708
1708
|
}
|
|
1709
1709
|
console.log();
|
|
1710
1710
|
}
|
|
1711
|
-
console.log(chalk.gray(`${running.length} teammate${running.length === 1 ? '' : 's'} running. See 'agents
|
|
1711
|
+
console.log(chalk.gray(`${running.length} teammate${running.length === 1 ? '' : 's'} running. See 'agents ps' for the full cross-context view.`));
|
|
1712
1712
|
});
|
|
1713
1713
|
addHostOption(teams.command('start [team]'))
|
|
1714
1714
|
.description('Launch ready teammates independently. Failed launch/placement and blocked --after dependencies persist in status; --watch keeps draining viable DAG branches.')
|
package/dist/commands/utils.d.ts
CHANGED
|
@@ -11,7 +11,6 @@ export interface Surface {
|
|
|
11
11
|
interactive: boolean;
|
|
12
12
|
}
|
|
13
13
|
export declare function resolveSurface(cmd: Command): Surface;
|
|
14
|
-
export declare function normalizeSingleDeviceOption(value: string | string[] | undefined, commandLabel: string): string | undefined;
|
|
15
14
|
export declare function requireInteractiveSelection(action: string, alternatives: string[]): never;
|
|
16
15
|
export declare function requireDestructiveArg(opts: {
|
|
17
16
|
argName: string;
|
package/dist/commands/utils.js
CHANGED
|
@@ -31,16 +31,6 @@ export function resolveSurface(cmd) {
|
|
|
31
31
|
interactive: tty && !json,
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
|
-
export function normalizeSingleDeviceOption(value, commandLabel) {
|
|
35
|
-
const list = value == null ? [] : Array.isArray(value) ? value : [value];
|
|
36
|
-
const hosts = list.map((v) => String(v).trim()).filter((v) => v.length > 0);
|
|
37
|
-
if (hosts.length === 0)
|
|
38
|
-
return undefined;
|
|
39
|
-
if (hosts.length > 1) {
|
|
40
|
-
throw new Error(`${commandLabel} targets a single device, but --device named ${hosts.length}: ${hosts.join(', ')}.`);
|
|
41
|
-
}
|
|
42
|
-
return hosts[0];
|
|
43
|
-
}
|
|
44
34
|
export function requireInteractiveSelection(action, alternatives) {
|
|
45
35
|
console.error(chalk.red(`${action} requires an interactive terminal.`));
|
|
46
36
|
if (alternatives.length > 0) {
|
package/dist/index.js
CHANGED
|
@@ -67,76 +67,5 @@ if (process.argv[2] === '__daemon-run') {
|
|
|
67
67
|
}
|
|
68
68
|
process.exit(process.exitCode ?? 0);
|
|
69
69
|
}
|
|
70
|
-
if (process.argv[2] === 'sessions') {
|
|
71
|
-
const forwarded = process.argv.slice(3);
|
|
72
|
-
const { isReadQuery, usesFilterFlags, usesHostFlag, sessionsBinSupportsFilters, sessionsBinSupportsHost, planDeviceHostRead, resolveSessionsBin, invocation, SessionsClientError, SESSIONS_INSTALL_HINT, } = await import('./lib/sessions-client.js');
|
|
73
|
-
let bin = null;
|
|
74
|
-
try {
|
|
75
|
-
bin = resolveSessionsBin();
|
|
76
|
-
}
|
|
77
|
-
catch (err) {
|
|
78
|
-
if (!(err instanceof SessionsClientError && err.code === 'SESSIONS_BIN_MISSING'))
|
|
79
|
-
throw err;
|
|
80
|
-
}
|
|
81
|
-
const filters = bin !== null && usesFilterFlags(forwarded) ? sessionsBinSupportsFilters(bin) : false;
|
|
82
|
-
const host = bin !== null && usesHostFlag(forwarded) ? sessionsBinSupportsHost(bin) : false;
|
|
83
|
-
if (bin !== null) {
|
|
84
|
-
const deviceRead = planDeviceHostRead(forwarded, { filters });
|
|
85
|
-
if (deviceRead && sessionsBinSupportsHost(bin)) {
|
|
86
|
-
let target = null;
|
|
87
|
-
try {
|
|
88
|
-
const { resolveRemoteDevice } = await import('./lib/ssh-tunnel.js');
|
|
89
|
-
target = (await resolveRemoteDevice(deviceRead.device, {})).target;
|
|
90
|
-
}
|
|
91
|
-
catch {
|
|
92
|
-
target = null;
|
|
93
|
-
}
|
|
94
|
-
if (target !== null) {
|
|
95
|
-
const { spawnSync } = await import('node:child_process');
|
|
96
|
-
const { command, prefix } = invocation(bin);
|
|
97
|
-
const hostArgs = [...deviceRead.readArgs, '--host', `ssh://${target}`];
|
|
98
|
-
const childEnv = { ...process.env };
|
|
99
|
-
if (process.stdout.isTTY && !hostArgs.includes('--json')) {
|
|
100
|
-
if (childEnv.FORCE_COLOR === undefined)
|
|
101
|
-
childEnv.FORCE_COLOR = '1';
|
|
102
|
-
if (process.stdout.columns)
|
|
103
|
-
childEnv.COLUMNS = String(process.stdout.columns);
|
|
104
|
-
if (process.stdout.rows)
|
|
105
|
-
childEnv.LINES = String(process.stdout.rows);
|
|
106
|
-
}
|
|
107
|
-
const res = spawnSync(command, [...prefix, ...hostArgs], {
|
|
108
|
-
encoding: 'utf8',
|
|
109
|
-
env: childEnv,
|
|
110
|
-
maxBuffer: 256 * 1024 * 1024,
|
|
111
|
-
});
|
|
112
|
-
if (res.error) {
|
|
113
|
-
process.stderr.write(`Failed to run \`sessions\`: ${res.error.message}\n`);
|
|
114
|
-
process.exit(1);
|
|
115
|
-
}
|
|
116
|
-
if (res.status !== 127) {
|
|
117
|
-
if (res.stdout)
|
|
118
|
-
process.stdout.write(res.stdout);
|
|
119
|
-
if (res.stderr)
|
|
120
|
-
process.stderr.write(res.stderr);
|
|
121
|
-
process.exit(res.status ?? 1);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
if (isReadQuery(forwarded, { filters, host })) {
|
|
127
|
-
if (!bin) {
|
|
128
|
-
process.stderr.write(`agents: the standalone \`sessions\` CLI was not found. Install it with ${SESSIONS_INSTALL_HINT}, or point $SESSIONS_BIN at its executable.\n`);
|
|
129
|
-
process.exit(1);
|
|
130
|
-
}
|
|
131
|
-
const { spawnSync } = await import('node:child_process');
|
|
132
|
-
const { command, prefix } = invocation(bin);
|
|
133
|
-
const res = spawnSync(command, [...prefix, ...forwarded], { stdio: 'inherit' });
|
|
134
|
-
if (res.error) {
|
|
135
|
-
process.stderr.write(`Failed to run \`sessions\`: ${res.error.message}\n`);
|
|
136
|
-
process.exit(1);
|
|
137
|
-
}
|
|
138
|
-
process.exit(res.status ?? 1);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
70
|
await import('./bootstrap.js');
|
|
142
71
|
export {};
|
|
@@ -42,6 +42,9 @@ export declare function parseAccountSelector(input: string): {
|
|
|
42
42
|
export declare function assertUnambiguousNativeAccount(meta: Pick<Meta, 'accounts' | 'deviceAccounts'>, name: string, agent?: AgentId): void;
|
|
43
43
|
export declare function assertNativeAccountNameAvailable(name: string, agent: AgentId): void;
|
|
44
44
|
export declare function addNativeAccount(name: string, agent: AgentId, identityKey: string, identityLabel: string | undefined, scope: 'version' | 'device'): NativeAccount;
|
|
45
|
+
export declare const PEER_ACCOUNT_ROW_LIMIT = 256;
|
|
46
|
+
export declare function peerAccountRow(record: NativeAccountRecord): NativeAccountRecord;
|
|
47
|
+
export declare function adoptPeerNativeAccounts(records: readonly NativeAccountRecord[]): string[];
|
|
45
48
|
export declare function labelNativeAccount(agent: AgentId, identityKey: string, identityLabel: string | undefined, label: string | undefined, scope: 'version' | 'device'): NativeAccount;
|
|
46
49
|
export declare function nativeAccountHome(accountId: string, meta: Pick<Meta, 'deviceAccounts'>): string | null;
|
|
47
50
|
export declare function setDefaultAccountIfAbsent(agent: AgentId, name: string): boolean;
|
|
@@ -213,6 +213,46 @@ export function addNativeAccount(name, agent, identityKey, identityLabel, scope)
|
|
|
213
213
|
}
|
|
214
214
|
return account;
|
|
215
215
|
}
|
|
216
|
+
export const PEER_ACCOUNT_ROW_LIMIT = 256;
|
|
217
|
+
const PEER_ACCOUNT_ID = /^[a-zA-Z0-9][a-zA-Z0-9-]{0,63}$/;
|
|
218
|
+
export function peerAccountRow(record) {
|
|
219
|
+
const { id, name, agent, identityKey, identityLabel, createdOn } = record;
|
|
220
|
+
return {
|
|
221
|
+
id, name, agent, identityKey, scope: 'version', provisioning: 'per-device',
|
|
222
|
+
...(identityLabel ? { identityLabel } : {}),
|
|
223
|
+
...(createdOn ? { createdOn } : {}),
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
function missingPeerRows(meta, records) {
|
|
227
|
+
const known = listNativeAccounts(meta);
|
|
228
|
+
const missing = [];
|
|
229
|
+
for (const record of records.slice(0, PEER_ACCOUNT_ROW_LIMIT)) {
|
|
230
|
+
if (record.scope !== 'version' || record.provisioning !== 'per-device' || !PEER_ACCOUNT_ID.test(record.id))
|
|
231
|
+
continue;
|
|
232
|
+
if (Object.hasOwn(meta.accounts?.native ?? {}, record.id))
|
|
233
|
+
continue;
|
|
234
|
+
const taken = [...known, ...missing].some(account => account.id === record.id || account.agent === record.agent
|
|
235
|
+
&& (account.identityKey === record.identityKey || account.name === record.name));
|
|
236
|
+
if (!taken)
|
|
237
|
+
missing.push(peerAccountRow(record));
|
|
238
|
+
}
|
|
239
|
+
return missing;
|
|
240
|
+
}
|
|
241
|
+
export function adoptPeerNativeAccounts(records) {
|
|
242
|
+
if (missingPeerRows(readMeta(), records).length === 0)
|
|
243
|
+
return [];
|
|
244
|
+
let adopted = [];
|
|
245
|
+
updateMeta(current => {
|
|
246
|
+
adopted = missingPeerRows(current, records);
|
|
247
|
+
if (adopted.length === 0)
|
|
248
|
+
return current;
|
|
249
|
+
const native = { ...current.accounts?.native };
|
|
250
|
+
for (const row of adopted)
|
|
251
|
+
native[row.id] = row;
|
|
252
|
+
return { ...current, accounts: { ...current.accounts, native } };
|
|
253
|
+
});
|
|
254
|
+
return adopted.map(row => row.id);
|
|
255
|
+
}
|
|
216
256
|
export function labelNativeAccount(agent, identityKey, identityLabel, label, scope) {
|
|
217
257
|
const resolvedLabel = label ?? identityLabel;
|
|
218
258
|
if (!resolvedLabel)
|
|
@@ -88,6 +88,7 @@ interface ApplyPeerStateOptions {
|
|
|
88
88
|
export interface ApplyPeerStateResult {
|
|
89
89
|
path: string;
|
|
90
90
|
merged: number;
|
|
91
|
+
adoptedAccounts: string[];
|
|
91
92
|
receivedAt: number;
|
|
92
93
|
}
|
|
93
94
|
export declare function applyPeerFleetState(state: FleetSharedDeviceState, options?: ApplyPeerStateOptions): Promise<ApplyPeerStateResult>;
|
|
@@ -20,10 +20,11 @@
|
|
|
20
20
|
* scheduled because a repo was bloated. Git now carries human-authored
|
|
21
21
|
* resources only; `devices/<device>/daemon-state.json` is untracked.
|
|
22
22
|
*/
|
|
23
|
-
import { isHeadedDeviceRole, selfConfiguredDeviceRole } from '../device-config.js';
|
|
23
|
+
import { configuredDeviceRole, isHeadedDeviceRole, selfConfiguredDeviceRole } from '../device-config.js';
|
|
24
24
|
import { FLEET_SHARED_STATE_VERSION, parseFleetSharedDeviceStateEnvelope, readFleetSharedDeviceStates, readOwnFleetSharedDeviceState, storePeerFleetSharedDeviceState, updateFleetSharedDeviceStateAsync, } from '../fleet-shared-state.js';
|
|
25
25
|
import { getUserAgentsDir } from '../state.js';
|
|
26
26
|
import { machineId, normalizeHost } from '../session/sync/config.js';
|
|
27
|
+
import { resolveDeviceProfile } from '../devices/resolve-profile.js';
|
|
27
28
|
import { exportClaudeUsageCacheRows, ingestPeerClaudeUsageRows, } from './usage.js';
|
|
28
29
|
export const USAGE_SYNC_INTERVAL_MS = 15 * 60_000;
|
|
29
30
|
export const USAGE_PUBLISH_HEARTBEAT_MS = 10 * 60_000;
|
|
@@ -193,6 +194,21 @@ function stampSyncRows(rows, sender) {
|
|
|
193
194
|
}
|
|
194
195
|
return out;
|
|
195
196
|
}
|
|
197
|
+
async function adoptHeadedPeerAccounts(state) {
|
|
198
|
+
const native = state.accounts?.native;
|
|
199
|
+
if (!native?.length)
|
|
200
|
+
return [];
|
|
201
|
+
if (!isHeadedDeviceRole(configuredDeviceRole(state.device)))
|
|
202
|
+
return [];
|
|
203
|
+
const { isAgentId } = await import('../types.js');
|
|
204
|
+
const records = native.filter((record) => typeof record?.id === 'string' && typeof record.name === 'string'
|
|
205
|
+
&& isAgentId(record.agent) && typeof record.identityKey === 'string' && record.scope === 'version'
|
|
206
|
+
&& normalizeHost(record.createdOn ?? '') === normalizeHost(state.device));
|
|
207
|
+
if (records.length === 0)
|
|
208
|
+
return [];
|
|
209
|
+
const { adoptPeerNativeAccounts } = await import('../account-registry.js');
|
|
210
|
+
return adoptPeerNativeAccounts(records);
|
|
211
|
+
}
|
|
196
212
|
// Peer state is newest-wins and can never overwrite this device's own publisher file.
|
|
197
213
|
export async function applyPeerFleetState(state, options = {}) {
|
|
198
214
|
const self = normalizeHost(options.device ?? machineId());
|
|
@@ -204,7 +220,8 @@ export async function applyPeerFleetState(state, options = {}) {
|
|
|
204
220
|
const merged = state.usage
|
|
205
221
|
? await ingestPeerClaudeUsageRows(stampSyncRows(state.usage.rows, state.device), options.cachePath)
|
|
206
222
|
: 0;
|
|
207
|
-
|
|
223
|
+
const adoptedAccounts = await adoptHeadedPeerAccounts(state);
|
|
224
|
+
return { path: write.path, merged, adoptedAccounts, receivedAt };
|
|
208
225
|
}
|
|
209
226
|
export async function buildFleetStateExchangeCommand(os) {
|
|
210
227
|
const { buildRemoteAgentsInvocation, buildWindowsStdinAgentsCommand, remoteShellFor } = await import('../hosts/remote-cmd.js');
|
|
@@ -241,7 +258,7 @@ export async function exchangeFleetStateWithPeers(options = {}) {
|
|
|
241
258
|
const outcomes = await Promise.all(peers.map(async (peer) => {
|
|
242
259
|
const outcome = { device: peer.name, delivered: false, receivedAt: null, merged: 0, error: null, peerErrors: [] };
|
|
243
260
|
try {
|
|
244
|
-
const remoteCmd = await buildFleetStateExchangeCommand(peer.shell === 'powershell' ? 'windows' : undefined);
|
|
261
|
+
const remoteCmd = await buildFleetStateExchangeCommand(resolveDeviceProfile(peer).shell === 'powershell' ? 'windows' : undefined);
|
|
245
262
|
const res = await dial(peer, remoteCmd, input);
|
|
246
263
|
if (res.timedOut)
|
|
247
264
|
throw new Error(`timed out after ${Math.round(timeoutMs / 1000)}s`);
|
|
@@ -53,6 +53,7 @@ export interface UsageSnapshot {
|
|
|
53
53
|
unavailable?: {
|
|
54
54
|
reason: 'session_limit' | 'out_of_credits';
|
|
55
55
|
resetsAt?: Date;
|
|
56
|
+
notedAt?: Date;
|
|
56
57
|
};
|
|
57
58
|
freshness?: {
|
|
58
59
|
source: UsageCaptureSource;
|
|
@@ -125,6 +126,7 @@ export interface CachedUsageSnapshot {
|
|
|
125
126
|
unavailable?: {
|
|
126
127
|
reason: 'session_limit' | 'out_of_credits';
|
|
127
128
|
resetsAt?: string;
|
|
129
|
+
notedAt?: string;
|
|
128
130
|
};
|
|
129
131
|
modelRefusals?: Record<string, CachedModelRefusal>;
|
|
130
132
|
freshnessSource?: UsageCaptureSource;
|
|
@@ -317,7 +319,8 @@ export declare function writeClaudeUsageCache(usageKey: string, snapshot: UsageS
|
|
|
317
319
|
export declare function mergeClaudeUsageCacheWindows(usageKey: string, snapshot: UsageSnapshot, cachePath?: string): void;
|
|
318
320
|
export declare function exportClaudeUsageCacheRows(cachePath?: string): Record<string, CachedUsageSnapshot>;
|
|
319
321
|
export declare function ingestPeerClaudeUsageRows(rows: Record<string, CachedUsageSnapshot>, cachePath?: string): Promise<number>;
|
|
320
|
-
export declare
|
|
322
|
+
export declare const OUT_OF_CREDITS_REPROBE_MS: number;
|
|
323
|
+
export declare function noteClaudeOutOfCredits(usageKey: string, cachePath?: string, now?: Date): void;
|
|
321
324
|
export declare function clearClaudeAccountRefusal(usageKey: string, cachePath?: string): void;
|
|
322
325
|
export declare function noteClaudeSessionLimit(usageKey: string, resetsAt: Date, cachePath?: string): void;
|
|
323
326
|
export declare function claudeModelRefusalKey(accountId?: string | null, home?: string | null): string | undefined;
|