@phnx-labs/agents-cli 1.22.10 → 1.22.12

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 (43) hide show
  1. package/CHANGELOG.md +64 -0
  2. package/dist/bin/agents +0 -0
  3. package/dist/commands/beta.js +21 -9
  4. package/dist/commands/cli.js +12 -12
  5. package/dist/commands/events.d.ts +20 -1
  6. package/dist/commands/events.js +71 -55
  7. package/dist/commands/logs.js +14 -138
  8. package/dist/commands/projects.d.ts +1 -2
  9. package/dist/commands/projects.js +39 -47
  10. package/dist/commands/repo.d.ts +1 -1
  11. package/dist/commands/repo.js +3 -3
  12. package/dist/commands/view.d.ts +1 -1
  13. package/dist/commands/view.js +7 -7
  14. package/dist/index.js +1 -1
  15. package/dist/lib/beta.d.ts +1 -1
  16. package/dist/lib/beta.js +1 -1
  17. package/dist/lib/cli-resources.js +2 -2
  18. package/dist/lib/event-stream.d.ts +1 -1
  19. package/dist/lib/event-stream.js +1 -1
  20. package/dist/lib/events.d.ts +21 -12
  21. package/dist/lib/events.js +311 -64
  22. package/dist/lib/exec.js +1 -2
  23. package/dist/lib/feed-broadcast.d.ts +19 -5
  24. package/dist/lib/feed-broadcast.js +41 -8
  25. package/dist/lib/menubar/MenubarHelper.app/Contents/CodeResources +0 -0
  26. package/dist/lib/menubar/MenubarHelper.app/Contents/MacOS/MenubarHelper +0 -0
  27. package/dist/lib/migrate.d.ts +8 -0
  28. package/dist/lib/migrate.js +26 -1
  29. package/dist/lib/project-probe.d.ts +1 -1
  30. package/dist/lib/project-probe.js +1 -1
  31. package/dist/lib/projects.d.ts +1 -1
  32. package/dist/lib/resources.d.ts +1 -1
  33. package/dist/lib/runner.js +1 -2
  34. package/dist/lib/secrets/Agents CLI.app/Contents/CodeResources +0 -0
  35. package/dist/lib/secrets/Agents CLI.app/Contents/MacOS/Agents CLI +0 -0
  36. package/dist/lib/secrets/audit.js +1 -1
  37. package/dist/lib/startup/command-registry.js +1 -1
  38. package/dist/lib/state.d.ts +1 -1
  39. package/dist/lib/state.js +60 -2
  40. package/dist/lib/types.d.ts +1 -1
  41. package/dist/lib/watchdog/runner.d.ts +13 -0
  42. package/dist/lib/watchdog/runner.js +75 -6
  43. package/package.json +1 -1
@@ -1,8 +1,7 @@
1
1
  /**
2
2
  * `agents projects` — named, multi-repo projects and the progress
3
3
  * rollup. Definitions live in `~/.agents/projects/<name>.yaml` (see
4
- * `lib/projects.ts`); this registers the command tree over them. Beta-gated on
5
- * `isBetaEnabled('projects')`, mirroring `agents factory`.
4
+ * `lib/projects.ts`); this registers the command tree over them.
6
5
  *
7
6
  * The headline is `status`: instead of the vague per-agent activity line, it
8
7
  * rolls every session up by project (matched on cwd) into one card — agents by
@@ -12,7 +11,6 @@ import chalk from 'chalk';
12
11
  import * as fs from 'fs';
13
12
  import * as path from 'path';
14
13
  import { execFileSync, spawnSync } from 'child_process';
15
- import { betaEnableHint, isBetaEnabled } from '../lib/beta.js';
16
14
  import { setHelpSections } from '../lib/help.js';
17
15
  import { getMainRepoRoot } from '../lib/git.js';
18
16
  import { parseOwnerRepoFromRemote } from '../lib/registry.js';
@@ -437,25 +435,24 @@ warnWorkspaces = []) {
437
435
  console.log('');
438
436
  }
439
437
  export function registerProjectsCommands(program) {
440
- const enabled = isBetaEnabled('projects');
441
438
  const projects = program
442
- .command('projects', { hidden: !enabled })
439
+ .command('projects')
443
440
  .description('Named multi-repo projects with a progress rollup.');
444
441
  setHelpSections(projects, {
445
442
  examples: `
446
443
  agents projects import --from-linear # the projects you actually track
447
444
  agents projects add rush --repo phnx-labs/rush --path apps/web
448
445
  agents projects list
449
- agents projects status # progress card for every project
446
+ agents projects status # every project, across the whole fleet
450
447
  agents projects status rush # one project (same body as view/show)
451
448
  agents projects view rush # alias of status <name>
452
- agents projects status --fleet # + per-device workspace drift over SSH
449
+ agents projects status --device s0 # scope to one device (or --devices a,b,c)
453
450
  agents projects link rush --linear # bind the Linear project (auto-suggest)
454
451
  agents run --project rush # land an agent in the project
455
452
  `,
456
453
  notes: `
457
454
  Definitions are hand-editable YAML in ~/.agents/projects/ and sync across
458
- machines with 'agents push/pull'. Enable with: agents beta enable projects.
455
+ machines with 'agents push/pull'.
459
456
 
460
457
  'import --from-factory' reads Factory's auto-detected registry, which
461
458
  guesses from checkouts on disk — it imports only 'high' confidence rows by
@@ -463,18 +460,6 @@ export function registerProjectsCommands(program) {
463
460
  with 'agents projects rm <name>'.
464
461
  `,
465
462
  });
466
- projects.hook('preAction', (_thisCommand, actionCommand) => {
467
- if (enabled)
468
- return;
469
- // `probe` is the peer half of `status --fleet`: it must answer whenever the
470
- // binary carries it, even where the beta flag is off — a gated peer would
471
- // look unreachable to every fleet member on a newer CLI.
472
- if (actionCommand.name() === 'probe')
473
- return;
474
- console.error(chalk.red('agents projects is in beta.'));
475
- console.error(chalk.gray(betaEnableHint('projects')));
476
- process.exit(1);
477
- });
478
463
  // ---- list ----
479
464
  projects
480
465
  .command('list')
@@ -553,6 +538,15 @@ export function registerProjectsCommands(program) {
553
538
  console.log(chalk.gray(` ${target}`));
554
539
  console.log(chalk.gray(` root ${def.root}${def.repo ? ` · repo ${def.repo}` : ''}`));
555
540
  });
541
+ /** Merge `--device a b` (variadic) and `--devices a,b,c` (comma list) into one
542
+ * deduped device filter; undefined when neither was given (= whole fleet). */
543
+ function resolveDeviceFilter(device, devices) {
544
+ const merged = [
545
+ ...(device ?? []),
546
+ ...(devices ? devices.split(',').map((s) => s.trim()).filter(Boolean) : []),
547
+ ];
548
+ return merged.length ? [...new Set(merged)] : undefined;
549
+ }
556
550
  /** Print the YAML-side fields that sit under the shared card in `view` mode. */
557
551
  function printProjectDefinition(def, name) {
558
552
  console.log();
@@ -598,16 +592,16 @@ export function registerProjectsCommands(program) {
598
592
  }
599
593
  const windowDays = Math.max(1, Number.parseInt(opts.window ?? '7', 10) || 7);
600
594
  const nowMs = Date.now();
601
- // --fleet: probe each shown def's workspace paths (root + repos[].path)
602
- // locally and on every peer in one parallel SSH round, and widen the
603
- // live-session rollup to the whole fleet via the existing sessions
604
- // fan-out. Both are opt-in — they dial the fleet. `view` accepts the flag
605
- // too so the two verbs stay interchangeable once a name is given.
606
- const fleetTargets = opts.fleet ? [...new Set(defs.flatMap(workspaceTargetsForDef))] : [];
595
+ // Fleet is the default: probe each shown def's workspace paths (root +
596
+ // repos[].path) locally AND on every peer in one parallel SSH round, and
597
+ // widen the live-session rollup to the fleet via the sessions fan-out.
598
+ // `--device`/`--devices` scopes the remote fan-out to a subset; with no
599
+ // filter every registered device is dialled.
600
+ const fleetTargets = [...new Set(defs.flatMap(workspaceTargetsForDef))];
607
601
  let fleetWs = [];
608
602
  let fleetSkipped = [];
609
603
  let fleetSessions = [];
610
- if (opts.fleet) {
604
+ {
611
605
  const self = machineId();
612
606
  fleetWs.push(...probeProjectWorkspaces(fleetTargets).map((s) => ({ ...s, host: self })));
613
607
  const [probeRes, activeRes] = await Promise.all([
@@ -615,11 +609,12 @@ export function registerProjectsCommands(program) {
615
609
  ? gatherRemoteAgentsJson({
616
610
  args: ['projects', 'probe', '--json', ...fleetTargets],
617
611
  noFanoutEnv: PROJECTS_NO_FANOUT_ENV,
612
+ hosts: opts.deviceFilter,
618
613
  parse: parseRemoteProbe,
619
614
  quiet: true,
620
615
  })
621
616
  : Promise.resolve({ items: [], deviceCount: 0, skipped: [] }),
622
- gatherRemoteActive(undefined, { quiet: true }),
617
+ gatherRemoteActive(opts.deviceFilter, { quiet: true }),
623
618
  ]);
624
619
  fleetWs.push(...probeRes.items);
625
620
  fleetSkipped = probeRes.skipped;
@@ -636,17 +631,6 @@ export function registerProjectsCommands(program) {
636
631
  const targets = new Set(workspaceTargetsForDef(d));
637
632
  return fleetWs.filter((s) => targets.has(s.path));
638
633
  };
639
- /** Local-only workspace probe for the warnings footer when --fleet is off. */
640
- const localWsCache = new Map();
641
- const localWsFor = (d) => {
642
- const cached = localWsCache.get(d.name);
643
- if (cached)
644
- return cached;
645
- const self = machineId();
646
- const rows = probeProjectWorkspaces(workspaceTargetsForDef(d)).map((s) => ({ ...s, host: self }));
647
- localWsCache.set(d.name, rows);
648
- return rows;
649
- };
650
634
  if (opts.json) {
651
635
  if (fleetSkipped.length > 0)
652
636
  process.stderr.write(formatFleetSkippedNote(fleetSkipped));
@@ -677,7 +661,7 @@ export function registerProjectsCommands(program) {
677
661
  lastArtifact: rem?.lastArtifact ?? null,
678
662
  windowDays,
679
663
  repos: [d.repo, ...(d.repos ?? []).map((r2) => r2.slug)].filter(Boolean),
680
- ...(opts.fleet ? { workspaces: fleetFor(d) } : {}),
664
+ workspaces: fleetFor(d),
681
665
  };
682
666
  }), null, 2));
683
667
  return;
@@ -685,10 +669,10 @@ export function registerProjectsCommands(program) {
685
669
  // Compact rollup shows the next milestone; `view` shows every declared one.
686
670
  const milestoneLimit = detail ? Number.POSITIVE_INFINITY : 1;
687
671
  for (const d of defs) {
688
- renderCard(d, roll.get(d.name), remote.get(d.name), opts.fleet ? fleetFor(d) : undefined, linear.get(d.name), nowMs, milestoneLimit, focus.get(d.name) ?? [], detail,
689
- // Always feed workspace rows into the warnings footer — full fleet when
690
- // --fleet, otherwise a local-only probe so behind/dirty is never silent.
691
- opts.fleet ? fleetFor(d) : localWsFor(d));
672
+ renderCard(d, roll.get(d.name), remote.get(d.name), fleetFor(d), linear.get(d.name), nowMs, milestoneLimit, focus.get(d.name) ?? [], detail,
673
+ // Always feed workspace rows into the warnings footer so behind/dirty
674
+ // is never silent.
675
+ fleetFor(d));
692
676
  if (detail)
693
677
  printProjectDefinition(d, d.name);
694
678
  }
@@ -699,15 +683,23 @@ export function registerProjectsCommands(program) {
699
683
  .command('status [name]')
700
684
  .alias('view')
701
685
  .alias('show')
702
- .description('Progress card for every project, or one named project (aliases: view, show). Named form also prints every milestone and the stored definition.')
686
+ .description('Progress card for every project across the whole fleet, or one named project (aliases: view, show). Named form also prints every milestone and the stored definition.')
703
687
  .option('--json', 'Machine-readable output')
704
688
  .option('--window <days>', 'Window for merged PRs, artifacts, and focus areas', '7')
705
689
  .option('--no-remote', 'Skip the GitHub and Linear lookups; faster, offline')
706
- .option('--fleet', 'Also dial every fleet device for workspace presence, branch, and drift (one SSH per peer)')
707
- .action(async (name, opts) => {
690
+ .option('--device <name...>', 'Scope fleet status to one or more devices (repeatable)')
691
+ .option('--devices <names>', 'Scope fleet status to a comma-separated list of devices')
692
+ .action(async (name, rawOpts) => {
708
693
  // Named invocation = `view` depth (all milestones + definition). Unnamed
709
694
  // stays the scannable multi-project rollup. `view`/`show` are commander
710
695
  // aliases of this same command, so there is only one implementation.
696
+ // Fleet is dialled by default; --device/--devices narrows it to a subset.
697
+ const opts = {
698
+ json: rawOpts.json,
699
+ window: rawOpts.window,
700
+ remote: rawOpts.remote,
701
+ deviceFilter: resolveDeviceFilter(rawOpts.device, rawOpts.devices),
702
+ };
711
703
  const mode = name ? 'view' : 'status';
712
704
  await runProjectCard(name, opts, mode);
713
705
  });
@@ -17,7 +17,7 @@ import type { Command } from 'commander';
17
17
  * unit a user reasons about: one skill, one command, one plugin — even if it
18
18
  * spans several files on disk.
19
19
  */
20
- type RepoResourceKind = 'skill' | 'command' | 'plugin' | 'hook' | 'mcp' | 'subagent' | 'rule' | 'workflow' | 'routine' | 'profile' | 'permission' | 'cli' | 'config' | 'other';
20
+ type RepoResourceKind = 'skill' | 'command' | 'plugin' | 'hook' | 'mcp' | 'subagent' | 'rule' | 'workflow' | 'routine' | 'profile' | 'permission' | 'clis' | 'config' | 'other';
21
21
  export type ChangeAction = 'new' | 'changed' | 'removed';
22
22
  /**
23
23
  * Map a repo-relative path to the resource unit it belongs to. Directory-based
@@ -78,7 +78,7 @@ const RESOURCE_DIRS = {
78
78
  skills: 'skill', commands: 'command', prompts: 'command', plugins: 'plugin',
79
79
  hooks: 'hook', mcp: 'mcp', subagents: 'subagent', rules: 'rule',
80
80
  workflows: 'workflow', routines: 'routine', profiles: 'profile',
81
- permissions: 'permission', cli: 'cli',
81
+ permissions: 'permission', clis: 'clis',
82
82
  };
83
83
  /** [singular, plural] display labels per kind. */
84
84
  const RESOURCE_LABELS = {
@@ -87,13 +87,13 @@ const RESOURCE_LABELS = {
87
87
  subagent: ['subagent', 'subagents'], rule: ['rule', 'rules'],
88
88
  workflow: ['workflow', 'workflows'], routine: ['routine', 'routines'],
89
89
  profile: ['profile', 'profiles'], permission: ['permission', 'permissions'],
90
- cli: ['CLI', 'CLIs'], config: ['config file', 'config files'],
90
+ clis: ['CLI', 'CLIs'], config: ['config file', 'config files'],
91
91
  other: ['other file', 'other files'],
92
92
  };
93
93
  /** Display order — the resources a user cares about most come first. */
94
94
  const RESOURCE_ORDER = [
95
95
  'skill', 'command', 'plugin', 'hook', 'mcp', 'subagent', 'rule',
96
- 'workflow', 'routine', 'profile', 'permission', 'cli', 'config', 'other',
96
+ 'workflow', 'routine', 'profile', 'permission', 'clis', 'config', 'other',
97
97
  ];
98
98
  /**
99
99
  * Map a repo-relative path to the resource unit it belongs to. Directory-based
@@ -32,7 +32,7 @@ export interface ViewSectionFilter {
32
32
  rules?: boolean;
33
33
  hooks?: boolean;
34
34
  promptcuts?: boolean;
35
- cli?: boolean;
35
+ clis?: boolean;
36
36
  }
37
37
  /** Trim a description to a column-friendly snippet. Strips newlines, collapses whitespace. */
38
38
  export declare function summarizeDescription(desc: string | undefined, maxLen?: number): string;
@@ -154,7 +154,7 @@ function getProjectVersionFromCwd(agent) {
154
154
  return null;
155
155
  }
156
156
  }
157
- const SECTION_KEYS = ['commands', 'skills', 'mcp', 'workflows', 'plugins', 'rules', 'hooks', 'promptcuts', 'cli'];
157
+ const SECTION_KEYS = ['commands', 'skills', 'mcp', 'workflows', 'plugins', 'rules', 'hooks', 'promptcuts', 'clis'];
158
158
  /**
159
159
  * Decide whether a section should render given the filter. If no flags are set,
160
160
  * everything renders (current behavior). If any flag is set, only those sections
@@ -231,7 +231,7 @@ function hostCliSourceTag(source) {
231
231
  }
232
232
  /**
233
233
  * Render the host-CLI section. Host CLIs are host-global: declared in any
234
- * DotAgents repo's `cli/` (project > user > system > extras), installed to PATH
234
+ * DotAgents repo's `clis/` (project > user > system > extras), installed to PATH
235
235
  * rather than copied into a version home. They render identically in the overview
236
236
  * and in a per-agent detail view because every agent on the host shares them.
237
237
  * The source tag shows which repo layer declared each — so user-level and
@@ -241,7 +241,7 @@ function renderHostClisSection(cwd) {
241
241
  const { statuses, errors } = listCliStatus(cwd);
242
242
  console.log(chalk.bold('\nHost CLIs\n'));
243
243
  if (statuses.length === 0) {
244
- console.log(` ${chalk.gray('none declared')} ${chalk.gray('— add one with `agents cli add <name>`')}`);
244
+ console.log(` ${chalk.gray('none declared')} ${chalk.gray('— add one with `agents clis add <name>`')}`);
245
245
  }
246
246
  else {
247
247
  const nameWidth = Math.max(...statuses.map((s) => s.manifest.name.length));
@@ -258,7 +258,7 @@ function renderHostClisSection(cwd) {
258
258
  console.log(prefix + desc);
259
259
  }
260
260
  if (anyMissing) {
261
- console.log(chalk.gray(' Install missing with `agents cli install`'));
261
+ console.log(chalk.gray(' Install missing with `agents clis install`'));
262
262
  }
263
263
  }
264
264
  for (const err of errors) {
@@ -1100,7 +1100,7 @@ async function showAgentResources(agentId, requestedVersion, filter) {
1100
1100
  if (shouldRenderSection('promptcuts', filter)) {
1101
1101
  renderPromptcuts();
1102
1102
  }
1103
- if (shouldRenderSection('cli', filter)) {
1103
+ if (shouldRenderSection('clis', filter)) {
1104
1104
  renderHostClisSection(cwd);
1105
1105
  }
1106
1106
  // Show legend at the end if git repo exists and we showed all sections.
@@ -1565,7 +1565,7 @@ export async function viewAction(agentArg, options) {
1565
1565
  rules: options?.rules,
1566
1566
  hooks: options?.hooks,
1567
1567
  promptcuts: options?.promptcuts,
1568
- cli: options?.cli,
1568
+ clis: options?.clis,
1569
1569
  };
1570
1570
  const filterIsSet = SECTION_KEYS.some((k) => filter[k]);
1571
1571
  // RUSH-1320: fold any stale literal `latest` version-home into its concrete
@@ -1684,7 +1684,7 @@ export function registerViewCommand(program) {
1684
1684
  .option('--rules', 'Show only rules in the detail view.')
1685
1685
  .option('--hooks', 'Show only hooks in the detail view.')
1686
1686
  .option('--promptcuts', 'Show only promptcuts in the detail view.')
1687
- .option('--cli', 'Show only host CLIs (declared in cli/, installed to PATH).')
1687
+ .option('--clis', 'Show only host CLIs (declared in clis/, installed to PATH).')
1688
1688
  .option('--merged', 'Show the merged, first-wins resource surface across all layers (project, user, extras, system) in one table with the winning layer per row.')
1689
1689
  .addHelpText('after', `
1690
1690
  Examples:
package/dist/index.js CHANGED
@@ -1177,7 +1177,7 @@ if (process.env.AGENTS_SKIP_MIGRATION !== '1') {
1177
1177
  // Bumping the suffix re-runs migrations for every user; binary releases that
1178
1178
  // don't change the schema must NOT re-run (they would destroy user content
1179
1179
  // when migration steps overlap with user-authored paths). See issue #20.
1180
- const sentinelValue = 'v13';
1180
+ const sentinelValue = 'v14';
1181
1181
  let needRun = true;
1182
1182
  try {
1183
1183
  if (fs.existsSync(sentinel) && fs.readFileSync(sentinel, 'utf-8').trim() === sentinelValue) {
@@ -8,7 +8,7 @@
8
8
  * checks.
9
9
  */
10
10
  import type { BetaFeatureName } from './types.js';
11
- export declare const ALL_BETA_FEATURES: readonly ["factory", "projects"];
11
+ export declare const ALL_BETA_FEATURES: readonly ["factory"];
12
12
  export declare function getEnabledBetaFeatures(): BetaFeatureName[];
13
13
  export declare function isBetaEnabled(feature: BetaFeatureName): boolean;
14
14
  export declare function getBetaConfigLocation(): {
package/dist/lib/beta.js CHANGED
@@ -10,7 +10,7 @@
10
10
  import * as path from 'path';
11
11
  import { getAgentsDir, getOptionalUserAgentsDir, readMeta, writeMeta } from './state.js';
12
12
  import { readManifest, writeManifest } from './manifest.js';
13
- export const ALL_BETA_FEATURES = ['factory', 'projects'];
13
+ export const ALL_BETA_FEATURES = ['factory'];
14
14
  function isBetaFeatureName(value) {
15
15
  return typeof value === 'string' && ALL_BETA_FEATURES.includes(value);
16
16
  }
@@ -217,7 +217,7 @@ export function parseCliManifest(contents, opts) {
217
217
  * manifests and any parse errors separately so the CLI can show both.
218
218
  */
219
219
  export function listCliManifests(cwd) {
220
- const resolved = listResources('cli', cwd);
220
+ const resolved = listResources('clis', cwd);
221
221
  const manifests = [];
222
222
  const errors = [];
223
223
  for (const entry of resolved) {
@@ -240,7 +240,7 @@ export function listCliManifests(cwd) {
240
240
  }
241
241
  /** Resolve a single CLI manifest by name. Returns null when not declared. */
242
242
  export function resolveCliManifest(name, cwd) {
243
- const resolved = resolveResource('cli', name, cwd);
243
+ const resolved = resolveResource('clis', name, cwd);
244
244
  if (!resolved)
245
245
  return null;
246
246
  if (!resolved.path.endsWith('.yaml') && !resolved.path.endsWith('.yml'))
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * The unified event reader -- one stream over BOTH operational events
3
- * (`~/.agents/events.jsonl` via events.ts: secrets, commands, teams, ...) and
3
+ * (`~/.agents/.history/events/YYYY-MM-DD/` via events.ts: secrets, commands, teams, ...) and
4
4
  * agent-semantic events (the per-session activity logs via activity.ts: plans,
5
5
  * PRs, worktrees, sub-agents, artifacts). They share one {@link EventType}
6
6
  * vocabulary and one {@link EventRecord} shape, so `agents events` and any
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * The unified event reader -- one stream over BOTH operational events
3
- * (`~/.agents/events.jsonl` via events.ts: secrets, commands, teams, ...) and
3
+ * (`~/.agents/.history/events/YYYY-MM-DD/` via events.ts: secrets, commands, teams, ...) and
4
4
  * agent-semantic events (the per-session activity logs via activity.ts: plans,
5
5
  * PRs, worktrees, sub-agents, artifacts). They share one {@link EventType}
6
6
  * vocabulary and one {@link EventRecord} shape, so `agents events` and any
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * Centralized event logging for agents-cli.
3
3
  *
4
- * Structured JSONL audit log at ~/.agents/events.jsonl with lossless numbered
5
- * gzip rotation at 10 MB and rich metadata for debugging/auditing.
4
+ * Structured JSONL audit logs at ~/.agents/.history/events/YYYY-MM-DD/events.jsonl with
5
+ * lossless numbered gzip rotation at 10 MiB and bounded retention.
6
6
  *
7
7
  * Features:
8
8
  * - Rich metadata: hostname, platform, arch, pid, timezone
@@ -75,6 +75,17 @@ export interface EventPayload {
75
75
  [key: string]: unknown;
76
76
  }
77
77
  export type EventRecord = EventMeta & EventPayload;
78
+ /**
79
+ * Move root-level and interim flat-history event families into dated directories.
80
+ *
81
+ * The common case is a whole-family rename into an empty destination. A
82
+ * Each segment is assigned to the local calendar day of its filesystem mtime;
83
+ * new writes are split by day at source. A partially completed migration keeps
84
+ * the destination active file authoritative and assigns a fresh archive number,
85
+ * so no record is overwritten or silently discarded. The legacy active-file
86
+ * lock serializes this with older installed processes that still append there.
87
+ */
88
+ export declare function migrateLegacyEventLogs(userDir?: string): number;
78
89
  /**
79
90
  * Replace a prompt string with length + short SHA so we can correlate runs
80
91
  * without persisting the raw text. Returns the fields to spread into a payload.
@@ -187,15 +198,13 @@ export declare function emitError(err: Error | string, payload?: EventPayload):
187
198
  * the same failure across sessions (e.g. 'remote-cwd-on-add', 'not-installed').
188
199
  */
189
200
  export declare function emitFriction(surface: string, failureId: string, payload?: EventPayload): void;
190
- /**
191
- * Remove log files older than the retention period.
192
- * Removes numbered gzip archives whose filesystem mtime exceeds retention.
193
- *
194
- * @param retentionDays - Number of days to keep (default 7, from DEFAULT_RETENTION_DAYS)
195
- * @returns Number of files removed
196
- */
197
- export declare function rotate(retentionDays?: number): number;
198
- export declare function maybeRotate(): void;
201
+ export interface RotationResult {
202
+ removedByAge: number;
203
+ removedBySize: number;
204
+ bytesReclaimed: number;
205
+ }
206
+ /** Apply age retention and the total-size ceiling immediately. */
207
+ export declare function rotate(retentionDays?: number, maxStorageBytes?: number): RotationResult;
199
208
  /**
200
209
  * Read events from log files within a date range.
201
210
  *
@@ -245,4 +254,4 @@ export declare function stats(options?: {
245
254
  days?: number;
246
255
  }): EventStats;
247
256
  export declare function getLogsPath(): string;
248
- export declare function _resetForTest(overrideEventsPath?: string): void;
257
+ export declare function _resetForTest(overrideEventsPath?: string, overrideUserAgentsDir?: string): void;