@phnx-labs/agents-cli 1.23.27 → 1.23.29

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 (165) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +33 -82
  3. package/dist/bootstrap.js +0 -17
  4. package/dist/cli/command-registry.js +0 -2
  5. package/dist/commands/cloud.js +0 -58
  6. package/dist/commands/config.js +0 -4
  7. package/dist/commands/daemon-index.js +1 -1
  8. package/dist/commands/daemon.js +14 -63
  9. package/dist/commands/doctor.js +0 -12
  10. package/dist/commands/events.js +1 -1
  11. package/dist/commands/feed.d.ts +1 -3
  12. package/dist/commands/feed.js +1 -6
  13. package/dist/commands/fleet-capture.js +2 -4
  14. package/dist/commands/focus.d.ts +0 -1
  15. package/dist/commands/focus.js +2 -4
  16. package/dist/commands/inspect.d.ts +1 -19
  17. package/dist/commands/inspect.js +8 -474
  18. package/dist/commands/mine.js +1 -1
  19. package/dist/commands/prune.js +2 -64
  20. package/dist/commands/ps-roster.d.ts +0 -4
  21. package/dist/commands/ps-roster.js +2 -30
  22. package/dist/commands/ps.js +1 -4
  23. package/dist/commands/repo.d.ts +1 -1
  24. package/dist/commands/repo.js +4 -4
  25. package/dist/commands/sessions-browser.d.ts +0 -2
  26. package/dist/commands/sessions-browser.js +2 -32
  27. package/dist/commands/sessions-optimize.js +3 -4
  28. package/dist/commands/setup-mine.js +0 -1
  29. package/dist/commands/ssh.js +8 -9
  30. package/dist/commands/sync.js +1 -1
  31. package/dist/commands/update.js +2 -2
  32. package/dist/commands/watchdog.js +3 -4
  33. package/dist/lib/accounting/rotate.d.ts +0 -2
  34. package/dist/lib/accounting/rotate.js +1 -4
  35. package/dist/lib/agent-spec/agents.d.ts +0 -1
  36. package/dist/lib/agent-spec/agents.js +0 -8
  37. package/dist/lib/auth-health.d.ts +0 -1
  38. package/dist/lib/auth-health.js +0 -3
  39. package/dist/lib/cli-entry.d.ts +0 -1
  40. package/dist/lib/cli-entry.js +0 -36
  41. package/dist/lib/cloud/types.d.ts +0 -2
  42. package/dist/lib/config-keys.d.ts +1 -1
  43. package/dist/lib/config-keys.js +1 -4
  44. package/dist/lib/daemon/daemon.d.ts +0 -4
  45. package/dist/lib/daemon/daemon.js +6 -202
  46. package/dist/lib/daemon/heartbeat-service.d.ts +1 -1
  47. package/dist/lib/daemon/heartbeat-service.js +1 -8
  48. package/dist/lib/daemon-services.d.ts +1 -1
  49. package/dist/lib/daemon-services.js +1 -11
  50. package/dist/lib/device-config.d.ts +0 -2
  51. package/dist/lib/device-config.js +4 -22
  52. package/dist/lib/devices/config-migration.js +1 -3
  53. package/dist/lib/exec.d.ts +2 -5
  54. package/dist/lib/exec.js +18 -18
  55. package/dist/lib/factory/snapshot.d.ts +0 -5
  56. package/dist/lib/factory/snapshot.js +1 -28
  57. package/dist/lib/feed/events.d.ts +1 -11
  58. package/dist/lib/feed/events.js +0 -20
  59. package/dist/lib/feed/feed.d.ts +0 -2
  60. package/dist/lib/feed-outcome.d.ts +0 -2
  61. package/dist/lib/feed-outcome.js +0 -5
  62. package/dist/lib/fleet/capture.d.ts +0 -1
  63. package/dist/lib/fleet/capture.js +0 -3
  64. package/dist/lib/fleet/manifest.js +0 -6
  65. package/dist/lib/fleet/types.d.ts +0 -1
  66. package/dist/lib/harness/adapter.d.ts +0 -7
  67. package/dist/lib/harness/adapters/claude.js +0 -18
  68. package/dist/lib/harness/adapters/codex.js +0 -10
  69. package/dist/lib/harness/adapters/cursor.js +0 -11
  70. package/dist/lib/harness/adapters/kimi.js +0 -3
  71. package/dist/lib/harness/adapters/muse.js +0 -11
  72. package/dist/lib/harness/index.d.ts +1 -1
  73. package/dist/lib/harness/index.js +0 -2
  74. package/dist/lib/hosts/passthrough.js +2 -10
  75. package/dist/lib/hosts/ready.d.ts +0 -4
  76. package/dist/lib/hosts/ready.js +0 -9
  77. package/dist/lib/hosts/reconcile.d.ts +0 -1
  78. package/dist/lib/hosts/reconcile.js +0 -8
  79. package/dist/lib/installations/migrate.d.ts +0 -2
  80. package/dist/lib/installations/migrate.js +0 -145
  81. package/dist/lib/loop.js +1 -2
  82. package/dist/lib/menubar/snapshot.d.ts +0 -1
  83. package/dist/lib/menubar/snapshot.js +1 -4
  84. package/dist/lib/placement.d.ts +1 -2
  85. package/dist/lib/placement.js +4 -24
  86. package/dist/lib/profiles.d.ts +0 -1
  87. package/dist/lib/profiles.js +0 -6
  88. package/dist/lib/projects.js +15 -17
  89. package/dist/lib/session/active.d.ts +1 -3
  90. package/dist/lib/session/active.js +0 -4
  91. package/dist/lib/session/db.d.ts +0 -1
  92. package/dist/lib/session/db.js +4 -8
  93. package/dist/lib/session/discover.d.ts +0 -1
  94. package/dist/lib/session/discover.js +3 -128
  95. package/dist/lib/session/live-metadata.js +0 -2
  96. package/dist/lib/session/presentation.d.ts +0 -1
  97. package/dist/lib/session/presentation.js +3 -8
  98. package/dist/lib/session/selection.d.ts +0 -2
  99. package/dist/lib/session/selection.js +2 -12
  100. package/dist/lib/staleness/detectors/commands.d.ts +1 -1
  101. package/dist/lib/staleness/detectors/hooks.d.ts +1 -1
  102. package/dist/lib/staleness/detectors/mcp.d.ts +1 -1
  103. package/dist/lib/staleness/detectors/permissions.d.ts +1 -1
  104. package/dist/lib/staleness/detectors/plugins.d.ts +1 -1
  105. package/dist/lib/staleness/detectors/rules.d.ts +1 -1
  106. package/dist/lib/staleness/detectors/skills.d.ts +1 -1
  107. package/dist/lib/staleness/detectors/subagents.d.ts +1 -1
  108. package/dist/lib/staleness/detectors/workflows.d.ts +1 -1
  109. package/dist/lib/staleness/writers/commands.d.ts +1 -1
  110. package/dist/lib/staleness/writers/hooks.d.ts +1 -1
  111. package/dist/lib/staleness/writers/mcp.d.ts +1 -1
  112. package/dist/lib/staleness/writers/permissions.d.ts +1 -1
  113. package/dist/lib/staleness/writers/plugins.d.ts +1 -1
  114. package/dist/lib/staleness/writers/rules.d.ts +1 -1
  115. package/dist/lib/staleness/writers/skills.d.ts +1 -1
  116. package/dist/lib/staleness/writers/subagents.d.ts +1 -1
  117. package/dist/lib/staleness/writers/workflows.d.ts +1 -1
  118. package/dist/lib/startup/command-registry.js +5 -2
  119. package/dist/lib/state.d.ts +0 -3
  120. package/dist/lib/state.js +2 -25
  121. package/dist/lib/types.d.ts +0 -1
  122. package/dist/lib/watchdog/runner.d.ts +0 -2
  123. package/dist/lib/watchdog/runner.js +0 -2
  124. package/package.json +1 -1
  125. package/scripts/postinstall.js +2 -2
  126. package/dist/commands/routines.d.ts +0 -14
  127. package/dist/commands/routines.js +0 -2149
  128. package/dist/commands/routines.test-fixture.d.ts +0 -52
  129. package/dist/commands/routines.test-fixture.js +0 -254
  130. package/dist/lib/catchup.d.ts +0 -19
  131. package/dist/lib/catchup.js +0 -83
  132. package/dist/lib/daemon/catchup-service.d.ts +0 -18
  133. package/dist/lib/daemon/catchup-service.js +0 -21
  134. package/dist/lib/daemon/runner.d.ts +0 -91
  135. package/dist/lib/daemon/runner.js +0 -1927
  136. package/dist/lib/harness/adapters/droid.d.ts +0 -2
  137. package/dist/lib/harness/adapters/droid.js +0 -14
  138. package/dist/lib/overdue.d.ts +0 -9
  139. package/dist/lib/overdue.js +0 -74
  140. package/dist/lib/routine-activation.d.ts +0 -13
  141. package/dist/lib/routine-activation.js +0 -117
  142. package/dist/lib/routine-context.d.ts +0 -59
  143. package/dist/lib/routine-context.js +0 -181
  144. package/dist/lib/routine-notify-owner.d.ts +0 -4
  145. package/dist/lib/routine-notify-owner.js +0 -49
  146. package/dist/lib/routine-notify.d.ts +0 -17
  147. package/dist/lib/routine-notify.js +0 -138
  148. package/dist/lib/routine-process-cleanup.d.ts +0 -9
  149. package/dist/lib/routine-process-cleanup.js +0 -81
  150. package/dist/lib/routine-readiness.d.ts +0 -31
  151. package/dist/lib/routine-readiness.js +0 -256
  152. package/dist/lib/routines-format.d.ts +0 -7
  153. package/dist/lib/routines-format.js +0 -127
  154. package/dist/lib/routines-placement.d.ts +0 -16
  155. package/dist/lib/routines-placement.js +0 -60
  156. package/dist/lib/routines-project.d.ts +0 -49
  157. package/dist/lib/routines-project.js +0 -306
  158. package/dist/lib/sandbox.d.ts +0 -15
  159. package/dist/lib/sandbox.js +0 -309
  160. package/dist/lib/scheduler.d.ts +0 -23
  161. package/dist/lib/scheduler.js +0 -106
  162. package/dist/lib/scheduling/routines.d.ts +0 -264
  163. package/dist/lib/scheduling/routines.js +0 -1292
  164. package/dist/lib/triggers/webhook.d.ts +0 -26
  165. package/dist/lib/triggers/webhook.js +0 -181
@@ -10,10 +10,7 @@ import { AGENTS, agentConfigDirName, findInPath } from '../agents.js';
10
10
  import { createLink } from '../platform/index.js';
11
11
  import { foldLegacySystemRepo, copyDirSkipExisting } from '../migrate-fold.js';
12
12
  export { foldLegacySystemRepo } from '../migrate-fold.js';
13
- import { migrateLegacyRoutineActivation, listJobs, validateJob } from '../scheduling/routines.js';
14
13
  import { setConfigValue } from '../device-config.js';
15
- import { enabledRoutineNames, replaceEnabledRoutines } from '../routine-activation.js';
16
- import { evaluateActivationReadiness } from '../routine-readiness.js';
17
14
  import { migrateDeviceConfigStores } from '../devices/config-migration.js';
18
15
  import { detrackViaGitExclude } from '../project-resources.js';
19
16
  import { META_HEADER as DEVICE_META_HEADER, commitCentralConfig } from '../state.js';
@@ -157,17 +154,6 @@ function migrateSystemVersionsToUser() {
157
154
  console.error(`Skipped ${skippedCount} version dir${skippedCount === 1 ? '' : 's'} already present in ~/.agents/versions/ (kept legacy copy at ~/.agents-system/versions/)`);
158
155
  }
159
156
  }
160
- function migrateRunsIntoRoutines() {
161
- const src = path.join(USER_DIR, 'runs');
162
- const dest = path.join(USER_DIR, 'routines', 'runs');
163
- if (!fs.existsSync(src) || fs.existsSync(dest))
164
- return;
165
- try {
166
- fs.mkdirSync(path.dirname(dest), { recursive: true, mode: 0o700 });
167
- fs.renameSync(src, dest);
168
- }
169
- catch { }
170
- }
171
157
  function migrateTrashToHidden() {
172
158
  const src = path.join(USER_DIR, 'trash');
173
159
  const dest = path.join(USER_DIR, '.trash');
@@ -379,16 +365,6 @@ function cleanupUserConfigJson() {
379
365
  }
380
366
  catch { }
381
367
  }
382
- function cleanupEmptyTopLevelRuns() {
383
- const dir = path.join(USER_DIR, 'runs');
384
- if (!fs.existsSync(dir))
385
- return;
386
- try {
387
- if (fs.readdirSync(dir).length === 0)
388
- fs.rmdirSync(dir);
389
- }
390
- catch { }
391
- }
392
368
  function migrateAliasesToUser() {
393
369
  const src = path.join(SYSTEM_DIR, 'aliases.json');
394
370
  const dest = path.join(USER_DIR, 'aliases.json');
@@ -685,7 +661,6 @@ function migrateRuntimeToHistory() {
685
661
  moveDirOnce(path.join(USER_DIR, '.trash'), path.join(HISTORY_DIR, 'trash'));
686
662
  moveDirOnce(path.join(USER_DIR, 'trash'), path.join(HISTORY_DIR, 'trash'));
687
663
  moveDirOnce(path.join(USER_DIR, '.backups'), path.join(HISTORY_DIR, 'backups'));
688
- moveDirOnce(path.join(USER_DIR, 'routines', 'runs'), path.join(HISTORY_DIR, 'runs'));
689
664
  moveDirOnce(path.join(USER_DIR, 'teams', 'agents'), path.join(HISTORY_DIR, 'teams', 'agents'));
690
665
  rmEmptyDirTree(path.join(USER_DIR, 'versions'));
691
666
  rmEmptyDirTree(path.join(USER_DIR, 'sessions'));
@@ -1464,120 +1439,6 @@ export function migrateExtrasExtrasToAgentsExtras(historyDir = HISTORY_DIR) {
1464
1439
  console.error(`Renamed extras-extras → agents-extras (dirs: ${renamedDirs}, known_marketplaces: ${rewroteKnown}, settings: ${rewroteSettings})`);
1465
1440
  }
1466
1441
  }
1467
- export function migrateRoutineDeviceToDevices(routinesDir) {
1468
- const dir = routinesDir ?? path.join(USER_DIR, 'routines');
1469
- if (!fs.existsSync(dir))
1470
- return;
1471
- const files = fs.readdirSync(dir).filter((f) => f.endsWith('.yml') || f.endsWith('.yaml'));
1472
- let migrated = 0;
1473
- for (const file of files) {
1474
- const filePath = path.join(dir, file);
1475
- const raw = fs.readFileSync(filePath, 'utf-8');
1476
- let doc;
1477
- try {
1478
- doc = yaml.parse(raw);
1479
- if (!doc || typeof doc !== 'object')
1480
- continue;
1481
- }
1482
- catch {
1483
- continue;
1484
- }
1485
- if (!('device' in doc))
1486
- continue;
1487
- if ('devices' in doc) {
1488
- delete doc.device;
1489
- atomicWriteFileSync(filePath, yaml.stringify(doc));
1490
- continue;
1491
- }
1492
- const val = doc.device;
1493
- if (typeof val !== 'string' || !val.trim()) {
1494
- throw new Error(`${file}: legacy 'device' field is not a valid device name — repair the file and retry`);
1495
- }
1496
- delete doc.device;
1497
- doc.devices = [val.trim()];
1498
- atomicWriteFileSync(filePath, yaml.stringify(doc));
1499
- migrated++;
1500
- }
1501
- if (migrated > 0) {
1502
- console.error(`Migrated ${migrated} routine${migrated === 1 ? '' : 's'}: device → devices`);
1503
- }
1504
- }
1505
- export function migrateRoutineRemoteCwdToCwd(routinesDir) {
1506
- const dir = routinesDir ?? path.join(USER_DIR, 'routines');
1507
- if (!fs.existsSync(dir))
1508
- return;
1509
- const files = fs.readdirSync(dir).filter((f) => f.endsWith('.yml') || f.endsWith('.yaml'));
1510
- let migrated = 0;
1511
- let conflicts = 0;
1512
- for (const file of files) {
1513
- const filePath = path.join(dir, file);
1514
- const raw = fs.readFileSync(filePath, 'utf-8');
1515
- let doc;
1516
- try {
1517
- doc = yaml.parse(raw);
1518
- if (!doc || typeof doc !== 'object')
1519
- continue;
1520
- }
1521
- catch {
1522
- continue;
1523
- }
1524
- if (!('remoteCwd' in doc))
1525
- continue;
1526
- const remote = doc.remoteCwd;
1527
- if (typeof remote !== 'string' || !remote.trim()) {
1528
- delete doc.remoteCwd;
1529
- atomicWriteFileSync(filePath, yaml.stringify(doc));
1530
- continue;
1531
- }
1532
- if ('cwd' in doc) {
1533
- if (doc.cwd === remote) {
1534
- delete doc.remoteCwd;
1535
- atomicWriteFileSync(filePath, yaml.stringify(doc));
1536
- migrated++;
1537
- }
1538
- else {
1539
- conflicts++;
1540
- }
1541
- continue;
1542
- }
1543
- delete doc.remoteCwd;
1544
- doc.cwd = remote;
1545
- atomicWriteFileSync(filePath, yaml.stringify(doc));
1546
- migrated++;
1547
- }
1548
- if (migrated > 0) {
1549
- console.error(`Migrated ${migrated} routine${migrated === 1 ? '' : 's'}: remoteCwd → cwd`);
1550
- }
1551
- if (conflicts > 0) {
1552
- console.error(`${conflicts} routine${conflicts === 1 ? '' : 's'} have conflicting remoteCwd/cwd — left paused for manual repair (migration_conflict)`);
1553
- }
1554
- }
1555
- function pauseUnreadyEnabledRoutines() {
1556
- const enabled = enabledRoutineNames();
1557
- if (enabled === null)
1558
- return;
1559
- const enabledSet = new Set(enabled);
1560
- const paused = [];
1561
- for (const job of listJobs()) {
1562
- if (!enabledSet.has(job.name))
1563
- continue;
1564
- let ready = true;
1565
- try {
1566
- ready = validateJob(job).length === 0 && evaluateActivationReadiness(job).ready;
1567
- }
1568
- catch {
1569
- ready = true;
1570
- }
1571
- if (!ready)
1572
- paused.push(job.name);
1573
- }
1574
- if (paused.length === 0)
1575
- return;
1576
- const pausedSet = new Set(paused);
1577
- replaceEnabledRoutines(enabled.filter((name) => !pausedSet.has(name)));
1578
- console.error(`Paused ${paused.length} routine${paused.length === 1 ? '' : 's'} with an unresolved execution context ` +
1579
- `(run 'agents routines doctor --all' to see why): ${paused.join(', ')}`);
1580
- }
1581
1442
  export function migrateWatchdogSentinelToConfig(sentinelPath = path.join(CACHE_DIR, 'state', 'watchdog', 'enabled'), enable = (value) => setConfigValue('watchdog.enabled', value)) {
1582
1443
  if (!fs.existsSync(sentinelPath))
1583
1444
  return;
@@ -1875,7 +1736,6 @@ export async function runMigration() {
1875
1736
  mergeOverlappingVersionHomes();
1876
1737
  seedActiveCursorLoginPerVersion();
1877
1738
  migrateKimiSubagentsToMarkdown();
1878
- migrateRunsIntoRoutines();
1879
1739
  migrateTrashToHidden();
1880
1740
  migrateBackupsToHidden();
1881
1741
  migrateAliasesToUser();
@@ -1885,7 +1745,6 @@ export async function runMigration() {
1885
1745
  deleteTeamsConfigJson();
1886
1746
  moveTeamsRegistryToHistory();
1887
1747
  cleanupUserConfigJson();
1888
- cleanupEmptyTopLevelRuns();
1889
1748
  foldUserHooksYamlIntoAgentsYaml();
1890
1749
  foldBrowserProfilesIntoAgentsYaml();
1891
1750
  migrateVersionResourcesToPatterns();
@@ -1907,13 +1766,9 @@ export async function runMigration() {
1907
1766
  dropDeadSystemArtifacts();
1908
1767
  warnSystemOrphans();
1909
1768
  migrateExtrasExtrasToAgentsExtras();
1910
- migrateRoutineDeviceToDevices();
1911
- migrateRoutineRemoteCwdToCwd();
1912
- migrateLegacyRoutineActivation();
1913
1769
  migrateWatchdogSentinelToConfig();
1914
1770
  migrateMenubarSentinelToConfig();
1915
1771
  removeHomeCompiledProjectRules();
1916
- pauseUnreadyEnabledRoutines();
1917
1772
  repairAgentConfigSymlinks();
1918
1773
  repairSelfReferentialBinShims();
1919
1774
  try {
package/dist/lib/loop.js CHANGED
@@ -2,9 +2,8 @@ import { spawn } from 'child_process';
2
2
  import { randomUUID } from 'crypto';
3
3
  import * as fs from 'fs';
4
4
  import * as path from 'path';
5
- import { buildExecCommand, buildExecEnv } from './exec.js';
5
+ import { buildExecCommand, buildExecEnv, parseTimeout } from './exec.js';
6
6
  import { extractUsageEvents } from './budget/enforce.js';
7
- import { parseTimeout } from './scheduling/routines.js';
8
7
  import { writeCheckpoint } from './checkpoint.js';
9
8
  import { mailboxDir } from './mailbox.js';
10
9
  import { composeWin32CommandLine } from './platform/index.js';
@@ -41,7 +41,6 @@ interface MenubarSnapshot {
41
41
  capturedAt: string;
42
42
  cliVersion: string;
43
43
  menubarUpdate: MenubarUpdateResult;
44
- routines: Record<string, unknown>[];
45
44
  recentSessions: Record<string, unknown>[];
46
45
  activeSessions: Record<string, unknown>[];
47
46
  devices: MenubarDevice[];
@@ -4,7 +4,6 @@ import * as path from 'path';
4
4
  import { httpsUrl } from '../actor.js';
5
5
  import { cachedViewer, emailDigest } from '../github/viewer.js';
6
6
  import { readSession } from '../identity/client.js';
7
- import { buildRoutineListJson } from '../scheduling/routines.js';
8
7
  import { backfillActiveRowsFromIndex, isRunningLiveSession, serializeActiveSessionsForJson, serializeSessionsJson } from '../session/active.js';
9
8
  import { getConfigValue, listConfiguredDeviceRoles, loadAutoLaunchPreferences } from '../device-config.js';
10
9
  import { filterAutoPool } from '../devices/pool.js';
@@ -119,8 +118,7 @@ export function readLastWatchdogTick(stateDir = path.join(getRuntimeStateDir(),
119
118
  export async function computeMenubarSnapshot() {
120
119
  migrateMenubarPreferencesFromUserDefaults();
121
120
  const viewerRead = cachedViewer();
122
- const [routines, recent, devices, viewer] = await Promise.all([
123
- Promise.resolve(buildRoutineListJson()),
121
+ const [recent, devices, viewer] = await Promise.all([
124
122
  Promise.resolve(querySessions({ limit: 40, skipExistenceCheck: true })),
125
123
  buildMenubarDevices(),
126
124
  viewerRead,
@@ -138,7 +136,6 @@ export async function computeMenubarSnapshot() {
138
136
  capturedAt: new Date().toISOString(),
139
137
  cliVersion: getCliVersion(),
140
138
  menubarUpdate: getMenubarUpdateStatus(),
141
- routines,
142
139
  recentSessions: JSON.parse(serializeSessionsJson(recent)),
143
140
  activeSessions: serializeActiveSessionsForJson(activeSessions),
144
141
  devices,
@@ -1,4 +1,4 @@
1
- type PlacementKind = 'local' | 'device' | 'fleet' | 'cloud' | 'lease';
1
+ type PlacementKind = 'local' | 'device' | 'cloud' | 'lease';
2
2
  export interface Placement {
3
3
  kind: PlacementKind;
4
4
  target?: string;
@@ -23,6 +23,5 @@ export declare function parseWhereSpec(raw: string, source?: string): Placement;
23
23
  export declare function hostFamilyTarget(flags: RunPlacementFlags): string | undefined;
24
24
  export declare function placementFromRunFlags(flags: RunPlacementFlags): Placement;
25
25
  export declare function expandPlacementToRunFlags(placement: Placement): Pick<RunPlacementFlags, 'host' | 'device' | 'lease' | 'box' | 'cloud' | 'provider'>;
26
- export declare function placementFromHostStrategy(strategy: 'local' | 'host' | 'fleet' | 'cloud', host?: string): Placement;
27
26
  export declare function formatPlacement(p: Placement): string;
28
27
  export {};
@@ -4,19 +4,17 @@ export class PlacementError extends Error {
4
4
  this.name = 'PlacementError';
5
5
  }
6
6
  }
7
- const KINDS = new Set(['local', 'device', 'fleet', 'cloud', 'lease', 'host']);
7
+ const KINDS = new Set(['local', 'device', 'cloud', 'lease', 'host']);
8
8
  export function parseWhereSpec(raw, source = '--where') {
9
9
  const spec = raw.trim();
10
10
  if (!spec) {
11
- throw new PlacementError(`${source} requires a value (local | device:<name> | auto | lease | cloud | fleet)`);
11
+ throw new PlacementError(`${source} requires a value (local | device:<name> | auto | lease | cloud)`);
12
12
  }
13
13
  const lower = spec.toLowerCase();
14
14
  if (lower === 'local')
15
15
  return { kind: 'local', source };
16
16
  if (lower === 'auto')
17
17
  return { kind: 'device', target: 'auto', source };
18
- if (lower === 'fleet')
19
- return { kind: 'fleet', source };
20
18
  if (lower === 'cloud')
21
19
  return { kind: 'cloud', source };
22
20
  if (lower === 'lease')
@@ -24,7 +22,7 @@ export function parseWhereSpec(raw, source = '--where') {
24
22
  const colon = spec.indexOf(':');
25
23
  if (colon === -1) {
26
24
  if (KINDS.has(lower)) {
27
- throw new PlacementError(`${source} ${spec}: name a target (device:<name>, device:auto) or use local|lease|cloud|fleet`);
25
+ throw new PlacementError(`${source} ${spec}: name a target (device:<name>, device:auto) or use local|lease|cloud`);
28
26
  }
29
27
  return { kind: 'device', target: spec, source };
30
28
  }
@@ -42,10 +40,7 @@ export function parseWhereSpec(raw, source = '--where') {
42
40
  if (head === 'cloud') {
43
41
  return { kind: 'cloud', target: tail, source };
44
42
  }
45
- if (head === 'fleet') {
46
- return { kind: 'fleet', target: tail, source };
47
- }
48
- throw new PlacementError(`${source} ${spec}: unknown kind '${head}' (use local | device:<name> | auto | lease[:backend] | cloud | fleet)`);
43
+ throw new PlacementError(`${source} ${spec}: unknown kind '${head}' (use local | device:<name> | auto | lease[:backend] | cloud)`);
49
44
  }
50
45
  export function hostFamilyTarget(flags) {
51
46
  for (const v of [flags.host, flags.device, flags.on, flags.computer]) {
@@ -109,21 +104,6 @@ export function expandPlacementToRunFlags(placement) {
109
104
  return placement.target ? { lease: placement.target } : { lease: true };
110
105
  case 'cloud':
111
106
  return placement.target ? { cloud: true, provider: placement.target } : { cloud: true };
112
- case 'fleet':
113
- throw new PlacementError(`fleet placement is for routines (agents routines add … --placement fleet), not agents run. ` +
114
- `Use --where device:auto for an affinity pick, or --where device:<name>.`);
115
- }
116
- }
117
- export function placementFromHostStrategy(strategy, host) {
118
- switch (strategy) {
119
- case 'local':
120
- return { kind: 'local', source: 'hostStrategy:local' };
121
- case 'host':
122
- return { kind: 'device', target: host, source: 'hostStrategy:host' };
123
- case 'fleet':
124
- return { kind: 'fleet', source: 'hostStrategy:fleet' };
125
- case 'cloud':
126
- return { kind: 'cloud', source: 'hostStrategy:cloud' };
127
107
  }
128
108
  }
129
109
  export function formatPlacement(p) {
@@ -38,7 +38,6 @@ export interface ProfileSummary {
38
38
  export declare function getProfilePath(name: string): string;
39
39
  export declare function validateProfileName(name: string): void;
40
40
  export declare function profileExists(name: string): boolean;
41
- export declare function isCustomHarnessName(name: string): boolean;
42
41
  export declare function readProfile(name: string): Profile;
43
42
  export declare function writeProfile(profile: Profile): void;
44
43
  export declare function deleteProfile(name: string): boolean;
@@ -2,7 +2,6 @@ import * as fs from 'fs';
2
2
  import * as path from 'path';
3
3
  import * as crypto from 'node:crypto';
4
4
  import * as yaml from 'yaml';
5
- import { ALL_AGENT_IDS } from './agents.js';
6
5
  import { getUserAgentsDir } from './state.js';
7
6
  import { deleteKeychainTokenSync, getKeychainTokenSync, hasKeychainTokenSync, isSecretsClientError, isSecretsTransportError, profileKeychainItem, } from './secrets-client.js';
8
7
  import { MODEL_TIERS, isTierToken } from './model-tiers.js';
@@ -28,11 +27,6 @@ export function validateProfileName(name) {
28
27
  export function profileExists(name) {
29
28
  return fs.existsSync(profilePath(name));
30
29
  }
31
- export function isCustomHarnessName(name) {
32
- if (!PROFILE_NAME_PATTERN.test(name))
33
- return false;
34
- return !ALL_AGENT_IDS.includes(name) && profileExists(name);
35
- }
36
30
  export function readProfile(name) {
37
31
  validateProfileName(name);
38
32
  const file = profilePath(name);
@@ -327,25 +327,23 @@ export function projectNameForCwd(cwd, defs) {
327
327
  if (!cwd)
328
328
  return undefined;
329
329
  const abs = path.resolve(localizeHome(expandLocalHome(cwd)));
330
- let best;
331
- let bestLen = -1;
332
- let weakBest;
333
- let weakLen = -1;
334
- for (const { name, abs: root, weak } of projectRootsAbs(defs)) {
335
- if (!isUnder(abs, root))
336
- continue;
337
- if (weak) {
338
- if (root.length > weakLen) {
339
- weakBest = name;
340
- weakLen = root.length;
330
+ const deepest = (weak) => {
331
+ let name;
332
+ let len = -1;
333
+ for (const r of projectRootsAbs(defs)) {
334
+ if (!!r.weak !== weak || !isUnder(abs, r.abs))
335
+ continue;
336
+ if (r.abs.length > len) {
337
+ name = r.name;
338
+ len = r.abs.length;
341
339
  }
340
+ else if (r.abs.length === len && r.name !== name)
341
+ name = undefined;
342
342
  }
343
- else if (root.length > bestLen) {
344
- best = name;
345
- bestLen = root.length;
346
- }
347
- }
348
- return best ?? weakBest;
343
+ return { name, len };
344
+ };
345
+ const strong = deepest(false);
346
+ return strong.len >= 0 ? strong.name : deepest(true).name;
349
347
  }
350
348
  let projectDefsMemo = null;
351
349
  function projectDefsStamp() {
@@ -20,7 +20,7 @@ export declare function unattributedFullRescanCountForTest(): number;
20
20
  export declare function attributedSetLostPids(prev: Set<number>, next: Set<number>): boolean;
21
21
  export declare function filterCachedUnattributed(sessions: ActiveSession[], attributed: Set<number>, alive: (pid: number, processStartedAtMs?: number) => boolean, ppidMap?: Map<number, number>): ActiveSession[];
22
22
  export type ActiveContext = 'terminal' | 'teams' | 'cloud' | 'headless';
23
- type BackfillMeta = Pick<SessionMeta, 'version' | 'account' | 'accountId' | 'accountKey' | 'timestamp' | 'label' | 'firstUserMessage' | 'lastUserMessage' | 'generatedTitle' | 'ticketId' | 'prUrl' | 'prNumber' | 'origin' | 'routineName' | 'harness' | 'tokenCount' | 'durationMs' | 'subAgentCount' | 'lastActivity'>;
23
+ type BackfillMeta = Pick<SessionMeta, 'version' | 'account' | 'accountId' | 'accountKey' | 'timestamp' | 'label' | 'firstUserMessage' | 'lastUserMessage' | 'generatedTitle' | 'ticketId' | 'prUrl' | 'prNumber' | 'harness' | 'tokenCount' | 'durationMs' | 'subAgentCount' | 'lastActivity'>;
24
24
  export declare function backfillActiveRowsFromMeta(sessions: ActiveSession[], metaById: Map<string, BackfillMeta>): void;
25
25
  export declare function applySessionNames(sessions: ActiveSession[]): void;
26
26
  export declare function sessionAccountLabel(kind: string, session: Pick<SessionMeta, 'accountId' | 'accountKey' | 'account'>, accounts?: import("../account-registry.js").NativeAccount[]): string | undefined;
@@ -127,8 +127,6 @@ export interface ActiveSession {
127
127
  quietSinceMs?: number;
128
128
  status: ActiveStatus;
129
129
  phase?: SessionPhase;
130
- origin?: 'cli' | 'routine';
131
- routineName?: string;
132
130
  presence?: Presence;
133
131
  hostLink?: HostLink;
134
132
  pidAlive?: boolean;
@@ -114,10 +114,6 @@ export function backfillActiveRowsFromMeta(sessions, metaById) {
114
114
  if (!Number.isNaN(ts))
115
115
  s.startedAtMs = ts;
116
116
  }
117
- if (!s.origin && m.origin)
118
- s.origin = m.origin;
119
- if (!s.routineName && m.routineName)
120
- s.routineName = m.routineName;
121
117
  if (!s.harness && m.harness)
122
118
  s.harness = m.harness;
123
119
  if (s.tokenCount == null && m.tokenCount != null)
@@ -16,7 +16,6 @@ export interface ScanStamp {
16
16
  export interface QueryOptions {
17
17
  agent?: SessionAgentId;
18
18
  agents?: SessionAgentId[];
19
- origin?: 'cli' | 'routine';
20
19
  version?: string;
21
20
  cwd?: string;
22
21
  cwdPrefix?: string;
@@ -2222,10 +2222,6 @@ function buildSessionWhere(options) {
2222
2222
  where.push('version = ?');
2223
2223
  params.push(options.version);
2224
2224
  }
2225
- if (options.origin) {
2226
- where.push("IFNULL(origin, 'cli') = ?");
2227
- params.push(options.origin);
2228
- }
2229
2225
  if (options.cwd) {
2230
2226
  where.push('cwd = ?');
2231
2227
  params.push(options.cwd);
@@ -2243,12 +2239,12 @@ function buildSessionWhere(options) {
2243
2239
  params.push(options.machine);
2244
2240
  }
2245
2241
  if (options.idExact) {
2246
- where.push('(id = ? COLLATE NOCASE OR short_id = ? COLLATE NOCASE OR routine_run_id = ? COLLATE NOCASE)');
2247
- params.push(options.idExact, options.idExact, options.idExact);
2242
+ where.push('(id = ? COLLATE NOCASE OR short_id = ? COLLATE NOCASE)');
2243
+ params.push(options.idExact, options.idExact);
2248
2244
  }
2249
2245
  if (options.idPrefix) {
2250
- where.push('(id LIKE ? OR short_id LIKE ? OR routine_run_id LIKE ?)');
2251
- params.push(`${options.idPrefix}%`, `${options.idPrefix}%`, `${options.idPrefix}%`);
2246
+ where.push('(id LIKE ? OR short_id LIKE ?)');
2247
+ params.push(`${options.idPrefix}%`, `${options.idPrefix}%`);
2252
2248
  }
2253
2249
  if (typeof options.sinceMs === 'number') {
2254
2250
  where.push('timestamp >= ?');
@@ -18,7 +18,6 @@ interface DiscoverOptions {
18
18
  until?: string;
19
19
  excludeTeamOrigin?: boolean;
20
20
  onlyTeamOrigin?: boolean;
21
- origin?: 'cli' | 'routine';
22
21
  sortBy?: 'timestamp' | 'cost' | 'duration';
23
22
  skipExistenceCheck?: boolean;
24
23
  onProgress?: (progress: ScanProgress) => void;
@@ -131,8 +131,7 @@ export async function findLocalSessionTranscripts(selector, agent) {
131
131
  if (agent && agent !== harness)
132
132
  continue;
133
133
  const subdir = harness === 'claude' ? 'projects' : 'sessions';
134
- const roots = [...getAgentSessionDirs(harness, subdir), ...getRoutineArchiveSessionDirs(harness, subdir)];
135
- for (const root of roots) {
134
+ for (const root of getAgentSessionDirs(harness, subdir)) {
136
135
  for (const file of walkForFilesWithStat(root, '.jsonl', Number.MAX_SAFE_INTEGER)) {
137
136
  const name = path.basename(file.path, '.jsonl');
138
137
  const id = harness === 'claude' ? name : name.match(/([0-9a-f]{8}-[0-9a-f-]{27})$/i)?.[1];
@@ -201,7 +200,6 @@ export async function scanSessionsIncremental(options) {
201
200
  };
202
201
  try {
203
202
  await scanAgentsBounded(agents, agent => dispatchAgentScan(agent, track('dotfiles')));
204
- await scanAgentsBounded(agents, agent => scanRoutineArchivesIncremental(agent, track('routines')));
205
203
  seedLabelsFromNames(buildRunNameMap());
206
204
  }
207
205
  finally {
@@ -386,7 +384,6 @@ function buildQueryOptions(options, agents, opts) {
386
384
  limit: opts.includeLimit && !options?.unbounded ? (options?.limit ?? 50) : undefined,
387
385
  excludeTeamOrigin: options?.excludeTeamOrigin,
388
386
  onlyTeamOrigin: options?.onlyTeamOrigin,
389
- origin: options?.origin,
390
387
  sortBy: options?.sortBy,
391
388
  skipExistenceCheck: options?.skipExistenceCheck,
392
389
  skill: options?.skill,
@@ -428,13 +425,11 @@ export function looksLikeSessionId(query) {
428
425
  export function resolveSessionById(sessions, idQuery) {
429
426
  const query = idQuery.toLowerCase();
430
427
  const exact = sessions.filter(s => s.id.toLowerCase() === query ||
431
- s.shortId.toLowerCase() === query ||
432
- s.routineRunId?.toLowerCase() === query);
428
+ s.shortId.toLowerCase() === query);
433
429
  if (exact.length > 0)
434
430
  return exact;
435
431
  return sessions.filter(s => s.id.toLowerCase().startsWith(query) ||
436
- s.shortId.toLowerCase().startsWith(query) ||
437
- s.routineRunId?.toLowerCase().startsWith(query));
432
+ s.shortId.toLowerCase().startsWith(query));
438
433
  }
439
434
  export function searchContentIndex(sessions, query) {
440
435
  if (!query.trim())
@@ -625,131 +620,11 @@ export function getSessionRoots() {
625
620
  const out = [];
626
621
  for (const { agent, subdir } of SESSION_ROOT_SPECS) {
627
622
  const dirs = getAgentSessionDirs(agent, subdir);
628
- dirs.push(...getRoutineArchiveSessionDirs(agent, subdir));
629
623
  if (dirs.length > 0)
630
624
  out.push({ agent, dirs });
631
625
  }
632
626
  return out;
633
627
  }
634
- function getRoutineArchiveSessionDirs(agent, subdir) {
635
- const runsDir = getRunsDir();
636
- if (!fs.existsSync(runsDir))
637
- return [];
638
- const dirs = [];
639
- let jobDirs;
640
- try {
641
- jobDirs = fs.readdirSync(runsDir, { withFileTypes: true });
642
- }
643
- catch {
644
- return dirs;
645
- }
646
- for (const jobDir of jobDirs) {
647
- if (!jobDir.isDirectory())
648
- continue;
649
- const jobRunsDir = path.join(runsDir, jobDir.name);
650
- let runDirs;
651
- try {
652
- runDirs = fs.readdirSync(jobRunsDir, { withFileTypes: true });
653
- }
654
- catch {
655
- continue;
656
- }
657
- for (const runDir of runDirs) {
658
- if (!runDir.isDirectory())
659
- continue;
660
- const dir = path.join(jobRunsDir, runDir.name, 'sessions', agent, subdir);
661
- if (fs.existsSync(dir))
662
- dirs.push(dir);
663
- }
664
- }
665
- return dirs;
666
- }
667
- function routineArchiveInfo(filePath) {
668
- const rel = path.relative(getRunsDir(), filePath);
669
- if (rel.startsWith('..') || path.isAbsolute(rel))
670
- return null;
671
- const parts = rel.split(path.sep);
672
- if (parts.length < 6 || parts[2] !== 'sessions')
673
- return null;
674
- return { jobName: parts[0], runId: parts[1] };
675
- }
676
- function decorateRoutineSession(meta, info) {
677
- return {
678
- ...meta,
679
- origin: 'routine',
680
- routineName: info.jobName,
681
- routineRunId: info.runId,
682
- project: info.jobName,
683
- label: info.jobName,
684
- };
685
- }
686
- async function readRoutineArchiveMeta(agent, filePath) {
687
- const info = routineArchiveInfo(filePath);
688
- if (!info)
689
- return null;
690
- if (agent === 'claude') {
691
- const sessionId = path.basename(filePath).replace(/\.jsonl$/, '');
692
- const stat = safeStatSync(filePath);
693
- if (!stat)
694
- return null;
695
- const scanStamp = { fileMtimeMs: Math.floor(stat.mtimeMs), fileSize: stat.size };
696
- const result = await readClaudeMeta(filePath, sessionId, scanStamp, undefined);
697
- return result ? { ...result, meta: decorateRoutineSession(result.meta, info) } : null;
698
- }
699
- if (agent === 'codex') {
700
- const result = await readCodexMeta(filePath);
701
- return result ? { ...result, meta: decorateRoutineSession(result.meta, info) } : null;
702
- }
703
- if (agent === 'cursor') {
704
- const currentVersion = await getCurrentAgentVersion('cursor');
705
- const result = readCursorMeta(filePath, currentVersion);
706
- return result ? { ...result, meta: decorateRoutineSession(result.meta, info) } : null;
707
- }
708
- return null;
709
- }
710
- async function scanRoutineArchivesIncremental(agent, onProgress) {
711
- const subdir = sessionRootSubdir(agent);
712
- if (!subdir)
713
- return;
714
- const ext = '.jsonl';
715
- const prestat = [];
716
- for (const sessionsDir of getRoutineArchiveSessionDirs(agent, subdir)) {
717
- for (const f of walkForFilesWithStat(sessionsDir, ext, 100_000)) {
718
- prestat.push({ filePath: f.path, fileMtimeMs: f.mtimeMs, fileSize: f.size });
719
- }
720
- }
721
- const changed = filterChangedEntries(prestat);
722
- if (changed.length === 0)
723
- return;
724
- onProgress?.({ agent, parsed: 0, total: changed.length });
725
- const entries = [];
726
- const touched = [];
727
- let parsed = 0;
728
- for (const { filePath, scan } of changed) {
729
- try {
730
- const result = await readRoutineArchiveMeta(agent, filePath);
731
- if (result)
732
- entries.push({
733
- meta: result.meta,
734
- content: result.content,
735
- assistantContent: result.assistantContent,
736
- scan,
737
- events: result.events,
738
- toolCalls: result.toolCalls,
739
- toolIndexMode: result.toolIndexMode,
740
- });
741
- else
742
- touched.push({ filePath, scan });
743
- }
744
- catch {
745
- touched.push({ filePath, scan });
746
- }
747
- parsed++;
748
- onProgress?.({ agent, parsed, total: changed.length });
749
- }
750
- upsertSessionsBatch(entries);
751
- recordScans(touched);
752
- }
753
628
  let cachedClaudeAccountIndex;
754
629
  function claudeAccountIndex(refresh = false) {
755
630
  if (refresh || !cachedClaudeAccountIndex)
@@ -31,8 +31,6 @@ export function activeSessionToSessionMeta(active, self, nowMs) {
31
31
  prNumber: active.pr?.number,
32
32
  worktreeSlug: active.worktree?.slug,
33
33
  gitBranch: active.worktree?.branch,
34
- origin: active.origin,
35
- routineName: active.routineName,
36
34
  };
37
35
  }
38
36
  export function liveSessionMetas(active, self, nowMs) {