@ai-devkit/agent-manager 0.1.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 (57) hide show
  1. package/.eslintrc.json +31 -0
  2. package/dist/AgentManager.d.ts +104 -0
  3. package/dist/AgentManager.d.ts.map +1 -0
  4. package/dist/AgentManager.js +185 -0
  5. package/dist/AgentManager.js.map +1 -0
  6. package/dist/adapters/AgentAdapter.d.ts +76 -0
  7. package/dist/adapters/AgentAdapter.d.ts.map +1 -0
  8. package/dist/adapters/AgentAdapter.js +20 -0
  9. package/dist/adapters/AgentAdapter.js.map +1 -0
  10. package/dist/adapters/ClaudeCodeAdapter.d.ts +58 -0
  11. package/dist/adapters/ClaudeCodeAdapter.d.ts.map +1 -0
  12. package/dist/adapters/ClaudeCodeAdapter.js +274 -0
  13. package/dist/adapters/ClaudeCodeAdapter.js.map +1 -0
  14. package/dist/adapters/index.d.ts +4 -0
  15. package/dist/adapters/index.d.ts.map +1 -0
  16. package/dist/adapters/index.js +8 -0
  17. package/dist/adapters/index.js.map +1 -0
  18. package/dist/index.d.ts +10 -0
  19. package/dist/index.d.ts.map +1 -0
  20. package/dist/index.js +23 -0
  21. package/dist/index.js.map +1 -0
  22. package/dist/terminal/TerminalFocusManager.d.ts +22 -0
  23. package/dist/terminal/TerminalFocusManager.d.ts.map +1 -0
  24. package/dist/terminal/TerminalFocusManager.js +196 -0
  25. package/dist/terminal/TerminalFocusManager.js.map +1 -0
  26. package/dist/terminal/index.d.ts +3 -0
  27. package/dist/terminal/index.d.ts.map +1 -0
  28. package/dist/terminal/index.js +6 -0
  29. package/dist/terminal/index.js.map +1 -0
  30. package/dist/utils/file.d.ts +52 -0
  31. package/dist/utils/file.d.ts.map +1 -0
  32. package/dist/utils/file.js +135 -0
  33. package/dist/utils/file.js.map +1 -0
  34. package/dist/utils/index.d.ts +4 -0
  35. package/dist/utils/index.d.ts.map +1 -0
  36. package/dist/utils/index.js +15 -0
  37. package/dist/utils/index.js.map +1 -0
  38. package/dist/utils/process.d.ts +61 -0
  39. package/dist/utils/process.d.ts.map +1 -0
  40. package/dist/utils/process.js +166 -0
  41. package/dist/utils/process.js.map +1 -0
  42. package/jest.config.js +21 -0
  43. package/package.json +42 -0
  44. package/project.json +29 -0
  45. package/src/AgentManager.ts +198 -0
  46. package/src/__tests__/AgentManager.test.ts +308 -0
  47. package/src/__tests__/adapters/ClaudeCodeAdapter.test.ts +286 -0
  48. package/src/adapters/AgentAdapter.ts +94 -0
  49. package/src/adapters/ClaudeCodeAdapter.ts +344 -0
  50. package/src/adapters/index.ts +3 -0
  51. package/src/index.ts +12 -0
  52. package/src/terminal/TerminalFocusManager.ts +206 -0
  53. package/src/terminal/index.ts +2 -0
  54. package/src/utils/file.ts +100 -0
  55. package/src/utils/index.ts +3 -0
  56. package/src/utils/process.ts +184 -0
  57. package/tsconfig.json +17 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../src/utils/file.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,GAAE,MAAY,GAAG,MAAM,EAAE,CAejF;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAAC,CAAC,GAAG,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAa,GAAG,CAAC,EAAE,CAUzF;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAMpD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,QAAQ,CAAC,CAAC,GAAG,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,CAAC,GAAG,IAAI,CAYhE"}
@@ -0,0 +1,135 @@
1
+ "use strict";
2
+ /**
3
+ * File Utilities
4
+ *
5
+ * Helper functions for reading files efficiently
6
+ */
7
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
+ if (k2 === undefined) k2 = k;
9
+ var desc = Object.getOwnPropertyDescriptor(m, k);
10
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11
+ desc = { enumerable: true, get: function() { return m[k]; } };
12
+ }
13
+ Object.defineProperty(o, k2, desc);
14
+ }) : (function(o, m, k, k2) {
15
+ if (k2 === undefined) k2 = k;
16
+ o[k2] = m[k];
17
+ }));
18
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
19
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
20
+ }) : function(o, v) {
21
+ o["default"] = v;
22
+ });
23
+ var __importStar = (this && this.__importStar) || (function () {
24
+ var ownKeys = function(o) {
25
+ ownKeys = Object.getOwnPropertyNames || function (o) {
26
+ var ar = [];
27
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
28
+ return ar;
29
+ };
30
+ return ownKeys(o);
31
+ };
32
+ return function (mod) {
33
+ if (mod && mod.__esModule) return mod;
34
+ var result = {};
35
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
36
+ __setModuleDefault(result, mod);
37
+ return result;
38
+ };
39
+ })();
40
+ Object.defineProperty(exports, "__esModule", { value: true });
41
+ exports.readLastLines = readLastLines;
42
+ exports.readJsonLines = readJsonLines;
43
+ exports.fileExists = fileExists;
44
+ exports.readJson = readJson;
45
+ const fs = __importStar(require("fs"));
46
+ /**
47
+ * Read last N lines from a file efficiently
48
+ *
49
+ * @param filePath Path to the file
50
+ * @param lineCount Number of lines to read from the end (default: 100)
51
+ * @returns Array of lines
52
+ *
53
+ * @example
54
+ * ```typescript
55
+ * const lastLines = readLastLines('/path/to/log.txt', 50);
56
+ * ```
57
+ */
58
+ function readLastLines(filePath, lineCount = 100) {
59
+ if (!fs.existsSync(filePath)) {
60
+ return [];
61
+ }
62
+ try {
63
+ const content = fs.readFileSync(filePath, 'utf-8');
64
+ const allLines = content.trim().split('\n');
65
+ // Return last N lines (or all if file has fewer lines)
66
+ return allLines.slice(-lineCount);
67
+ }
68
+ catch (error) {
69
+ console.error(`Failed to read ${filePath}:`, error);
70
+ return [];
71
+ }
72
+ }
73
+ /**
74
+ * Read a JSONL (JSON Lines) file and parse each line
75
+ *
76
+ * @param filePath Path to the JSONL file
77
+ * @param maxLines Maximum number of lines to read from end (default: 1000)
78
+ * @returns Array of parsed objects
79
+ *
80
+ * @example
81
+ * ```typescript
82
+ * const entries = readJsonLines<MyType>('/path/to/data.jsonl');
83
+ * const recent = readJsonLines<MyType>('/path/to/data.jsonl', 100);
84
+ * ```
85
+ */
86
+ function readJsonLines(filePath, maxLines = 1000) {
87
+ const lines = readLastLines(filePath, maxLines);
88
+ return lines.map(line => {
89
+ try {
90
+ return JSON.parse(line);
91
+ }
92
+ catch {
93
+ return null;
94
+ }
95
+ }).filter((entry) => entry !== null);
96
+ }
97
+ /**
98
+ * Check if a file exists
99
+ *
100
+ * @param filePath Path to check
101
+ * @returns True if file exists
102
+ */
103
+ function fileExists(filePath) {
104
+ try {
105
+ return fs.existsSync(filePath);
106
+ }
107
+ catch {
108
+ return false;
109
+ }
110
+ }
111
+ /**
112
+ * Read a JSON file safely
113
+ *
114
+ * @param filePath Path to JSON file
115
+ * @returns Parsed JSON object or null if error
116
+ *
117
+ * @example
118
+ * ```typescript
119
+ * const config = readJson<ConfigType>('/path/to/config.json');
120
+ * ```
121
+ */
122
+ function readJson(filePath) {
123
+ if (!fs.existsSync(filePath)) {
124
+ return null;
125
+ }
126
+ try {
127
+ const content = fs.readFileSync(filePath, 'utf-8');
128
+ return JSON.parse(content);
129
+ }
130
+ catch (error) {
131
+ console.error(`Failed to parse JSON from ${filePath}:`, error);
132
+ return null;
133
+ }
134
+ }
135
+ //# sourceMappingURL=file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file.js","sourceRoot":"","sources":["../../src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QAAgB;IACvC,IAAI,CAAC;QACD,OAAO,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IACnC,CAAC;IAAC,MAAM,CAAC;QACL,OAAO,KAAK,CAAC;IACjB,CAAC;AACL,CAAC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,QAAQ,CAAc,QAAgB;IAClD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC3B,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,IAAI,CAAC;QACD,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QACnD,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAM,CAAC;IACpC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,6BAA6B,QAAQ,GAAG,EAAE,KAAK,CAAC,CAAC;QAC/D,OAAO,IAAI,CAAC;IAChB,CAAC;AACL,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { listProcesses, getProcessCwd, getProcessTty, isProcessRunning, getProcessInfo } from './process';
2
+ export type { ListProcessesOptions } from './process';
3
+ export { readLastLines, readJsonLines, fileExists, readJson } from './file';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,aAAa,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC1G,YAAY,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC"}
@@ -0,0 +1,15 @@
1
+ "use strict";
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;
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; } });
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Process Detection Utilities
3
+ *
4
+ * Utilities for detecting and inspecting running processes on the system.
5
+ * Primarily focused on macOS/Unix-like systems using the `ps` command.
6
+ */
7
+ import type { ProcessInfo } from '../adapters/AgentAdapter';
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
19
+ *
20
+ * @param options Filtering options
21
+ * @returns Array of process information
22
+ *
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
+ * ```
31
+ */
32
+ export declare function listProcesses(options?: ListProcessesOptions): ProcessInfo[];
33
+ /**
34
+ * Get the current working directory for a specific process
35
+ *
36
+ * @param pid Process ID
37
+ * @returns Working directory path, or empty string if unavailable
38
+ */
39
+ export declare function getProcessCwd(pid: number): string;
40
+ /**
41
+ * Get the TTY device for a specific process
42
+ *
43
+ * @param pid Process ID
44
+ * @returns TTY device name (e.g., "ttys030"), or "?" if unavailable
45
+ */
46
+ export declare function getProcessTty(pid: number): string;
47
+ /**
48
+ * Check if a process with the given PID is running
49
+ *
50
+ * @param pid Process ID
51
+ * @returns True if process is running
52
+ */
53
+ export declare function isProcessRunning(pid: number): boolean;
54
+ /**
55
+ * Get detailed information for a specific process
56
+ *
57
+ * @param pid Process ID
58
+ * @returns Process information, or null if process not found
59
+ */
60
+ export declare function getProcessInfo(pid: number): ProcessInfo | null;
61
+ //# sourceMappingURL=process.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,166 @@
1
+ "use strict";
2
+ /**
3
+ * Process Detection Utilities
4
+ *
5
+ * Utilities for detecting and inspecting running processes on the system.
6
+ * Primarily focused on macOS/Unix-like systems using the `ps` command.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.listProcesses = listProcesses;
10
+ exports.getProcessCwd = getProcessCwd;
11
+ exports.getProcessTty = getProcessTty;
12
+ exports.isProcessRunning = isProcessRunning;
13
+ exports.getProcessInfo = getProcessInfo;
14
+ const child_process_1 = require("child_process");
15
+ /**
16
+ * List running processes on the system
17
+ *
18
+ * @param options Filtering options
19
+ * @returns Array of process information
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * // List all Claude Code processes
24
+ * const processes = listProcesses({ namePattern: 'claude' });
25
+ *
26
+ * // Get specific process info
27
+ * const process = listProcesses({ pids: [12345] });
28
+ * ```
29
+ */
30
+ function listProcesses(options = {}) {
31
+ 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);
38
+ 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
42
+ const parts = line.trim().split(/\s+/);
43
+ if (parts.length < 11)
44
+ continue;
45
+ const pid = parseInt(parts[1], 10);
46
+ if (isNaN(pid))
47
+ continue;
48
+ const tty = parts[6];
49
+ const command = parts.slice(10).join(' ');
50
+ // Apply PID filter
51
+ if (options.pids && !options.pids.includes(pid)) {
52
+ continue;
53
+ }
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
+ const ttyShort = tty.startsWith('/dev/') ? tty.slice(5) : tty;
66
+ processes.push({
67
+ pid,
68
+ command,
69
+ cwd,
70
+ tty: ttyShort,
71
+ });
72
+ }
73
+ return processes;
74
+ }
75
+ catch (error) {
76
+ // If ps command fails, return empty array
77
+ console.error('Failed to list processes:', error);
78
+ return [];
79
+ }
80
+ }
81
+ /**
82
+ * Get the current working directory for a specific process
83
+ *
84
+ * @param pid Process ID
85
+ * @returns Working directory path, or empty string if unavailable
86
+ */
87
+ function getProcessCwd(pid) {
88
+ 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
100
+ }
101
+ }
102
+ return '';
103
+ }
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 '';
117
+ }
118
+ }
119
+ }
120
+ /**
121
+ * Get the TTY device for a specific process
122
+ *
123
+ * @param pid Process ID
124
+ * @returns TTY device name (e.g., "ttys030"), or "?" if unavailable
125
+ */
126
+ function getProcessTty(pid) {
127
+ 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;
134
+ }
135
+ catch (error) {
136
+ return '?';
137
+ }
138
+ }
139
+ /**
140
+ * Check if a process with the given PID is running
141
+ *
142
+ * @param pid Process ID
143
+ * @returns True if process is running
144
+ */
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;
154
+ }
155
+ }
156
+ /**
157
+ * Get detailed information for a specific process
158
+ *
159
+ * @param pid Process ID
160
+ * @returns Process information, or null if process not found
161
+ */
162
+ function getProcessInfo(pid) {
163
+ const processes = listProcesses({ pids: [pid] });
164
+ return processes.length > 0 ? processes[0] : null;
165
+ }
166
+ //# sourceMappingURL=process.js.map
@@ -0,0 +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;QAC3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C,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AACtD,CAAC"}
package/jest.config.js ADDED
@@ -0,0 +1,21 @@
1
+ module.exports = {
2
+ preset: 'ts-jest',
3
+ testEnvironment: 'node',
4
+ roots: ['<rootDir>/src'],
5
+ testMatch: ['**/__tests__/**/*.test.ts', '**/?(*.)+(spec|test).ts'],
6
+ collectCoverageFrom: [
7
+ 'src/**/*.{ts,js}',
8
+ '!src/**/*.d.ts',
9
+ '!src/index.ts'
10
+ ],
11
+ coverageDirectory: 'coverage',
12
+ coverageReporters: ['text', 'lcov', 'html'],
13
+ coverageThreshold: {
14
+ global: {
15
+ branches: 80,
16
+ functions: 80,
17
+ lines: 80,
18
+ statements: 80
19
+ }
20
+ }
21
+ };
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@ai-devkit/agent-manager",
3
+ "version": "0.1.0",
4
+ "description": "Standalone agent detection and management utilities for AI DevKit",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "default": "./dist/index.js"
11
+ }
12
+ },
13
+ "scripts": {
14
+ "build": "tsc",
15
+ "test": "jest",
16
+ "test:coverage": "jest --coverage",
17
+ "lint": "eslint src --ext .ts",
18
+ "typecheck": "tsc --noEmit",
19
+ "clean": "rm -rf dist"
20
+ },
21
+ "keywords": [
22
+ "ai",
23
+ "agent",
24
+ "manager",
25
+ "claude"
26
+ ],
27
+ "author": "",
28
+ "license": "MIT",
29
+ "devDependencies": {
30
+ "@types/jest": "^30.0.0",
31
+ "@types/node": "^20.11.5",
32
+ "@typescript-eslint/eslint-plugin": "^6.19.1",
33
+ "@typescript-eslint/parser": "^6.19.1",
34
+ "eslint": "^8.56.0",
35
+ "jest": "^29.7.0",
36
+ "ts-jest": "^29.4.5",
37
+ "typescript": "^5.3.3"
38
+ },
39
+ "engines": {
40
+ "node": ">=16.0.0"
41
+ }
42
+ }
package/project.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "agent-manager",
3
+ "root": "packages/agent-manager",
4
+ "sourceRoot": "packages/agent-manager/src",
5
+ "projectType": "library",
6
+ "targets": {
7
+ "build": {
8
+ "executor": "nx:run-commands",
9
+ "options": {
10
+ "command": "npm run build",
11
+ "cwd": "packages/agent-manager"
12
+ }
13
+ },
14
+ "test": {
15
+ "executor": "nx:run-commands",
16
+ "options": {
17
+ "command": "npm run test",
18
+ "cwd": "packages/agent-manager"
19
+ }
20
+ },
21
+ "lint": {
22
+ "executor": "nx:run-commands",
23
+ "options": {
24
+ "command": "npm run lint",
25
+ "cwd": "packages/agent-manager"
26
+ }
27
+ }
28
+ }
29
+ }