agent-web-interface 4.1.1 → 4.2.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/src/browser/session-manager.d.ts +28 -1
- package/dist/src/browser/session-manager.d.ts.map +1 -1
- package/dist/src/browser/session-manager.js +73 -0
- package/dist/src/browser/session-manager.js.map +1 -1
- package/dist/src/index.d.ts +10 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +47 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/server/mcp-server.d.ts +14 -1
- package/dist/src/server/mcp-server.d.ts.map +1 -1
- package/dist/src/server/mcp-server.js +21 -6
- package/dist/src/server/mcp-server.js.map +1 -1
- package/dist/src/server/session-store.d.ts +18 -3
- package/dist/src/server/session-store.d.ts.map +1 -1
- package/dist/src/server/session-store.js +27 -3
- package/dist/src/server/session-store.js.map +1 -1
- package/dist/src/session/session-worker-binding.d.ts +57 -0
- package/dist/src/session/session-worker-binding.d.ts.map +1 -0
- package/dist/src/session/session-worker-binding.js +109 -0
- package/dist/src/session/session-worker-binding.js.map +1 -0
- package/dist/src/shared/services/logging.service.d.ts +8 -0
- package/dist/src/shared/services/logging.service.d.ts.map +1 -1
- package/dist/src/shared/services/logging.service.js +10 -0
- package/dist/src/shared/services/logging.service.js.map +1 -1
- package/dist/src/snapshot/snapshot-compiler.d.ts.map +1 -1
- package/dist/src/snapshot/snapshot-compiler.js +68 -1
- package/dist/src/snapshot/snapshot-compiler.js.map +1 -1
- package/dist/src/tools/tool-schemas.d.ts +22 -22
- package/dist/src/tools/tool-schemas.d.ts.map +1 -1
- package/dist/src/tools/tool-schemas.js.map +1 -1
- package/dist/src/worker/chrome-worker-process.d.ts +123 -0
- package/dist/src/worker/chrome-worker-process.d.ts.map +1 -0
- package/dist/src/worker/chrome-worker-process.js +294 -0
- package/dist/src/worker/chrome-worker-process.js.map +1 -0
- package/dist/src/worker/errors/index.d.ts +5 -0
- package/dist/src/worker/errors/index.d.ts.map +1 -0
- package/dist/src/worker/errors/index.js +5 -0
- package/dist/src/worker/errors/index.js.map +1 -0
- package/dist/src/worker/errors/worker.error.d.ts +122 -0
- package/dist/src/worker/errors/worker.error.d.ts.map +1 -0
- package/dist/src/worker/errors/worker.error.js +199 -0
- package/dist/src/worker/errors/worker.error.js.map +1 -0
- package/dist/src/worker/health-monitor.d.ts +141 -0
- package/dist/src/worker/health-monitor.d.ts.map +1 -0
- package/dist/src/worker/health-monitor.js +260 -0
- package/dist/src/worker/health-monitor.js.map +1 -0
- package/dist/src/worker/index.d.ts +16 -0
- package/dist/src/worker/index.d.ts.map +1 -0
- package/dist/src/worker/index.js +19 -0
- package/dist/src/worker/index.js.map +1 -0
- package/dist/src/worker/lease-manager.d.ts +137 -0
- package/dist/src/worker/lease-manager.d.ts.map +1 -0
- package/dist/src/worker/lease-manager.js +334 -0
- package/dist/src/worker/lease-manager.js.map +1 -0
- package/dist/src/worker/multi-tenant-config.d.ts +46 -0
- package/dist/src/worker/multi-tenant-config.d.ts.map +1 -0
- package/dist/src/worker/multi-tenant-config.js +94 -0
- package/dist/src/worker/multi-tenant-config.js.map +1 -0
- package/dist/src/worker/port-allocator.d.ts +96 -0
- package/dist/src/worker/port-allocator.d.ts.map +1 -0
- package/dist/src/worker/port-allocator.js +153 -0
- package/dist/src/worker/port-allocator.js.map +1 -0
- package/dist/src/worker/types.d.ts +218 -0
- package/dist/src/worker/types.d.ts.map +1 -0
- package/dist/src/worker/types.js +38 -0
- package/dist/src/worker/types.js.map +1 -0
- package/dist/src/worker/worker-manager.d.ts +157 -0
- package/dist/src/worker/worker-manager.d.ts.map +1 -0
- package/dist/src/worker/worker-manager.js +500 -0
- package/dist/src/worker/worker-manager.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Port Allocator
|
|
3
|
+
*
|
|
4
|
+
* Manages allocation and release of ports for Chrome CDP endpoints.
|
|
5
|
+
* Tracks which ports are in use and provides the next available port.
|
|
6
|
+
*/
|
|
7
|
+
import { createServer } from 'net';
|
|
8
|
+
import { WorkerError } from './errors/index.js';
|
|
9
|
+
/**
|
|
10
|
+
* Manages port allocation for Chrome CDP endpoints.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const allocator = new PortAllocator({ min: 9300, max: 9399 });
|
|
15
|
+
*
|
|
16
|
+
* const port1 = allocator.allocate(); // 9300
|
|
17
|
+
* const port2 = allocator.allocate(); // 9301
|
|
18
|
+
*
|
|
19
|
+
* allocator.release(port1); // Return 9300 to pool
|
|
20
|
+
* const port3 = allocator.allocate(); // 9300 (reused)
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export class PortAllocator {
|
|
24
|
+
min;
|
|
25
|
+
max;
|
|
26
|
+
allocatedPorts = new Set();
|
|
27
|
+
constructor(config) {
|
|
28
|
+
if (config.min > config.max) {
|
|
29
|
+
throw new Error(`Invalid port range: min (${config.min}) > max (${config.max})`);
|
|
30
|
+
}
|
|
31
|
+
if (config.min < 1 || config.max > 65535) {
|
|
32
|
+
throw new Error(`Port range must be between 1 and 65535`);
|
|
33
|
+
}
|
|
34
|
+
this.min = config.min;
|
|
35
|
+
this.max = config.max;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Get the port range configuration
|
|
39
|
+
*/
|
|
40
|
+
get portRange() {
|
|
41
|
+
return { min: this.min, max: this.max };
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Get the number of currently allocated ports
|
|
45
|
+
*/
|
|
46
|
+
get allocatedCount() {
|
|
47
|
+
return this.allocatedPorts.size;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Get the total capacity (max possible allocations)
|
|
51
|
+
*/
|
|
52
|
+
get capacity() {
|
|
53
|
+
return this.max - this.min + 1;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Allocate the next available port.
|
|
57
|
+
*
|
|
58
|
+
* @returns The allocated port number
|
|
59
|
+
* @throws WorkerError with PORT_EXHAUSTED if no ports are available
|
|
60
|
+
*/
|
|
61
|
+
allocate() {
|
|
62
|
+
for (let port = this.min; port <= this.max; port++) {
|
|
63
|
+
if (!this.allocatedPorts.has(port)) {
|
|
64
|
+
this.allocatedPorts.add(port);
|
|
65
|
+
return port;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
throw WorkerError.portExhausted(this.min, this.max, {
|
|
69
|
+
allocatedCount: this.allocatedPorts.size,
|
|
70
|
+
capacity: this.capacity,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Release a previously allocated port back to the pool.
|
|
75
|
+
*
|
|
76
|
+
* @param port - The port number to release
|
|
77
|
+
* @returns true if the port was released, false if it wasn't allocated
|
|
78
|
+
*/
|
|
79
|
+
release(port) {
|
|
80
|
+
return this.allocatedPorts.delete(port);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Check if a specific port is currently allocated.
|
|
84
|
+
*
|
|
85
|
+
* @param port - The port number to check
|
|
86
|
+
* @returns true if the port is allocated
|
|
87
|
+
*/
|
|
88
|
+
isAllocated(port) {
|
|
89
|
+
return this.allocatedPorts.has(port);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Check if a port is available for use by attempting to bind to it.
|
|
93
|
+
* This verifies that no other process is using the port.
|
|
94
|
+
*
|
|
95
|
+
* @param port - The port number to check
|
|
96
|
+
* @returns Promise that resolves to true if the port is available
|
|
97
|
+
*/
|
|
98
|
+
async isPortAvailable(port) {
|
|
99
|
+
return new Promise((resolve) => {
|
|
100
|
+
const server = createServer();
|
|
101
|
+
server.once('error', () => {
|
|
102
|
+
resolve(false);
|
|
103
|
+
});
|
|
104
|
+
server.once('listening', () => {
|
|
105
|
+
server.close(() => {
|
|
106
|
+
resolve(true);
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
server.listen(port, '127.0.0.1');
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Allocate a port that is verified to be available on the system.
|
|
114
|
+
* This is slower than allocate() but ensures the port can actually be used.
|
|
115
|
+
*
|
|
116
|
+
* @returns Promise that resolves to the allocated port number
|
|
117
|
+
* @throws WorkerError with PORT_EXHAUSTED if no available ports are found
|
|
118
|
+
*/
|
|
119
|
+
async allocateVerified() {
|
|
120
|
+
for (let port = this.min; port <= this.max; port++) {
|
|
121
|
+
if (!this.allocatedPorts.has(port)) {
|
|
122
|
+
// Reserve port before async check to prevent race condition
|
|
123
|
+
this.allocatedPorts.add(port);
|
|
124
|
+
const available = await this.isPortAvailable(port);
|
|
125
|
+
if (available) {
|
|
126
|
+
return port;
|
|
127
|
+
}
|
|
128
|
+
// Release if port is not actually available on the system
|
|
129
|
+
this.allocatedPorts.delete(port);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
throw WorkerError.portExhausted(this.min, this.max, {
|
|
133
|
+
allocatedCount: this.allocatedPorts.size,
|
|
134
|
+
capacity: this.capacity,
|
|
135
|
+
verified: true,
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Get all currently allocated ports.
|
|
140
|
+
*
|
|
141
|
+
* @returns Array of allocated port numbers
|
|
142
|
+
*/
|
|
143
|
+
getAllocatedPorts() {
|
|
144
|
+
return Array.from(this.allocatedPorts).sort((a, b) => a - b);
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Reset the allocator, releasing all ports.
|
|
148
|
+
*/
|
|
149
|
+
reset() {
|
|
150
|
+
this.allocatedPorts.clear();
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=port-allocator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"port-allocator.js","sourceRoot":"","sources":["../../../src/worker/port-allocator.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,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EAAE,EAAE,CAAC;YACnD,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;gBACnC,4DAA4D;gBAC5D,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;gBAC9B,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;gBACnD,IAAI,SAAS,EAAE,CAAC;oBACd,OAAO,IAAI,CAAC;gBACd,CAAC;gBACD,0DAA0D;gBAC1D,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YACnC,CAAC;QACH,CAAC;QAED,MAAM,WAAW,CAAC,aAAa,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE;YAClD,cAAc,EAAE,IAAI,CAAC,cAAc,CAAC,IAAI;YACxC,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,QAAQ,EAAE,IAAI;SACf,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,iBAAiB;QACf,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAC/D,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC;IAC9B,CAAC;CACF"}
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Worker Module Types
|
|
3
|
+
*
|
|
4
|
+
* Type definitions for the Browser Worker Manager system.
|
|
5
|
+
* Manages tenant-bound Chrome workers with exclusive lease-based access control.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Worker lifecycle states
|
|
9
|
+
*/
|
|
10
|
+
export type WorkerState = 'idle' | 'starting' | 'running' | 'stopping' | 'crashed' | 'stopped';
|
|
11
|
+
/**
|
|
12
|
+
* Lease status values
|
|
13
|
+
*/
|
|
14
|
+
export type LeaseStatus = 'active' | 'expired' | 'revoked';
|
|
15
|
+
/**
|
|
16
|
+
* Describes a Chrome worker instance
|
|
17
|
+
*/
|
|
18
|
+
export interface WorkerDescriptor {
|
|
19
|
+
/** Unique worker identifier */
|
|
20
|
+
workerId: string;
|
|
21
|
+
/** Tenant this worker is bound to */
|
|
22
|
+
tenantId: string;
|
|
23
|
+
/** Current worker state */
|
|
24
|
+
state: WorkerState;
|
|
25
|
+
/** CDP WebSocket endpoint (e.g., ws://127.0.0.1:9300/devtools/browser/...) */
|
|
26
|
+
cdpEndpoint?: string;
|
|
27
|
+
/** CDP port number */
|
|
28
|
+
port: number;
|
|
29
|
+
/** Chrome user data directory path */
|
|
30
|
+
profileDir: string;
|
|
31
|
+
/** Chrome process ID */
|
|
32
|
+
pid?: number;
|
|
33
|
+
/** When the worker was created */
|
|
34
|
+
createdAt: number;
|
|
35
|
+
/** When the worker was last used */
|
|
36
|
+
lastUsedAt: number;
|
|
37
|
+
/** When the worker started (state became 'running') */
|
|
38
|
+
startedAt?: number;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Describes an active lease on a worker
|
|
42
|
+
*/
|
|
43
|
+
export interface LeaseDescriptor {
|
|
44
|
+
/** Unique lease identifier */
|
|
45
|
+
leaseId: string;
|
|
46
|
+
/** Tenant holding the lease */
|
|
47
|
+
tenantId: string;
|
|
48
|
+
/** Worker being leased */
|
|
49
|
+
workerId: string;
|
|
50
|
+
/** When the lease was acquired */
|
|
51
|
+
acquiredAt: number;
|
|
52
|
+
/** When the lease expires (absolute timestamp) */
|
|
53
|
+
expiresAt: number;
|
|
54
|
+
/** Current lease status */
|
|
55
|
+
status: LeaseStatus;
|
|
56
|
+
/** Controller/session that holds the lease */
|
|
57
|
+
controllerId: string;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Result of attempting to acquire a lease
|
|
61
|
+
*/
|
|
62
|
+
export interface LeaseAcquisitionResult {
|
|
63
|
+
/** Whether the lease was acquired */
|
|
64
|
+
success: boolean;
|
|
65
|
+
/** The lease descriptor if successful */
|
|
66
|
+
lease?: LeaseDescriptor;
|
|
67
|
+
/** CDP endpoint if successful */
|
|
68
|
+
cdpEndpoint?: string;
|
|
69
|
+
/** Worker ID if successful */
|
|
70
|
+
workerId?: string;
|
|
71
|
+
/** Error message if unsuccessful */
|
|
72
|
+
error?: string;
|
|
73
|
+
/** Error code if unsuccessful */
|
|
74
|
+
errorCode?: string;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Configuration for the WorkerManager
|
|
78
|
+
*/
|
|
79
|
+
export interface WorkerManagerConfig {
|
|
80
|
+
/** Base directory for Chrome user data profiles */
|
|
81
|
+
profileBaseDir: string;
|
|
82
|
+
/** Time (ms) after which an idle worker is stopped */
|
|
83
|
+
idleTimeoutMs: number;
|
|
84
|
+
/** Maximum time (ms) a worker can run before forced restart */
|
|
85
|
+
hardTtlMs: number;
|
|
86
|
+
/** Default lease TTL (ms) */
|
|
87
|
+
leaseTtlMs: number;
|
|
88
|
+
/** Interval (ms) between health checks */
|
|
89
|
+
healthCheckIntervalMs: number;
|
|
90
|
+
/** Port range for CDP endpoints */
|
|
91
|
+
portRange: PortRange;
|
|
92
|
+
/** Maximum number of concurrent workers */
|
|
93
|
+
maxWorkers: number;
|
|
94
|
+
/** Path to Chrome executable (optional, auto-detected if not set) */
|
|
95
|
+
chromePath?: string;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Port range configuration
|
|
99
|
+
*/
|
|
100
|
+
export interface PortRange {
|
|
101
|
+
/** Minimum port number (inclusive) */
|
|
102
|
+
min: number;
|
|
103
|
+
/** Maximum port number (inclusive) */
|
|
104
|
+
max: number;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Health check result
|
|
108
|
+
*/
|
|
109
|
+
export interface HealthCheckResult {
|
|
110
|
+
/** Whether the worker is healthy */
|
|
111
|
+
healthy: boolean;
|
|
112
|
+
/** Response time in ms (if healthy) */
|
|
113
|
+
responseTimeMs?: number;
|
|
114
|
+
/** Error message (if unhealthy) */
|
|
115
|
+
error?: string;
|
|
116
|
+
/** CDP version info (if healthy) */
|
|
117
|
+
versionInfo?: CdpVersionInfo;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* CDP /json/version response
|
|
121
|
+
*/
|
|
122
|
+
export interface CdpVersionInfo {
|
|
123
|
+
Browser: string;
|
|
124
|
+
'Protocol-Version': string;
|
|
125
|
+
'User-Agent': string;
|
|
126
|
+
'V8-Version': string;
|
|
127
|
+
'WebKit-Version': string;
|
|
128
|
+
webSocketDebuggerUrl: string;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Events emitted by ChromeWorkerProcess
|
|
132
|
+
*/
|
|
133
|
+
export interface WorkerProcessEvents {
|
|
134
|
+
/** Emitted when the process starts successfully */
|
|
135
|
+
started: {
|
|
136
|
+
pid: number;
|
|
137
|
+
cdpEndpoint: string;
|
|
138
|
+
};
|
|
139
|
+
/** Emitted when the process exits */
|
|
140
|
+
exit: {
|
|
141
|
+
code: number | null;
|
|
142
|
+
signal: string | null;
|
|
143
|
+
};
|
|
144
|
+
/** Emitted on process error */
|
|
145
|
+
error: {
|
|
146
|
+
error: Error;
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Events emitted by HealthMonitor
|
|
151
|
+
*/
|
|
152
|
+
export interface HealthMonitorEvents {
|
|
153
|
+
/** Emitted when health state changes */
|
|
154
|
+
healthChange: {
|
|
155
|
+
workerId: string;
|
|
156
|
+
healthy: boolean;
|
|
157
|
+
result: HealthCheckResult;
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Events emitted by WorkerManager
|
|
162
|
+
*/
|
|
163
|
+
export interface WorkerManagerEvents {
|
|
164
|
+
/** Emitted when a worker is created */
|
|
165
|
+
workerCreated: {
|
|
166
|
+
workerId: string;
|
|
167
|
+
tenantId: string;
|
|
168
|
+
};
|
|
169
|
+
/** Emitted when a worker starts */
|
|
170
|
+
workerStarted: {
|
|
171
|
+
workerId: string;
|
|
172
|
+
tenantId: string;
|
|
173
|
+
cdpEndpoint: string;
|
|
174
|
+
};
|
|
175
|
+
/** Emitted when a worker stops */
|
|
176
|
+
workerStopped: {
|
|
177
|
+
workerId: string;
|
|
178
|
+
tenantId: string;
|
|
179
|
+
reason: string;
|
|
180
|
+
};
|
|
181
|
+
/** Emitted when a worker crashes */
|
|
182
|
+
workerCrashed: {
|
|
183
|
+
workerId: string;
|
|
184
|
+
tenantId: string;
|
|
185
|
+
exitCode: number | null;
|
|
186
|
+
};
|
|
187
|
+
/** Emitted when a lease is acquired */
|
|
188
|
+
leaseAcquired: {
|
|
189
|
+
leaseId: string;
|
|
190
|
+
tenantId: string;
|
|
191
|
+
controllerId: string;
|
|
192
|
+
};
|
|
193
|
+
/** Emitted when a lease is released */
|
|
194
|
+
leaseReleased: {
|
|
195
|
+
leaseId: string;
|
|
196
|
+
tenantId: string;
|
|
197
|
+
};
|
|
198
|
+
/** Emitted when a lease expires */
|
|
199
|
+
leaseExpired: {
|
|
200
|
+
leaseId: string;
|
|
201
|
+
tenantId: string;
|
|
202
|
+
};
|
|
203
|
+
/** Emitted when a lease is revoked */
|
|
204
|
+
leaseRevoked: {
|
|
205
|
+
leaseId: string;
|
|
206
|
+
tenantId: string;
|
|
207
|
+
reason: string;
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Default configuration values
|
|
212
|
+
*/
|
|
213
|
+
export declare const DEFAULT_WORKER_CONFIG: Omit<WorkerManagerConfig, 'profileBaseDir'>;
|
|
214
|
+
/**
|
|
215
|
+
* Chrome launch arguments for worker processes
|
|
216
|
+
*/
|
|
217
|
+
export declare const CHROME_WORKER_ARGS: readonly ["--disable-background-networking", "--disable-client-side-phishing-detection", "--disable-default-apps", "--disable-extensions", "--disable-hang-monitor", "--disable-popup-blocking", "--disable-prompt-on-repost", "--disable-sync", "--disable-translate", "--metrics-recording-only", "--no-first-run", "--safebrowsing-disable-auto-update"];
|
|
218
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/worker/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,UAAU,GAAG,SAAS,GAAG,UAAU,GAAG,SAAS,GAAG,SAAS,CAAC;AAE/F;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,CAAC;AAE3D;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,+BAA+B;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,qCAAqC;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,2BAA2B;IAC3B,KAAK,EAAE,WAAW,CAAC;IACnB,8EAA8E;IAC9E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sBAAsB;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,sCAAsC;IACtC,UAAU,EAAE,MAAM,CAAC;IACnB,wBAAwB;IACxB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,kCAAkC;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,oCAAoC;IACpC,UAAU,EAAE,MAAM,CAAC;IACnB,uDAAuD;IACvD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,8BAA8B;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,+BAA+B;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,0BAA0B;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,kCAAkC;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,kDAAkD;IAClD,SAAS,EA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AAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;IAC/E,uCAAuC;IACvC,aAAa,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,CAAC;IAC3E,uCAAuC;IACvC,aAAa,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;IACrD,mCAAmC;IACnC,YAAY,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;IACpD,sCAAsC;IACtC,YAAY,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CACrE;AAED;;GAEG;AACH,eAAO,MAAM,qBAAqB,EAAE,IAAI,CAAC,mBAAmB,EAAE,gBAAgB,CAU7E,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kBAAkB,6VAarB,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Worker Module Types
|
|
3
|
+
*
|
|
4
|
+
* Type definitions for the Browser Worker Manager system.
|
|
5
|
+
* Manages tenant-bound Chrome workers with exclusive lease-based access control.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Default configuration values
|
|
9
|
+
*/
|
|
10
|
+
export const DEFAULT_WORKER_CONFIG = {
|
|
11
|
+
idleTimeoutMs: 300_000, // 5 minutes
|
|
12
|
+
hardTtlMs: 7_200_000, // 2 hours
|
|
13
|
+
leaseTtlMs: 300_000, // 5 minutes
|
|
14
|
+
healthCheckIntervalMs: 30_000, // 30 seconds
|
|
15
|
+
portRange: {
|
|
16
|
+
min: 9300,
|
|
17
|
+
max: 9399,
|
|
18
|
+
},
|
|
19
|
+
maxWorkers: 100,
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Chrome launch arguments for worker processes
|
|
23
|
+
*/
|
|
24
|
+
export const CHROME_WORKER_ARGS = [
|
|
25
|
+
'--disable-background-networking',
|
|
26
|
+
'--disable-client-side-phishing-detection',
|
|
27
|
+
'--disable-default-apps',
|
|
28
|
+
'--disable-extensions',
|
|
29
|
+
'--disable-hang-monitor',
|
|
30
|
+
'--disable-popup-blocking',
|
|
31
|
+
'--disable-prompt-on-repost',
|
|
32
|
+
'--disable-sync',
|
|
33
|
+
'--disable-translate',
|
|
34
|
+
'--metrics-recording-only',
|
|
35
|
+
'--no-first-run',
|
|
36
|
+
'--safebrowsing-disable-auto-update',
|
|
37
|
+
];
|
|
38
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/worker/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAgLH;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAgD;IAChF,aAAa,EAAE,OAAO,EAAE,YAAY;IACpC,SAAS,EAAE,SAAS,EAAE,UAAU;IAChC,UAAU,EAAE,OAAO,EAAE,YAAY;IACjC,qBAAqB,EAAE,MAAM,EAAE,aAAa;IAC5C,SAAS,EAAE;QACT,GAAG,EAAE,IAAI;QACT,GAAG,EAAE,IAAI;KACV;IACD,UAAU,EAAE,GAAG;CAChB,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,iCAAiC;IACjC,0CAA0C;IAC1C,wBAAwB;IACxB,sBAAsB;IACtB,wBAAwB;IACxB,0BAA0B;IAC1B,4BAA4B;IAC5B,gBAAgB;IAChB,qBAAqB;IACrB,0BAA0B;IAC1B,gBAAgB;IAChB,oCAAoC;CAC5B,CAAC"}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Worker Manager
|
|
3
|
+
*
|
|
4
|
+
* Main orchestrator for managing tenant-bound Chrome workers with exclusive
|
|
5
|
+
* lease-based access control. Coordinates worker lifecycle, health monitoring,
|
|
6
|
+
* and lease management.
|
|
7
|
+
*/
|
|
8
|
+
import { EventEmitter } from 'events';
|
|
9
|
+
import type { WorkerManagerConfig, WorkerDescriptor, LeaseAcquisitionResult, WorkerManagerEvents } from './types.js';
|
|
10
|
+
/**
|
|
11
|
+
* Type-safe EventEmitter for WorkerManager
|
|
12
|
+
*/
|
|
13
|
+
interface WorkerManagerEmitter {
|
|
14
|
+
on<K extends keyof WorkerManagerEvents>(event: K, listener: (data: WorkerManagerEvents[K]) => void): this;
|
|
15
|
+
once<K extends keyof WorkerManagerEvents>(event: K, listener: (data: WorkerManagerEvents[K]) => void): this;
|
|
16
|
+
emit<K extends keyof WorkerManagerEvents>(event: K, data: WorkerManagerEvents[K]): boolean;
|
|
17
|
+
off<K extends keyof WorkerManagerEvents>(event: K, listener: (data: WorkerManagerEvents[K]) => void): this;
|
|
18
|
+
removeAllListeners<K extends keyof WorkerManagerEvents>(event?: K): this;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Manages tenant-bound Chrome workers with exclusive lease-based access.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* const manager = new WorkerManager({
|
|
26
|
+
* profileBaseDir: '/var/lib/athena/profiles',
|
|
27
|
+
* idleTimeoutMs: 300000,
|
|
28
|
+
* hardTtlMs: 7200000,
|
|
29
|
+
* leaseTtlMs: 300000,
|
|
30
|
+
* healthCheckIntervalMs: 30000,
|
|
31
|
+
* portRange: { min: 9300, max: 9399 },
|
|
32
|
+
* maxWorkers: 100,
|
|
33
|
+
* });
|
|
34
|
+
*
|
|
35
|
+
* // Acquire a worker for a tenant
|
|
36
|
+
* const result = await manager.acquireForTenant('tenant-a', 'controller-1');
|
|
37
|
+
* if (result.success) {
|
|
38
|
+
* console.log(`CDP endpoint: ${result.cdpEndpoint}`);
|
|
39
|
+
* }
|
|
40
|
+
*
|
|
41
|
+
* // Release when done
|
|
42
|
+
* manager.releaseLease('tenant-a');
|
|
43
|
+
*
|
|
44
|
+
* // Shutdown all workers
|
|
45
|
+
* await manager.shutdown();
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export declare class WorkerManager extends EventEmitter implements WorkerManagerEmitter {
|
|
49
|
+
private readonly config;
|
|
50
|
+
private readonly portAllocator;
|
|
51
|
+
private readonly healthMonitor;
|
|
52
|
+
private readonly leaseManager;
|
|
53
|
+
/** Worker entries by worker ID */
|
|
54
|
+
private readonly workers;
|
|
55
|
+
/** Tenant to worker ID mapping */
|
|
56
|
+
private readonly tenantToWorker;
|
|
57
|
+
private _isShuttingDown;
|
|
58
|
+
constructor(config: WorkerManagerConfig);
|
|
59
|
+
/**
|
|
60
|
+
* Get current worker count
|
|
61
|
+
*/
|
|
62
|
+
get workerCount(): number;
|
|
63
|
+
/**
|
|
64
|
+
* Get current lease count
|
|
65
|
+
*/
|
|
66
|
+
get leaseCount(): number;
|
|
67
|
+
/**
|
|
68
|
+
* Check if shutdown is in progress
|
|
69
|
+
*/
|
|
70
|
+
get isShuttingDown(): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Acquire a worker for a tenant.
|
|
73
|
+
* Creates a new worker if one doesn't exist for the tenant.
|
|
74
|
+
*
|
|
75
|
+
* @param tenantId - Tenant identifier
|
|
76
|
+
* @param controllerId - Controller/session identifier
|
|
77
|
+
* @param ttlMs - Optional custom lease TTL
|
|
78
|
+
* @returns Lease acquisition result with CDP endpoint
|
|
79
|
+
*/
|
|
80
|
+
acquireForTenant(tenantId: string, controllerId: string, ttlMs?: number): Promise<LeaseAcquisitionResult>;
|
|
81
|
+
/**
|
|
82
|
+
* Release a tenant's lease.
|
|
83
|
+
*
|
|
84
|
+
* @param tenantId - Tenant identifier
|
|
85
|
+
* @param controllerId - Optional controller ID to validate ownership
|
|
86
|
+
* @returns true if lease was released
|
|
87
|
+
*/
|
|
88
|
+
releaseLease(tenantId: string, controllerId?: string): boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Refresh a tenant's lease.
|
|
91
|
+
*
|
|
92
|
+
* @param tenantId - Tenant identifier
|
|
93
|
+
* @param ttlMs - Optional new TTL
|
|
94
|
+
* @returns true if lease was refreshed
|
|
95
|
+
*/
|
|
96
|
+
refreshLease(tenantId: string, ttlMs?: number): boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Get the CDP endpoint for a tenant's worker.
|
|
99
|
+
*
|
|
100
|
+
* @param tenantId - Tenant identifier
|
|
101
|
+
* @returns CDP endpoint URL or undefined if no active worker
|
|
102
|
+
*/
|
|
103
|
+
getCdpEndpoint(tenantId: string): string | undefined;
|
|
104
|
+
/**
|
|
105
|
+
* Check if a tenant has an active lease.
|
|
106
|
+
*/
|
|
107
|
+
hasActiveLease(tenantId: string): boolean;
|
|
108
|
+
/**
|
|
109
|
+
* Check if a specific controller holds the lease for a tenant.
|
|
110
|
+
*/
|
|
111
|
+
isLeaseHeldBy(tenantId: string, controllerId: string): boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Get worker descriptor for a tenant.
|
|
114
|
+
*/
|
|
115
|
+
getWorkerForTenant(tenantId: string): WorkerDescriptor | undefined;
|
|
116
|
+
/**
|
|
117
|
+
* Stop a specific worker.
|
|
118
|
+
*
|
|
119
|
+
* @param tenantId - Tenant identifier
|
|
120
|
+
* @param reason - Reason for stopping
|
|
121
|
+
*/
|
|
122
|
+
stopWorker(tenantId: string, reason: string): Promise<void>;
|
|
123
|
+
/**
|
|
124
|
+
* Shutdown the WorkerManager and all workers.
|
|
125
|
+
*/
|
|
126
|
+
shutdown(): Promise<void>;
|
|
127
|
+
/**
|
|
128
|
+
* Create a new worker for a tenant.
|
|
129
|
+
*/
|
|
130
|
+
private createWorker;
|
|
131
|
+
/**
|
|
132
|
+
* Clean up a worker.
|
|
133
|
+
*/
|
|
134
|
+
private cleanupWorker;
|
|
135
|
+
/**
|
|
136
|
+
* Set up event handlers for sub-components.
|
|
137
|
+
*/
|
|
138
|
+
private setupEventHandlers;
|
|
139
|
+
/**
|
|
140
|
+
* Set up event handlers for a worker process.
|
|
141
|
+
*/
|
|
142
|
+
private setupWorkerProcessHandlers;
|
|
143
|
+
/**
|
|
144
|
+
* Start idle timer for a worker.
|
|
145
|
+
*/
|
|
146
|
+
private startIdleTimer;
|
|
147
|
+
/**
|
|
148
|
+
* Reset idle timer (on activity).
|
|
149
|
+
*/
|
|
150
|
+
private resetIdleTimer;
|
|
151
|
+
/**
|
|
152
|
+
* Start hard TTL timer for a worker.
|
|
153
|
+
*/
|
|
154
|
+
private startHardTtlTimer;
|
|
155
|
+
}
|
|
156
|
+
export {};
|
|
157
|
+
//# sourceMappingURL=worker-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker-manager.d.ts","sourceRoot":"","sources":["../../../src/worker/worker-manager.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAGtC,OAAO,KAAK,EACV,mBAAmB,EACnB,gBAAgB,EAChB,sBAAsB,EACtB,mBAAmB,EACpB,MAAM,YAAY,CAAC;AAUpB;;GAEG;AACH,UAAU,oBAAoB;IAC5B,EAAE,CAAC,CAAC,SAAS,MAAM,mBAAmB,EACpC,KAAK,EAAE,CAAC,EACR,QAAQ,EAAE,CAAC,IAAI,EAAE,mBAAmB,CAAC,CAAC,CAAC,KAAK,IAAI,GAC/C,IAAI,CAAC;IACR,IAAI,CAAC,CAAC,SAAS,MAAM,mBAAmB,EACtC,KAAK,EAAE,CAAC,EACR,QAAQ,EAAE,CAAC,IAAI,EAAE,mBAAmB,CAAC,CAAC,CAAC,KAAK,IAAI,GAC/C,IAAI,CAAC;IACR,IAAI,CAAC,CAAC,SAAS,MAAM,mBAAmB,EAAE,KAAK,EAAE,CAAC,EA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