agentreel 0.2.0 → 0.2.2
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/bin/agentreel.mjs +44 -2
- package/package.json +1 -1
package/bin/agentreel.mjs
CHANGED
|
@@ -61,6 +61,42 @@ function findPython() {
|
|
|
61
61
|
return "python3";
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
+
function ensureBrowserDeps() {
|
|
65
|
+
const venvDir = join(ROOT, "scripts", ".venv");
|
|
66
|
+
const venvPython = join(venvDir, "bin", "python");
|
|
67
|
+
|
|
68
|
+
if (existsSync(venvPython)) {
|
|
69
|
+
// Check if playwright is installed
|
|
70
|
+
try {
|
|
71
|
+
execFileSync(venvPython, ["-c", "import playwright"], {
|
|
72
|
+
stdio: "ignore",
|
|
73
|
+
});
|
|
74
|
+
return; // all good
|
|
75
|
+
} catch {
|
|
76
|
+
// playwright missing, install below
|
|
77
|
+
}
|
|
78
|
+
} else {
|
|
79
|
+
// Create venv
|
|
80
|
+
console.error(" Setting up Python environment...");
|
|
81
|
+
execFileSync("python3", ["-m", "venv", venvDir], {
|
|
82
|
+
stdio: ["ignore", "inherit", "inherit"],
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const pip = join(venvDir, "bin", "pip");
|
|
87
|
+
console.error(" Installing playwright...");
|
|
88
|
+
execFileSync(pip, ["install", "-q", "playwright"], {
|
|
89
|
+
stdio: ["ignore", "inherit", "inherit"],
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
console.error(" Installing Chromium (one-time, ~150MB)...");
|
|
93
|
+
const browsersDir = join(venvDir, "playwright-browsers");
|
|
94
|
+
execFileSync(venvPython, ["-m", "playwright", "install", "chromium"], {
|
|
95
|
+
stdio: ["ignore", "inherit", "inherit"],
|
|
96
|
+
env: { ...process.env, PLAYWRIGHT_BROWSERS_PATH: browsersDir },
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
64
100
|
function recordCLI(command, workDir, context) {
|
|
65
101
|
const python = findPython();
|
|
66
102
|
const script = join(ROOT, "scripts", "cli_demo.py");
|
|
@@ -88,6 +124,11 @@ function extractHighlightsFromCast(castPath, context) {
|
|
|
88
124
|
|
|
89
125
|
// ── Browser Recording ───────────────────────────────────────
|
|
90
126
|
|
|
127
|
+
function browserEnv() {
|
|
128
|
+
const browsersDir = join(ROOT, "scripts", ".venv", "playwright-browsers");
|
|
129
|
+
return { ...process.env, PLAYWRIGHT_BROWSERS_PATH: browsersDir };
|
|
130
|
+
}
|
|
131
|
+
|
|
91
132
|
function recordBrowser(url, task) {
|
|
92
133
|
const python = findPython();
|
|
93
134
|
const script = join(ROOT, "scripts", "browser_demo.py");
|
|
@@ -96,7 +137,7 @@ function recordBrowser(url, task) {
|
|
|
96
137
|
console.error(`Agent demoing browser app: ${url}`);
|
|
97
138
|
execFileSync(python, [script, url, outFile, task], {
|
|
98
139
|
stdio: ["ignore", "inherit", "inherit"],
|
|
99
|
-
env:
|
|
140
|
+
env: browserEnv(),
|
|
100
141
|
timeout: 120000,
|
|
101
142
|
});
|
|
102
143
|
return outFile;
|
|
@@ -109,7 +150,7 @@ function extractBrowserHighlights(videoPath, task) {
|
|
|
109
150
|
|
|
110
151
|
execFileSync(python, [script, "--highlights", videoPath, outFile, task], {
|
|
111
152
|
stdio: ["ignore", "inherit", "inherit"],
|
|
112
|
-
env:
|
|
153
|
+
env: browserEnv(),
|
|
113
154
|
});
|
|
114
155
|
return outFile;
|
|
115
156
|
}
|
|
@@ -263,6 +304,7 @@ async function main() {
|
|
|
263
304
|
if (demoURL) {
|
|
264
305
|
const task = prompt || "Explore the main features of this app";
|
|
265
306
|
|
|
307
|
+
ensureBrowserDeps();
|
|
266
308
|
console.error("Step 1/3: Recording browser demo...");
|
|
267
309
|
const videoPath = recordBrowser(demoURL, task);
|
|
268
310
|
|