@proagentstore/cli 0.1.20 → 0.1.22
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/runner.js +6 -1
- package/dist/index.js +90 -32
- package/package.json +1 -1
|
@@ -472,9 +472,14 @@ export class LocalRunner {
|
|
|
472
472
|
headless: this.config.headless,
|
|
473
473
|
acceptDownloads: true,
|
|
474
474
|
downloadsPath,
|
|
475
|
+
// viewport:null + --start-maximized → the page uses the FULL window size
|
|
476
|
+
// instead of Playwright's cramped 1280x720 default. Without this a
|
|
477
|
+
// reCAPTCHA challenge popup near the edge overflows and gets cut off the
|
|
478
|
+
// right in the takeover view, so it can't be solved.
|
|
479
|
+
viewport: null,
|
|
475
480
|
// Light anti-detection: drop the most obvious automation tell so fewer
|
|
476
481
|
// CAPTCHAs trigger in the first place (the human still solves the rest).
|
|
477
|
-
args: ["--disable-blink-features=AutomationControlled"],
|
|
482
|
+
args: ["--disable-blink-features=AutomationControlled", "--start-maximized", "--window-size=1512,982"],
|
|
478
483
|
};
|
|
479
484
|
// Prefer the real Chrome build (better TLS/fingerprint → fewer CAPTCHAs);
|
|
480
485
|
// fall back to bundled Chromium if Chrome isn't installed. Disable with
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
7
7
|
});
|
|
8
8
|
|
|
9
9
|
// src/index.ts
|
|
10
|
-
import { createRequire } from "module";
|
|
10
|
+
import { createRequire as createRequire2 } from "module";
|
|
11
11
|
import { Command as Command8 } from "commander";
|
|
12
12
|
|
|
13
13
|
// src/commands/check.ts
|
|
@@ -774,7 +774,11 @@ async function resolveCloudflaredCommand(requested) {
|
|
|
774
774
|
return downloadCloudflared(cloudflaredAssetForPlatform());
|
|
775
775
|
}
|
|
776
776
|
function parseCloudflaredTunnelUrl(text) {
|
|
777
|
-
|
|
777
|
+
const matches = text.match(/https:\/\/[a-z0-9-]+\.trycloudflare\.com/gi) || [];
|
|
778
|
+
for (const m of matches) {
|
|
779
|
+
if (!/^https:\/\/api\.trycloudflare\.com/i.test(m)) return m;
|
|
780
|
+
}
|
|
781
|
+
return null;
|
|
778
782
|
}
|
|
779
783
|
function buildRuntimeRegistrationBody(opts, capabilities = []) {
|
|
780
784
|
return {
|
|
@@ -977,7 +981,9 @@ function createRunnerCommand() {
|
|
|
977
981
|
const first = await openTunnel();
|
|
978
982
|
tunnel = first.proc;
|
|
979
983
|
let tunnelUrl = first.url;
|
|
980
|
-
await registerRuntime(tunnelUrl)
|
|
984
|
+
await registerRuntime(tunnelUrl).catch((error) => {
|
|
985
|
+
writeError(`registration will retry (${error instanceof Error ? error.message : String(error)})`);
|
|
986
|
+
});
|
|
981
987
|
writeLine("Runtime registered with PAGS \u2713");
|
|
982
988
|
writeLine("");
|
|
983
989
|
writeLine("\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550");
|
|
@@ -1004,7 +1010,10 @@ function createRunnerCommand() {
|
|
|
1004
1010
|
await new Promise((r) => setTimeout(r, 3e4));
|
|
1005
1011
|
if (stopped) break;
|
|
1006
1012
|
if (await probeTunnel(tunnelUrl)) {
|
|
1007
|
-
await requestPags("POST", heartbeatPath, opts, {}).catch(() =>
|
|
1013
|
+
const beat = await requestPags("POST", heartbeatPath, opts, {}).then(() => true).catch(() => false);
|
|
1014
|
+
if (!beat) {
|
|
1015
|
+
await registerRuntime(tunnelUrl).then(() => writeLine("\u2705 Re-registered with PAGS")).catch(() => void 0);
|
|
1016
|
+
}
|
|
1008
1017
|
continue;
|
|
1009
1018
|
}
|
|
1010
1019
|
writeLine("\u26A0 Tunnel unreachable \u2014 reconnecting\u2026");
|
|
@@ -1142,6 +1151,7 @@ function createRunnerCommand() {
|
|
|
1142
1151
|
}
|
|
1143
1152
|
|
|
1144
1153
|
// src/commands/up.ts
|
|
1154
|
+
import { createRequire } from "module";
|
|
1145
1155
|
import { Command as Command7 } from "commander";
|
|
1146
1156
|
|
|
1147
1157
|
// src/tui.ts
|
|
@@ -1163,43 +1173,56 @@ var LOGO = [
|
|
|
1163
1173
|
function clearScreen() {
|
|
1164
1174
|
console.clear();
|
|
1165
1175
|
}
|
|
1166
|
-
function printLogo() {
|
|
1176
|
+
function printLogo(version2) {
|
|
1167
1177
|
console.log("");
|
|
1168
1178
|
for (const line of LOGO) {
|
|
1169
1179
|
console.log(pad + c(line));
|
|
1170
1180
|
}
|
|
1181
|
+
console.log(pad + d(" Browser runner") + (version2 ? d(` \xB7 v${version2}`) : ""));
|
|
1171
1182
|
console.log("");
|
|
1172
1183
|
}
|
|
1184
|
+
function describe(kind, s) {
|
|
1185
|
+
const ok = s === "online" || s === "registered";
|
|
1186
|
+
const busy = s === "starting" || s === "pending";
|
|
1187
|
+
const icon = ok ? chalk.green("\u2713") : busy ? chalk.yellow("\u2026") : chalk.red("\u2717");
|
|
1188
|
+
const map = {
|
|
1189
|
+
runner: { label: "Browser", ok: "running on your computer", busy: "starting up\u2026", bad: "stopped \u2014 press r to retry" },
|
|
1190
|
+
tunnel: { label: "Secure link", ok: "connected to ProAgentStore", busy: "opening\u2026", bad: "offline" },
|
|
1191
|
+
pags: { label: "ProAgentStore", ok: "connected \u2014 ready for jobs", busy: "registering\u2026", bad: "not registered (retries automatically)" }
|
|
1192
|
+
};
|
|
1193
|
+
const m = map[kind];
|
|
1194
|
+
return { icon, label: m.label, note: ok ? m.ok : busy ? m.busy : m.bad };
|
|
1195
|
+
}
|
|
1173
1196
|
function printStatus(state) {
|
|
1174
1197
|
clearScreen();
|
|
1175
|
-
printLogo();
|
|
1176
|
-
const
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
const statusText = (s) => {
|
|
1183
|
-
if (s === "online" || s === "registered") return chalk.green(s);
|
|
1184
|
-
if (s === "starting" || s === "pending") return chalk.yellow(s);
|
|
1185
|
-
if (s === "error" || s === "failed") return chalk.red(s);
|
|
1186
|
-
return d(s);
|
|
1198
|
+
printLogo(state.version);
|
|
1199
|
+
const connected = state.runner === "online" && state.tunnel === "online" && state.registration === "registered";
|
|
1200
|
+
console.log(pad + d("Signed in as ") + w(state.user) + d(" \xB7 agent: ") + w(state.activeInstance));
|
|
1201
|
+
console.log("");
|
|
1202
|
+
const row = (kind, s) => {
|
|
1203
|
+
const { icon, label, note } = describe(kind, s);
|
|
1204
|
+
console.log(pad + icon + " " + w(label.padEnd(13)) + d(note));
|
|
1187
1205
|
};
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
console.log(pad + d("Tunnel ") + statusIcon(state.tunnel) + " " + statusText(state.tunnel));
|
|
1192
|
-
console.log(pad + d("PAGS ") + statusIcon(state.registration) + " " + statusText(state.registration));
|
|
1193
|
-
if (state.tunnelUrl) {
|
|
1194
|
-
console.log(pad + d("URL ") + c(state.tunnelUrl));
|
|
1195
|
-
}
|
|
1206
|
+
row("runner", state.runner);
|
|
1207
|
+
row("tunnel", state.tunnel);
|
|
1208
|
+
row("pags", state.registration);
|
|
1196
1209
|
console.log("");
|
|
1197
|
-
if (
|
|
1198
|
-
console.log(pad +
|
|
1210
|
+
if (connected) {
|
|
1211
|
+
console.log(pad + chalk.green("\u2713 You're all set!") + d(" Your agent can now act on the web."));
|
|
1212
|
+
console.log("");
|
|
1213
|
+
console.log(pad + w("What to do next:"));
|
|
1214
|
+
console.log(pad + d(" 1. Open ") + c("https://proagentstore.online/console"));
|
|
1215
|
+
console.log(pad + d(" 2. Pick your agent and paste a job link to apply"));
|
|
1216
|
+
console.log(pad + d(" 3. Keep ") + w("this window open") + d(" while your agent works"));
|
|
1217
|
+
console.log("");
|
|
1218
|
+
console.log(pad + d("The website can take a few seconds to show \u201Conline\u201D \u2014 that's normal."));
|
|
1219
|
+
} else {
|
|
1220
|
+
console.log(pad + d("Setting things up\u2026 this takes a few seconds. Keep this window open."));
|
|
1221
|
+
if (state.lastEvent) console.log(pad + d("Status: ") + d(state.lastEvent));
|
|
1199
1222
|
}
|
|
1200
1223
|
console.log("");
|
|
1201
1224
|
console.log(
|
|
1202
|
-
pad + c("r") + d("
|
|
1225
|
+
pad + c("r") + d(" Reconnect ") + c("l") + d(" View logs ") + c("q") + d(" Quit (disconnect)")
|
|
1203
1226
|
);
|
|
1204
1227
|
console.log("");
|
|
1205
1228
|
}
|
|
@@ -1234,6 +1257,7 @@ async function waitForKey(keys) {
|
|
|
1234
1257
|
|
|
1235
1258
|
// src/commands/up.ts
|
|
1236
1259
|
var API_BASE2 = "https://api.proagentstore.online";
|
|
1260
|
+
var CLI_VERSION = createRequire(import.meta.url)("../package.json").version;
|
|
1237
1261
|
var upCommand = new Command7("up").description("Start the browser runner for all your agent instances").option("--headless", "Run browser in headless mode").option("--instance <id>", "Connect to a specific instance only").action(async (opts) => {
|
|
1238
1262
|
const session = requireSession();
|
|
1239
1263
|
const state = {
|
|
@@ -1245,10 +1269,11 @@ var upCommand = new Command7("up").description("Start the browser runner for all
|
|
|
1245
1269
|
tunnelUrl: "",
|
|
1246
1270
|
registration: "pending",
|
|
1247
1271
|
lastEvent: "Fetching instances...",
|
|
1248
|
-
taskCount: 0
|
|
1272
|
+
taskCount: 0,
|
|
1273
|
+
version: CLI_VERSION
|
|
1249
1274
|
};
|
|
1250
1275
|
clearScreen();
|
|
1251
|
-
printLogo();
|
|
1276
|
+
printLogo(CLI_VERSION);
|
|
1252
1277
|
printStep("Signed in as " + session.user.login, "ok");
|
|
1253
1278
|
printStep("Fetching instances...", "wait");
|
|
1254
1279
|
const res = await fetch(`${API_BASE2}/v1/instances/my/instances`, {
|
|
@@ -1293,7 +1318,7 @@ var upCommand = new Command7("up").description("Start the browser runner for all
|
|
|
1293
1318
|
logs.push(trimmed);
|
|
1294
1319
|
if (logs.length > 200) logs.shift();
|
|
1295
1320
|
const tunnelMatch = trimmed.match(/https:\/\/[a-z0-9-]+\.trycloudflare\.com/i);
|
|
1296
|
-
if (tunnelMatch) {
|
|
1321
|
+
if (tunnelMatch && !/^https:\/\/api\.trycloudflare\.com/i.test(tunnelMatch[0])) {
|
|
1297
1322
|
state.tunnel = "online";
|
|
1298
1323
|
state.tunnelUrl = tunnelMatch[0];
|
|
1299
1324
|
state.lastEvent = "Tunnel created";
|
|
@@ -1386,9 +1411,41 @@ var upCommand = new Command7("up").description("Start the browser runner for all
|
|
|
1386
1411
|
}
|
|
1387
1412
|
}
|
|
1388
1413
|
});
|
|
1414
|
+
var downCommand = new Command7("down").description("Stop the browser runner and disconnect (cleans up any stuck processes)").action(async () => {
|
|
1415
|
+
clearScreen();
|
|
1416
|
+
printLogo(CLI_VERSION);
|
|
1417
|
+
if (process.platform === "win32") {
|
|
1418
|
+
writeLine(" On Windows: switch to the 'pags up' window and press Ctrl+C to disconnect.");
|
|
1419
|
+
writeLine("");
|
|
1420
|
+
return;
|
|
1421
|
+
}
|
|
1422
|
+
const { execSync } = await import("child_process");
|
|
1423
|
+
const patterns = [
|
|
1424
|
+
"dist/browser-runner/index.js",
|
|
1425
|
+
"browser-runner/src/index",
|
|
1426
|
+
"runner connect",
|
|
1427
|
+
"tunnel --url http://127.0.0.1"
|
|
1428
|
+
];
|
|
1429
|
+
let stopped = false;
|
|
1430
|
+
for (const p of patterns) {
|
|
1431
|
+
try {
|
|
1432
|
+
execSync(`pkill -f ${JSON.stringify(p)}`, { stdio: "ignore" });
|
|
1433
|
+
stopped = true;
|
|
1434
|
+
} catch {
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
1437
|
+
if (stopped) {
|
|
1438
|
+
writeLine(" \u2713 Runner stopped \u2014 you're disconnected.");
|
|
1439
|
+
writeLine("");
|
|
1440
|
+
writeLine(" Your agent won't act on the web until you run 'pags up' again.");
|
|
1441
|
+
} else {
|
|
1442
|
+
writeLine(" No runner was running \u2014 nothing to stop.");
|
|
1443
|
+
}
|
|
1444
|
+
writeLine("");
|
|
1445
|
+
});
|
|
1389
1446
|
|
|
1390
1447
|
// src/index.ts
|
|
1391
|
-
var require2 =
|
|
1448
|
+
var require2 = createRequire2(import.meta.url);
|
|
1392
1449
|
var { version } = require2("../package.json");
|
|
1393
1450
|
var program = new Command8();
|
|
1394
1451
|
program.name("pags").description(
|
|
@@ -1398,6 +1455,7 @@ program.addCommand(loginCommand);
|
|
|
1398
1455
|
program.addCommand(logoutCommand);
|
|
1399
1456
|
program.addCommand(whoamiCommand);
|
|
1400
1457
|
program.addCommand(upCommand);
|
|
1458
|
+
program.addCommand(downCommand);
|
|
1401
1459
|
program.addCommand(initCommand);
|
|
1402
1460
|
program.addCommand(checkCommand);
|
|
1403
1461
|
program.addCommand(publishCommand);
|