pm-orchestrator-runner 1.0.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/LICENSE +21 -0
- package/README.md +108 -0
- package/dist/cli/cli-interface.d.ts +150 -0
- package/dist/cli/cli-interface.d.ts.map +1 -0
- package/dist/cli/cli-interface.js +606 -0
- package/dist/cli/cli-interface.js.map +1 -0
- package/dist/cli/index.d.ts +13 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +243 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/llm-sentinel.d.ts +15 -0
- package/dist/cli/llm-sentinel.d.ts.map +1 -0
- package/dist/cli/llm-sentinel.js +184 -0
- package/dist/cli/llm-sentinel.js.map +1 -0
- package/dist/config/configuration-manager.d.ts +149 -0
- package/dist/config/configuration-manager.d.ts.map +1 -0
- package/dist/config/configuration-manager.js +241 -0
- package/dist/config/configuration-manager.js.map +1 -0
- package/dist/continuation/continuation-control-manager.d.ts +154 -0
- package/dist/continuation/continuation-control-manager.d.ts.map +1 -0
- package/dist/continuation/continuation-control-manager.js +303 -0
- package/dist/continuation/continuation-control-manager.js.map +1 -0
- package/dist/core/runner-core.d.ts +474 -0
- package/dist/core/runner-core.d.ts.map +1 -0
- package/dist/core/runner-core.js +1311 -0
- package/dist/core/runner-core.js.map +1 -0
- package/dist/errors/error-codes.d.ts +105 -0
- package/dist/errors/error-codes.d.ts.map +1 -0
- package/dist/errors/error-codes.js +198 -0
- package/dist/errors/error-codes.js.map +1 -0
- package/dist/errors/runner-error.d.ts +14 -0
- package/dist/errors/runner-error.d.ts.map +1 -0
- package/dist/errors/runner-error.js +33 -0
- package/dist/errors/runner-error.js.map +1 -0
- package/dist/evidence/evidence-manager.d.ts +112 -0
- package/dist/evidence/evidence-manager.d.ts.map +1 -0
- package/dist/evidence/evidence-manager.js +337 -0
- package/dist/evidence/evidence-manager.js.map +1 -0
- package/dist/executor/claude-code-executor.d.ts +136 -0
- package/dist/executor/claude-code-executor.d.ts.map +1 -0
- package/dist/executor/claude-code-executor.js +643 -0
- package/dist/executor/claude-code-executor.js.map +1 -0
- package/dist/executor/deterministic-executor.d.ts +40 -0
- package/dist/executor/deterministic-executor.d.ts.map +1 -0
- package/dist/executor/deterministic-executor.js +269 -0
- package/dist/executor/deterministic-executor.js.map +1 -0
- package/dist/lifecycle/lifecycle-controller.d.ts +270 -0
- package/dist/lifecycle/lifecycle-controller.d.ts.map +1 -0
- package/dist/lifecycle/lifecycle-controller.js +596 -0
- package/dist/lifecycle/lifecycle-controller.js.map +1 -0
- package/dist/limits/resource-limit-manager.d.ts +200 -0
- package/dist/limits/resource-limit-manager.d.ts.map +1 -0
- package/dist/limits/resource-limit-manager.js +376 -0
- package/dist/limits/resource-limit-manager.js.map +1 -0
- package/dist/locks/lock-manager.d.ts +116 -0
- package/dist/locks/lock-manager.d.ts.map +1 -0
- package/dist/locks/lock-manager.js +306 -0
- package/dist/locks/lock-manager.js.map +1 -0
- package/dist/logging/index.d.ts +8 -0
- package/dist/logging/index.d.ts.map +1 -0
- package/dist/logging/index.js +22 -0
- package/dist/logging/index.js.map +1 -0
- package/dist/logging/sensitive-data-masker.d.ts +90 -0
- package/dist/logging/sensitive-data-masker.d.ts.map +1 -0
- package/dist/logging/sensitive-data-masker.js +228 -0
- package/dist/logging/sensitive-data-masker.js.map +1 -0
- package/dist/logging/task-log-manager.d.ts +215 -0
- package/dist/logging/task-log-manager.d.ts.map +1 -0
- package/dist/logging/task-log-manager.js +743 -0
- package/dist/logging/task-log-manager.js.map +1 -0
- package/dist/mediation/fail-closed-runner.d.ts +131 -0
- package/dist/mediation/fail-closed-runner.d.ts.map +1 -0
- package/dist/mediation/fail-closed-runner.js +245 -0
- package/dist/mediation/fail-closed-runner.js.map +1 -0
- package/dist/mediation/llm-client-with-evidence.d.ts +123 -0
- package/dist/mediation/llm-client-with-evidence.d.ts.map +1 -0
- package/dist/mediation/llm-client-with-evidence.js +245 -0
- package/dist/mediation/llm-client-with-evidence.js.map +1 -0
- package/dist/mediation/llm-client.d.ts +102 -0
- package/dist/mediation/llm-client.d.ts.map +1 -0
- package/dist/mediation/llm-client.js +206 -0
- package/dist/mediation/llm-client.js.map +1 -0
- package/dist/mediation/llm-evidence-manager.d.ts +108 -0
- package/dist/mediation/llm-evidence-manager.d.ts.map +1 -0
- package/dist/mediation/llm-evidence-manager.js +230 -0
- package/dist/mediation/llm-evidence-manager.js.map +1 -0
- package/dist/mediation/llm-mediation-layer.d.ts +175 -0
- package/dist/mediation/llm-mediation-layer.d.ts.map +1 -0
- package/dist/mediation/llm-mediation-layer.js +315 -0
- package/dist/mediation/llm-mediation-layer.js.map +1 -0
- package/dist/mediation/llm-sentinel.d.ts +107 -0
- package/dist/mediation/llm-sentinel.d.ts.map +1 -0
- package/dist/mediation/llm-sentinel.js +187 -0
- package/dist/mediation/llm-sentinel.js.map +1 -0
- package/dist/mediation/real-llm-mediation-layer.d.ts +104 -0
- package/dist/mediation/real-llm-mediation-layer.d.ts.map +1 -0
- package/dist/mediation/real-llm-mediation-layer.js +322 -0
- package/dist/mediation/real-llm-mediation-layer.js.map +1 -0
- package/dist/mediation/verdict-reporter.d.ts +61 -0
- package/dist/mediation/verdict-reporter.d.ts.map +1 -0
- package/dist/mediation/verdict-reporter.js +178 -0
- package/dist/mediation/verdict-reporter.js.map +1 -0
- package/dist/models/enums.d.ts +133 -0
- package/dist/models/enums.d.ts.map +1 -0
- package/dist/models/enums.js +201 -0
- package/dist/models/enums.js.map +1 -0
- package/dist/models/evidence.d.ts +60 -0
- package/dist/models/evidence.d.ts.map +1 -0
- package/dist/models/evidence.js +135 -0
- package/dist/models/evidence.js.map +1 -0
- package/dist/models/execution-result.d.ts +89 -0
- package/dist/models/execution-result.d.ts.map +1 -0
- package/dist/models/execution-result.js +197 -0
- package/dist/models/execution-result.js.map +1 -0
- package/dist/models/file-lock.d.ts +62 -0
- package/dist/models/file-lock.d.ts.map +1 -0
- package/dist/models/file-lock.js +133 -0
- package/dist/models/file-lock.js.map +1 -0
- package/dist/models/index.d.ts +12 -0
- package/dist/models/index.d.ts.map +1 -0
- package/dist/models/index.js +91 -0
- package/dist/models/index.js.map +1 -0
- package/dist/models/repl/index.d.ts +7 -0
- package/dist/models/repl/index.d.ts.map +1 -0
- package/dist/models/repl/index.js +32 -0
- package/dist/models/repl/index.js.map +1 -0
- package/dist/models/repl/model-registry.d.ts +73 -0
- package/dist/models/repl/model-registry.d.ts.map +1 -0
- package/dist/models/repl/model-registry.js +116 -0
- package/dist/models/repl/model-registry.js.map +1 -0
- package/dist/models/repl/repl-state.d.ts +86 -0
- package/dist/models/repl/repl-state.d.ts.map +1 -0
- package/dist/models/repl/repl-state.js +152 -0
- package/dist/models/repl/repl-state.js.map +1 -0
- package/dist/models/repl/task-log.d.ts +247 -0
- package/dist/models/repl/task-log.d.ts.map +1 -0
- package/dist/models/repl/task-log.js +178 -0
- package/dist/models/repl/task-log.js.map +1 -0
- package/dist/models/session.d.ts +71 -0
- package/dist/models/session.d.ts.map +1 -0
- package/dist/models/session.js +140 -0
- package/dist/models/session.js.map +1 -0
- package/dist/models/supporting.d.ts +97 -0
- package/dist/models/supporting.d.ts.map +1 -0
- package/dist/models/supporting.js +208 -0
- package/dist/models/supporting.js.map +1 -0
- package/dist/models/task.d.ts +77 -0
- package/dist/models/task.d.ts.map +1 -0
- package/dist/models/task.js +170 -0
- package/dist/models/task.js.map +1 -0
- package/dist/output/output-control-manager.d.ts +217 -0
- package/dist/output/output-control-manager.d.ts.map +1 -0
- package/dist/output/output-control-manager.js +378 -0
- package/dist/output/output-control-manager.js.map +1 -0
- package/dist/pool/agent-pool.d.ts +284 -0
- package/dist/pool/agent-pool.d.ts.map +1 -0
- package/dist/pool/agent-pool.js +451 -0
- package/dist/pool/agent-pool.js.map +1 -0
- package/dist/repl/commands/index.d.ts +12 -0
- package/dist/repl/commands/index.d.ts.map +1 -0
- package/dist/repl/commands/index.js +26 -0
- package/dist/repl/commands/index.js.map +1 -0
- package/dist/repl/commands/init.d.ts +31 -0
- package/dist/repl/commands/init.d.ts.map +1 -0
- package/dist/repl/commands/init.js +234 -0
- package/dist/repl/commands/init.js.map +1 -0
- package/dist/repl/commands/keys.d.ts +63 -0
- package/dist/repl/commands/keys.d.ts.map +1 -0
- package/dist/repl/commands/keys.js +114 -0
- package/dist/repl/commands/keys.js.map +1 -0
- package/dist/repl/commands/logs.d.ts +91 -0
- package/dist/repl/commands/logs.d.ts.map +1 -0
- package/dist/repl/commands/logs.js +200 -0
- package/dist/repl/commands/logs.js.map +1 -0
- package/dist/repl/commands/model.d.ts +85 -0
- package/dist/repl/commands/model.d.ts.map +1 -0
- package/dist/repl/commands/model.js +225 -0
- package/dist/repl/commands/model.js.map +1 -0
- package/dist/repl/commands/models.d.ts +50 -0
- package/dist/repl/commands/models.d.ts.map +1 -0
- package/dist/repl/commands/models.js +180 -0
- package/dist/repl/commands/models.js.map +1 -0
- package/dist/repl/commands/provider.d.ts +79 -0
- package/dist/repl/commands/provider.d.ts.map +1 -0
- package/dist/repl/commands/provider.js +291 -0
- package/dist/repl/commands/provider.js.map +1 -0
- package/dist/repl/commands/session.d.ts +50 -0
- package/dist/repl/commands/session.d.ts.map +1 -0
- package/dist/repl/commands/session.js +152 -0
- package/dist/repl/commands/session.js.map +1 -0
- package/dist/repl/commands/status.d.ts +55 -0
- package/dist/repl/commands/status.d.ts.map +1 -0
- package/dist/repl/commands/status.js +182 -0
- package/dist/repl/commands/status.js.map +1 -0
- package/dist/repl/index.d.ts +6 -0
- package/dist/repl/index.d.ts.map +1 -0
- package/dist/repl/index.js +25 -0
- package/dist/repl/index.js.map +1 -0
- package/dist/repl/repl-interface.d.ts +371 -0
- package/dist/repl/repl-interface.d.ts.map +1 -0
- package/dist/repl/repl-interface.js +1214 -0
- package/dist/repl/repl-interface.js.map +1 -0
- package/dist/session/session-manager.d.ts +85 -0
- package/dist/session/session-manager.d.ts.map +1 -0
- package/dist/session/session-manager.js +217 -0
- package/dist/session/session-manager.js.map +1 -0
- package/dist/supervisor/executor-supervisor.d.ts +90 -0
- package/dist/supervisor/executor-supervisor.d.ts.map +1 -0
- package/dist/supervisor/executor-supervisor.js +223 -0
- package/dist/supervisor/executor-supervisor.js.map +1 -0
- package/dist/supervisor/index.d.ts +5 -0
- package/dist/supervisor/index.d.ts.map +1 -0
- package/dist/supervisor/index.js +9 -0
- package/dist/supervisor/index.js.map +1 -0
- package/package.json +57 -0
|
@@ -0,0 +1,451 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* L1/L2 Agent Pool
|
|
4
|
+
* Based on 04_COMPONENTS.md L98-155
|
|
5
|
+
*
|
|
6
|
+
* L1 Subagent Pool: Max 9 parallel read-only subagents
|
|
7
|
+
* L2 Executor Pool: Max 4 parallel executors with write permissions
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.L2ExecutorPool = exports.L1SubagentPool = exports.AgentPoolError = void 0;
|
|
11
|
+
const events_1 = require("events");
|
|
12
|
+
const enums_1 = require("../models/enums");
|
|
13
|
+
const error_codes_1 = require("../errors/error-codes");
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
15
|
+
const minimatch = require('minimatch');
|
|
16
|
+
/**
|
|
17
|
+
* Agent Pool Error
|
|
18
|
+
*/
|
|
19
|
+
class AgentPoolError extends Error {
|
|
20
|
+
code;
|
|
21
|
+
details;
|
|
22
|
+
constructor(code, message, details) {
|
|
23
|
+
super(message || (0, error_codes_1.getErrorMessage)(code));
|
|
24
|
+
this.name = 'AgentPoolError';
|
|
25
|
+
this.code = code;
|
|
26
|
+
this.details = details;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.AgentPoolError = AgentPoolError;
|
|
30
|
+
/**
|
|
31
|
+
* Global semaphore for coordinating pool access
|
|
32
|
+
*/
|
|
33
|
+
class GlobalSemaphore {
|
|
34
|
+
activeCount = 0;
|
|
35
|
+
acquire() {
|
|
36
|
+
this.activeCount++;
|
|
37
|
+
}
|
|
38
|
+
release() {
|
|
39
|
+
if (this.activeCount > 0) {
|
|
40
|
+
this.activeCount--;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
getActiveCount() {
|
|
44
|
+
return this.activeCount;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* L1 Subagent Pool
|
|
49
|
+
* Max 9 parallel read-only subagents
|
|
50
|
+
*/
|
|
51
|
+
class L1SubagentPool {
|
|
52
|
+
maxCapacity = 9;
|
|
53
|
+
agents = new Map();
|
|
54
|
+
queueEnabled = false;
|
|
55
|
+
queue = [];
|
|
56
|
+
totalAcquisitions = 0;
|
|
57
|
+
/**
|
|
58
|
+
* Get maximum pool capacity
|
|
59
|
+
*/
|
|
60
|
+
getMaxCapacity() {
|
|
61
|
+
return this.maxCapacity;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Get number of active subagents
|
|
65
|
+
*/
|
|
66
|
+
getActiveCount() {
|
|
67
|
+
return this.agents.size;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Get available slots
|
|
71
|
+
*/
|
|
72
|
+
getAvailableSlots() {
|
|
73
|
+
return this.maxCapacity - this.agents.size;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Enable or disable queueing
|
|
77
|
+
*/
|
|
78
|
+
enableQueueing(enabled) {
|
|
79
|
+
this.queueEnabled = enabled;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Acquire a subagent slot
|
|
83
|
+
*/
|
|
84
|
+
acquire(id, type, options) {
|
|
85
|
+
// L1 only allows READER type
|
|
86
|
+
if (type !== enums_1.AgentType.READER) {
|
|
87
|
+
throw new AgentPoolError(error_codes_1.ErrorCode.E206_RESOURCE_LIMIT_EXCEEDED, 'L1 pool only allows READER type agents', { type });
|
|
88
|
+
}
|
|
89
|
+
// Check capacity
|
|
90
|
+
if (this.agents.size >= this.maxCapacity) {
|
|
91
|
+
throw new AgentPoolError(error_codes_1.ErrorCode.E206_RESOURCE_LIMIT_EXCEEDED, 'L1 pool is at maximum capacity', { maxCapacity: this.maxCapacity, activeCount: this.agents.size });
|
|
92
|
+
}
|
|
93
|
+
const now = Date.now();
|
|
94
|
+
const info = {
|
|
95
|
+
id,
|
|
96
|
+
type,
|
|
97
|
+
permissions: {
|
|
98
|
+
read: true,
|
|
99
|
+
write: false,
|
|
100
|
+
execute: false,
|
|
101
|
+
allowedPaths: options?.allowedPaths,
|
|
102
|
+
},
|
|
103
|
+
started_at: new Date(now).toISOString(),
|
|
104
|
+
duration_seconds: 0,
|
|
105
|
+
};
|
|
106
|
+
this.agents.set(id, { info, startTime: now });
|
|
107
|
+
this.totalAcquisitions++;
|
|
108
|
+
return info;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Queue an acquisition when pool is full
|
|
112
|
+
*/
|
|
113
|
+
queueAcquisition(id, type, options) {
|
|
114
|
+
if (!this.queueEnabled) {
|
|
115
|
+
throw new AgentPoolError(error_codes_1.ErrorCode.E206_RESOURCE_LIMIT_EXCEEDED, 'Queueing is not enabled');
|
|
116
|
+
}
|
|
117
|
+
this.queue.push({ id, type, options });
|
|
118
|
+
return {
|
|
119
|
+
queued: true,
|
|
120
|
+
position: this.queue.length - 1,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Release a subagent slot
|
|
125
|
+
*/
|
|
126
|
+
release(id) {
|
|
127
|
+
const removed = this.agents.delete(id);
|
|
128
|
+
// Process queue if enabled and agent was removed
|
|
129
|
+
if (removed && this.queueEnabled && this.queue.length > 0) {
|
|
130
|
+
const next = this.queue.shift();
|
|
131
|
+
if (next) {
|
|
132
|
+
this.acquire(next.id, next.type, next.options);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Release all subagents
|
|
138
|
+
*/
|
|
139
|
+
releaseAll() {
|
|
140
|
+
this.agents.clear();
|
|
141
|
+
this.queue = [];
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Check if agent is active
|
|
145
|
+
*/
|
|
146
|
+
isActive(id) {
|
|
147
|
+
return this.agents.has(id);
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Assign task to agent
|
|
151
|
+
*/
|
|
152
|
+
assignTask(id, taskId) {
|
|
153
|
+
const agent = this.agents.get(id);
|
|
154
|
+
if (agent) {
|
|
155
|
+
agent.info.current_task = taskId;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Get agent info
|
|
160
|
+
*/
|
|
161
|
+
getAgentInfo(id) {
|
|
162
|
+
const agent = this.agents.get(id);
|
|
163
|
+
if (!agent) {
|
|
164
|
+
throw new AgentPoolError(error_codes_1.ErrorCode.E206_RESOURCE_LIMIT_EXCEEDED, `Agent not found: ${id}`, { id });
|
|
165
|
+
}
|
|
166
|
+
const now = Date.now();
|
|
167
|
+
return {
|
|
168
|
+
...agent.info,
|
|
169
|
+
duration_seconds: Math.floor((now - agent.startTime) / 1000),
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Set start time for testing
|
|
174
|
+
*/
|
|
175
|
+
setStartTimeForTesting(id, timestamp) {
|
|
176
|
+
const agent = this.agents.get(id);
|
|
177
|
+
if (agent) {
|
|
178
|
+
agent.startTime = timestamp;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Get pool statistics
|
|
183
|
+
*/
|
|
184
|
+
getStatistics() {
|
|
185
|
+
return {
|
|
186
|
+
total_capacity: this.maxCapacity,
|
|
187
|
+
active_count: this.agents.size,
|
|
188
|
+
available_slots: this.getAvailableSlots(),
|
|
189
|
+
utilization_percent: Math.round((this.agents.size / this.maxCapacity) * 100),
|
|
190
|
+
total_acquisitions: this.totalAcquisitions,
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
exports.L1SubagentPool = L1SubagentPool;
|
|
195
|
+
/**
|
|
196
|
+
* L2 Executor Pool
|
|
197
|
+
* Max 4 parallel executors with write permissions
|
|
198
|
+
*/
|
|
199
|
+
class L2ExecutorPool extends events_1.EventEmitter {
|
|
200
|
+
maxCapacity = 4;
|
|
201
|
+
executors = new Map();
|
|
202
|
+
locks = new Map(); // path -> executor_id
|
|
203
|
+
globalSemaphore = new GlobalSemaphore();
|
|
204
|
+
totalAcquisitions = 0;
|
|
205
|
+
/**
|
|
206
|
+
* Get maximum pool capacity
|
|
207
|
+
*/
|
|
208
|
+
getMaxCapacity() {
|
|
209
|
+
return this.maxCapacity;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Get number of active executors
|
|
213
|
+
*/
|
|
214
|
+
getActiveCount() {
|
|
215
|
+
return this.executors.size;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Get available slots
|
|
219
|
+
*/
|
|
220
|
+
getAvailableSlots() {
|
|
221
|
+
return this.maxCapacity - this.executors.size;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Acquire an executor slot
|
|
225
|
+
*/
|
|
226
|
+
acquire(id, options) {
|
|
227
|
+
// Check capacity
|
|
228
|
+
if (this.executors.size >= this.maxCapacity) {
|
|
229
|
+
throw new AgentPoolError(error_codes_1.ErrorCode.E206_RESOURCE_LIMIT_EXCEEDED, 'L2 pool is at maximum capacity', { maxCapacity: this.maxCapacity, activeCount: this.executors.size });
|
|
230
|
+
}
|
|
231
|
+
// Check lock availability
|
|
232
|
+
const lockPaths = options?.lockPaths || [];
|
|
233
|
+
for (const path of lockPaths) {
|
|
234
|
+
if (this.locks.has(path)) {
|
|
235
|
+
throw new AgentPoolError(error_codes_1.ErrorCode.E401_LOCK_ACQUISITION_FAILED, `Lock already held: ${path}`, { path, holder: this.locks.get(path) });
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
// Acquire locks
|
|
239
|
+
for (const path of lockPaths) {
|
|
240
|
+
this.locks.set(path, id);
|
|
241
|
+
}
|
|
242
|
+
const now = Date.now();
|
|
243
|
+
const canWrite = (path) => {
|
|
244
|
+
if (!options?.writeScopes || options.writeScopes.length === 0) {
|
|
245
|
+
return true; // Default: can write anywhere
|
|
246
|
+
}
|
|
247
|
+
return options.writeScopes.some(scope => minimatch(path, scope));
|
|
248
|
+
};
|
|
249
|
+
const info = {
|
|
250
|
+
id,
|
|
251
|
+
permissions: {
|
|
252
|
+
read: true,
|
|
253
|
+
write: true,
|
|
254
|
+
execute: true,
|
|
255
|
+
writeScopes: options?.writeScopes,
|
|
256
|
+
readScopes: options?.readScopes,
|
|
257
|
+
},
|
|
258
|
+
started_at: new Date(now).toISOString(),
|
|
259
|
+
heldLocks: [...lockPaths],
|
|
260
|
+
current_task: {},
|
|
261
|
+
canWrite,
|
|
262
|
+
};
|
|
263
|
+
this.executors.set(id, {
|
|
264
|
+
info,
|
|
265
|
+
startTime: now,
|
|
266
|
+
lastActivity: now,
|
|
267
|
+
evidence: [],
|
|
268
|
+
});
|
|
269
|
+
this.globalSemaphore.acquire();
|
|
270
|
+
this.totalAcquisitions++;
|
|
271
|
+
this.emit('executor_acquired', { executor_id: id });
|
|
272
|
+
return info;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Release an executor slot
|
|
276
|
+
*/
|
|
277
|
+
release(id, options) {
|
|
278
|
+
const executor = this.executors.get(id);
|
|
279
|
+
if (!executor) {
|
|
280
|
+
return; // Ignore release for unknown executor
|
|
281
|
+
}
|
|
282
|
+
// Check if task is in progress (unless force)
|
|
283
|
+
if (!options?.force) {
|
|
284
|
+
const taskStatus = executor.info.current_task?.status;
|
|
285
|
+
if (taskStatus === enums_1.TaskStatus.IN_PROGRESS) {
|
|
286
|
+
throw new AgentPoolError(error_codes_1.ErrorCode.E206_RESOURCE_LIMIT_EXCEEDED, 'Cannot release executor with in-progress task', { id, taskStatus });
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
// Release all held locks
|
|
290
|
+
for (const path of executor.info.heldLocks) {
|
|
291
|
+
this.locks.delete(path);
|
|
292
|
+
}
|
|
293
|
+
this.executors.delete(id);
|
|
294
|
+
this.globalSemaphore.release();
|
|
295
|
+
this.emit('executor_released', { executor_id: id });
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Release all executors
|
|
299
|
+
*/
|
|
300
|
+
releaseAll() {
|
|
301
|
+
for (const [id] of this.executors) {
|
|
302
|
+
this.release(id, { force: true });
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Get lock info
|
|
307
|
+
*/
|
|
308
|
+
getLockInfo(path) {
|
|
309
|
+
const holder = this.locks.get(path);
|
|
310
|
+
return {
|
|
311
|
+
locked: !!holder,
|
|
312
|
+
holder,
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Assign task to executor
|
|
317
|
+
*/
|
|
318
|
+
assignTask(id, task) {
|
|
319
|
+
const executor = this.executors.get(id);
|
|
320
|
+
if (!executor) {
|
|
321
|
+
throw new AgentPoolError(error_codes_1.ErrorCode.E206_RESOURCE_LIMIT_EXCEEDED, `Executor not found: ${id}`, { id });
|
|
322
|
+
}
|
|
323
|
+
executor.info.current_task = {
|
|
324
|
+
task_id: task.task_id || '',
|
|
325
|
+
description: task.description,
|
|
326
|
+
files: task.files,
|
|
327
|
+
status: enums_1.TaskStatus.PENDING,
|
|
328
|
+
};
|
|
329
|
+
executor.lastActivity = Date.now();
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Update task status
|
|
333
|
+
*/
|
|
334
|
+
updateTaskStatus(id, status) {
|
|
335
|
+
const executor = this.executors.get(id);
|
|
336
|
+
if (!executor) {
|
|
337
|
+
throw new AgentPoolError(error_codes_1.ErrorCode.E206_RESOURCE_LIMIT_EXCEEDED, `Executor not found: ${id}`, { id });
|
|
338
|
+
}
|
|
339
|
+
executor.info.current_task.status = status;
|
|
340
|
+
executor.lastActivity = Date.now();
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Complete task with evidence
|
|
344
|
+
*/
|
|
345
|
+
completeTask(id, completion) {
|
|
346
|
+
const executor = this.executors.get(id);
|
|
347
|
+
if (!executor) {
|
|
348
|
+
throw new AgentPoolError(error_codes_1.ErrorCode.E206_RESOURCE_LIMIT_EXCEEDED, `Executor not found: ${id}`, { id });
|
|
349
|
+
}
|
|
350
|
+
// Require evidence for completion
|
|
351
|
+
if (completion.status === enums_1.TaskStatus.COMPLETED && !completion.evidence) {
|
|
352
|
+
throw new AgentPoolError(error_codes_1.ErrorCode.E301_EVIDENCE_MISSING, 'Evidence required for task completion', { id });
|
|
353
|
+
}
|
|
354
|
+
executor.info.current_task.status = completion.status;
|
|
355
|
+
executor.info.current_task.evidence = completion.evidence || undefined;
|
|
356
|
+
executor.lastActivity = Date.now();
|
|
357
|
+
this.emit('task_completed', {
|
|
358
|
+
task_id: executor.info.current_task.task_id,
|
|
359
|
+
executor_id: id,
|
|
360
|
+
status: completion.status,
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* Record evidence
|
|
365
|
+
*/
|
|
366
|
+
recordEvidence(id, evidence) {
|
|
367
|
+
const executor = this.executors.get(id);
|
|
368
|
+
if (!executor) {
|
|
369
|
+
throw new AgentPoolError(error_codes_1.ErrorCode.E206_RESOURCE_LIMIT_EXCEEDED, `Executor not found: ${id}`, { id });
|
|
370
|
+
}
|
|
371
|
+
executor.evidence.push(evidence);
|
|
372
|
+
executor.lastActivity = Date.now();
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* Get task evidence
|
|
376
|
+
*/
|
|
377
|
+
getTaskEvidence(id) {
|
|
378
|
+
const executor = this.executors.get(id);
|
|
379
|
+
if (!executor) {
|
|
380
|
+
throw new AgentPoolError(error_codes_1.ErrorCode.E206_RESOURCE_LIMIT_EXCEEDED, `Executor not found: ${id}`, { id });
|
|
381
|
+
}
|
|
382
|
+
return [...executor.evidence];
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Get executor info
|
|
386
|
+
*/
|
|
387
|
+
getExecutorInfo(id) {
|
|
388
|
+
const executor = this.executors.get(id);
|
|
389
|
+
if (!executor) {
|
|
390
|
+
throw new AgentPoolError(error_codes_1.ErrorCode.E206_RESOURCE_LIMIT_EXCEEDED, `Executor not found: ${id}`, { id });
|
|
391
|
+
}
|
|
392
|
+
return executor.info;
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* Get executor health
|
|
396
|
+
*/
|
|
397
|
+
getExecutorHealth(id) {
|
|
398
|
+
const executor = this.executors.get(id);
|
|
399
|
+
if (!executor) {
|
|
400
|
+
throw new AgentPoolError(error_codes_1.ErrorCode.E206_RESOURCE_LIMIT_EXCEEDED, `Executor not found: ${id}`, { id });
|
|
401
|
+
}
|
|
402
|
+
const now = Date.now();
|
|
403
|
+
const inactiveTime = now - executor.lastActivity;
|
|
404
|
+
const staleThreshold = 300000; // 5 minutes
|
|
405
|
+
return {
|
|
406
|
+
status: inactiveTime > staleThreshold ? 'stale' : 'healthy',
|
|
407
|
+
last_activity: new Date(executor.lastActivity).toISOString(),
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* Set last activity for testing
|
|
412
|
+
*/
|
|
413
|
+
setLastActivityForTesting(id, timestamp) {
|
|
414
|
+
const executor = this.executors.get(id);
|
|
415
|
+
if (executor) {
|
|
416
|
+
executor.lastActivity = timestamp;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* Cleanup stale executors
|
|
421
|
+
*/
|
|
422
|
+
cleanupStaleExecutors(thresholdSeconds) {
|
|
423
|
+
const now = Date.now();
|
|
424
|
+
const thresholdMs = thresholdSeconds * 1000;
|
|
425
|
+
for (const [id, executor] of this.executors) {
|
|
426
|
+
if (now - executor.lastActivity > thresholdMs) {
|
|
427
|
+
this.release(id, { force: true });
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* Get global semaphore
|
|
433
|
+
*/
|
|
434
|
+
getGlobalSemaphore() {
|
|
435
|
+
return this.globalSemaphore;
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* Get pool statistics
|
|
439
|
+
*/
|
|
440
|
+
getStatistics() {
|
|
441
|
+
return {
|
|
442
|
+
total_capacity: this.maxCapacity,
|
|
443
|
+
active_count: this.executors.size,
|
|
444
|
+
available_slots: this.getAvailableSlots(),
|
|
445
|
+
utilization_percent: Math.round((this.executors.size / this.maxCapacity) * 100),
|
|
446
|
+
total_acquisitions: this.totalAcquisitions,
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
exports.L2ExecutorPool = L2ExecutorPool;
|
|
451
|
+
//# sourceMappingURL=agent-pool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-pool.js","sourceRoot":"","sources":["../../src/pool/agent-pool.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,mCAAsC;AACtC,2CAAwD;AACxD,uDAAmE;AACnE,8DAA8D;AAC9D,MAAM,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;AAEvC;;GAEG;AACH,MAAa,cAAe,SAAQ,KAAK;IACvB,IAAI,CAAY;IAChB,OAAO,CAA2B;IAElD,YAAY,IAAe,EAAE,OAAgB,EAAE,OAAiC;QAC9E,KAAK,CAAC,OAAO,IAAI,IAAA,6BAAe,EAAC,IAAI,CAAC,CAAC,CAAC;QACxC,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CACF;AAVD,wCAUC;AAqGD;;GAEG;AACH,MAAM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CAAC;YAC5C,IAAI,GAAG,GAAG,QAAQ,CAAC,YAAY,GAAG,WAAW,EAAE,CAAC;gBAC9C,IAAI,CAAC,OAAO,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;YACpC,CAAC;QACH,CAAC;IACH,CAAC;IAED;;OAEG;IACH,kBAAkB;QAChB,OAAO,IAAI,CAAC,eAAe,CAAC;IAC9B,CAAC;IAED;;OAEG;IACH,aAAa;QACX,OAAO;YACL,cAAc,EAAE,IAAI,CAAC,WAAW;YAChC,YAAY,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI;YACjC,eAAe,EAAE,IAAI,CAAC,iBAAiB,EAAE;YACzC,mBAAmB,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,GAAG,CAAC;YAC/E,kBAAkB,EAAE,IAAI,CAAC,iBAAiB;SAC3C,CAAC;IACJ,CAAC;CACF;AArVD,wCAqVC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* REPL Commands Index
|
|
3
|
+
*/
|
|
4
|
+
export { InitCommand, InitResult } from './init';
|
|
5
|
+
export { ModelCommand, ModelResult, AVAILABLE_MODELS, ModelName } from './model';
|
|
6
|
+
export { SessionCommands, SessionResult } from './session';
|
|
7
|
+
export { StatusCommands } from './status';
|
|
8
|
+
export { ProviderCommand, ProviderResult, REPL_STATE_FILE } from './provider';
|
|
9
|
+
export { ModelsCommand, ModelsResult } from './models';
|
|
10
|
+
export { KeysCommand, KeysResult, KeyStatus } from './keys';
|
|
11
|
+
export { LogsCommand, LogsResult } from './logs';
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/repl/commands/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACjF,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAG1C,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC9E,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* REPL Commands Index
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.LogsCommand = exports.KeysCommand = exports.ModelsCommand = exports.REPL_STATE_FILE = exports.ProviderCommand = exports.StatusCommands = exports.SessionCommands = exports.AVAILABLE_MODELS = exports.ModelCommand = exports.InitCommand = void 0;
|
|
7
|
+
var init_1 = require("./init");
|
|
8
|
+
Object.defineProperty(exports, "InitCommand", { enumerable: true, get: function () { return init_1.InitCommand; } });
|
|
9
|
+
var model_1 = require("./model");
|
|
10
|
+
Object.defineProperty(exports, "ModelCommand", { enumerable: true, get: function () { return model_1.ModelCommand; } });
|
|
11
|
+
Object.defineProperty(exports, "AVAILABLE_MODELS", { enumerable: true, get: function () { return model_1.AVAILABLE_MODELS; } });
|
|
12
|
+
var session_1 = require("./session");
|
|
13
|
+
Object.defineProperty(exports, "SessionCommands", { enumerable: true, get: function () { return session_1.SessionCommands; } });
|
|
14
|
+
var status_1 = require("./status");
|
|
15
|
+
Object.defineProperty(exports, "StatusCommands", { enumerable: true, get: function () { return status_1.StatusCommands; } });
|
|
16
|
+
// New commands per spec 10_REPL_UX.md
|
|
17
|
+
var provider_1 = require("./provider");
|
|
18
|
+
Object.defineProperty(exports, "ProviderCommand", { enumerable: true, get: function () { return provider_1.ProviderCommand; } });
|
|
19
|
+
Object.defineProperty(exports, "REPL_STATE_FILE", { enumerable: true, get: function () { return provider_1.REPL_STATE_FILE; } });
|
|
20
|
+
var models_1 = require("./models");
|
|
21
|
+
Object.defineProperty(exports, "ModelsCommand", { enumerable: true, get: function () { return models_1.ModelsCommand; } });
|
|
22
|
+
var keys_1 = require("./keys");
|
|
23
|
+
Object.defineProperty(exports, "KeysCommand", { enumerable: true, get: function () { return keys_1.KeysCommand; } });
|
|
24
|
+
var logs_1 = require("./logs");
|
|
25
|
+
Object.defineProperty(exports, "LogsCommand", { enumerable: true, get: function () { return logs_1.LogsCommand; } });
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/repl/commands/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,+BAAiD;AAAxC,mGAAA,WAAW,OAAA;AACpB,iCAAiF;AAAxE,qGAAA,YAAY,OAAA;AAAe,yGAAA,gBAAgB,OAAA;AACpD,qCAA2D;AAAlD,0GAAA,eAAe,OAAA;AACxB,mCAA0C;AAAjC,wGAAA,cAAc,OAAA;AAEvB,sCAAsC;AACtC,uCAA8E;AAArE,2GAAA,eAAe,OAAA;AAAkB,2GAAA,eAAe,OAAA;AACzD,mCAAuD;AAA9C,uGAAA,aAAa,OAAA;AACtB,+BAA4D;AAAnD,mGAAA,WAAW,OAAA;AACpB,+BAAiD;AAAxC,mGAAA,WAAW,OAAA"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* /init Command Handler
|
|
3
|
+
* Creates .claude/ scaffold in target project
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Result of init command
|
|
7
|
+
*/
|
|
8
|
+
export interface InitResult {
|
|
9
|
+
success: boolean;
|
|
10
|
+
message: string;
|
|
11
|
+
createdPaths?: string[];
|
|
12
|
+
existingFiles?: string[];
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Init command handler
|
|
16
|
+
*/
|
|
17
|
+
export declare class InitCommand {
|
|
18
|
+
/**
|
|
19
|
+
* Execute init command
|
|
20
|
+
* Per spec 10_REPL_UX.md L96-99:
|
|
21
|
+
* - Check ALL files BEFORE creating any
|
|
22
|
+
* - If ANY exist, return ERROR with list of existing files
|
|
23
|
+
* - Only create if NONE exist
|
|
24
|
+
*/
|
|
25
|
+
execute(targetPath: string): Promise<InitResult>;
|
|
26
|
+
/**
|
|
27
|
+
* Check if a directory is already initialized
|
|
28
|
+
*/
|
|
29
|
+
isInitialized(targetPath: string): boolean;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=init.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/repl/commands/init.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B;AA2FD;;GAEG;AACH,qBAAa,WAAW;IACtB;;;;;;OAMG;IACG,OAAO,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAoGtD;;OAEG;IACH,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO;CAI3C"}
|