reevesagents 1.2.0 → 1.3.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/CHANGELOG.md +41 -0
- package/README.ar.md +397 -0
- package/README.de.md +406 -0
- package/README.es.md +418 -0
- package/README.fr.md +340 -0
- package/README.it.md +400 -0
- package/README.md +290 -171
- package/README.pt.md +417 -0
- package/README.ru.md +401 -0
- package/README.tr.md +415 -0
- package/README.zh-Hans.md +340 -0
- package/dist/chunk-4LWTEYRI.js +4878 -0
- package/dist/chunk-4W6MVOPK.js +29 -0
- package/dist/{chunk-4Q3JF22J.js → chunk-5DOCQLT7.js} +2 -2
- package/dist/{chunk-MVMGFG4W.js → chunk-65LHCGPC.js} +836 -263
- package/dist/chunk-D24DQQ6V.js +0 -0
- package/dist/chunk-HS6TOISU.js +30 -0
- package/dist/chunk-Z2JHNE7V.js +317 -0
- package/dist/cli.d.ts +4 -1
- package/dist/cli.js +374 -45
- package/dist/extras-25AF6TAR.js +0 -0
- package/dist/index.d.ts +13 -37
- package/dist/index.js +13 -19
- package/dist/open-browser-DRSIJQ37.js +0 -0
- package/dist/{router-WCFLHJV7.js → router-I4WDR7CD.js} +1478 -764
- package/dist/server-H2XEJQYT.js +622 -0
- package/dist/{server-Z2YTGWSX.js → server-ZJKAIRL5.js} +261 -135
- package/dist/{tui-launch-7RGFE5KY.js → tui-launch-VHLX6JOW.js} +2 -2
- package/dist/web/app.css +321 -13
- package/dist/web/app.js +626 -51
- package/dist/web/index.html +115 -10
- package/package.json +22 -18
- package/dist/chunk-3IXII4H5.js +0 -129
- package/dist/chunk-DHAW6OY3.js +0 -40
- package/dist/chunk-G6FN75ZW.js +0 -2393
- package/dist/chunk-JY4ZTTRK.js +0 -172
- package/dist/chunk-LUW6GCPO.js +0 -108
|
@@ -1,40 +1,52 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
localeCatalog
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-4LWTEYRI.js";
|
|
5
5
|
import {
|
|
6
6
|
modelValuesForProvider
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-HS6TOISU.js";
|
|
8
8
|
import {
|
|
9
|
+
REEVESAGENTS_VERSION,
|
|
10
|
+
attach,
|
|
11
|
+
attachAll,
|
|
12
|
+
detach,
|
|
13
|
+
hostStatus,
|
|
14
|
+
listRunApprovals,
|
|
15
|
+
resolveRunApproval
|
|
16
|
+
} from "./chunk-Z2JHNE7V.js";
|
|
17
|
+
import {
|
|
18
|
+
CONFIG_FIELDS,
|
|
9
19
|
LANGUAGE_OPTIONS,
|
|
10
20
|
PROVIDERS,
|
|
11
21
|
archiveAndRemoveRun,
|
|
12
22
|
autoCleanupRuns,
|
|
13
23
|
computeRunStatus,
|
|
14
24
|
deleteAgent,
|
|
25
|
+
deletePreset,
|
|
15
26
|
deleteRunHistory,
|
|
16
27
|
detectAvailable,
|
|
17
28
|
findAgent,
|
|
18
|
-
findAgentAny,
|
|
19
29
|
isLanguageCode,
|
|
20
30
|
killAgent,
|
|
21
31
|
listAgents,
|
|
22
|
-
|
|
32
|
+
listPresets,
|
|
23
33
|
listRunHistory,
|
|
24
34
|
listRuns,
|
|
25
|
-
listRunsAny,
|
|
26
35
|
loadConfig,
|
|
27
36
|
normalizeProvider,
|
|
28
37
|
providerColor,
|
|
29
38
|
providerDisplayName,
|
|
30
39
|
readRun,
|
|
31
|
-
|
|
40
|
+
runDoctor,
|
|
32
41
|
runHasLiveTmuxTarget,
|
|
33
|
-
|
|
42
|
+
savePresetFromRun,
|
|
43
|
+
setConfigValues,
|
|
34
44
|
spawnWorker,
|
|
35
45
|
startRun,
|
|
46
|
+
startRunFromPreset,
|
|
36
47
|
stopRun
|
|
37
|
-
} from "./chunk-
|
|
48
|
+
} from "./chunk-65LHCGPC.js";
|
|
49
|
+
import "./chunk-D24DQQ6V.js";
|
|
38
50
|
|
|
39
51
|
// src/web/server.ts
|
|
40
52
|
import { createServer } from "http";
|
|
@@ -78,32 +90,6 @@ function isAllowedOrigin(originHeader, port) {
|
|
|
78
90
|
return url.port === String(port);
|
|
79
91
|
}
|
|
80
92
|
|
|
81
|
-
// src/web/prebeta-orchestrator.ts
|
|
82
|
-
var ORCHESTRATOR_WEB_PROVIDERS = ["cc", "codex", "opencode", "hermes"];
|
|
83
|
-
function isOrchestratorWebProvider(provider) {
|
|
84
|
-
return ORCHESTRATOR_WEB_PROVIDERS.includes(provider);
|
|
85
|
-
}
|
|
86
|
-
function isRuntime(value) {
|
|
87
|
-
if (!value || typeof value !== "object") return false;
|
|
88
|
-
const maybe = value;
|
|
89
|
-
return typeof maybe.startRun === "function" && typeof maybe.spawnWorker === "function" && typeof maybe.killAgent === "function" && typeof maybe.stopRun === "function";
|
|
90
|
-
}
|
|
91
|
-
async function loadWebOrchestratorRuntime(injected) {
|
|
92
|
-
if (injected) return injected;
|
|
93
|
-
try {
|
|
94
|
-
const specifier = "reevesagents-orchestrator";
|
|
95
|
-
const mod = await import(specifier);
|
|
96
|
-
if (isRuntime(mod)) return mod;
|
|
97
|
-
} catch {
|
|
98
|
-
}
|
|
99
|
-
throw new Error([
|
|
100
|
-
"PRE-BETA orchestrator web mode requires the separate orchestrator package.",
|
|
101
|
-
"Install the all-in pre-beta option, then rerun:",
|
|
102
|
-
" npm install -g reevesagents reevesagents-orchestrator",
|
|
103
|
-
" reevesagents web --prebeta-orchestrator"
|
|
104
|
-
].join("\n"));
|
|
105
|
-
}
|
|
106
|
-
|
|
107
93
|
// src/web/state.ts
|
|
108
94
|
function monogram(nickname, provider) {
|
|
109
95
|
const base = (nickname || provider).trim();
|
|
@@ -111,17 +97,18 @@ function monogram(nickname, provider) {
|
|
|
111
97
|
return (alnum.slice(0, 2) || provider.slice(0, 2)).toUpperCase();
|
|
112
98
|
}
|
|
113
99
|
function buildWebState(options = {}) {
|
|
114
|
-
const
|
|
115
|
-
const
|
|
116
|
-
const runs =
|
|
117
|
-
|
|
100
|
+
const agentIndex = /* @__PURE__ */ new Map();
|
|
101
|
+
const runNameById = /* @__PURE__ */ new Map();
|
|
102
|
+
const runs = listRuns().map((run) => {
|
|
103
|
+
runNameById.set(run.id, run.name);
|
|
118
104
|
const live = options.liveTmuxTarget ? options.liveTmuxTarget(run) : runHasLiveTmuxTarget(run);
|
|
119
105
|
const runStatus = computeRunStatus(run, live);
|
|
120
|
-
const terminals =
|
|
106
|
+
const terminals = listAgents(run.id).map((agent) => {
|
|
107
|
+
agentIndex.set(agent.id, { nickname: agent.nickname, provider: agent.provider });
|
|
121
108
|
const status = agent.ended_at ? "ended" : agent.task_status;
|
|
122
109
|
const hasWindow = !agent.headless && !!agent.tmux_window_id;
|
|
123
110
|
const canAttach = live && hasWindow && status !== "ended";
|
|
124
|
-
const canKill = live && status !== "ended" && hasWindow
|
|
111
|
+
const canKill = live && status !== "ended" && hasWindow;
|
|
125
112
|
const canDelete = status === "ended";
|
|
126
113
|
return {
|
|
127
114
|
id: agent.id,
|
|
@@ -138,12 +125,12 @@ function buildWebState(options = {}) {
|
|
|
138
125
|
canDelete,
|
|
139
126
|
disabledReason: canAttach ? null : status === "ended" ? "agent has ended" : !live ? "run tmux session is unavailable" : "agent has no tmux window",
|
|
140
127
|
monogram: monogram(agent.nickname, agent.provider),
|
|
141
|
-
color: providerColor(agent.provider)
|
|
128
|
+
color: providerColor(agent.provider),
|
|
129
|
+
task: agent.task
|
|
142
130
|
};
|
|
143
131
|
});
|
|
144
132
|
return {
|
|
145
133
|
id: run.id,
|
|
146
|
-
mode,
|
|
147
134
|
name: run.name,
|
|
148
135
|
status: runStatus,
|
|
149
136
|
working_dir: run.working_dir,
|
|
@@ -152,10 +139,9 @@ function buildWebState(options = {}) {
|
|
|
152
139
|
terminals
|
|
153
140
|
};
|
|
154
141
|
});
|
|
155
|
-
const history = listRunHistory(
|
|
142
|
+
const history = listRunHistory().map((record) => ({
|
|
156
143
|
id: record.id,
|
|
157
144
|
name: record.name,
|
|
158
|
-
mode: record.mode,
|
|
159
145
|
status: record.status,
|
|
160
146
|
working_dir: record.working_dir,
|
|
161
147
|
started_at: record.started_at,
|
|
@@ -165,7 +151,24 @@ function buildWebState(options = {}) {
|
|
|
165
151
|
root_provider: record.root_provider,
|
|
166
152
|
root_provider_label: record.root_provider ? providerDisplayName(record.root_provider) : null
|
|
167
153
|
}));
|
|
168
|
-
|
|
154
|
+
const approvals = listRunApprovals(void 0, "pending").map((approval) => {
|
|
155
|
+
const info = agentIndex.get(approval.agent_id);
|
|
156
|
+
return {
|
|
157
|
+
id: approval.id,
|
|
158
|
+
run_id: approval.run_id,
|
|
159
|
+
run_name: runNameById.get(approval.run_id) ?? approval.run_id,
|
|
160
|
+
agent_id: approval.agent_id,
|
|
161
|
+
agent_nickname: info?.nickname ?? approval.agent_id,
|
|
162
|
+
provider: info?.provider ?? null,
|
|
163
|
+
provider_label: info ? providerDisplayName(info.provider) : null,
|
|
164
|
+
color: info ? providerColor(info.provider) : null,
|
|
165
|
+
action: approval.action,
|
|
166
|
+
summary: approval.summary,
|
|
167
|
+
risk: approval.risk,
|
|
168
|
+
requested_at: approval.requested_at
|
|
169
|
+
};
|
|
170
|
+
});
|
|
171
|
+
return { runs, history, approvals };
|
|
169
172
|
}
|
|
170
173
|
function listWebProviders() {
|
|
171
174
|
const available = detectAvailable();
|
|
@@ -173,7 +176,6 @@ function listWebProviders() {
|
|
|
173
176
|
id,
|
|
174
177
|
name: providerDisplayName(id),
|
|
175
178
|
available: available[id],
|
|
176
|
-
orchestrator: isOrchestratorWebProvider(id),
|
|
177
179
|
color: providerColor(id),
|
|
178
180
|
models: [...modelValuesForProvider(id)]
|
|
179
181
|
}));
|
|
@@ -238,7 +240,7 @@ function placeholderPage() {
|
|
|
238
240
|
<body>
|
|
239
241
|
<header>
|
|
240
242
|
<h1>ReevesAgents</h1>
|
|
241
|
-
<span class="tag">web ui
|
|
243
|
+
<span class="tag">web ui \xB7 loopback only</span>
|
|
242
244
|
</header>
|
|
243
245
|
<main id="app"><p class="empty">Loading agents...</p></main>
|
|
244
246
|
<script>
|
|
@@ -283,11 +285,10 @@ import { randomBytes } from "crypto";
|
|
|
283
285
|
import { URL as URL2 } from "url";
|
|
284
286
|
import { WebSocketServer } from "ws";
|
|
285
287
|
import pty from "@lydell/node-pty";
|
|
286
|
-
function resolveTerminalTarget(id
|
|
288
|
+
function resolveTerminalTarget(id) {
|
|
287
289
|
if (!id) throw new Error("missing agent id");
|
|
288
|
-
const agent =
|
|
289
|
-
|
|
290
|
-
else readRun(agent.run_id);
|
|
290
|
+
const agent = findAgent(id);
|
|
291
|
+
readRun(agent.run_id);
|
|
291
292
|
if (agent.ended_at) throw new Error("agent has ended");
|
|
292
293
|
if (agent.headless || !agent.tmux_window_id) throw new Error("agent has no tmux window");
|
|
293
294
|
return { session: agent.tmux_session, windowId: agent.tmux_window_id, nickname: agent.nickname };
|
|
@@ -337,10 +338,10 @@ function disposeBridge(bridge) {
|
|
|
337
338
|
} catch {
|
|
338
339
|
}
|
|
339
340
|
}
|
|
340
|
-
function openBridge(ws, id, bridges
|
|
341
|
+
function openBridge(ws, id, bridges) {
|
|
341
342
|
let target;
|
|
342
343
|
try {
|
|
343
|
-
target = resolveTerminalTarget(id
|
|
344
|
+
target = resolveTerminalTarget(id);
|
|
344
345
|
} catch (err) {
|
|
345
346
|
send(ws, { t: "e", m: err instanceof Error ? err.message : "agent not found" });
|
|
346
347
|
ws.close();
|
|
@@ -399,7 +400,7 @@ function openBridge(ws, id, bridges, options) {
|
|
|
399
400
|
ws.on("close", cleanup);
|
|
400
401
|
ws.on("error", cleanup);
|
|
401
402
|
}
|
|
402
|
-
function attachTerminalBridge(server, getPort
|
|
403
|
+
function attachTerminalBridge(server, getPort) {
|
|
403
404
|
const wss = new WebSocketServer({ noServer: true });
|
|
404
405
|
const bridges = /* @__PURE__ */ new Set();
|
|
405
406
|
server.on("upgrade", (req, socket, head) => {
|
|
@@ -422,7 +423,7 @@ function attachTerminalBridge(server, getPort, options = {}) {
|
|
|
422
423
|
socket.destroy();
|
|
423
424
|
return;
|
|
424
425
|
}
|
|
425
|
-
wss.handleUpgrade(req, socket, head, (ws) => openBridge(ws, id, bridges
|
|
426
|
+
wss.handleUpgrade(req, socket, head, (ws) => openBridge(ws, id, bridges));
|
|
426
427
|
});
|
|
427
428
|
return {
|
|
428
429
|
close: () => new Promise((resolve) => {
|
|
@@ -496,13 +497,13 @@ function serveIndex(res, ctx) {
|
|
|
496
497
|
}
|
|
497
498
|
send2(res, 200, buf, "text/html; charset=utf-8");
|
|
498
499
|
}
|
|
499
|
-
function createSseHub(
|
|
500
|
+
function createSseHub() {
|
|
500
501
|
const clients = /* @__PURE__ */ new Set();
|
|
501
502
|
let timer = null;
|
|
502
503
|
let last = "";
|
|
503
504
|
const snapshot = () => {
|
|
504
|
-
autoCleanupRuns({
|
|
505
|
-
return JSON.stringify(buildWebState(
|
|
505
|
+
autoCleanupRuns({ cleanStale: false });
|
|
506
|
+
return JSON.stringify(buildWebState());
|
|
506
507
|
};
|
|
507
508
|
const write = (res, payload) => {
|
|
508
509
|
try {
|
|
@@ -590,55 +591,38 @@ function normalizePermissionsInput(raw) {
|
|
|
590
591
|
if (raw === "ask" || raw === "skip") return raw;
|
|
591
592
|
throw new Error("unknown permission mode");
|
|
592
593
|
}
|
|
593
|
-
|
|
594
|
+
function parseAuthModeInput(raw) {
|
|
595
|
+
if (raw === void 0 || raw === null || raw === "") return void 0;
|
|
596
|
+
if (raw === "default" || raw === "api-key") return raw;
|
|
597
|
+
throw new Error("unknown auth mode");
|
|
598
|
+
}
|
|
599
|
+
function parseEffortInput(raw) {
|
|
600
|
+
if (raw === void 0 || raw === null || raw === "") return void 0;
|
|
601
|
+
if (raw === "default" || raw === "low" || raw === "medium" || raw === "high" || raw === "xhigh" || raw === "max") return raw;
|
|
602
|
+
throw new Error("unknown effort");
|
|
603
|
+
}
|
|
604
|
+
async function createTerminal(body) {
|
|
594
605
|
const provider = body.provider;
|
|
595
606
|
const normalizedProvider = normalizeProvider(provider);
|
|
596
607
|
if (!normalizedProvider) throw new Error("unknown provider");
|
|
597
608
|
const model = normalizeModel(normalizedProvider, body.model);
|
|
598
609
|
const permissions = normalizePermissionsInput(body.permissions);
|
|
610
|
+
const auth_mode = parseAuthModeInput(body.auth_mode);
|
|
611
|
+
const effort = parseEffortInput(body.effort);
|
|
599
612
|
const nickname = sanitizeNickname(typeof body.nickname === "string" ? body.nickname : "");
|
|
600
613
|
const runName = sanitizeRunName(typeof body.run_name === "string" ? body.run_name : "");
|
|
601
614
|
const prompt = typeof body.prompt === "string" ? body.prompt : "";
|
|
602
615
|
const runId = typeof body.run_id === "string" && body.run_id ? body.run_id : null;
|
|
603
616
|
if (runId) {
|
|
604
|
-
|
|
605
|
-
const
|
|
606
|
-
if (mode2 === "orchestrator") {
|
|
607
|
-
if (!ctx.orchestratorRuntime) throw new Error("PRE-BETA orchestrator web mode is not enabled");
|
|
608
|
-
if (!isOrchestratorWebProvider(normalizedProvider)) throw new Error("provider is not supported in PRE-BETA orchestrator mode");
|
|
609
|
-
const agent2 = ctx.orchestratorRuntime.spawnWorker({
|
|
610
|
-
run_id: runId,
|
|
611
|
-
provider: normalizedProvider,
|
|
612
|
-
nickname: nickname || void 0,
|
|
613
|
-
model,
|
|
614
|
-
permissions,
|
|
615
|
-
task: prompt
|
|
616
|
-
});
|
|
617
|
-
return { id: agent2.id, run_id: agent2.run_id };
|
|
618
|
-
}
|
|
619
|
-
const agent = spawnWorker({ run_id: runId, provider: normalizedProvider, nickname: nickname || void 0, model, permissions, task: prompt });
|
|
617
|
+
readRun(runId);
|
|
618
|
+
const agent = spawnWorker({ run_id: runId, provider: normalizedProvider, nickname: nickname || void 0, model, permissions, auth_mode, effort, task: prompt });
|
|
620
619
|
return { id: agent.id, run_id: agent.run_id };
|
|
621
620
|
}
|
|
622
|
-
const mode = body.mode === "orchestrator" ? "orchestrator" : "spawner";
|
|
623
621
|
const workingDir = typeof body.working_dir === "string" && body.working_dir.trim() ? body.working_dir.trim() : process.cwd();
|
|
624
|
-
if (mode === "orchestrator") {
|
|
625
|
-
if (!ctx.prebetaOrchestrator || !ctx.orchestratorRuntime) throw new Error("PRE-BETA orchestrator web mode is not enabled");
|
|
626
|
-
if (!isOrchestratorWebProvider(normalizedProvider)) throw new Error("provider is not supported in PRE-BETA orchestrator mode");
|
|
627
|
-
const result2 = ctx.orchestratorRuntime.startRun({
|
|
628
|
-
mode: "orchestrator",
|
|
629
|
-
name: runName || nickname || providerDisplayName(normalizedProvider),
|
|
630
|
-
working_dir: workingDir,
|
|
631
|
-
root: { provider: normalizedProvider, nickname: nickname || void 0, model, permissions, task: prompt }
|
|
632
|
-
});
|
|
633
|
-
const root2 = result2.agents[0];
|
|
634
|
-
if (!root2) throw new Error("run created no agent");
|
|
635
|
-
return { id: root2.id, run_id: result2.run.id };
|
|
636
|
-
}
|
|
637
622
|
const result = startRun({
|
|
638
|
-
mode: "spawner",
|
|
639
623
|
name: runName || nickname || providerDisplayName(normalizedProvider),
|
|
640
624
|
working_dir: workingDir,
|
|
641
|
-
root: { provider: normalizedProvider, nickname: nickname || void 0, model, permissions, task: prompt }
|
|
625
|
+
root: { provider: normalizedProvider, nickname: nickname || void 0, model, permissions, auth_mode, effort, task: prompt }
|
|
642
626
|
});
|
|
643
627
|
const root = result.agents[0];
|
|
644
628
|
if (!root) throw new Error("run created no agent");
|
|
@@ -649,45 +633,84 @@ function requireConfirm(body) {
|
|
|
649
633
|
}
|
|
650
634
|
function updateLanguage(body) {
|
|
651
635
|
if (!isLanguageCode(body.language)) throw new Error("unknown language");
|
|
652
|
-
|
|
653
|
-
cfg.global.language = body.language;
|
|
654
|
-
saveConfig(cfg);
|
|
636
|
+
setConfigValues({ language: body.language });
|
|
655
637
|
return webLanguagePayload();
|
|
656
638
|
}
|
|
657
|
-
function
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
639
|
+
function mcpHostsPayload() {
|
|
640
|
+
return { hosts: hostStatus() };
|
|
641
|
+
}
|
|
642
|
+
function attachMcpHostAction(body) {
|
|
643
|
+
const key = typeof body.key === "string" ? body.key : "";
|
|
644
|
+
if (!key) throw new Error("host key is required");
|
|
645
|
+
const result = attach(key);
|
|
646
|
+
return { result, hosts: hostStatus() };
|
|
647
|
+
}
|
|
648
|
+
function detachMcpHostAction(body) {
|
|
649
|
+
const key = typeof body.key === "string" ? body.key : "";
|
|
650
|
+
if (!key) throw new Error("host key is required");
|
|
651
|
+
const result = detach(key);
|
|
652
|
+
return { result, hosts: hostStatus() };
|
|
653
|
+
}
|
|
654
|
+
function attachAllMcpHostsAction() {
|
|
655
|
+
return { results: attachAll(), hosts: hostStatus() };
|
|
656
|
+
}
|
|
657
|
+
function configPayload() {
|
|
658
|
+
return { config: loadConfig().global, fields: CONFIG_FIELDS.filter((field) => field.kind !== "language") };
|
|
659
|
+
}
|
|
660
|
+
function updateConfigAction(body) {
|
|
661
|
+
const patch = {};
|
|
662
|
+
for (const field of CONFIG_FIELDS.filter((field2) => field2.kind !== "language")) {
|
|
663
|
+
if (body[field.key] !== void 0) patch[field.key] = body[field.key];
|
|
663
664
|
}
|
|
664
|
-
if (
|
|
665
|
-
|
|
665
|
+
if (Object.keys(patch).length === 0) throw new Error("no config fields to set");
|
|
666
|
+
return { config: setConfigValues(patch).global };
|
|
667
|
+
}
|
|
668
|
+
function presetsPayload() {
|
|
669
|
+
return { presets: listPresets() };
|
|
670
|
+
}
|
|
671
|
+
function savePresetAction(body) {
|
|
672
|
+
const runId = typeof body.run_id === "string" ? body.run_id : "";
|
|
673
|
+
if (!runId) throw new Error("run_id is required");
|
|
674
|
+
const name = typeof body.name === "string" ? body.name : "";
|
|
675
|
+
const description = typeof body.description === "string" ? body.description : "";
|
|
676
|
+
return { preset: savePresetFromRun(runId, name, description), presets: listPresets() };
|
|
677
|
+
}
|
|
678
|
+
function startPresetAction(name) {
|
|
679
|
+
if (!listPresets().some((preset) => preset.name === name)) throw new Error("preset not found");
|
|
680
|
+
const result = startRunFromPreset(name);
|
|
681
|
+
return { run: result.run, agents: result.agents };
|
|
682
|
+
}
|
|
683
|
+
function deletePresetAction(name) {
|
|
684
|
+
if (!listPresets().some((preset) => preset.name === name)) throw new Error("preset not found");
|
|
685
|
+
deletePreset(name);
|
|
686
|
+
}
|
|
687
|
+
function killTerminal(id) {
|
|
688
|
+
killAgent(id);
|
|
666
689
|
}
|
|
667
|
-
function deleteTerminal(id
|
|
668
|
-
const agent =
|
|
690
|
+
function deleteTerminal(id) {
|
|
691
|
+
const agent = findAgent(id);
|
|
669
692
|
if (!agent.ended_at) throw new Error("Stop agent before deleting it");
|
|
670
|
-
deleteAgent(id
|
|
693
|
+
deleteAgent(id);
|
|
671
694
|
}
|
|
672
|
-
function stopWebRun(id
|
|
673
|
-
|
|
674
|
-
if (run.mode === "spawner") {
|
|
675
|
-
stopRun(id);
|
|
676
|
-
return;
|
|
677
|
-
}
|
|
678
|
-
if (!ctx.orchestratorRuntime) throw new Error("PRE-BETA orchestrator web mode is not enabled");
|
|
679
|
-
ctx.orchestratorRuntime.stopRun(id);
|
|
695
|
+
function stopWebRun(id) {
|
|
696
|
+
stopRun(id);
|
|
680
697
|
}
|
|
681
|
-
function deleteWebRun(id
|
|
682
|
-
const run =
|
|
698
|
+
function deleteWebRun(id) {
|
|
699
|
+
const run = readRun(id);
|
|
683
700
|
if (run.status !== "ended" && run.ended_at === null) throw new Error("Stop run before deleting it");
|
|
684
701
|
archiveAndRemoveRun(id, "ended");
|
|
685
702
|
}
|
|
686
|
-
function deleteHistoryRecord(id
|
|
687
|
-
const history = listRunHistory(
|
|
703
|
+
function deleteHistoryRecord(id) {
|
|
704
|
+
const history = listRunHistory();
|
|
688
705
|
if (!history.some((record) => record.id === id)) throw new Error("history record not found");
|
|
689
706
|
deleteRunHistory(id);
|
|
690
707
|
}
|
|
708
|
+
function resolveApprovalAction(id, body) {
|
|
709
|
+
const decision = body.decision === "approved" ? "approved" : body.decision === "denied" ? "denied" : null;
|
|
710
|
+
if (!decision) throw new Error("decision must be approved or denied");
|
|
711
|
+
const note = typeof body.note === "string" ? body.note : "";
|
|
712
|
+
return resolveRunApproval(id, decision, note);
|
|
713
|
+
}
|
|
691
714
|
async function handleRequest(req, res, ctx) {
|
|
692
715
|
if (!isAllowedHostHeader(req.headers.host)) {
|
|
693
716
|
send2(res, 403, "forbidden host", "text/plain; charset=utf-8");
|
|
@@ -709,15 +732,47 @@ async function handleRequest(req, res, ctx) {
|
|
|
709
732
|
return;
|
|
710
733
|
}
|
|
711
734
|
if (method === "GET" && path === "/api/state") {
|
|
712
|
-
autoCleanupRuns({
|
|
735
|
+
autoCleanupRuns({ cleanStale: false });
|
|
713
736
|
sendJson(res, 200, {
|
|
714
|
-
...buildWebState(
|
|
737
|
+
...buildWebState(),
|
|
715
738
|
providers: listWebProviders(),
|
|
716
|
-
|
|
717
|
-
|
|
739
|
+
language: webLanguagePayload(),
|
|
740
|
+
version: REEVESAGENTS_VERSION
|
|
718
741
|
});
|
|
719
742
|
return;
|
|
720
743
|
}
|
|
744
|
+
if (method === "GET" && path === "/api/mcp-hosts") {
|
|
745
|
+
try {
|
|
746
|
+
sendJson(res, 200, mcpHostsPayload());
|
|
747
|
+
} catch (err) {
|
|
748
|
+
sendJson(res, 400, { error: errMessage(err) });
|
|
749
|
+
}
|
|
750
|
+
return;
|
|
751
|
+
}
|
|
752
|
+
if (method === "GET" && path === "/api/doctor") {
|
|
753
|
+
try {
|
|
754
|
+
sendJson(res, 200, runDoctor());
|
|
755
|
+
} catch (err) {
|
|
756
|
+
sendJson(res, 400, { error: errMessage(err) });
|
|
757
|
+
}
|
|
758
|
+
return;
|
|
759
|
+
}
|
|
760
|
+
if (method === "GET" && path === "/api/config") {
|
|
761
|
+
try {
|
|
762
|
+
sendJson(res, 200, configPayload());
|
|
763
|
+
} catch (err) {
|
|
764
|
+
sendJson(res, 400, { error: errMessage(err) });
|
|
765
|
+
}
|
|
766
|
+
return;
|
|
767
|
+
}
|
|
768
|
+
if (method === "GET" && path === "/api/presets") {
|
|
769
|
+
try {
|
|
770
|
+
sendJson(res, 200, presetsPayload());
|
|
771
|
+
} catch (err) {
|
|
772
|
+
sendJson(res, 400, { error: errMessage(err) });
|
|
773
|
+
}
|
|
774
|
+
return;
|
|
775
|
+
}
|
|
721
776
|
if (method === "GET" && path === "/api/events") {
|
|
722
777
|
ctx.sse.add(res);
|
|
723
778
|
return;
|
|
@@ -729,7 +784,7 @@ async function handleRequest(req, res, ctx) {
|
|
|
729
784
|
if (method === "POST" && path === "/api/terminals") {
|
|
730
785
|
try {
|
|
731
786
|
const body = await readJsonBody(req);
|
|
732
|
-
sendJson(res, 200, await createTerminal(body
|
|
787
|
+
sendJson(res, 200, await createTerminal(body));
|
|
733
788
|
} catch (err) {
|
|
734
789
|
sendJson(res, 400, { error: errMessage(err) });
|
|
735
790
|
}
|
|
@@ -744,12 +799,77 @@ async function handleRequest(req, res, ctx) {
|
|
|
744
799
|
}
|
|
745
800
|
return;
|
|
746
801
|
}
|
|
802
|
+
if (method === "POST" && path === "/api/mcp-hosts/attach") {
|
|
803
|
+
try {
|
|
804
|
+
const body = await readJsonBody(req);
|
|
805
|
+
sendJson(res, 200, attachMcpHostAction(body));
|
|
806
|
+
} catch (err) {
|
|
807
|
+
sendJson(res, 400, { error: errMessage(err) });
|
|
808
|
+
}
|
|
809
|
+
return;
|
|
810
|
+
}
|
|
811
|
+
if (method === "POST" && path === "/api/mcp-hosts/detach") {
|
|
812
|
+
try {
|
|
813
|
+
const body = await readJsonBody(req);
|
|
814
|
+
sendJson(res, 200, detachMcpHostAction(body));
|
|
815
|
+
} catch (err) {
|
|
816
|
+
sendJson(res, 400, { error: errMessage(err) });
|
|
817
|
+
}
|
|
818
|
+
return;
|
|
819
|
+
}
|
|
820
|
+
if (method === "POST" && path === "/api/mcp-hosts/attach-all") {
|
|
821
|
+
try {
|
|
822
|
+
sendJson(res, 200, attachAllMcpHostsAction());
|
|
823
|
+
} catch (err) {
|
|
824
|
+
sendJson(res, 400, { error: errMessage(err) });
|
|
825
|
+
}
|
|
826
|
+
return;
|
|
827
|
+
}
|
|
828
|
+
if (method === "POST" && path === "/api/config") {
|
|
829
|
+
try {
|
|
830
|
+
const body = await readJsonBody(req);
|
|
831
|
+
sendJson(res, 200, updateConfigAction(body));
|
|
832
|
+
} catch (err) {
|
|
833
|
+
sendJson(res, 400, { error: errMessage(err) });
|
|
834
|
+
}
|
|
835
|
+
return;
|
|
836
|
+
}
|
|
837
|
+
if (method === "POST" && path === "/api/presets/save") {
|
|
838
|
+
try {
|
|
839
|
+
const body = await readJsonBody(req);
|
|
840
|
+
sendJson(res, 200, savePresetAction(body));
|
|
841
|
+
} catch (err) {
|
|
842
|
+
sendJson(res, 400, { error: errMessage(err) });
|
|
843
|
+
}
|
|
844
|
+
return;
|
|
845
|
+
}
|
|
846
|
+
const startPresetMatch = path.match(/^\/api\/presets\/([^/]+)\/start$/);
|
|
847
|
+
if (method === "POST" && startPresetMatch) {
|
|
848
|
+
try {
|
|
849
|
+
sendJson(res, 200, startPresetAction(decodeURIComponent(startPresetMatch[1])));
|
|
850
|
+
} catch (err) {
|
|
851
|
+
sendJson(res, 400, { error: errMessage(err) });
|
|
852
|
+
}
|
|
853
|
+
return;
|
|
854
|
+
}
|
|
855
|
+
const deletePresetMatch = path.match(/^\/api\/presets\/([^/]+)\/delete$/);
|
|
856
|
+
if (method === "POST" && deletePresetMatch) {
|
|
857
|
+
try {
|
|
858
|
+
const body = await readJsonBody(req);
|
|
859
|
+
requireConfirm(body);
|
|
860
|
+
deletePresetAction(decodeURIComponent(deletePresetMatch[1]));
|
|
861
|
+
sendJson(res, 200, { ok: true });
|
|
862
|
+
} catch (err) {
|
|
863
|
+
sendJson(res, 400, { error: errMessage(err) });
|
|
864
|
+
}
|
|
865
|
+
return;
|
|
866
|
+
}
|
|
747
867
|
const killMatch = path.match(/^\/api\/terminals\/([^/]+)\/kill$/);
|
|
748
868
|
if (method === "POST" && killMatch) {
|
|
749
869
|
try {
|
|
750
870
|
const body = await readJsonBody(req);
|
|
751
871
|
requireConfirm(body);
|
|
752
|
-
killTerminal(decodeURIComponent(killMatch[1])
|
|
872
|
+
killTerminal(decodeURIComponent(killMatch[1]));
|
|
753
873
|
sendJson(res, 200, { ok: true });
|
|
754
874
|
} catch (err) {
|
|
755
875
|
sendJson(res, 400, { error: errMessage(err) });
|
|
@@ -761,7 +881,7 @@ async function handleRequest(req, res, ctx) {
|
|
|
761
881
|
try {
|
|
762
882
|
const body = await readJsonBody(req);
|
|
763
883
|
requireConfirm(body);
|
|
764
|
-
deleteTerminal(decodeURIComponent(deleteTerminalMatch[1])
|
|
884
|
+
deleteTerminal(decodeURIComponent(deleteTerminalMatch[1]));
|
|
765
885
|
sendJson(res, 200, { ok: true });
|
|
766
886
|
} catch (err) {
|
|
767
887
|
sendJson(res, 400, { error: errMessage(err) });
|
|
@@ -773,7 +893,7 @@ async function handleRequest(req, res, ctx) {
|
|
|
773
893
|
try {
|
|
774
894
|
const body = await readJsonBody(req);
|
|
775
895
|
requireConfirm(body);
|
|
776
|
-
stopWebRun(decodeURIComponent(stopMatch[1])
|
|
896
|
+
stopWebRun(decodeURIComponent(stopMatch[1]));
|
|
777
897
|
sendJson(res, 200, { ok: true });
|
|
778
898
|
} catch (err) {
|
|
779
899
|
sendJson(res, 400, { error: errMessage(err) });
|
|
@@ -785,7 +905,7 @@ async function handleRequest(req, res, ctx) {
|
|
|
785
905
|
try {
|
|
786
906
|
const body = await readJsonBody(req);
|
|
787
907
|
requireConfirm(body);
|
|
788
|
-
deleteWebRun(decodeURIComponent(deleteRunMatch[1])
|
|
908
|
+
deleteWebRun(decodeURIComponent(deleteRunMatch[1]));
|
|
789
909
|
sendJson(res, 200, { ok: true });
|
|
790
910
|
} catch (err) {
|
|
791
911
|
sendJson(res, 400, { error: errMessage(err) });
|
|
@@ -797,13 +917,23 @@ async function handleRequest(req, res, ctx) {
|
|
|
797
917
|
try {
|
|
798
918
|
const body = await readJsonBody(req);
|
|
799
919
|
requireConfirm(body);
|
|
800
|
-
deleteHistoryRecord(decodeURIComponent(deleteHistoryMatch[1])
|
|
920
|
+
deleteHistoryRecord(decodeURIComponent(deleteHistoryMatch[1]));
|
|
801
921
|
sendJson(res, 200, { ok: true });
|
|
802
922
|
} catch (err) {
|
|
803
923
|
sendJson(res, 400, { error: errMessage(err) });
|
|
804
924
|
}
|
|
805
925
|
return;
|
|
806
926
|
}
|
|
927
|
+
const resolveApprovalMatch = path.match(/^\/api\/approvals\/([^/]+)\/resolve$/);
|
|
928
|
+
if (method === "POST" && resolveApprovalMatch) {
|
|
929
|
+
try {
|
|
930
|
+
const body = await readJsonBody(req);
|
|
931
|
+
sendJson(res, 200, resolveApprovalAction(decodeURIComponent(resolveApprovalMatch[1]), body));
|
|
932
|
+
} catch (err) {
|
|
933
|
+
sendJson(res, 400, { error: errMessage(err) });
|
|
934
|
+
}
|
|
935
|
+
return;
|
|
936
|
+
}
|
|
807
937
|
send2(res, 404, "not found", "text/plain; charset=utf-8");
|
|
808
938
|
}
|
|
809
939
|
function listenWithFallback(server, basePort, range) {
|
|
@@ -831,19 +961,15 @@ async function startWebServer(options = {}) {
|
|
|
831
961
|
const basePort = options.port && Number.isFinite(options.port) ? options.port : DEFAULT_PORT;
|
|
832
962
|
const range = options.range && options.range > 0 ? options.range : DEFAULT_RANGE;
|
|
833
963
|
const webRoot = options.webRoot ?? DEFAULT_WEB_ROOT;
|
|
834
|
-
const prebetaOrchestrator = options.prebetaOrchestrator === true;
|
|
835
|
-
const orchestratorRuntime = prebetaOrchestrator ? await loadWebOrchestratorRuntime(options.orchestratorRuntime) : void 0;
|
|
836
964
|
const cache = /* @__PURE__ */ new Map();
|
|
837
|
-
const sse = createSseHub(
|
|
965
|
+
const sse = createSseHub();
|
|
838
966
|
const sockets = /* @__PURE__ */ new Set();
|
|
839
967
|
let boundPort = basePort;
|
|
840
968
|
const ctx = {
|
|
841
969
|
port: () => boundPort,
|
|
842
970
|
webRoot,
|
|
843
971
|
cache,
|
|
844
|
-
sse
|
|
845
|
-
prebetaOrchestrator,
|
|
846
|
-
orchestratorRuntime
|
|
972
|
+
sse
|
|
847
973
|
};
|
|
848
974
|
const server = createServer((req, res) => {
|
|
849
975
|
handleRequest(req, res, ctx).catch(() => {
|
|
@@ -857,7 +983,7 @@ async function startWebServer(options = {}) {
|
|
|
857
983
|
sockets.add(socket);
|
|
858
984
|
socket.on("close", () => sockets.delete(socket));
|
|
859
985
|
});
|
|
860
|
-
const bridge = attachTerminalBridge(server, () => boundPort
|
|
986
|
+
const bridge = attachTerminalBridge(server, () => boundPort);
|
|
861
987
|
boundPort = await listenWithFallback(server, basePort, range);
|
|
862
988
|
const url = `http://${HOST}:${boundPort}`;
|
|
863
989
|
if (options.open !== false) {
|
|
@@ -880,4 +1006,4 @@ async function startWebServer(options = {}) {
|
|
|
880
1006
|
export {
|
|
881
1007
|
startWebServer
|
|
882
1008
|
};
|
|
883
|
-
//# sourceMappingURL=server-
|
|
1009
|
+
//# sourceMappingURL=server-ZJKAIRL5.js.map
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import {
|
|
3
3
|
closeTuiWebServer,
|
|
4
4
|
startWebFromTui
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-5DOCQLT7.js";
|
|
6
6
|
export {
|
|
7
7
|
closeTuiWebServer,
|
|
8
8
|
startWebFromTui
|
|
9
9
|
};
|
|
10
|
-
//# sourceMappingURL=tui-launch-
|
|
10
|
+
//# sourceMappingURL=tui-launch-VHLX6JOW.js.map
|