@inkeep/agents-cli 0.1.0 → 0.1.1
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/LICENSE.md +22 -17
- package/README.md +1 -13
- package/dist/__tests__/config-validation.test.js +0 -8
- package/dist/__tests__/utils/ts-loader.test.js +0 -1
- package/dist/commands/pull.js +0 -8
- package/dist/config.d.ts +6 -36
- package/dist/config.js +9 -292
- package/dist/index.d.ts +2 -2
- package/dist/index.js +37398 -96
- package/dist/index.js.map +7 -0
- package/dist/utils/ts-loader.js +0 -1
- package/package.json +20 -19
- package/dist/__tests__/commands/pull-retry.test.d.ts +0 -1
- package/dist/__tests__/commands/pull-retry.test.js +0 -156
- package/dist/__tests__/utils/port-manager.test.d.ts +0 -1
- package/dist/__tests__/utils/port-manager.test.js +0 -144
- package/dist/commands/mcp-list.d.ts +0 -4
- package/dist/commands/mcp-list.js +0 -156
- package/dist/commands/mcp-start-simple.d.ts +0 -5
- package/dist/commands/mcp-start-simple.js +0 -193
- package/dist/commands/mcp-start.d.ts +0 -5
- package/dist/commands/mcp-start.js +0 -217
- package/dist/commands/mcp-status.d.ts +0 -1
- package/dist/commands/mcp-status.js +0 -96
- package/dist/commands/mcp-stop.d.ts +0 -5
- package/dist/commands/mcp-stop.js +0 -160
- package/dist/utils/port-manager.d.ts +0 -43
- package/dist/utils/port-manager.js +0 -92
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Manages dynamic port allocation for local MCP servers
|
|
3
|
-
*/
|
|
4
|
-
export declare class PortManager {
|
|
5
|
-
private static instance;
|
|
6
|
-
private static readonly BASE_PORT;
|
|
7
|
-
private static readonly MAX_PORT;
|
|
8
|
-
private allocatedPorts;
|
|
9
|
-
private constructor();
|
|
10
|
-
static getInstance(): PortManager;
|
|
11
|
-
/**
|
|
12
|
-
* Allocate an available port in the configured range
|
|
13
|
-
*/
|
|
14
|
-
allocatePort(preferredPort?: number): Promise<number>;
|
|
15
|
-
/**
|
|
16
|
-
* Release a previously allocated port
|
|
17
|
-
*/
|
|
18
|
-
releasePort(port: number): void;
|
|
19
|
-
/**
|
|
20
|
-
* Release all allocated ports
|
|
21
|
-
*/
|
|
22
|
-
releaseAll(): void;
|
|
23
|
-
/**
|
|
24
|
-
* Check if a specific port is available
|
|
25
|
-
*/
|
|
26
|
-
private isPortAvailable;
|
|
27
|
-
/**
|
|
28
|
-
* Get list of currently allocated ports
|
|
29
|
-
*/
|
|
30
|
-
getAllocatedPorts(): number[];
|
|
31
|
-
/**
|
|
32
|
-
* Get port allocation statistics
|
|
33
|
-
*/
|
|
34
|
-
getStats(): {
|
|
35
|
-
allocated: number;
|
|
36
|
-
available: number;
|
|
37
|
-
range: {
|
|
38
|
-
min: number;
|
|
39
|
-
max: number;
|
|
40
|
-
};
|
|
41
|
-
ports: number[];
|
|
42
|
-
};
|
|
43
|
-
}
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { createServer } from 'node:net';
|
|
2
|
-
/**
|
|
3
|
-
* Manages dynamic port allocation for local MCP servers
|
|
4
|
-
*/
|
|
5
|
-
export class PortManager {
|
|
6
|
-
static instance;
|
|
7
|
-
static BASE_PORT = 3100;
|
|
8
|
-
static MAX_PORT = 3200;
|
|
9
|
-
allocatedPorts = new Set();
|
|
10
|
-
constructor() { }
|
|
11
|
-
static getInstance() {
|
|
12
|
-
if (!PortManager.instance) {
|
|
13
|
-
PortManager.instance = new PortManager();
|
|
14
|
-
}
|
|
15
|
-
return PortManager.instance;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Allocate an available port in the configured range
|
|
19
|
-
*/
|
|
20
|
-
async allocatePort(preferredPort) {
|
|
21
|
-
// If a preferred port is provided and available, use it
|
|
22
|
-
if (preferredPort) {
|
|
23
|
-
const isAvailable = await this.isPortAvailable(preferredPort);
|
|
24
|
-
if (isAvailable && !this.allocatedPorts.has(preferredPort)) {
|
|
25
|
-
this.allocatedPorts.add(preferredPort);
|
|
26
|
-
return preferredPort;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
// Find next available port in range
|
|
30
|
-
for (let port = PortManager.BASE_PORT; port <= PortManager.MAX_PORT; port++) {
|
|
31
|
-
if (this.allocatedPorts.has(port)) {
|
|
32
|
-
continue;
|
|
33
|
-
}
|
|
34
|
-
const isAvailable = await this.isPortAvailable(port);
|
|
35
|
-
if (isAvailable) {
|
|
36
|
-
this.allocatedPorts.add(port);
|
|
37
|
-
return port;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
throw new Error(`No available ports in range ${PortManager.BASE_PORT}-${PortManager.MAX_PORT}`);
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Release a previously allocated port
|
|
44
|
-
*/
|
|
45
|
-
releasePort(port) {
|
|
46
|
-
this.allocatedPorts.delete(port);
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Release all allocated ports
|
|
50
|
-
*/
|
|
51
|
-
releaseAll() {
|
|
52
|
-
this.allocatedPorts.clear();
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Check if a specific port is available
|
|
56
|
-
*/
|
|
57
|
-
async isPortAvailable(port) {
|
|
58
|
-
return new Promise((resolve) => {
|
|
59
|
-
const server = createServer();
|
|
60
|
-
server.once('error', () => {
|
|
61
|
-
resolve(false);
|
|
62
|
-
});
|
|
63
|
-
server.once('listening', () => {
|
|
64
|
-
server.close(() => {
|
|
65
|
-
resolve(true);
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
server.listen(port, '127.0.0.1');
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Get list of currently allocated ports
|
|
73
|
-
*/
|
|
74
|
-
getAllocatedPorts() {
|
|
75
|
-
return Array.from(this.allocatedPorts).sort((a, b) => a - b);
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Get port allocation statistics
|
|
79
|
-
*/
|
|
80
|
-
getStats() {
|
|
81
|
-
const totalPorts = PortManager.MAX_PORT - PortManager.BASE_PORT + 1;
|
|
82
|
-
return {
|
|
83
|
-
allocated: this.allocatedPorts.size,
|
|
84
|
-
available: totalPorts - this.allocatedPorts.size,
|
|
85
|
-
range: {
|
|
86
|
-
min: PortManager.BASE_PORT,
|
|
87
|
-
max: PortManager.MAX_PORT,
|
|
88
|
-
},
|
|
89
|
-
ports: this.getAllocatedPorts(),
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
}
|