@ai-devkit/agent-manager 0.3.0 → 0.5.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 (50) hide show
  1. package/dist/adapters/AgentAdapter.d.ts +2 -0
  2. package/dist/adapters/AgentAdapter.d.ts.map +1 -1
  3. package/dist/adapters/ClaudeCodeAdapter.d.ts +49 -38
  4. package/dist/adapters/ClaudeCodeAdapter.d.ts.map +1 -1
  5. package/dist/adapters/ClaudeCodeAdapter.js +286 -293
  6. package/dist/adapters/ClaudeCodeAdapter.js.map +1 -1
  7. package/dist/adapters/CodexAdapter.d.ts +32 -30
  8. package/dist/adapters/CodexAdapter.d.ts.map +1 -1
  9. package/dist/adapters/CodexAdapter.js +148 -284
  10. package/dist/adapters/CodexAdapter.js.map +1 -1
  11. package/dist/index.d.ts +1 -3
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +1 -10
  14. package/dist/index.js.map +1 -1
  15. package/dist/utils/index.d.ts +6 -3
  16. package/dist/utils/index.d.ts.map +1 -1
  17. package/dist/utils/index.js +12 -11
  18. package/dist/utils/index.js.map +1 -1
  19. package/dist/utils/matching.d.ts +39 -0
  20. package/dist/utils/matching.d.ts.map +1 -0
  21. package/dist/utils/matching.js +103 -0
  22. package/dist/utils/matching.js.map +1 -0
  23. package/dist/utils/process.d.ts +25 -40
  24. package/dist/utils/process.d.ts.map +1 -1
  25. package/dist/utils/process.js +151 -105
  26. package/dist/utils/process.js.map +1 -1
  27. package/dist/utils/session.d.ts +30 -0
  28. package/dist/utils/session.d.ts.map +1 -0
  29. package/dist/utils/session.js +101 -0
  30. package/dist/utils/session.js.map +1 -0
  31. package/package.json +2 -2
  32. package/src/__tests__/AgentManager.test.ts +0 -25
  33. package/src/__tests__/adapters/ClaudeCodeAdapter.test.ts +921 -205
  34. package/src/__tests__/adapters/CodexAdapter.test.ts +468 -269
  35. package/src/__tests__/utils/matching.test.ts +191 -0
  36. package/src/__tests__/utils/process.test.ts +202 -0
  37. package/src/__tests__/utils/session.test.ts +117 -0
  38. package/src/adapters/AgentAdapter.ts +3 -0
  39. package/src/adapters/ClaudeCodeAdapter.ts +341 -418
  40. package/src/adapters/CodexAdapter.ts +155 -420
  41. package/src/index.ts +1 -3
  42. package/src/utils/index.ts +6 -3
  43. package/src/utils/matching.ts +92 -0
  44. package/src/utils/process.ts +133 -119
  45. package/src/utils/session.ts +92 -0
  46. package/dist/utils/file.d.ts +0 -52
  47. package/dist/utils/file.d.ts.map +0 -1
  48. package/dist/utils/file.js +0 -135
  49. package/dist/utils/file.js.map +0 -1
  50. package/src/utils/file.ts +0 -100
@@ -1,15 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.readJson = exports.fileExists = exports.readJsonLines = exports.readLastLines = exports.getProcessInfo = exports.isProcessRunning = exports.getProcessTty = exports.getProcessCwd = exports.listProcesses = void 0;
3
+ exports.generateAgentName = exports.matchProcessesToSessions = exports.batchGetSessionFileBirthtimes = exports.getProcessTty = exports.enrichProcesses = exports.batchGetProcessStartTimes = exports.batchGetProcessCwds = exports.listAgentProcesses = void 0;
4
4
  var process_1 = require("./process");
5
- Object.defineProperty(exports, "listProcesses", { enumerable: true, get: function () { return process_1.listProcesses; } });
6
- Object.defineProperty(exports, "getProcessCwd", { enumerable: true, get: function () { return process_1.getProcessCwd; } });
7
- Object.defineProperty(exports, "getProcessTty", { enumerable: true, get: function () { return process_1.getProcessTty; } });
8
- Object.defineProperty(exports, "isProcessRunning", { enumerable: true, get: function () { return process_1.isProcessRunning; } });
9
- Object.defineProperty(exports, "getProcessInfo", { enumerable: true, get: function () { return process_1.getProcessInfo; } });
10
- var file_1 = require("./file");
11
- Object.defineProperty(exports, "readLastLines", { enumerable: true, get: function () { return file_1.readLastLines; } });
12
- Object.defineProperty(exports, "readJsonLines", { enumerable: true, get: function () { return file_1.readJsonLines; } });
13
- Object.defineProperty(exports, "fileExists", { enumerable: true, get: function () { return file_1.fileExists; } });
14
- Object.defineProperty(exports, "readJson", { enumerable: true, get: function () { return file_1.readJson; } });
5
+ Object.defineProperty(exports, "listAgentProcesses", { enumerable: true, get: function () { return process_1.listAgentProcesses; } });
6
+ Object.defineProperty(exports, "batchGetProcessCwds", { enumerable: true, get: function () { return process_1.batchGetProcessCwds; } });
7
+ Object.defineProperty(exports, "batchGetProcessStartTimes", { enumerable: true, get: function () { return process_1.batchGetProcessStartTimes; } });
8
+ Object.defineProperty(exports, "enrichProcesses", { enumerable: true, get: function () { return process_1.enrichProcesses; } });
9
+ var process_2 = require("./process");
10
+ Object.defineProperty(exports, "getProcessTty", { enumerable: true, get: function () { return process_2.getProcessTty; } });
11
+ var session_1 = require("./session");
12
+ Object.defineProperty(exports, "batchGetSessionFileBirthtimes", { enumerable: true, get: function () { return session_1.batchGetSessionFileBirthtimes; } });
13
+ var matching_1 = require("./matching");
14
+ Object.defineProperty(exports, "matchProcessesToSessions", { enumerable: true, get: function () { return matching_1.matchProcessesToSessions; } });
15
+ Object.defineProperty(exports, "generateAgentName", { enumerable: true, get: function () { return matching_1.generateAgentName; } });
15
16
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;AAAA,qCAA0G;AAAjG,wGAAA,aAAa,OAAA;AAAE,wGAAA,aAAa,OAAA;AAAE,wGAAA,aAAa,OAAA;AAAE,2GAAA,gBAAgB,OAAA;AAAE,yGAAA,cAAc,OAAA;AAEtF,+BAA4E;AAAnE,qGAAA,aAAa,OAAA;AAAE,qGAAA,aAAa,OAAA;AAAE,kGAAA,UAAU,OAAA;AAAE,gGAAA,QAAQ,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;AAAA,qCAAgH;AAAvG,6GAAA,kBAAkB,OAAA;AAAE,8GAAA,mBAAmB,OAAA;AAAE,oHAAA,yBAAyB,OAAA;AAAE,0GAAA,eAAe,OAAA;AAC5F,qCAA0C;AAAjC,wGAAA,aAAa,OAAA;AACtB,qCAA0D;AAAjD,wHAAA,6BAA6B,OAAA;AAEtC,uCAAyE;AAAhE,oHAAA,wBAAwB,OAAA;AAAE,6GAAA,iBAAiB,OAAA"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Session Matching Utilities
3
+ *
4
+ * Shared 1:1 greedy matching algorithm that pairs running processes with session files
5
+ * based on CWD and birth-time proximity to process start time.
6
+ */
7
+ import type { ProcessInfo } from '../adapters/AgentAdapter';
8
+ import type { SessionFile } from './session';
9
+ /**
10
+ * Result of matching a process to a session file.
11
+ */
12
+ export interface MatchResult {
13
+ /** The matched process */
14
+ process: ProcessInfo;
15
+ /** The matched session file */
16
+ session: SessionFile;
17
+ /** Absolute time delta in ms between process start and session birth time */
18
+ deltaMs: number;
19
+ }
20
+ /**
21
+ * Match processes to session files using 1:1 greedy assignment.
22
+ *
23
+ * Algorithm:
24
+ * 1. Exclude processes without startTime (they become process-only fallback).
25
+ * 2. Build candidate pairs where process.cwd === session.resolvedCwd
26
+ * and |process.startTime - session.birthtimeMs| <= 3 minutes.
27
+ * 3. Sort candidates by deltaMs ascending (best matches first).
28
+ * 4. Greedily assign: once a process or session is matched, skip it.
29
+ *
30
+ * Adapters must set session.resolvedCwd before calling this function.
31
+ */
32
+ export declare function matchProcessesToSessions(processes: ProcessInfo[], sessions: SessionFile[]): MatchResult[];
33
+ /**
34
+ * Generate a deterministic agent name from CWD and PID.
35
+ *
36
+ * Format: "folderName (pid)"
37
+ */
38
+ export declare function generateAgentName(cwd: string, pid: number): string;
39
+ //# sourceMappingURL=matching.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"matching.d.ts","sourceRoot":"","sources":["../../src/utils/matching.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAK7C;;GAEG;AACH,MAAM,WAAW,WAAW;IACxB,0BAA0B;IAC1B,OAAO,EAAE,WAAW,CAAC;IAErB,+BAA+B;IAC/B,OAAO,EAAE,WAAW,CAAC;IAErB,6EAA6E;IAC7E,OAAO,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,wBAAwB,CACpC,SAAS,EAAE,WAAW,EAAE,EACxB,QAAQ,EAAE,WAAW,EAAE,GACxB,WAAW,EAAE,CAsCf;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAGlE"}
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+ /**
3
+ * Session Matching Utilities
4
+ *
5
+ * Shared 1:1 greedy matching algorithm that pairs running processes with session files
6
+ * based on CWD and birth-time proximity to process start time.
7
+ */
8
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ var desc = Object.getOwnPropertyDescriptor(m, k);
11
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
+ desc = { enumerable: true, get: function() { return m[k]; } };
13
+ }
14
+ Object.defineProperty(o, k2, desc);
15
+ }) : (function(o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ o[k2] = m[k];
18
+ }));
19
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
20
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
21
+ }) : function(o, v) {
22
+ o["default"] = v;
23
+ });
24
+ var __importStar = (this && this.__importStar) || (function () {
25
+ var ownKeys = function(o) {
26
+ ownKeys = Object.getOwnPropertyNames || function (o) {
27
+ var ar = [];
28
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
+ return ar;
30
+ };
31
+ return ownKeys(o);
32
+ };
33
+ return function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ })();
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ exports.matchProcessesToSessions = matchProcessesToSessions;
43
+ exports.generateAgentName = generateAgentName;
44
+ const path = __importStar(require("path"));
45
+ /** Maximum allowed delta between process start time and session file birth time. */
46
+ const TOLERANCE_MS = 3 * 60 * 1000; // 3 minutes
47
+ /**
48
+ * Match processes to session files using 1:1 greedy assignment.
49
+ *
50
+ * Algorithm:
51
+ * 1. Exclude processes without startTime (they become process-only fallback).
52
+ * 2. Build candidate pairs where process.cwd === session.resolvedCwd
53
+ * and |process.startTime - session.birthtimeMs| <= 3 minutes.
54
+ * 3. Sort candidates by deltaMs ascending (best matches first).
55
+ * 4. Greedily assign: once a process or session is matched, skip it.
56
+ *
57
+ * Adapters must set session.resolvedCwd before calling this function.
58
+ */
59
+ function matchProcessesToSessions(processes, sessions) {
60
+ // Build all candidate pairs
61
+ const candidates = [];
62
+ for (const proc of processes) {
63
+ if (!proc.startTime || !proc.cwd)
64
+ continue;
65
+ const processStartMs = proc.startTime.getTime();
66
+ for (const session of sessions) {
67
+ if (!session.resolvedCwd)
68
+ continue;
69
+ if (proc.cwd !== session.resolvedCwd)
70
+ continue;
71
+ const deltaMs = Math.abs(processStartMs - session.birthtimeMs);
72
+ if (deltaMs > TOLERANCE_MS)
73
+ continue;
74
+ candidates.push({ process: proc, session, deltaMs });
75
+ }
76
+ }
77
+ // Sort by smallest delta first
78
+ candidates.sort((a, b) => a.deltaMs - b.deltaMs);
79
+ // Greedy 1:1 assignment
80
+ const matchedPids = new Set();
81
+ const matchedSessionIds = new Set();
82
+ const results = [];
83
+ for (const candidate of candidates) {
84
+ if (matchedPids.has(candidate.process.pid))
85
+ continue;
86
+ if (matchedSessionIds.has(candidate.session.sessionId))
87
+ continue;
88
+ matchedPids.add(candidate.process.pid);
89
+ matchedSessionIds.add(candidate.session.sessionId);
90
+ results.push(candidate);
91
+ }
92
+ return results;
93
+ }
94
+ /**
95
+ * Generate a deterministic agent name from CWD and PID.
96
+ *
97
+ * Format: "folderName (pid)"
98
+ */
99
+ function generateAgentName(cwd, pid) {
100
+ const folderName = path.basename(cwd) || 'unknown';
101
+ return `${folderName} (${pid})`;
102
+ }
103
+ //# sourceMappingURL=matching.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"matching.js","sourceRoot":"","sources":["../../src/utils/matching.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCH,4DAyCC;AAOD,8CAGC;AApFD,2CAA6B;AAI7B,oFAAoF;AACpF,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,YAAY;AAgBhD;;;;;;;;;;;GAWG;AACH,SAAgB,wBAAwB,CACpC,SAAwB,EACxB,QAAuB;IAEvB,4BAA4B;IAC5B,MAAM,UAAU,GAA2E,EAAE,CAAC;IAE9F,KAAK,MAAM,IAAI,IAAI,SAAS,EAAE,CAAC;QAC3B,IAAI,CAAC,IAAI,CAAC,SAAS,IAAI,CAAC,IAAI,CAAC,GAAG;YAAE,SAAS;QAE3C,MAAM,cAAc,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;QAEhD,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;YAC7B,IAAI,CAAC,OAAO,CAAC,WAAW;gBAAE,SAAS;YACnC,IAAI,IAAI,CAAC,GAAG,KAAK,OAAO,CAAC,WAAW;gBAAE,SAAS;YAE/C,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,cAAc,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;YAC/D,IAAI,OAAO,GAAG,YAAY;gBAAE,SAAS;YAErC,UAAU,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;QACzD,CAAC;IACL,CAAC;IAED,+BAA+B;IAC/B,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC;IAEjD,wBAAwB;IACxB,MAAM,WAAW,GAAG,IAAI,GAAG,EAAU,CAAC;IACtC,MAAM,iBAAiB,GAAG,IAAI,GAAG,EAAU,CAAC;IAC5C,MAAM,OAAO,GAAkB,EAAE,CAAC;IAElC,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACjC,IAAI,WAAW,CAAC,GAAG,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC;YAAE,SAAS;QACrD,IAAI,iBAAiB,CAAC,GAAG,CAAC,SAAS,CAAC,OAAO,CAAC,SAAS,CAAC;YAAE,SAAS;QAEjE,WAAW,CAAC,GAAG,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACvC,iBAAiB,CAAC,GAAG,CAAC,SAAS,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QACnD,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC5B,CAAC;IAED,OAAO,OAAO,CAAC;AACnB,CAAC;AAED;;;;GAIG;AACH,SAAgB,iBAAiB,CAAC,GAAW,EAAE,GAAW;IACtD,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,SAAS,CAAC;IACnD,OAAO,GAAG,UAAU,KAAK,GAAG,GAAG,CAAC;AACpC,CAAC"}
@@ -1,61 +1,46 @@
1
1
  /**
2
2
  * Process Detection Utilities
3
3
  *
4
- * Utilities for detecting and inspecting running processes on the system.
5
- * Primarily focused on macOS/Unix-like systems using the `ps` command.
4
+ * Shared shell command wrappers for detecting and inspecting running processes.
5
+ * All execSync calls for process data live here — adapters must not call execSync directly.
6
6
  */
7
7
  import type { ProcessInfo } from '../adapters/AgentAdapter';
8
8
  /**
9
- * Options for listing processes
10
- */
11
- export interface ListProcessesOptions {
12
- /** Filter processes by name pattern (case-insensitive) */
13
- namePattern?: string;
14
- /** Include only processes matching these PIDs */
15
- pids?: number[];
16
- }
17
- /**
18
- * List running processes on the system
9
+ * List running processes matching an agent executable name.
19
10
  *
20
- * @param options Filtering options
21
- * @returns Array of process information
11
+ * Uses `ps aux | grep <pattern>` at shell level for performance, then post-filters
12
+ * by checking that the executable basename matches exactly (avoids matching
13
+ * `claude-helper`, `vscode-claude-extension`, or the grep process itself).
22
14
  *
23
- * @example
24
- * ```typescript
25
- * // List all Claude Code processes
26
- * const processes = listProcesses({ namePattern: 'claude' });
27
- *
28
- * // Get specific process info
29
- * const process = listProcesses({ pids: [12345] });
30
- * ```
15
+ * Returned ProcessInfo has pid, command, tty populated.
16
+ * cwd and startTime are NOT populated — call enrichProcesses() to fill them.
31
17
  */
32
- export declare function listProcesses(options?: ListProcessesOptions): ProcessInfo[];
18
+ export declare function listAgentProcesses(namePattern: string): ProcessInfo[];
33
19
  /**
34
- * Get the current working directory for a specific process
20
+ * Batch-get current working directories for multiple PIDs.
35
21
  *
36
- * @param pid Process ID
37
- * @returns Working directory path, or empty string if unavailable
22
+ * Single `lsof -a -d cwd -Fn -p PID1,PID2,...` call.
23
+ * Returns partial results if lsof fails for one PID, others still return.
38
24
  */
39
- export declare function getProcessCwd(pid: number): string;
25
+ export declare function batchGetProcessCwds(pids: number[]): Map<number, string>;
40
26
  /**
41
- * Get the TTY device for a specific process
27
+ * Batch-get process start times for multiple PIDs.
42
28
  *
43
- * @param pid Process ID
44
- * @returns TTY device name (e.g., "ttys030"), or "?" if unavailable
29
+ * Single `ps -o pid=,lstart= -p PID1,PID2,...` call.
30
+ * Uses lstart format which gives full timestamp (e.g., "Thu Feb 5 16:00:57 2026").
31
+ * Returns partial results.
45
32
  */
46
- export declare function getProcessTty(pid: number): string;
33
+ export declare function batchGetProcessStartTimes(pids: number[]): Map<number, Date>;
47
34
  /**
48
- * Check if a process with the given PID is running
35
+ * Enrich ProcessInfo array with cwd and startTime.
49
36
  *
50
- * @param pid Process ID
51
- * @returns True if process is running
37
+ * Calls batchGetProcessCwds and batchGetProcessStartTimes in batched shell calls,
38
+ * then populates each ProcessInfo in-place. Returns partial results —
39
+ * if a PID fails, that process keeps empty cwd / undefined startTime.
52
40
  */
53
- export declare function isProcessRunning(pid: number): boolean;
41
+ export declare function enrichProcesses(processes: ProcessInfo[]): ProcessInfo[];
54
42
  /**
55
- * Get detailed information for a specific process
56
- *
57
- * @param pid Process ID
58
- * @returns Process information, or null if process not found
43
+ * Get the TTY device for a specific process
59
44
  */
60
- export declare function getProcessInfo(pid: number): ProcessInfo | null;
45
+ export declare function getProcessTty(pid: number): string;
61
46
  //# sourceMappingURL=process.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../../src/utils/process.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAE5D;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACjC,0DAA0D;IAC1D,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,iDAAiD;IACjD,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,aAAa,CAAC,OAAO,GAAE,oBAAyB,GAAG,WAAW,EAAE,CA2D/E;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAgCjD;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAYjD;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CASrD;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAG9D"}
1
+ {"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../../src/utils/process.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAE5D;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG,WAAW,EAAE,CAkDrE;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAoCvE;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAkC3E;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,WAAW,EAAE,GAAG,WAAW,EAAE,CAavE;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAWjD"}
@@ -2,165 +2,211 @@
2
2
  /**
3
3
  * Process Detection Utilities
4
4
  *
5
- * Utilities for detecting and inspecting running processes on the system.
6
- * Primarily focused on macOS/Unix-like systems using the `ps` command.
5
+ * Shared shell command wrappers for detecting and inspecting running processes.
6
+ * All execSync calls for process data live here — adapters must not call execSync directly.
7
7
  */
8
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ var desc = Object.getOwnPropertyDescriptor(m, k);
11
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
+ desc = { enumerable: true, get: function() { return m[k]; } };
13
+ }
14
+ Object.defineProperty(o, k2, desc);
15
+ }) : (function(o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ o[k2] = m[k];
18
+ }));
19
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
20
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
21
+ }) : function(o, v) {
22
+ o["default"] = v;
23
+ });
24
+ var __importStar = (this && this.__importStar) || (function () {
25
+ var ownKeys = function(o) {
26
+ ownKeys = Object.getOwnPropertyNames || function (o) {
27
+ var ar = [];
28
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
+ return ar;
30
+ };
31
+ return ownKeys(o);
32
+ };
33
+ return function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ })();
8
41
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.listProcesses = listProcesses;
10
- exports.getProcessCwd = getProcessCwd;
42
+ exports.listAgentProcesses = listAgentProcesses;
43
+ exports.batchGetProcessCwds = batchGetProcessCwds;
44
+ exports.batchGetProcessStartTimes = batchGetProcessStartTimes;
45
+ exports.enrichProcesses = enrichProcesses;
11
46
  exports.getProcessTty = getProcessTty;
12
- exports.isProcessRunning = isProcessRunning;
13
- exports.getProcessInfo = getProcessInfo;
47
+ const path = __importStar(require("path"));
14
48
  const child_process_1 = require("child_process");
15
49
  /**
16
- * List running processes on the system
17
- *
18
- * @param options Filtering options
19
- * @returns Array of process information
50
+ * List running processes matching an agent executable name.
20
51
  *
21
- * @example
22
- * ```typescript
23
- * // List all Claude Code processes
24
- * const processes = listProcesses({ namePattern: 'claude' });
52
+ * Uses `ps aux | grep <pattern>` at shell level for performance, then post-filters
53
+ * by checking that the executable basename matches exactly (avoids matching
54
+ * `claude-helper`, `vscode-claude-extension`, or the grep process itself).
25
55
  *
26
- * // Get specific process info
27
- * const process = listProcesses({ pids: [12345] });
28
- * ```
56
+ * Returned ProcessInfo has pid, command, tty populated.
57
+ * cwd and startTime are NOT populated — call enrichProcesses() to fill them.
29
58
  */
30
- function listProcesses(options = {}) {
59
+ function listAgentProcesses(namePattern) {
60
+ // Validate pattern contains only safe characters (alphanumeric, dash, underscore)
61
+ if (!namePattern || !/^[a-zA-Z0-9_-]+$/.test(namePattern)) {
62
+ return [];
63
+ }
31
64
  try {
32
- // Get all processes with full details
33
- // Format: user pid command
34
- const psOutput = (0, child_process_1.execSync)('ps aux', { encoding: 'utf-8' });
35
- const lines = psOutput.trim().split('\n');
36
- // Skip header line
37
- const processLines = lines.slice(1);
65
+ // Use [c]laude trick to avoid matching the grep process itself
66
+ const escapedPattern = `[${namePattern[0]}]${namePattern.slice(1)}`;
67
+ const output = (0, child_process_1.execSync)(`ps aux | grep -i '${escapedPattern}'`, { encoding: 'utf-8' });
38
68
  const processes = [];
39
- for (const line of processLines) {
40
- // Parse ps aux output
41
- // Format: USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
69
+ for (const line of output.trim().split('\n')) {
70
+ if (!line.trim())
71
+ continue;
42
72
  const parts = line.trim().split(/\s+/);
43
73
  if (parts.length < 11)
44
74
  continue;
45
75
  const pid = parseInt(parts[1], 10);
46
- if (isNaN(pid))
76
+ if (Number.isNaN(pid))
47
77
  continue;
48
78
  const tty = parts[6];
49
79
  const command = parts.slice(10).join(' ');
50
- // Apply PID filter
51
- if (options.pids && !options.pids.includes(pid)) {
80
+ // Post-filter: check that the executable basename matches exactly
81
+ const executable = command.trim().split(/\s+/)[0] || '';
82
+ const base = path.basename(executable).toLowerCase();
83
+ if (base !== namePattern.toLowerCase() && base !== `${namePattern.toLowerCase()}.exe`) {
52
84
  continue;
53
85
  }
54
- // Apply name pattern filter (case-insensitive)
55
- if (options.namePattern) {
56
- const pattern = options.namePattern.toLowerCase();
57
- const commandLower = command.toLowerCase();
58
- if (!commandLower.includes(pattern)) {
59
- continue;
60
- }
61
- }
62
- // Get working directory for this process
63
- const cwd = getProcessCwd(pid);
64
- // Get TTY in short format (remove /dev/ prefix if present)
65
86
  const ttyShort = tty.startsWith('/dev/') ? tty.slice(5) : tty;
66
87
  processes.push({
67
88
  pid,
68
89
  command,
69
- cwd,
90
+ cwd: '',
70
91
  tty: ttyShort,
71
92
  });
72
93
  }
73
94
  return processes;
74
95
  }
75
- catch (error) {
76
- // If ps command fails, return empty array
77
- console.error('Failed to list processes:', error);
96
+ catch {
78
97
  return [];
79
98
  }
80
99
  }
81
100
  /**
82
- * Get the current working directory for a specific process
101
+ * Batch-get current working directories for multiple PIDs.
83
102
  *
84
- * @param pid Process ID
85
- * @returns Working directory path, or empty string if unavailable
103
+ * Single `lsof -a -d cwd -Fn -p PID1,PID2,...` call.
104
+ * Returns partial results if lsof fails for one PID, others still return.
86
105
  */
87
- function getProcessCwd(pid) {
106
+ function batchGetProcessCwds(pids) {
107
+ const result = new Map();
108
+ if (pids.length === 0)
109
+ return result;
88
110
  try {
89
- // Use lsof to get the current working directory
90
- // -a: AND the selections, -d cwd: get cwd only, -Fn: output format (file names only)
91
- const output = (0, child_process_1.execSync)(`lsof -a -p ${pid} -d cwd -Fn 2>/dev/null`, {
92
- encoding: 'utf-8',
93
- });
94
- // Parse lsof output
95
- // Format: p{PID}\nn{path}
96
- const lines = output.trim().split('\n');
97
- for (const line of lines) {
98
- if (line.startsWith('n')) {
99
- return line.slice(1); // Remove 'n' prefix
111
+ const output = (0, child_process_1.execSync)(`lsof -a -d cwd -Fn -p ${pids.join(',')} 2>/dev/null`, { encoding: 'utf-8' });
112
+ // lsof output format: p{PID}\nn{path}\np{PID}\nn{path}...
113
+ let currentPid = null;
114
+ for (const line of output.trim().split('\n')) {
115
+ if (line.startsWith('p')) {
116
+ currentPid = parseInt(line.slice(1), 10);
117
+ }
118
+ else if (line.startsWith('n') && currentPid !== null) {
119
+ result.set(currentPid, line.slice(1));
120
+ currentPid = null;
100
121
  }
101
122
  }
102
- return '';
103
123
  }
104
- catch (error) {
105
- // If lsof fails, try alternative method using pwdx (Linux)
106
- try {
107
- const output = (0, child_process_1.execSync)(`pwdx ${pid} 2>/dev/null`, {
108
- encoding: 'utf-8',
109
- });
110
- // Format: {PID}: {path}
111
- const match = output.match(/^\d+:\s*(.+)$/);
112
- return match ? match[1].trim() : '';
113
- }
114
- catch {
115
- // Both methods failed
116
- return '';
124
+ catch {
125
+ // Try per-PID fallback with pwdx (Linux)
126
+ for (const pid of pids) {
127
+ try {
128
+ const output = (0, child_process_1.execSync)(`pwdx ${pid} 2>/dev/null`, { encoding: 'utf-8' });
129
+ const match = output.match(/^\d+:\s*(.+)$/);
130
+ if (match) {
131
+ result.set(pid, match[1].trim());
132
+ }
133
+ }
134
+ catch {
135
+ // Skip this PID
136
+ }
117
137
  }
118
138
  }
139
+ return result;
119
140
  }
120
141
  /**
121
- * Get the TTY device for a specific process
142
+ * Batch-get process start times for multiple PIDs.
122
143
  *
123
- * @param pid Process ID
124
- * @returns TTY device name (e.g., "ttys030"), or "?" if unavailable
144
+ * Single `ps -o pid=,lstart= -p PID1,PID2,...` call.
145
+ * Uses lstart format which gives full timestamp (e.g., "Thu Feb 5 16:00:57 2026").
146
+ * Returns partial results.
125
147
  */
126
- function getProcessTty(pid) {
148
+ function batchGetProcessStartTimes(pids) {
149
+ const result = new Map();
150
+ if (pids.length === 0)
151
+ return result;
127
152
  try {
128
- const output = (0, child_process_1.execSync)(`ps -p ${pid} -o tty=`, {
129
- encoding: 'utf-8',
130
- });
131
- const tty = output.trim();
132
- // Remove /dev/ prefix if present
133
- return tty.startsWith('/dev/') ? tty.slice(5) : tty;
153
+ const output = (0, child_process_1.execSync)(`ps -o pid=,lstart= -p ${pids.join(',')}`, { encoding: 'utf-8' });
154
+ for (const rawLine of output.split('\n')) {
155
+ const line = rawLine.trim();
156
+ if (!line)
157
+ continue;
158
+ // Format: " PID DAY MON DD HH:MM:SS YYYY"
159
+ // e.g., " 78070 Wed Mar 18 23:18:01 2026"
160
+ const match = line.match(/^\s*(\d+)\s+(.+)$/);
161
+ if (!match)
162
+ continue;
163
+ const pid = parseInt(match[1], 10);
164
+ const dateStr = match[2].trim();
165
+ if (!Number.isFinite(pid))
166
+ continue;
167
+ const date = new Date(dateStr);
168
+ if (!Number.isNaN(date.getTime())) {
169
+ result.set(pid, date);
170
+ }
171
+ }
134
172
  }
135
- catch (error) {
136
- return '?';
173
+ catch {
174
+ // Return whatever we have
137
175
  }
176
+ return result;
138
177
  }
139
178
  /**
140
- * Check if a process with the given PID is running
179
+ * Enrich ProcessInfo array with cwd and startTime.
141
180
  *
142
- * @param pid Process ID
143
- * @returns True if process is running
181
+ * Calls batchGetProcessCwds and batchGetProcessStartTimes in batched shell calls,
182
+ * then populates each ProcessInfo in-place. Returns partial results —
183
+ * if a PID fails, that process keeps empty cwd / undefined startTime.
144
184
  */
145
- function isProcessRunning(pid) {
146
- try {
147
- // Send signal 0 to check if process exists
148
- // This doesn't actually send a signal, just checks if we can
149
- (0, child_process_1.execSync)(`kill -0 ${pid} 2>/dev/null`);
150
- return true;
151
- }
152
- catch {
153
- return false;
185
+ function enrichProcesses(processes) {
186
+ if (processes.length === 0)
187
+ return processes;
188
+ const pids = processes.map(p => p.pid);
189
+ const cwdMap = batchGetProcessCwds(pids);
190
+ const startTimeMap = batchGetProcessStartTimes(pids);
191
+ for (const proc of processes) {
192
+ proc.cwd = cwdMap.get(proc.pid) || '';
193
+ proc.startTime = startTimeMap.get(proc.pid);
154
194
  }
195
+ return processes;
155
196
  }
156
197
  /**
157
- * Get detailed information for a specific process
158
- *
159
- * @param pid Process ID
160
- * @returns Process information, or null if process not found
198
+ * Get the TTY device for a specific process
161
199
  */
162
- function getProcessInfo(pid) {
163
- const processes = listProcesses({ pids: [pid] });
164
- return processes.length > 0 ? processes[0] : null;
200
+ function getProcessTty(pid) {
201
+ try {
202
+ const output = (0, child_process_1.execSync)(`ps -p ${pid} -o tty=`, {
203
+ encoding: 'utf-8',
204
+ });
205
+ const tty = output.trim();
206
+ return tty.startsWith('/dev/') ? tty.slice(5) : tty;
207
+ }
208
+ catch {
209
+ return '?';
210
+ }
165
211
  }
166
212
  //# sourceMappingURL=process.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"process.js","sourceRoot":"","sources":["../../src/utils/process.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AA+BH,sCA2DC;AAQD,sCAgCC;AAQD,sCAYC;AAQD,4CASC;AAQD,wCAGC;AAhLD,iDAAyC;AAczC;;;;;;;;;;;;;;GAcG;AACH,SAAgB,aAAa,CAAC,UAAgC,EAAE;IAC5D,IAAI,CAAC;QACD,sCAAsC;QACtC,2BAA2B;QAC3B,MAAM,QAAQ,GAAG,IAAA,wBAAQ,EAAC,QAAQ,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;QAE3D,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC1C,mBAAmB;QACnB,MAAM,YAAY,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAEpC,MAAM,SAAS,GAAkB,EAAE,CAAC;QAEpC,KAAK,MAAM,IAAI,IAAI,YAAY,EAAE,CAAC;YAC9B,sBAAsB;YACtB,iEAAiE;YACjE,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YAEvC,IAAI,KAAK,CAAC,MAAM,GAAG,EAAE;gBAAE,SAAS;YAEhC,MAAM,GAAG,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YACnC,IAAI,KAAK,CAAC,GAAG,CAAC;gBAAE,SAAS;YAEzB,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;YACrB,MAAM,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAE1C,mBAAmB;YACnB,IAAI,OAAO,CAAC,IAAI,IAAI,C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