@proagentstore/cli 0.2.5 → 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.
- package/dist/browser-runner/server.js +47 -0
- package/dist/index.js +11 -6
- package/package.json +1 -1
|
@@ -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 });
|
package/dist/index.js
CHANGED
|
@@ -616,7 +616,7 @@ import { randomUUID } from "crypto";
|
|
|
616
616
|
import { existsSync as existsSync5 } from "fs";
|
|
617
617
|
import { chmod, mkdir, writeFile } from "fs/promises";
|
|
618
618
|
import { gunzipSync } from "zlib";
|
|
619
|
-
import { arch, homedir as homedir2, platform } from "os";
|
|
619
|
+
import { arch, homedir as homedir2, hostname, platform } from "os";
|
|
620
620
|
import { resolve as resolve4 } from "path";
|
|
621
621
|
import { createServer as createServer2 } from "net";
|
|
622
622
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
@@ -786,7 +786,8 @@ function buildRuntimeRegistrationBody(opts, capabilities = []) {
|
|
|
786
786
|
token: clean(opts.runnerToken) || clean(opts.token) || clean(process.env.PAGS_RUNNER_TOKEN),
|
|
787
787
|
placement: opts.placement === "managed" ? "managed" : "local",
|
|
788
788
|
capabilities,
|
|
789
|
-
runnerVersion: clean(opts.runnerVersion) || ""
|
|
789
|
+
runnerVersion: clean(opts.runnerVersion) || "",
|
|
790
|
+
runnerNode: hostname()
|
|
790
791
|
};
|
|
791
792
|
}
|
|
792
793
|
function clean(value) {
|
|
@@ -917,7 +918,8 @@ async function connectViaRelay(instanceIds, localUrl, runnerToken, opts) {
|
|
|
917
918
|
token: runnerToken,
|
|
918
919
|
placement: "local",
|
|
919
920
|
capabilities: caps,
|
|
920
|
-
runnerVersion: ""
|
|
921
|
+
runnerVersion: "",
|
|
922
|
+
runnerNode: hostname()
|
|
921
923
|
}).catch((e) => writeError(`register ${id.slice(0, 8)}\u2026 failed: ${e instanceof Error ? e.message : String(e)}`));
|
|
922
924
|
}
|
|
923
925
|
for (const id of instanceIds) {
|
|
@@ -1083,7 +1085,8 @@ function createRunnerCommand() {
|
|
|
1083
1085
|
token: runnerToken,
|
|
1084
1086
|
placement: "local",
|
|
1085
1087
|
capabilities: caps,
|
|
1086
|
-
runnerVersion: clean(opts.runnerVersion) || ""
|
|
1088
|
+
runnerVersion: clean(opts.runnerVersion) || "",
|
|
1089
|
+
runnerNode: hostname()
|
|
1087
1090
|
});
|
|
1088
1091
|
} catch (error) {
|
|
1089
1092
|
writeError(`register ${id.slice(0, 8)}\u2026 failed (${error instanceof Error ? error.message : String(error)})`);
|
|
@@ -1141,7 +1144,8 @@ function createRunnerCommand() {
|
|
|
1141
1144
|
token: runnerToken,
|
|
1142
1145
|
placement: "local",
|
|
1143
1146
|
capabilities: caps,
|
|
1144
|
-
runnerVersion: clean(opts.runnerVersion) || ""
|
|
1147
|
+
runnerVersion: clean(opts.runnerVersion) || "",
|
|
1148
|
+
runnerNode: hostname()
|
|
1145
1149
|
});
|
|
1146
1150
|
} catch (error) {
|
|
1147
1151
|
writeError(`register ${id.slice(0, 8)}\u2026 failed (${error instanceof Error ? error.message : String(error)}); will retry`);
|
|
@@ -1348,6 +1352,7 @@ import { Command as Command7 } from "commander";
|
|
|
1348
1352
|
|
|
1349
1353
|
// src/tui.ts
|
|
1350
1354
|
import chalk from "chalk";
|
|
1355
|
+
import { hostname as hostname2 } from "os";
|
|
1351
1356
|
import readline from "readline";
|
|
1352
1357
|
var ACCENT = "#7c3aed";
|
|
1353
1358
|
var c = chalk.hex(ACCENT);
|
|
@@ -1389,7 +1394,7 @@ function printStatus(state) {
|
|
|
1389
1394
|
clearScreen();
|
|
1390
1395
|
printLogo(state.version);
|
|
1391
1396
|
const connected = state.runner === "online" && state.tunnel === "online" && state.registration === "registered";
|
|
1392
|
-
console.log(pad + d("Signed in as ") + w(state.user) + d(" \xB7 agent: ") + w(state.activeInstance));
|
|
1397
|
+
console.log(pad + d("Signed in as ") + w(state.user) + d(" \xB7 agent: ") + w(state.activeInstance) + d(" \xB7 node: ") + w(hostname2()));
|
|
1393
1398
|
console.log("");
|
|
1394
1399
|
const row = (kind, s) => {
|
|
1395
1400
|
const { icon, label, note } = describe(kind, s);
|