@phnx-labs/agents-cli 1.21.2 → 1.22.0

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 (102) hide show
  1. package/CHANGELOG.md +101 -0
  2. package/README.md +32 -3
  3. package/dist/bin/agents +0 -0
  4. package/dist/commands/computer-actions.d.ts +4 -0
  5. package/dist/commands/computer-actions.js +35 -0
  6. package/dist/commands/computer.js +4 -2
  7. package/dist/commands/exec.d.ts +27 -0
  8. package/dist/commands/exec.js +123 -6
  9. package/dist/commands/models.js +36 -1
  10. package/dist/commands/perf.d.ts +16 -0
  11. package/dist/commands/perf.js +11 -1
  12. package/dist/commands/projects.d.ts +11 -1
  13. package/dist/commands/projects.js +38 -4
  14. package/dist/commands/sessions-backfill.d.ts +32 -0
  15. package/dist/commands/sessions-backfill.js +186 -0
  16. package/dist/commands/sessions-picker.js +17 -2
  17. package/dist/commands/sessions.d.ts +22 -1
  18. package/dist/commands/sessions.js +331 -18
  19. package/dist/commands/teams.js +1 -1
  20. package/dist/commands/worktree.d.ts +3 -3
  21. package/dist/commands/worktree.js +35 -4
  22. package/dist/index.js +8 -0
  23. package/dist/lib/browser/service.js +13 -0
  24. package/dist/lib/computer/dispatch.d.ts +3 -1
  25. package/dist/lib/computer/dispatch.js +10 -2
  26. package/dist/lib/daemon.d.ts +5 -1
  27. package/dist/lib/daemon.js +63 -14
  28. package/dist/lib/devices/resolve-target.d.ts +6 -0
  29. package/dist/lib/devices/resolve-target.js +9 -3
  30. package/dist/lib/event-stream.d.ts +2 -0
  31. package/dist/lib/event-stream.js +3 -0
  32. package/dist/lib/events.d.ts +3 -1
  33. package/dist/lib/events.js +4 -2
  34. package/dist/lib/exec.js +39 -8
  35. package/dist/lib/git.d.ts +14 -0
  36. package/dist/lib/git.js +36 -0
  37. package/dist/lib/hooks/profile.js +1 -14
  38. package/dist/lib/hosts/dispatch.d.ts +12 -0
  39. package/dist/lib/hosts/dispatch.js +23 -6
  40. package/dist/lib/hosts/reconnect.d.ts +38 -0
  41. package/dist/lib/hosts/reconnect.js +85 -4
  42. package/dist/lib/hosts/run-target.js +14 -2
  43. package/dist/lib/menubar/MenubarHelper.app/Contents/CodeResources +0 -0
  44. package/dist/lib/menubar/MenubarHelper.app/Contents/MacOS/MenubarHelper +0 -0
  45. package/dist/lib/model-tiers.d.ts +54 -0
  46. package/dist/lib/model-tiers.js +229 -0
  47. package/dist/lib/models.d.ts +3 -0
  48. package/dist/lib/models.js +44 -7
  49. package/dist/lib/percentile.d.ts +12 -0
  50. package/dist/lib/percentile.js +24 -0
  51. package/dist/lib/perf/db.d.ts +1 -2
  52. package/dist/lib/perf/db.js +2 -14
  53. package/dist/lib/plugins.js +12 -1
  54. package/dist/lib/pricing/prices.json +16 -1
  55. package/dist/lib/project-focus.d.ts +42 -0
  56. package/dist/lib/project-focus.js +80 -0
  57. package/dist/lib/project-schedule.d.ts +75 -0
  58. package/dist/lib/project-schedule.js +110 -0
  59. package/dist/lib/redact.d.ts +2 -0
  60. package/dist/lib/redact.js +22 -0
  61. package/dist/lib/remote-agents-json.d.ts +2 -0
  62. package/dist/lib/remote-agents-json.js +3 -3
  63. package/dist/lib/resources.d.ts +16 -0
  64. package/dist/lib/resources.js +25 -14
  65. package/dist/lib/rotate.d.ts +84 -1
  66. package/dist/lib/rotate.js +155 -5
  67. package/dist/lib/routines.js +1 -14
  68. package/dist/lib/runner.d.ts +4 -2
  69. package/dist/lib/runner.js +21 -5
  70. package/dist/lib/secrets/Agents CLI.app/Contents/CodeResources +0 -0
  71. package/dist/lib/secrets/Agents CLI.app/Contents/MacOS/Agents CLI +0 -0
  72. package/dist/lib/session/bash-command.js +60 -9
  73. package/dist/lib/session/db.d.ts +22 -1
  74. package/dist/lib/session/db.js +516 -24
  75. package/dist/lib/session/discover.d.ts +68 -7
  76. package/dist/lib/session/discover.js +186 -84
  77. package/dist/lib/session/highlights.d.ts +24 -4
  78. package/dist/lib/session/highlights.js +52 -7
  79. package/dist/lib/session/parse.d.ts +8 -1
  80. package/dist/lib/session/parse.js +102 -35
  81. package/dist/lib/session/prompt.d.ts +19 -0
  82. package/dist/lib/session/prompt.js +43 -0
  83. package/dist/lib/session/remote-list.d.ts +71 -0
  84. package/dist/lib/session/remote-list.js +410 -2
  85. package/dist/lib/session/shell-programs.d.ts +15 -0
  86. package/dist/lib/session/shell-programs.js +359 -0
  87. package/dist/lib/session/tool-calls.d.ts +88 -0
  88. package/dist/lib/session/tool-calls.js +612 -0
  89. package/dist/lib/session/tool-index.d.ts +100 -0
  90. package/dist/lib/session/tool-index.js +773 -0
  91. package/dist/lib/session/tool-store.d.ts +15 -0
  92. package/dist/lib/session/tool-store.js +198 -0
  93. package/dist/lib/session/types.d.ts +49 -0
  94. package/dist/lib/state.d.ts +10 -1
  95. package/dist/lib/state.js +11 -2
  96. package/dist/lib/teams/remoteWorktree.d.ts +3 -4
  97. package/dist/lib/teams/remoteWorktree.js +3 -4
  98. package/dist/lib/teams/worktree.d.ts +11 -1
  99. package/dist/lib/teams/worktree.js +42 -4
  100. package/dist/lib/types.d.ts +31 -0
  101. package/dist/lib/types.js +17 -0
  102. package/package.json +3 -1
@@ -9,6 +9,9 @@
9
9
  import type { SessionAgentId, SessionEvent, SessionMeta, TodoProgress } from './types.js';
10
10
  export { machineForSessionFile } from './origin-machine.js';
11
11
  import { type ScanStamp } from './db.js';
12
+ import { ToolCallCollector, type IndexedToolCall, type ToolCallCollectorSnapshot } from './tool-calls.js';
13
+ /** One JSONL record may not force an unbounded string allocation. */
14
+ export declare const SESSION_JSONL_LINE_MAX_BYTES: number;
12
15
  /** Options controlling which sessions to discover and how to report progress. */
13
16
  export interface DiscoverOptions {
14
17
  agent?: SessionAgentId;
@@ -27,6 +30,8 @@ export interface DiscoverOptions {
27
30
  /** Match any session whose cwd equals this or is a descendant. Overrides `cwd`. */
28
31
  cwdPrefix?: string;
29
32
  limit?: number;
33
+ /** Internal indexed-query path: return every row in scope instead of the default page. */
34
+ unbounded?: boolean;
30
35
  /** Filter sessions newer than this (ISO timestamp or "7d", "30d", "90d") */
31
36
  since?: string;
32
37
  /** Filter sessions older than this (ISO timestamp) */
@@ -39,8 +44,14 @@ export interface DiscoverOptions {
39
44
  origin?: 'cli' | 'routine';
40
45
  /** Column to order results by (all descending): 'timestamp' (default), 'cost', or 'duration'. */
41
46
  sortBy?: 'timestamp' | 'cost' | 'duration';
47
+ /** Trust scan-ledger rows without stat'ing every returned transcript. */
48
+ skipExistenceCheck?: boolean;
42
49
  /** Called as each agent makes parsing progress. Totals count only files that need re-parsing (cache misses). */
43
50
  onProgress?: (progress: ScanProgress) => void;
51
+ /** Only sessions that invoked this skill (#12) — see QueryOptions.skill in session/db.ts. */
52
+ skill?: string;
53
+ /** Only sessions that used a skill/command owned by this plugin (#12) — see QueryOptions.plugin. */
54
+ plugin?: string;
44
55
  }
45
56
  /** Progress report emitted during incremental scanning. */
46
57
  export interface ScanProgress {
@@ -87,6 +98,16 @@ interface ClaudeSessionScan {
87
98
  plan?: string;
88
99
  todos?: TodoProgress;
89
100
  recentDirectoriesTouched?: string[];
101
+ /** Skills invoked (#12) — see SessionMeta.skillsUsed. */
102
+ skillsUsed?: Array<{
103
+ name: string;
104
+ count: number;
105
+ }>;
106
+ /** Slash commands invoked (#12) — see SessionMeta.slashCommandsUsed. */
107
+ slashCommandsUsed?: Array<{
108
+ name: string;
109
+ count: number;
110
+ }>;
90
111
  }
91
112
  /** Lightweight metadata extracted from a Codex JSONL file during incremental scan. */
92
113
  interface CodexSessionScan {
@@ -125,6 +146,22 @@ interface CodexSessionScan {
125
146
  * TTL, no external lock files needed.
126
147
  */
127
148
  export declare function discoverSessions(options?: DiscoverOptions): Promise<SessionMeta[]>;
149
+ /** Read the current SQLite snapshot without scanning or parsing transcript files. */
150
+ export declare function queryIndexedSessions(options?: DiscoverOptions, indexedOptions?: {
151
+ resolveLinear?: boolean;
152
+ skipExistenceCheck?: boolean;
153
+ }): Promise<SessionMeta[]>;
154
+ /**
155
+ * Drop unmanaged rows for agents that HAVE managed versions.
156
+ *
157
+ * Scoping happens here, at query time, rather than by narrowing the scan: the index
158
+ * stays complete, so `--unmanaged` needs no re-scan and every other consumer of the
159
+ * DB (watchdog, the Factory watcher, `--roots`) is unaffected.
160
+ *
161
+ * An agent with no managed versions is left alone entirely — someone who has never
162
+ * run `agents add` sees exactly what they saw before.
163
+ */
164
+ export declare function scopeToManaged(sessions: SessionMeta[], agents: readonly SessionAgentId[], options?: DiscoverOptions): SessionMeta[];
128
165
  /**
129
166
  * How many agents' dotfile dirs we scan at once, and the minimum spacing between
130
167
  * successive scan starts. A small bound + stagger turns a simultaneous bulk
@@ -356,6 +393,8 @@ export declare function readCodexMeta(filePath: string, resolveAccount?: () => s
356
393
  content: string;
357
394
  parserState?: string;
358
395
  contentText?: string;
396
+ toolCalls?: IndexedToolCall[];
397
+ toolIndexMode: 'replace' | 'append';
359
398
  } | null>;
360
399
  /**
361
400
  * Mutable accumulator for the Claude transcript reducer. One field per local
@@ -394,6 +433,12 @@ export interface ClaudeParseState {
394
433
  plan?: string;
395
434
  checklistEvents: SessionEvent[];
396
435
  recentDirectoriesTouched: string[];
436
+ toolCollector: ToolCallCollector;
437
+ /** Skill-invocation tool_use events, held for extractSkills() at finalize (#12). */
438
+ skillEvents: SessionEvent[];
439
+ /** Slash-command events (user-typed <command-name> wrapper OR a SlashCommand
440
+ * tool_use), held for extractSlashCommands() at finalize (#12). */
441
+ slashCommandEvents: SessionEvent[];
397
442
  }
398
443
  /** Zero-value accumulator for a fresh (from-byte-0) Claude parse. */
399
444
  export declare function initClaudeParseState(): ClaudeParseState;
@@ -423,8 +468,9 @@ export declare function scanClaudeSession(filePath: string): Promise<ClaudeSessi
423
468
  * exact even when the recent window is smaller than the true count.
424
469
  */
425
470
  export interface ClaudeParserState {
426
- v: 1;
471
+ v: 2;
427
472
  offset: number;
473
+ jsonlDroppingOversizedLine?: boolean;
428
474
  timestamp?: string;
429
475
  cwd?: string;
430
476
  gitBranch?: string;
@@ -456,13 +502,17 @@ export interface ClaudeParserState {
456
502
  contentText?: string;
457
503
  checklistEvents: SessionEvent[];
458
504
  recentDirectoriesTouched: string[];
505
+ toolCalls: ToolCallCollectorSnapshot;
506
+ /** #12: see ClaudeParseState.skillEvents/slashCommandEvents. */
507
+ skillEvents: SessionEvent[];
508
+ slashCommandEvents: SessionEvent[];
459
509
  }
460
510
  /**
461
511
  * Snapshot a live {@link ClaudeParseState} into its serializable form at
462
512
  * `offset` bytes consumed. Round-trips through {@link hydrateClaudeParseState}
463
513
  * so incremental replay equals a full parse.
464
514
  */
465
- export declare function serializeClaudeParserState(state: ClaudeParseState, offset: number): ClaudeParserState;
515
+ export declare function serializeClaudeParserState(state: ClaudeParseState, offset: number, jsonlDroppingOversizedLine?: boolean): ClaudeParserState;
466
516
  /**
467
517
  * Rebuild a live {@link ClaudeParseState} from a persisted continuation so that
468
518
  * applying the appended lines yields the same accumulator a full parse would.
@@ -495,6 +545,7 @@ export declare function scanClaudeSessionIncremental(filePath: string, fromOffse
495
545
  scan: ClaudeSessionScan;
496
546
  newState: ClaudeParserState;
497
547
  newOffset: number;
548
+ toolCalls: IndexedToolCall[];
498
549
  }>;
499
550
  /** Test seam: read the (incremental, full) Claude parse counters. */
500
551
  export declare function __claudeScanBranchCountsForTest(): {
@@ -531,6 +582,13 @@ export interface CodexParseState {
531
582
  spawnedTeam?: string;
532
583
  checklistEvents: SessionEvent[];
533
584
  recentDirectoriesTouched: string[];
585
+ toolCollector: ToolCallCollector;
586
+ /** #12: see ClaudeParseState.skillEvents. Empty in practice today — no
587
+ * verified Codex skill-invocation tool name — but wired for parity so a
588
+ * future confirmed tool name (or a literal 'SlashCommand' function_call)
589
+ * is picked up with no further plumbing. */
590
+ skillEvents: SessionEvent[];
591
+ slashCommandEvents: SessionEvent[];
534
592
  }
535
593
  /** Zero-value accumulator for a fresh (from-byte-0) Codex parse. */
536
594
  export declare function initCodexParseState(): CodexParseState;
@@ -558,8 +616,9 @@ export declare function finalizeCodexScan(state: CodexParseState): CodexSessionS
558
616
  * finalize is identical after a resume.
559
617
  */
560
618
  export interface CodexParserState {
561
- v: 1;
619
+ v: 2;
562
620
  offset: number;
621
+ jsonlDroppingOversizedLine?: boolean;
563
622
  sessionId?: string;
564
623
  timestamp?: string;
565
624
  cwd?: string;
@@ -582,13 +641,14 @@ export interface CodexParserState {
582
641
  contentText?: string;
583
642
  checklistEvents: SessionEvent[];
584
643
  recentDirectoriesTouched: string[];
644
+ toolCalls: ToolCallCollectorSnapshot;
585
645
  }
586
646
  /**
587
647
  * Snapshot a live {@link CodexParseState} into its serializable form at `offset`
588
648
  * bytes consumed. Round-trips through {@link hydrateCodexParseState} so
589
649
  * incremental replay equals a full parse.
590
650
  */
591
- export declare function serializeCodexParserState(state: CodexParseState, offset: number): CodexParserState;
651
+ export declare function serializeCodexParserState(state: CodexParseState, offset: number, jsonlDroppingOversizedLine?: boolean): CodexParserState;
592
652
  /**
593
653
  * Rebuild a live {@link CodexParseState} from a persisted continuation so that
594
654
  * applying the appended lines yields the same accumulator a full parse would.
@@ -607,9 +667,9 @@ export declare function hydrateCodexParseState(prior: CodexParserState): CodexPa
607
667
  *
608
668
  * Same trailing-line discipline as {@link scanClaudeSessionIncremental}: apply
609
669
  * ONLY the run of newline-terminated lines (slice at the last `'\n'`), and set
610
- * `newOffset = fromOffset + consumedBytes`. Any tail after the last `'\n'` —
611
- * syntactically broken OR a complete-but-not-yet-terminated record — is DEFERRED
612
- * to the next pass once its `'\n'` lands. Codex `messageCount` is additive with
670
+ * `newOffset = fromOffset + consumedBytes`. An ordinary tail after the last
671
+ * `'\n'` is deferred; an oversized one advances under a persisted discard bit.
672
+ * Codex `messageCount` is additive with
613
673
  * NO dedup, so re-reading a still-unterminated complete line would double-count
614
674
  * it; deferring prevents that (the bug class prix-cloud caught for Claude).
615
675
  */
@@ -617,6 +677,7 @@ export declare function scanCodexSessionIncremental(filePath: string, fromOffset
617
677
  scan: CodexSessionScan;
618
678
  newState: CodexParserState;
619
679
  newOffset: number;
680
+ toolCalls: IndexedToolCall[];
620
681
  }>;
621
682
  /** Test seam: read the (incremental, full) Codex parse counters. */
622
683
  export declare function __codexScanBranchCountsForTest(): {