@phnx-labs/agents-cli 1.23.18 → 1.23.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/CHANGELOG.md +187 -0
  2. package/README.md +1 -1
  3. package/dist/bootstrap.js +1 -1
  4. package/dist/commands/cloud.js +1 -1
  5. package/dist/commands/config.js +1 -1
  6. package/dist/commands/detach.js +5 -1
  7. package/dist/commands/doctor.js +11 -7
  8. package/dist/commands/exec.d.ts +0 -17
  9. package/dist/commands/exec.js +17 -51
  10. package/dist/commands/focus.d.ts +10 -2
  11. package/dist/commands/focus.js +80 -19
  12. package/dist/commands/projects-todo.js +10 -5
  13. package/dist/commands/ps.d.ts +8 -2
  14. package/dist/commands/ps.js +175 -92
  15. package/dist/commands/sessions-picker.d.ts +0 -7
  16. package/dist/commands/sessions-picker.js +5 -299
  17. package/dist/commands/sessions-stop.js +2 -2
  18. package/dist/lib/account-registry.d.ts +3 -0
  19. package/dist/lib/account-registry.js +40 -0
  20. package/dist/lib/accounting/account-pool-collect.d.ts +2 -2
  21. package/dist/lib/accounting/account-pool-collect.js +4 -4
  22. package/dist/lib/accounting/account-pool.d.ts +1 -1
  23. package/dist/lib/accounting/account-pool.js +3 -1
  24. package/dist/lib/accounting/usage-sync.d.ts +1 -0
  25. package/dist/lib/accounting/usage-sync.js +20 -3
  26. package/dist/lib/accounting/usage.d.ts +4 -1
  27. package/dist/lib/accounting/usage.js +38 -6
  28. package/dist/lib/agent-spec/agents.js +12 -11
  29. package/dist/lib/cloud/store.d.ts +5 -1
  30. package/dist/lib/cloud/store.js +10 -3
  31. package/dist/lib/config-keys.d.ts +1 -1
  32. package/dist/lib/config-keys.js +1 -0
  33. package/dist/lib/daemon/account-state-daemon-service.js +9 -2
  34. package/dist/lib/daemon/self-update-service.js +1 -1
  35. package/dist/lib/device-config.d.ts +2 -1
  36. package/dist/lib/device-config.js +21 -11
  37. package/dist/lib/devices/health.d.ts +6 -0
  38. package/dist/lib/devices/health.js +11 -4
  39. package/dist/lib/feed/watch.js +2 -1
  40. package/dist/lib/fleet/apply.d.ts +1 -1
  41. package/dist/lib/fleet/apply.js +5 -2
  42. package/dist/lib/fleet-shared-state.d.ts +2 -0
  43. package/dist/lib/fleet-shared-state.js +3 -1
  44. package/dist/lib/github/project-prs.js +14 -1
  45. package/dist/lib/helper-versions.js +1 -1
  46. package/dist/lib/installations/versions.js +4 -3
  47. package/dist/lib/project-root.d.ts +1 -0
  48. package/dist/lib/project-root.js +11 -3
  49. package/dist/lib/projects.js +2 -2
  50. package/dist/lib/quick-todo.d.ts +5 -1
  51. package/dist/lib/quick-todo.js +14 -1
  52. package/dist/lib/remote-agents-json.js +4 -2
  53. package/dist/lib/self-update.d.ts +1 -1
  54. package/dist/lib/self-update.js +59 -2
  55. package/dist/lib/session/db.js +1 -1
  56. package/dist/lib/session/glance-files.d.ts +21 -0
  57. package/dist/lib/session/glance-files.js +123 -0
  58. package/dist/lib/session/presentation.d.ts +3 -0
  59. package/dist/lib/session/preview-digest.d.ts +13 -0
  60. package/dist/lib/session/preview-digest.js +328 -0
  61. package/dist/lib/session/recovery.d.ts +1 -1
  62. package/dist/lib/session/recovery.js +1 -1
  63. package/dist/lib/session/remote/remote-list.d.ts +3 -2
  64. package/dist/lib/session/remote/remote-list.js +12 -6
  65. package/dist/lib/session/remote/watch.d.ts +2 -0
  66. package/dist/lib/session/remote/watch.js +86 -5
  67. package/dist/lib/smart-launch.js +6 -1
  68. package/dist/lib/teams/placement-probe.d.ts +2 -0
  69. package/dist/lib/teams/placement-probe.js +8 -3
  70. package/dist/lib/terminal/engine.d.ts +2 -0
  71. package/dist/lib/terminal/engine.js +5 -3
  72. package/dist/lib/terminal/index.d.ts +1 -1
  73. package/dist/lib/terminal/index.js +1 -1
  74. package/dist/lib/terminal/run-surface.d.ts +1 -0
  75. package/dist/lib/terminal/run-surface.js +9 -0
  76. package/package.json +1 -1
  77. package/dist/lib/onepassword.d.ts +0 -57
  78. package/dist/lib/onepassword.js +0 -140
@@ -1348,6 +1348,7 @@ function serializeClaudeUsageSnapshot(snapshot) {
1348
1348
  ? {
1349
1349
  reason: snapshot.unavailable.reason,
1350
1350
  resetsAt: snapshot.unavailable.resetsAt?.toISOString(),
1351
+ notedAt: snapshot.unavailable.notedAt?.toISOString(),
1351
1352
  }
1352
1353
  : undefined,
1353
1354
  windows: persistedWindows.map((window) => ({
@@ -1398,13 +1399,20 @@ function deserializeClaudeUsageSnapshot(snapshot, now) {
1398
1399
  : undefined,
1399
1400
  };
1400
1401
  }
1402
+ export const OUT_OF_CREDITS_REPROBE_MS = 60 * 60 * 1000;
1403
+ function liveOutOfCredits(cached, now) {
1404
+ const noted = parseDateValue(cached.notedAt);
1405
+ if (!noted || now.getTime() - noted.getTime() >= OUT_OF_CREDITS_REPROBE_MS)
1406
+ return undefined;
1407
+ return { reason: 'out_of_credits', notedAt: noted };
1408
+ }
1401
1409
  function carryForwardUnavailable(prior, live) {
1402
1410
  if (live)
1403
1411
  return live;
1404
1412
  if (!prior)
1405
1413
  return undefined;
1406
1414
  if (prior.reason === 'out_of_credits')
1407
- return { reason: 'out_of_credits' };
1415
+ return liveOutOfCredits(prior, new Date());
1408
1416
  const reset = parseDateValue(prior.resetsAt);
1409
1417
  return reset && reset.getTime() > Date.now()
1410
1418
  ? { reason: 'session_limit', resetsAt: reset }
@@ -1414,7 +1422,7 @@ function deserializeUnavailable(cached, now) {
1414
1422
  if (!cached)
1415
1423
  return undefined;
1416
1424
  if (cached.reason === 'out_of_credits')
1417
- return { reason: 'out_of_credits' };
1425
+ return liveOutOfCredits(cached, now);
1418
1426
  const reset = parseDateValue(cached.resetsAt);
1419
1427
  return reset && reset.getTime() > now.getTime()
1420
1428
  ? { reason: 'session_limit', resetsAt: reset }
@@ -1430,13 +1438,16 @@ function hasLiveModelRefusal(modelRefusals, now) {
1430
1438
  return !reset || reset.getTime() > now.getTime();
1431
1439
  });
1432
1440
  }
1433
- export function noteClaudeOutOfCredits(usageKey, cachePath = getClaudeUsageCachePath()) {
1441
+ export function noteClaudeOutOfCredits(usageKey, cachePath = getClaudeUsageCachePath(), now = new Date()) {
1434
1442
  try {
1435
1443
  ensureLockTarget(cachePath, '{}');
1436
1444
  withFileLock(cachePath, () => {
1437
1445
  const cache = readClaudeUsageCacheFile(cachePath);
1438
1446
  const existing = cache[usageKey] ?? { capturedAt: null, windows: [] };
1439
- cache[usageKey] = { ...existing, unavailable: { reason: 'out_of_credits' } };
1447
+ cache[usageKey] = {
1448
+ ...existing,
1449
+ unavailable: { reason: 'out_of_credits', notedAt: now.toISOString() },
1450
+ };
1440
1451
  atomicWriteFileSync(cachePath, JSON.stringify(cache, null, 2), 'utf-8');
1441
1452
  });
1442
1453
  }
@@ -1933,6 +1944,10 @@ async function getGrokUsageInfo(options) {
1933
1944
  return usageNoRecentUsageInfo();
1934
1945
  }
1935
1946
  const now = new Date();
1947
+ const unavailable = match.exhaustedAt
1948
+ && now.getTime() - match.exhaustedAt.getTime() < OUT_OF_CREDITS_REPROBE_MS
1949
+ ? { reason: 'out_of_credits', notedAt: match.exhaustedAt }
1950
+ : undefined;
1936
1951
  const windows = match.windows.filter((window) => isCachedUsageWindowFresh(window, match.capturedAt, now));
1937
1952
  const staleWindows = match.windows.filter((window) => !isCachedUsageWindowFresh(window, match.capturedAt, now));
1938
1953
  const version = options?.cliVersion;
@@ -1948,6 +1963,7 @@ async function getGrokUsageInfo(options) {
1948
1963
  staleWindows: staleWindows.length > 0 ? staleWindows : undefined,
1949
1964
  plan: match.subscriptionTier,
1950
1965
  refreshHint,
1966
+ unavailable,
1951
1967
  },
1952
1968
  error: null,
1953
1969
  };
@@ -2174,6 +2190,7 @@ async function readMuseLocalSessionUsage(base) {
2174
2190
  async function readLatestGrokBilling(filePath) {
2175
2191
  return new Promise((resolve) => {
2176
2192
  let latest = null;
2193
+ let exhaustedAt = null;
2177
2194
  const stream = fs.createReadStream(filePath, { encoding: 'utf-8' });
2178
2195
  const rl = readline.createInterface({ input: stream, crlfDelay: Infinity });
2179
2196
  rl.on('line', (line) => {
@@ -2184,6 +2201,12 @@ async function readLatestGrokBilling(filePath) {
2184
2201
  const ctx = parsed.ctx && typeof parsed.ctx === 'object' && !Array.isArray(parsed.ctx)
2185
2202
  ? parsed.ctx
2186
2203
  : null;
2204
+ if (parsed.msg === 'shell.turn.inference_failed'
2205
+ && ctx?.status_code === 402
2206
+ && /balance exhausted/i.test(String(ctx.message ?? ''))) {
2207
+ exhaustedAt = parseDateValue(parsed.ts) ?? exhaustedAt;
2208
+ return;
2209
+ }
2187
2210
  if (parsed.msg === 'billing: fetched credits config' && ctx?.config) {
2188
2211
  const config = ctx.config;
2189
2212
  const windows = [];
@@ -2207,13 +2230,22 @@ async function readLatestGrokBilling(filePath) {
2207
2230
  windows,
2208
2231
  identity: grokIdentityFromBillingPayload(parsed),
2209
2232
  };
2233
+ exhaustedAt = null;
2210
2234
  }
2211
2235
  }
2212
2236
  catch {
2213
2237
  }
2214
2238
  });
2215
- rl.on('close', () => resolve(latest));
2216
- rl.on('error', () => resolve(latest));
2239
+ const settle = () => {
2240
+ if (exhaustedAt) {
2241
+ resolve({ ...(latest ?? { capturedAt: exhaustedAt, windows: [], identity: null }), exhaustedAt });
2242
+ }
2243
+ else {
2244
+ resolve(latest);
2245
+ }
2246
+ };
2247
+ rl.on('close', settle);
2248
+ rl.on('error', settle);
2217
2249
  });
2218
2250
  }
2219
2251
  export function normalizeCursorUsage(data) {
@@ -16,6 +16,7 @@ import { registeredNativeAccountForEmail, parseNativeIdentityKey } from '../nati
16
16
  import { resolveVersion, getVersionHomePath, getBinaryPath } from '../installations/versions.js';
17
17
  import { supports } from '../capabilities.js';
18
18
  import { MCP_TARGETS } from '../mcp-registry.js';
19
+ import { HARNESS_AUTH } from '../harness-auth-capabilities.js';
19
20
  import { VERSION_RE } from './primitives.js';
20
21
  const execFileAsync = promisify(execFile);
21
22
  const HOME = os.homedir();
@@ -937,14 +938,14 @@ export function isAccountSlotDir(dir) {
937
938
  const resolved = path.resolve(dir);
938
939
  return resolved === root || resolved.startsWith(root + path.sep);
939
940
  }
940
- function resolveAccountCredentialPath(base, ...segments) {
941
+ function resolveAccountCredentialPath(agent, base, ...segments) {
941
942
  const perVersion = path.join(base, ...segments);
942
943
  try {
943
944
  if (fs.existsSync(perVersion))
944
945
  return perVersion;
945
946
  }
946
947
  catch { }
947
- if (isAccountSlotDir(base))
948
+ if (isAccountSlotDir(base) || HARNESS_AUTH[agent].slotEnv)
948
949
  return null;
949
950
  const active = path.join(process.env.AGENTS_REAL_HOME || os.homedir(), ...segments);
950
951
  if (active !== perVersion) {
@@ -995,8 +996,8 @@ export function credentialPresence(agentId, versionHome) {
995
996
  return { perVersion, active, knownLocation };
996
997
  }
997
998
  export function decryptDroidAuthPayload(base) {
998
- const filePath = resolveAccountCredentialPath(base, '.factory', 'auth.v2.file');
999
- const keyPath = resolveAccountCredentialPath(base, '.factory', 'auth.v2.key');
999
+ const filePath = resolveAccountCredentialPath('droid', base, '.factory', 'auth.v2.file');
1000
+ const keyPath = resolveAccountCredentialPath('droid', base, '.factory', 'auth.v2.key');
1000
1001
  if (!filePath || !keyPath)
1001
1002
  return null;
1002
1003
  return decryptDroidAuthFile(filePath, keyPath);
@@ -1423,7 +1424,7 @@ export async function getAccountInfo(agentId, home) {
1423
1424
  };
1424
1425
  }
1425
1426
  case 'cursor': {
1426
- const cfgPath = resolveAccountCredentialPath(base, '.cursor', 'cli-config.json');
1427
+ const cfgPath = resolveAccountCredentialPath('cursor', base, '.cursor', 'cli-config.json');
1427
1428
  if (!cfgPath)
1428
1429
  return { ...empty, lastActive };
1429
1430
  try {
@@ -1433,7 +1434,7 @@ export async function getAccountInfo(agentId, home) {
1433
1434
  const accountId = normalizeIdentityPart(authInfo?.authId ?? authInfo?.userId);
1434
1435
  if (!email && !accountId)
1435
1436
  return { ...empty, lastActive };
1436
- const authPath = resolveAccountCredentialPath(base, '.cursor', 'auth.json');
1437
+ const authPath = resolveAccountCredentialPath('cursor', base, '.cursor', 'auth.json');
1437
1438
  let hasToken = false;
1438
1439
  if (authPath) {
1439
1440
  try {
@@ -1451,7 +1452,7 @@ export async function getAccountInfo(agentId, home) {
1451
1452
  return { ...empty, lastActive };
1452
1453
  }
1453
1454
  case 'grok': {
1454
- const authPath = resolveAccountCredentialPath(base, '.grok', 'auth.json');
1455
+ const authPath = resolveAccountCredentialPath('grok', base, '.grok', 'auth.json');
1455
1456
  if (!authPath)
1456
1457
  return { ...empty, lastActive };
1457
1458
  try {
@@ -1473,7 +1474,7 @@ export async function getAccountInfo(agentId, home) {
1473
1474
  return { ...empty, lastActive };
1474
1475
  }
1475
1476
  case 'antigravity': {
1476
- const tokenPath = resolveAccountCredentialPath(base, '.gemini', 'antigravity-cli', 'antigravity-oauth-token');
1477
+ const tokenPath = resolveAccountCredentialPath('antigravity', base, '.gemini', 'antigravity-cli', 'antigravity-oauth-token');
1477
1478
  if (tokenPath) {
1478
1479
  const data = JSON.parse(await fs.promises.readFile(tokenPath, 'utf-8'));
1479
1480
  if (typeof data?.token?.refresh_token === 'string' && data.token.refresh_token) {
@@ -1488,7 +1489,7 @@ export async function getAccountInfo(agentId, home) {
1488
1489
  return { ...empty, lastActive };
1489
1490
  }
1490
1491
  case 'kimi': {
1491
- const credPath = resolveAccountCredentialPath(base, '.kimi-code', 'credentials', 'kimi-code.json');
1492
+ const credPath = resolveAccountCredentialPath('kimi', base, '.kimi-code', 'credentials', 'kimi-code.json');
1492
1493
  if (!credPath)
1493
1494
  return { ...empty, lastActive };
1494
1495
  const data = JSON.parse(await fs.promises.readFile(credPath, 'utf-8'));
@@ -1516,7 +1517,7 @@ export async function getAccountInfo(agentId, home) {
1516
1517
  };
1517
1518
  }
1518
1519
  // An unreadable encrypted payload still counts conservatively when its auth file exists.
1519
- const authPath = resolveAccountCredentialPath(base, '.factory', 'auth.v2.file');
1520
+ const authPath = resolveAccountCredentialPath('droid', base, '.factory', 'auth.v2.file');
1520
1521
  if (!authPath)
1521
1522
  return { ...empty, lastActive };
1522
1523
  return { ...empty, signedIn: true, lastActive };
@@ -1541,7 +1542,7 @@ export async function getAccountInfo(agentId, home) {
1541
1542
  const accountKey = buildIdentityKey(agentId, [['auth', 'env']]);
1542
1543
  return { ...empty, signedIn: true, accountId: 'env', accountKey, lastActive };
1543
1544
  }
1544
- const authPath = resolveAccountCredentialPath(base, '.config', 'muse', 'auth.json');
1545
+ const authPath = resolveAccountCredentialPath('muse', base, '.config', 'muse', 'auth.json');
1545
1546
  if (!authPath)
1546
1547
  return { ...empty, lastActive };
1547
1548
  const data = JSON.parse(await fs.promises.readFile(authPath, 'utf-8'));
@@ -8,4 +8,8 @@ export declare function listTasks(filter?: {
8
8
  status?: CloudTaskStatus;
9
9
  limit?: number;
10
10
  }): CloudTask[];
11
- export declare function listActiveTasks(): CloudTask[];
11
+ export declare const CLOUD_TASK_STALE_MS: number;
12
+ export declare function listActiveTasks(opts?: {
13
+ includeStale?: boolean;
14
+ nowMs?: number;
15
+ }): CloudTask[];
@@ -90,9 +90,16 @@ export function listTasks(filter) {
90
90
  return rows.map(rowToTask);
91
91
  }
92
92
  const TERMINAL_STATUSES = ['completed', 'failed', 'cancelled'];
93
- export function listActiveTasks() {
94
- const placeholders = TERMINAL_STATUSES.map(() => '?').join(', ');
95
- const rows = db().prepare(`SELECT * FROM tasks WHERE status NOT IN (${placeholders}) ORDER BY created_at DESC`).all(...TERMINAL_STATUSES);
93
+ const WORKING_STATUSES = ['queued', 'allocating', 'running'];
94
+ export const CLOUD_TASK_STALE_MS = 24 * 60 * 60 * 1000;
95
+ export function listActiveTasks(opts = {}) {
96
+ const terminal = TERMINAL_STATUSES.map(() => '?').join(', ');
97
+ if (opts.includeStale) {
98
+ return db().prepare(`SELECT * FROM tasks WHERE status NOT IN (${terminal}) ORDER BY created_at DESC`).all(...TERMINAL_STATUSES).map(rowToTask);
99
+ }
100
+ const working = WORKING_STATUSES.map(() => '?').join(', ');
101
+ const cutoff = new Date((opts.nowMs ?? Date.now()) - CLOUD_TASK_STALE_MS).toISOString();
102
+ const rows = db().prepare(`SELECT * FROM tasks WHERE status NOT IN (${terminal}) AND (status NOT IN (${working}) OR updated_at >= ?) ORDER BY created_at DESC`).all(...TERMINAL_STATUSES, ...WORKING_STATUSES, cutoff);
96
103
  return rows.map(rowToTask);
97
104
  }
98
105
  function rowToTask(row) {
@@ -1,7 +1,7 @@
1
1
  import type { AgentId } from './types.js';
2
2
  import { type ModelTier } from './model-tiers.js';
3
3
  export type ConfigScope = 'run' | 'interactive' | 'auto' | 'browser' | 'project' | 'device' | 'summarizer' | 'updates' | 'menubar';
4
- export declare const MENUBAR_MENU_PROPERTIES: readonly ["defaultProject", "workingRowsShown", "showPreviews", "projectPriorityFilter", "hideCompletedMilestones", "bannerWhenNeedsYou", "includeOtherDeviceRequests", "groupBy", "thenBy", "projectScope", "projectSort", "ticketSort", "showPullRequests", "sessionUpdates", "showBrowserSessions", "showComputerSessions", "deviceSort", "headlessAgent", "headlessFallbackAgent", "headlessPlacement", "pinnedProjects", "tabOrder", "hiddenTabs", "groupTicketsByMilestone", "ticketGroup", "prGroupOpen", "prGroupMerged", "homeGoals", "homeSections", "sessionFilter", "artifactApps", "githubHidden", "githubDrafts", "githubBots"];
4
+ export declare const MENUBAR_MENU_PROPERTIES: readonly ["defaultProject", "todoProject", "workingRowsShown", "showPreviews", "projectPriorityFilter", "hideCompletedMilestones", "bannerWhenNeedsYou", "includeOtherDeviceRequests", "groupBy", "thenBy", "projectScope", "projectSort", "ticketSort", "showPullRequests", "sessionUpdates", "showBrowserSessions", "showComputerSessions", "deviceSort", "headlessAgent", "headlessFallbackAgent", "headlessPlacement", "pinnedProjects", "tabOrder", "hiddenTabs", "groupTicketsByMilestone", "ticketGroup", "prGroupOpen", "prGroupMerged", "homeGoals", "homeSections", "sessionFilter", "artifactApps", "githubHidden", "githubDrafts", "githubBots"];
5
5
  export declare const MENUBAR_STATUSBAR_PROPERTIES: readonly ["goalCountdown"];
6
6
  export type MenubarSection = 'menu' | 'statusbar';
7
7
  export declare const MENUBAR_CONFIG_KEYS: readonly string[];
@@ -3,6 +3,7 @@ import { MODEL_TIERS } from './model-tiers.js';
3
3
  import { VERSION_RE } from './run-defaults.js';
4
4
  export const MENUBAR_MENU_PROPERTIES = [
5
5
  'defaultProject',
6
+ 'todoProject',
6
7
  'workingRowsShown',
7
8
  'showPreviews',
8
9
  'projectPriorityFilter',
@@ -2,7 +2,7 @@ import * as fsp from 'node:fs/promises';
2
2
  import * as path from 'node:path';
3
3
  import { BasePeriodicService } from './service.js';
4
4
  import { runUsageRefreshTick, refreshLocalFleetAuthState } from '../daemon-ticks.js';
5
- import { getDaemonDir } from '../state.js';
5
+ import { getDaemonDir, readMeta } from '../state.js';
6
6
  import { getCliLaunch } from '../cli-entry.js';
7
7
  import { execFileBounded } from '../exec-bounded.js';
8
8
  import { fleetSharedStatePath, FLEET_SHARED_STATE_VERSION } from '../fleet-shared-state.js';
@@ -10,6 +10,7 @@ import { withFileLockAsync } from '../fs-atomic.js';
10
10
  import { machineId } from '../machine-id.js';
11
11
  import { getConfigValueAsync, isHeadedDeviceRole } from '../device-config.js';
12
12
  import { harnessWorkerIsPerDevice } from '../harness-auth-capabilities.js';
13
+ import { peerAccountRow, PEER_ACCOUNT_ROW_LIMIT } from '../account-registry.js';
13
14
  export const USAGE_STATE_TICK_MS = 60_000;
14
15
  export const AUTH_STATE_TICK_MS = 3 * 60_000;
15
16
  const REFRESH_DEADLINE_MS = 2 * 60_000;
@@ -92,6 +93,12 @@ export async function publishAccountDaemonStateRows(rows, userAgentsDir) {
92
93
  : row.health.verdict === 'error' ? 'unverified' : row.health.verdict,
93
94
  checkedAt: new Date(row.health.checkedAt).toISOString(),
94
95
  }));
96
+ const native = headed
97
+ ? Object.values(readMeta().accounts?.native ?? {})
98
+ .filter((account) => account.scope === 'version' && account.provisioning === 'per-device')
99
+ .slice(0, PEER_ACCOUNT_ROW_LIMIT)
100
+ .map(peerAccountRow)
101
+ : undefined;
95
102
  await withFileLockAsync(file, async () => {
96
103
  const raw = await fsp.readFile(file, 'utf-8');
97
104
  let current = {};
@@ -109,7 +116,7 @@ export async function publishAccountDaemonStateRows(rows, userAgentsDir) {
109
116
  ...current,
110
117
  version: FLEET_SHARED_STATE_VERSION,
111
118
  device,
112
- accounts: { rows: accountRows },
119
+ accounts: { rows: accountRows, ...(native?.length ? { native } : {}) },
113
120
  };
114
121
  const serialized = `${JSON.stringify(next, null, 2)}\n`;
115
122
  if (serialized === raw)
@@ -34,7 +34,7 @@ export async function installAndVerifyDefault(metadata, packageRoot, signal) {
34
34
  try {
35
35
  await sweepStaleInstallStaging(packageRoot);
36
36
  if (detectPackageManager(packageRoot) === 'bun') {
37
- await installPackageWithBun(tarball, signal);
37
+ await installPackageWithBun(tarball, deriveGlobalPrefix(packageRoot), signal);
38
38
  }
39
39
  else {
40
40
  await installPackageIntoPrefix(tarball, deriveGlobalPrefix(packageRoot), signal);
@@ -29,7 +29,8 @@ interface ConfigTarget {
29
29
  }
30
30
  declare const DEVICE_ROLES: readonly ["worker", "personal", "desktop"];
31
31
  declare const AUTO_POOL_MODES: readonly ["workers", "all"];
32
- export declare const MENUBAR_TABS: readonly ["home", "goals", "secrets", "projects", "linear", "github", "sessions", "inbox"];
32
+ export declare const MENUBAR_TABS: readonly ["home", "goals", "secrets", "linear", "github", "sessions", "inbox"];
33
+ export declare const MENUBAR_RETIRED_TABS: readonly string[];
33
34
  export declare const MENUBAR_HOME_GOALS: readonly ["company", "week", "myWeek", "myDay"];
34
35
  export declare const MENUBAR_HOME_SECTIONS: readonly ["company", "cycle", "today", "needs", "prs", "issues", "sessions", "artifacts", "todos"];
35
36
  export declare const MENUBAR_ARTIFACT_KINDS: readonly ["image", "html", "markdown"];
@@ -13,19 +13,20 @@ const SSH_AUTH_METHODS = ['key', 'password'];
13
13
  const DEVICE_ROLES = ['worker', 'personal', 'desktop'];
14
14
  const AUTO_POOL_MODES = ['workers', 'all'];
15
15
  const DEVICE_FORM_FACTORS = ['laptop', 'desktop', 'server', 'unknown'];
16
- export const MENUBAR_TABS = ['home', 'goals', 'secrets', 'projects', 'linear', 'github', 'sessions', 'inbox'];
16
+ export const MENUBAR_TABS = ['home', 'goals', 'secrets', 'linear', 'github', 'sessions', 'inbox'];
17
+ export const MENUBAR_RETIRED_TABS = ['projects'];
18
+ const MENUBAR_STORABLE_TABS = [...MENUBAR_TABS, ...MENUBAR_RETIRED_TABS];
17
19
  const MENUBAR_TABS_ADDED_LATER = ['goals', 'secrets', 'linear', 'github'];
18
20
  export const MENUBAR_HOME_GOALS = ['company', 'week', 'myWeek', 'myDay'];
19
21
  export const MENUBAR_HOME_SECTIONS = ['company', 'cycle', 'today', 'needs', 'prs', 'issues', 'sessions', 'artifacts', 'todos'];
20
22
  export const MENUBAR_ARTIFACT_KINDS = ['image', 'html', 'markdown'];
21
23
  export function resolveMenubarTabOrder(stored) {
22
- const known = MENUBAR_TABS;
23
24
  const tabs = [];
24
25
  for (const id of stored) {
25
- if (known.includes(id) && !tabs.includes(id))
26
+ if (MENUBAR_STORABLE_TABS.includes(id) && !tabs.includes(id))
26
27
  tabs.push(id);
27
28
  }
28
- return [...tabs, ...known.filter((t) => !tabs.includes(t))];
29
+ return [...tabs, ...MENUBAR_TABS.filter((t) => !tabs.includes(t))];
29
30
  }
30
31
  function oneOf(name, allowed) {
31
32
  return (v) => (allowed.includes(v) ? null : `${name} must be one of ${allowed.join(' | ')}.`);
@@ -341,6 +342,14 @@ export const CONFIG_KEYS = [
341
342
  type: 'string',
342
343
  description: 'AGI Menu: the project name the menu opens focused on. Unset = no default project.',
343
344
  },
345
+ {
346
+ name: 'menubar.menu.todoProject',
347
+ yamlKey: 'menubarMenuTodoProject',
348
+ scope: 'user',
349
+ type: 'string',
350
+ description: 'AGI Menu: the project whose open Linear issues the menu lists as to-dos and files new to-dos into ' +
351
+ '(`agents projects todo list|add --project <name>`). Unset = the default quick to-do list.',
352
+ },
344
353
  {
345
354
  name: 'menubar.menu.workingRowsShown',
346
355
  yamlKey: 'menubarMenuWorkingRowsShown',
@@ -549,17 +558,18 @@ export const CONFIG_KEYS = [
549
558
  defaultValue: [...MENUBAR_TABS],
550
559
  description: `AGI Menu: the order of the tab bar — every one of ${MENUBAR_TABS.join(', ')} exactly once. ` +
551
560
  'Settings is always last and is not listed. An order saved before Goals, Secrets, Linear or GitHub existed may omit them; ' +
552
- 'they read back appended. Hiding a tab is menubar.menu.hiddenTabs, not this key.',
561
+ `they read back appended. The retired ${MENUBAR_RETIRED_TABS.join(', ')} tab is still accepted and kept where it was stored, ` +
562
+ 'for menus that predate its removal. Hiding a tab is menubar.menu.hiddenTabs, not this key.',
553
563
  validate: (v) => {
554
564
  const tabs = v;
555
565
  const required = MENUBAR_TABS.filter((t) => !MENUBAR_TABS_ADDED_LATER.includes(t));
556
566
  const ok = new Set(tabs).size === tabs.length
557
- && tabs.every((t) => MENUBAR_TABS.includes(t))
567
+ && tabs.every((t) => MENUBAR_STORABLE_TABS.includes(t))
558
568
  && required.every((t) => tabs.includes(t));
559
569
  return ok
560
570
  ? null
561
571
  : `menubar.menu.tabOrder must list each of ${MENUBAR_TABS.join(', ')} exactly once ` +
562
- `(${MENUBAR_TABS_ADDED_LATER.join(', ')} may be left out and are appended).`;
572
+ `(${MENUBAR_TABS_ADDED_LATER.join(', ')} may be left out and are appended; the retired ${MENUBAR_RETIRED_TABS.join(', ')} may be listed).`;
563
573
  },
564
574
  normalize: (v) => (Array.isArray(v) ? resolveMenubarTabOrder(v.map(String)) : v),
565
575
  },
@@ -591,12 +601,12 @@ export const CONFIG_KEYS = [
591
601
  'Settings cannot be hidden. Hiding Inbox loses nothing: its requests still show on Home. Secrets is hidden unless this list is set without it.',
592
602
  validate: (v) => {
593
603
  const tabs = v;
594
- const bad = tabs.find((t) => !MENUBAR_TABS.includes(t));
604
+ const bad = tabs.find((t) => !MENUBAR_STORABLE_TABS.includes(t));
595
605
  if (bad !== undefined)
596
606
  return `menubar.menu.hiddenTabs: "${bad}" is not one of ${MENUBAR_TABS.join(', ')}.`;
597
607
  if (new Set(tabs).size !== tabs.length)
598
608
  return 'menubar.menu.hiddenTabs lists a tab twice.';
599
- if (tabs.length === MENUBAR_TABS.length)
609
+ if (MENUBAR_TABS.every((t) => tabs.includes(t)))
600
610
  return 'menubar.menu.hiddenTabs cannot hide every tab.';
601
611
  return null;
602
612
  },
@@ -623,8 +633,8 @@ export const CONFIG_KEYS = [
623
633
  yamlKey: 'menubarMenuGithubDrafts',
624
634
  scope: 'user',
625
635
  type: 'bool',
626
- defaultValue: false,
627
- description: 'AGI Menu: show draft pull requests on the GitHub tab (default off).',
636
+ defaultValue: true,
637
+ description: 'AGI Menu: show draft pull requests on the GitHub tab (default on).',
628
638
  },
629
639
  {
630
640
  name: 'menubar.menu.githubBots',
@@ -55,6 +55,12 @@ interface FleetCapacity {
55
55
  export declare function fleetCapacity(statsList: Iterable<DeviceStats>): FleetCapacity;
56
56
  export type Headroom = 'idle' | 'light' | 'busy' | 'loaded' | 'unknown';
57
57
  export declare function headroom(stats: DeviceStats | undefined): Headroom;
58
+ export declare function buildProbeInvocation(device: DeviceProfile, askpassShimPath: string): {
59
+ args: string[];
60
+ env: Record<string, string>;
61
+ isWin: boolean;
62
+ budgetMs: number;
63
+ };
58
64
  export declare function probeDeviceStats(device: DeviceProfile, opts?: {
59
65
  timeoutMs?: number;
60
66
  now?: number;
@@ -1,5 +1,6 @@
1
1
  import { execFile } from 'child_process';
2
2
  import { buildSshInvocation, writeAskpassShim } from './connect.js';
3
+ import { resolveDeviceProfile } from './resolve-profile.js';
3
4
  export const PROBE_TIMEOUT_MS = 2_500;
4
5
  export const RELAYED_PROBE_TIMEOUT_MS = 8_000;
5
6
  // Only measured relayed peers receive the wider budget; unknown/manual peers are not assumed relayed.
@@ -171,16 +172,22 @@ export function headroom(stats) {
171
172
  return 'busy';
172
173
  return 'loaded';
173
174
  }
175
+ export function buildProbeInvocation(device, askpassShimPath) {
176
+ const resolved = resolveDeviceProfile(device);
177
+ const isWin = resolved.shell === 'powershell';
178
+ const { args, env } = buildSshInvocation(resolved, [isWin ? WIN_PROBE_SNIPPET : PROBE_SNIPPET], askpassShimPath, {}, { agentOnly: true });
179
+ return { args, env, isWin, budgetMs: probeBudgetMs(resolved) };
180
+ }
174
181
  // Stats probes are agentOnly so listing devices never opens credential UI; a timeout means slow, not conclusively unreachable.
175
182
  export function probeDeviceStats(device, opts = {}) {
176
183
  const host = device.name;
177
184
  const fetchedAt = opts.now ?? Date.now();
178
- const isWin = device.shell === 'powershell';
179
185
  let args;
180
186
  let env;
187
+ let isWin;
188
+ let budgetMs;
181
189
  try {
182
- const shim = writeAskpassShim();
183
- ({ args, env } = buildSshInvocation(device, [isWin ? WIN_PROBE_SNIPPET : PROBE_SNIPPET], shim, {}, { agentOnly: true }));
190
+ ({ args, env, isWin, budgetMs } = buildProbeInvocation(device, writeAskpassShim()));
184
191
  }
185
192
  catch {
186
193
  return Promise.resolve({ host, reachable: false, fetchedAt });
@@ -189,7 +196,7 @@ export function probeDeviceStats(device, opts = {}) {
189
196
  execFile('ssh', args, {
190
197
  encoding: 'utf-8',
191
198
  env: { ...process.env, ...env },
192
- timeout: opts.timeoutMs ?? probeBudgetMs(device),
199
+ timeout: opts.timeoutMs ?? budgetMs,
193
200
  }, (err, stdout) => {
194
201
  if (err || !stdout) {
195
202
  const timedOut = Boolean(err && err.killed);
@@ -3,6 +3,7 @@ import { span, spanSync } from '../daemon/diagnostics.js';
3
3
  import * as fs from 'node:fs';
4
4
  import * as path from 'node:path';
5
5
  import { loadDevices, isDialableDevice } from '../devices/registry.js';
6
+ import { resolveDeviceProfile } from '../devices/resolve-profile.js';
6
7
  import { machineId, normalizeHost } from '../machine-id.js';
7
8
  import { shellQuote } from '../ssh-exec.js';
8
9
  import { buildWindowsAgentsCommand, remoteShellFor } from '../hosts/remote-cmd.js';
@@ -361,7 +362,7 @@ export async function watchFleetFeed(options) {
361
362
  return;
362
363
  }
363
364
  const self = machineId();
364
- const peers = Object.values(devices).filter((device) => isDialableDevice(device) && normalizeHost(device.name) !== self && ['windows', 'linux', 'macos'].includes(device.platform));
365
+ const peers = Object.values(devices).map(resolveDeviceProfile).filter((device) => isDialableDevice(device) && normalizeHost(device.name) !== self && ['windows', 'linux', 'macos'].includes(device.platform));
365
366
  const tasks = peers.map((device) => {
366
367
  const scope = normalizeHost(device.name);
367
368
  return streamFromPeer({
@@ -68,7 +68,7 @@ interface ProbeOptions {
68
68
  withVersions?: boolean;
69
69
  withSecrets?: boolean;
70
70
  }
71
- export declare function probeDevice(device: DeviceProfile, opts?: ProbeOptions): DeviceProbe;
71
+ export declare function probeDevice(rawDevice: DeviceProfile, opts?: ProbeOptions): DeviceProbe;
72
72
  export declare function parseRemoteBundles(stdout: string): Record<string, string>;
73
73
  export interface ApplyStep {
74
74
  kind: FleetAction['kind'];
@@ -2,6 +2,7 @@ import * as os from 'os';
2
2
  import { pushBundleToHost } from '../secrets-client.js';
3
3
  import { AUTH_STORE_ALIAS, inspectReservedAuthBundle, isReservedBundleName } from '../secrets-policy.js';
4
4
  import { deviceIdentityArgs, sshTargetFor } from '../devices/connect.js';
5
+ import { resolveDeviceProfile } from '../devices/resolve-profile.js';
5
6
  import { readyProbe, bootstrapAgentsCli } from '../hosts/ready.js';
6
7
  import { buildRemoteAgentsInvocation } from '../hosts/remote-cmd.js';
7
8
  import { sshExec } from '../ssh-exec.js';
@@ -200,7 +201,8 @@ function osHint(platform) {
200
201
  function remoteEnv(platform) {
201
202
  return platform === 'windows' ? undefined : { PATH: '$HOME/.agents/.cache/shims:$HOME/.local/bin:$PATH' };
202
203
  }
203
- export function probeDevice(device, opts) {
204
+ export function probeDevice(rawDevice, opts) {
205
+ const device = resolveDeviceProfile(rawDevice);
204
206
  let target;
205
207
  try {
206
208
  target = sshTargetFor(device);
@@ -276,7 +278,8 @@ export function parseRemoteBundles(stdout) {
276
278
  return {};
277
279
  }
278
280
  }
279
- async function reconcileDevice(row, device, ctx) {
281
+ async function reconcileDevice(row, rawDevice, ctx) {
282
+ const device = resolveDeviceProfile(rawDevice);
280
283
  if (!row.probe.reachable) {
281
284
  return { device: row.device, ok: false, steps: [], note: row.probe.note ?? 'unreachable' };
282
285
  }
@@ -1,4 +1,5 @@
1
1
  import type { CachedUsageSnapshot } from './accounting/usage.js';
2
+ import type { NativeAccountRecord } from './types.js';
2
3
  export declare const FLEET_SHARED_STATE_VERSION = 1;
3
4
  export declare const FLEET_SHARED_STATE_FILE = "daemon-state.json";
4
5
  export type SharedAuthStatus = 'ready' | 'missing' | 'invalid';
@@ -40,6 +41,7 @@ export interface FleetSharedDeviceState {
40
41
  };
41
42
  accounts?: {
42
43
  rows: unknown[];
44
+ native?: NativeAccountRecord[];
43
45
  };
44
46
  ownerNotify?: {
45
47
  signedIn: boolean;
@@ -34,7 +34,9 @@ export function parseFleetSharedDeviceStateEnvelope(parsed, owner) {
34
34
  throw new Error('unrecognized session mirror');
35
35
  }
36
36
  const accounts = parsed.accounts;
37
- if (accounts !== undefined && (!isRecord(accounts) || !Array.isArray(accounts.rows))) {
37
+ if (accounts !== undefined
38
+ && (!isRecord(accounts) || !Array.isArray(accounts.rows)
39
+ || (accounts.native !== undefined && !Array.isArray(accounts.native)))) {
38
40
  throw new Error('unrecognized account verdict rows');
39
41
  }
40
42
  const ownerNotify = parsed.ownerNotify;
@@ -270,6 +270,16 @@ export async function listRecentlyMerged(repo, sinceMs, gh = ghExec) {
270
270
  }));
271
271
  return { merged, truncated };
272
272
  }
273
+ async function readMergeState(slug, number, gh, errors) {
274
+ try {
275
+ const { mergeable, mergeableState } = await fetchOnePr(slug, number, gh, '60s');
276
+ return { mergeable, mergeableState };
277
+ }
278
+ catch (err) {
279
+ errors.record(err);
280
+ return {};
281
+ }
282
+ }
273
283
  async function readMergedDetail(slug, number, gh, details, errors) {
274
284
  const hit = details.get(slug, number);
275
285
  if (hit)
@@ -454,7 +464,10 @@ export async function buildProjectPrs(def, opts = {}, gh = ghExec, peers = [], c
454
464
  : null;
455
465
  merged = merged.slice(0, MERGED_LIMIT);
456
466
  const [openCi, recentlyMerged] = await Promise.all([
457
- mapBounded(pullRequests, 8, (pr) => readCi(ci, pr.headSha)),
467
+ mapBounded(pullRequests, 8, async (pr) => {
468
+ const [prCi, mergeState] = await Promise.all([readCi(ci, pr.headSha), readMergeState(slug, pr.number, gh, errors)]);
469
+ return { ...prCi, ...mergeState };
470
+ }),
458
471
  mapBounded(merged, 8, async (m) => {
459
472
  const [detail, mergeCi] = await Promise.all([
460
473
  readMergedDetail(slug, m.pr.number, gh, details, errors),
@@ -1,5 +1,5 @@
1
1
  export const HELPER_RELEASES = {
2
- menubar: { tagPrefix: 'menubar', floor: '1.15.21' },
2
+ menubar: { tagPrefix: 'menubar', floor: '1.18.0' },
3
3
  };
4
4
  export function helperTag(helper, version) {
5
5
  const release = HELPER_RELEASES[helper];
@@ -1401,7 +1401,7 @@ export async function getInstalledVersion(agent, version) {
1401
1401
  }
1402
1402
  }
1403
1403
  export function isMissingBinarySignature(output) {
1404
- return /\bENOENT\b|no such file|cannot find|command not found|is not recognized|native binary not installed|postinstall did not run|optional dependency was not downloaded/i.test(output);
1404
+ return /\bENOENT\b|no such file|cannot find|command not found|is not recognized|native binary not installed|postinstall did not run|optional dependency was not downloaded|missing optional dependency/i.test(output);
1405
1405
  }
1406
1406
  export function probeSpawnSpec(binary, isWin) {
1407
1407
  if (isWin)
@@ -1429,8 +1429,9 @@ export async function verifyBinaryLaunches(posixBinary, home) {
1429
1429
  catch (err) {
1430
1430
  const blob = `${err?.code ?? ''} ${err?.stdout ?? ''} ${err?.stderr ?? ''} ${err?.message ?? ''}`;
1431
1431
  if (err?.code === 'ENOENT' || isMissingBinarySignature(blob)) {
1432
- const detail = String(err?.stderr || err?.message || '')
1433
- .split('\n').map((s) => s.trim()).filter(Boolean)[0];
1432
+ const lines = String(err?.stderr || err?.message || '')
1433
+ .split('\n').map((s) => s.trim()).filter(Boolean);
1434
+ const detail = lines.find((line) => isMissingBinarySignature(line)) ?? lines[0];
1434
1435
  return { ok: false, detail: detail || 'native binary missing (ENOENT)' };
1435
1436
  }
1436
1437
  return { ok: true };
@@ -2,6 +2,7 @@ export declare function toHomeRelative(abs: string): string;
2
2
  export declare function expandLocalHome(p: string): string;
3
3
  export declare function toRemotePortable(p: string): string;
4
4
  export declare function homeRemainder(p: string): string | null;
5
+ export declare function localizeHome(p: string, home?: string): string;
5
6
  export declare function localProjectFolder(cwd: string | undefined, home?: string): string | undefined;
6
7
  export declare function deriveMirroredCwd(localCwd: string): string | undefined;
7
8
  export declare function remoteCdPrefix(remoteCwd?: string, opts?: {