@ai-devkit/agent-manager 0.3.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.
- package/dist/adapters/ClaudeCodeAdapter.d.ts +44 -28
- package/dist/adapters/ClaudeCodeAdapter.d.ts.map +1 -1
- package/dist/adapters/ClaudeCodeAdapter.js +383 -234
- package/dist/adapters/ClaudeCodeAdapter.js.map +1 -1
- package/dist/adapters/CodexAdapter.d.ts.map +1 -1
- package/dist/adapters/CodexAdapter.js +1 -3
- package/dist/adapters/CodexAdapter.js.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/adapters/ClaudeCodeAdapter.test.ts +1045 -82
- package/src/__tests__/adapters/CodexAdapter.test.ts +7 -1
- package/src/adapters/ClaudeCodeAdapter.ts +498 -327
- package/src/adapters/CodexAdapter.ts +2 -13
|
@@ -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.
|
|
14
|
-
* 3.
|
|
15
|
-
* 4.
|
|
16
|
-
* 5. Extracting summary from
|
|
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
|
-
/**
|
|
21
|
-
private static readonly
|
|
22
|
-
private
|
|
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
|
|
31
|
+
private listClaudeProcesses;
|
|
32
|
+
private calculateSessionScanLimit;
|
|
35
33
|
private assignSessionsForMode;
|
|
36
|
-
private selectBestSession;
|
|
37
34
|
private mapSessionToAgent;
|
|
38
35
|
private mapProcessOnlyAgent;
|
|
39
|
-
private
|
|
40
|
-
private
|
|
41
|
-
private
|
|
36
|
+
private selectBestSession;
|
|
37
|
+
private filterCandidateSessions;
|
|
38
|
+
private rankCandidatesByStartTime;
|
|
39
|
+
private getProcessStartTimes;
|
|
40
|
+
private parseElapsedSeconds;
|
|
42
41
|
/**
|
|
43
|
-
* Read
|
|
42
|
+
* Read Claude Code sessions with bounded scanning
|
|
44
43
|
*/
|
|
45
44
|
private readSessions;
|
|
46
45
|
/**
|
|
47
|
-
*
|
|
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
|
|
48
|
+
private findSessionFiles;
|
|
51
49
|
/**
|
|
52
|
-
*
|
|
53
|
-
* Only reads last 100 lines for performance
|
|
50
|
+
* Parse a single session file into ClaudeSession
|
|
54
51
|
*/
|
|
55
|
-
private
|
|
52
|
+
private readSession;
|
|
56
53
|
/**
|
|
57
|
-
* Determine agent status from session
|
|
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":"
|
|
1
|
+
{"version":3,"file":"ClaudeCodeAdapter.d.ts","sourceRoot":"","sources":["../../src/adapters/ClaudeCodeAdapter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YA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