@ai-devkit/agent-manager 0.2.0 → 0.4.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.
@@ -1,60 +1,57 @@
1
- /**
2
- * Claude Code Adapter
3
- *
4
- * Detects running Claude Code agents by reading session files
5
- * from ~/.claude/ directory and correlating with running processes.
6
- */
7
1
  import type { AgentAdapter, AgentInfo, ProcessInfo } from './AgentAdapter';
8
2
  /**
9
3
  * Claude Code Adapter
10
4
  *
11
5
  * Detects Claude Code agents by:
12
6
  * 1. Finding running claude processes
13
- * 2. Reading session files from ~/.claude/projects/
14
- * 3. Matching sessions to processes via CWD
15
- * 4. Extracting status from session JSONL
16
- * 5. Extracting summary from history.jsonl
7
+ * 2. Getting process start times for accurate session matching
8
+ * 3. Reading bounded session files from ~/.claude/projects/
9
+ * 4. Matching sessions to processes via CWD then start time ranking
10
+ * 5. Extracting summary from last user message in session JSONL
17
11
  */
18
12
  export declare class ClaudeCodeAdapter implements AgentAdapter {
19
13
  readonly type: "claude";
20
- /** Threshold in minutes before considering a session idle */
21
- private static readonly IDLE_THRESHOLD_MINUTES;
22
- private claudeDir;
14
+ /** Limit session parsing per run to keep list latency bounded. */
15
+ private static readonly MIN_SESSION_SCAN;
16
+ private static readonly MAX_SESSION_SCAN;
17
+ private static readonly SESSION_SCAN_MULTIPLIER;
18
+ /** Matching tolerance between process start time and session start time. */
19
+ private static readonly PROCESS_SESSION_TIME_TOLERANCE_MS;
23
20
  private projectsDir;
24
- private historyPath;
25
21
  constructor();
26
22
  /**
27
23
  * Check if this adapter can handle a given process
28
24
  */
29
25
  canHandle(processInfo: ProcessInfo): boolean;
26
+ private isClaudeExecutable;
30
27
  /**
31
28
  * Detect running Claude Code agents
32
29
  */
33
30
  detectAgents(): Promise<AgentInfo[]>;
34
- private assignHistoryEntriesForExactProcessCwd;
31
+ private listClaudeProcesses;
32
+ private calculateSessionScanLimit;
35
33
  private assignSessionsForMode;
36
- private selectBestSession;
37
34
  private mapSessionToAgent;
38
35
  private mapProcessOnlyAgent;
39
- private mapHistoryToAgent;
40
- private indexHistoryByProjectPath;
41
- private selectHistoryForProcess;
36
+ private selectBestSession;
37
+ private filterCandidateSessions;
38
+ private rankCandidatesByStartTime;
39
+ private getProcessStartTimes;
40
+ private parseElapsedSeconds;
42
41
  /**
43
- * Read all Claude Code sessions
42
+ * Read Claude Code sessions with bounded scanning
44
43
  */
45
44
  private readSessions;
46
45
  /**
47
- * Read a session JSONL file
48
- * Only reads last 100 lines for performance with large files
46
+ * Find session files bounded by mtime, sorted most-recent first
49
47
  */
50
- private readSessionLog;
48
+ private findSessionFiles;
51
49
  /**
52
- * Read history.jsonl for user prompts
53
- * Only reads last 100 lines for performance
50
+ * Parse a single session file into ClaudeSession
54
51
  */
55
- private readHistory;
52
+ private readSession;
56
53
  /**
57
- * Determine agent status from session entry
54
+ * Determine agent status from session state
58
55
  */
59
56
  private determineStatus;
60
57
  /**
@@ -62,9 +59,28 @@ export declare class ClaudeCodeAdapter implements AgentAdapter {
62
59
  * Uses project basename, appends slug if multiple sessions for same project
63
60
  */
64
61
  private generateAgentName;
62
+ /** Check if two paths are equal, or one is a parent/child of the other. */
63
+ private pathRelated;
65
64
  private pathEquals;
66
65
  private isChildPath;
66
+ /**
67
+ * Extract meaningful text from a user message content.
68
+ * Handles string and array formats, skill command expansion, and noise filtering.
69
+ */
70
+ private extractUserMessageText;
71
+ /**
72
+ * Parse a <command-message> string into "/command args" format.
73
+ */
74
+ private parseCommandMessage;
75
+ /**
76
+ * Check if a message is noise (not a meaningful user intent).
77
+ */
78
+ private isNoiseMessage;
79
+ /**
80
+ * Check if an entry type is metadata (not conversation state).
81
+ * These should not overwrite lastEntryType used for status determination.
82
+ */
83
+ private isMetadataEntryType;
67
84
  private normalizePath;
68
- private pathDepth;
69
85
  }
70
86
  //# sourceMappingURL=ClaudeCodeAdapter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ClaudeCodeAdapter.d.ts","sourceRoot":"","sources":["../../src/adapters/ClaudeCodeAdapter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAkE3E;;;;;;;;;GASG;AACH,qBAAa,iBAAkB,YAAW,YAAY;IAClD,QAAQ,CAAC,IAAI,EAAG,QAAQ,CAAU;IAElC,6DAA6D;IAC7D,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,sBAAsB,CAAK;IAEnD,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,WAAW,CAAS;;IAS5B;;OAEG;IACH,SAAS,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO;IAI5C;;OAEG;IACG,YAAY,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;IAgE1C,OAAO,CAAC,sCAAsC;IAuB9C,OAAO,CAAC,qBAAqB;IAyB7B,OAAO,CAAC,iBAAiB;IA6CzB,OAAO,CAAC,iBAAiB;IAqBzB,OAAO,CAAC,mBAAmB;IAkC3B,OAAO,CAAC,iBAAiB;IA0BzB,OAAO,CAAC,yBAAyB;IAoBjC,OAAO,CAAC,uBAAuB;IAa/B;;OAEG;IACH,OAAO,CAAC,YAAY;IA0DpB;;;OAGG;IACH,OAAO,CAAC,cAAc;IAsCtB;;;OAGG;IACH,OAAO,CAAC,WAAW;IAInB;;OAEG;IACH,OAAO,CAAC,eAAe;IAqCvB;;;OAGG;IACH,OAAO,CAAC,iBAAiB;IAwBzB,OAAO,CAAC,UAAU;IAQlB,OAAO,CAAC,WAAW;IAUnB,OAAO,CAAC,aAAa;IAQrB,OAAO,CAAC,SAAS;CAQpB"}
1
+ {"version":3,"file":"ClaudeCodeAdapter.d.ts","sourceRoot":"","sources":["../../src/adapters/ClaudeCodeAdapter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE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