@proagentstore/cli 0.2.6 → 0.2.7
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.
|
@@ -175,6 +175,53 @@ async function route(runner, req, res) {
|
|
|
175
175
|
pagsTmuxTotal: pagsTmux.length,
|
|
176
176
|
});
|
|
177
177
|
}
|
|
178
|
+
if (req.method === "POST" && path === "/coding/browse") {
|
|
179
|
+
const { readdirSync, statSync } = await import("node:fs");
|
|
180
|
+
const { resolve, basename } = await import("node:path");
|
|
181
|
+
const { homedir } = await import("node:os");
|
|
182
|
+
const b = await readJson(req);
|
|
183
|
+
const raw = (b.dir || "~").replace(/^~(?=$|\/)/, homedir());
|
|
184
|
+
const dir = resolve(raw);
|
|
185
|
+
try {
|
|
186
|
+
const entries = readdirSync(dir, { withFileTypes: true })
|
|
187
|
+
.filter((e) => !e.name.startsWith("."))
|
|
188
|
+
.slice(0, 200)
|
|
189
|
+
.map((e) => ({
|
|
190
|
+
name: e.name,
|
|
191
|
+
type: e.isDirectory() ? "dir" : "file",
|
|
192
|
+
size: e.isFile() ? statSync(resolve(dir, e.name)).size : undefined,
|
|
193
|
+
}));
|
|
194
|
+
return json(res, 200, { dir, entries });
|
|
195
|
+
}
|
|
196
|
+
catch (e) {
|
|
197
|
+
return json(res, 400, { error: e instanceof Error ? e.message : String(e), dir });
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
if (req.method === "POST" && path === "/coding/kill-tmux") {
|
|
201
|
+
const { killSession: tmuxKill, listSessions: tmuxList } = await import("./coding/tmux.js");
|
|
202
|
+
const b = await readJson(req);
|
|
203
|
+
let targets = [];
|
|
204
|
+
if (b.orphansOnly) {
|
|
205
|
+
const allTmux = tmuxList();
|
|
206
|
+
const pagsTmux = allTmux.filter((n) => n.startsWith("pags-"));
|
|
207
|
+
const tracked = new Set(runner.coding.diagnostics().map((s) => s.tmuxSession));
|
|
208
|
+
targets = pagsTmux.filter((n) => !tracked.has(n));
|
|
209
|
+
}
|
|
210
|
+
else if (b.sessions?.length) {
|
|
211
|
+
targets = b.sessions.filter((n) => typeof n === "string" && n.startsWith("pags-"));
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
// Kill all pags-* tmux sessions
|
|
215
|
+
targets = tmuxList().filter((n) => n.startsWith("pags-"));
|
|
216
|
+
runner.coding.closeAll();
|
|
217
|
+
}
|
|
218
|
+
let killed = 0;
|
|
219
|
+
for (const name of targets) {
|
|
220
|
+
if (tmuxKill(name))
|
|
221
|
+
killed++;
|
|
222
|
+
}
|
|
223
|
+
return json(res, 200, { killed, sessions: targets });
|
|
224
|
+
}
|
|
178
225
|
if (req.method === "POST" && path === "/coding/event") {
|
|
179
226
|
// Brain progress events — recorded by PAGS, ignored locally. Accept + ack.
|
|
180
227
|
return json(res, 200, { ok: true });
|