Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

fix(x-content): refuse to review when the browser cannot start, instead of failing every post

nirholase6f175ac2a77
diff --git a/api/_lib/x-content/verify.js b/api/_lib/x-content/verify.js
index 256dad18a..b188e734f 100644
--- a/api/_lib/x-content/verify.js
+++ b/api/_lib/x-content/verify.js
@@ -74,6 +74,28 @@ export async function linkChecks(texts) {
return checks;
}
+// Whether this machine can run the browser the checks need. A missing system
+// library fails every page check, probe and scenario at once, and a review
+// that ran anyway would record those failures against the posts.
+export function describeBrowserError(message) {
+ const text = String(message || '');
+ const missing = /error while loading shared libraries: ([^:\s]+)/.exec(text)?.[1];
+ if (missing) return `the browser cannot start: ${missing} is missing on this machine. Install the system libraries with \`npx playwright install-deps chromium\` and run it again`;
+ if (/Executable doesn't exist/i.test(text)) return 'the browser is not installed on this machine. Install it with `npx playwright install chromium` and run it again';
+ return `the browser cannot start: ${text.split('\n')[0]}`;
+}
+
+export async function browserProblem() {
+ try {
+ const { chromium } = await import('playwright');
+ const browser = await chromium.launch();
+ await browser.close();
+ return null;
+ } catch (err) {
+ return describeBrowserError(err?.message || err);
+ }
+}
+
export function createPageReader() {
let browser = null;
const cache = new Map();
diff --git a/scripts/x-content.mjs b/scripts/x-content.mjs
index f8aab2ff5..9bed44228 100644
--- a/scripts/x-content.mjs
+++ b/scripts/x-content.mjs
@@ -44,6 +44,7 @@ import { approvalProblems, loadReview, reviewItem } from '../api/_lib/x-content/
import { FORMATS, proofPath, proofProblems, proveItem, scoutPage } from '../api/_lib/x-content/reel.js';
import { approvalPolicy, policyBlockers, releaseDigest, vetoUntil } from '../api/_lib/x-content/approval.js';
import { learnLifts, outcomesStore } from '../api/_lib/x-content/outcomes.js';
+import { browserProblem } from '../api/_lib/x-content/verify.js';
const root = resolve(fileURLToPath(new URL('..', import.meta.url)));
const DAY = 24 * 60 * 60_000;
@@ -75,6 +76,13 @@ function fail(message) {
process.exit(1);
}
+// Reviews, proofs and the line all drive a real browser. When this machine
+// cannot start one, nothing they record would be about the post.
+async function requireBrowser() {
+ const problem = await browserProblem();
+ if (problem) fail(`x-content: ${problem}. Nothing was reviewed or recorded.`);
+}
+
const store = () => (process.env.DATABASE_URL ? dbStore() : memoryStore());
async function check() {
@@ -395,6 +403,7 @@ function prepareVideo() {
// --- proof reels -----------------------------------------------------------
async function scout() {
+ await requireBrowser();
const url = positional[1];
if (!/^https:\/\//.test(String(url))) fail('Usage: scout <https url> [--format landscape|square|portrait] [--shot file.png]');
const format = option('format', 'landscape');
@@ -445,6 +454,7 @@ const saveQueue = (queue) => saveJson(resolve(root, QUEUE_PATH), queue);
const STORY_DIR = 'data/x-content/stories';
async function prove() {
+ await requireBrowser();
const filming = !has('no-film');
const file = option('file');
if (file) {
@@ -514,6 +524,7 @@ async function pause() {
// One command for the whole line. Each item is taken as far as it can go and
// stops at the first thing that needs a person, with the reason.
async function advance() {
+ await requireBrowser();
const queue = loadQueue(root);
const id = positional[1];
const dryRun = has('dry-run');
@@ -643,6 +654,7 @@ function printReview(record) {
}
async function review() {
+ await requireBrowser();
const queue = loadQueue(root);
const status = option('status');
const id = positional[1];
diff --git a/tests/x-content-reel.test.js b/tests/x-content-reel.test.js
index 6e2ddbbe9..4d90392c5 100644
--- a/tests/x-content-reel.test.js
+++ b/tests/x-content-reel.test.js
@@ -363,3 +363,13 @@ describe('facts that move', () => {
expect(factDrift(uncited, filmed, { agents: '9' })).toEqual([]);
});
});
+
+describe('a machine that cannot run the browser', () => {
+ it('says which library is missing and how to install it', async () => {
+ const { describeBrowserError } = await import('../api/_lib/x-content/verify.js');
+ const launch = 'browserType.launch: Target page, context or browser has been closed\n[pid=1][err] /home/user/.cache/ms-playwright/chromium_headless_shell-1243/chrome-headless-shell-linux64/chrome-headless-shell: error while loading shared libraries: libxkbcommon.so.0: cannot open shared object file: No such file or directory';
+ expect(describeBrowserError(launch)).toBe('the browser cannot start: libxkbcommon.so.0 is missing on this machine. Install the system libraries with `npx playwright install-deps chromium` and run it again');
+ expect(describeBrowserError("browserType.launch: Executable doesn't exist at /x/chrome")).toMatch(/npx playwright install chromium/);
+ expect(describeBrowserError('something else\nmore')).toBe('the browser cannot start: something else');
+ });
+});