viewable-one 0.12.2 → 0.12.3
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/CHANGELOG.md +47 -0
- package/README.md +2 -2
- package/SPAWN.md +107 -53
- package/glytch.mjs +41 -10
- package/lib/acp.mjs +110 -148
- package/lib/admission.mjs +25 -5
- package/lib/agents.mjs +59 -16
- package/lib/answerTag.mjs +47 -0
- package/lib/atomic.mjs +1 -16
- package/lib/auth.mjs +25 -9
- package/lib/boardside.mjs +28 -12
- package/lib/child.mjs +89 -116
- package/lib/claudeModels.mjs +168 -0
- package/lib/codex-rpc.mjs +2 -2
- package/lib/codex.mjs +43 -63
- package/lib/codexApps.mjs +5 -3
- package/lib/codexToolInputs.mjs +98 -22
- package/lib/codingChecks.mjs +8 -4
- package/lib/conversationRules.mjs +46 -6
- package/lib/detect.mjs +14 -23
- package/lib/devserver.mjs +6 -6
- package/lib/doctor.mjs +4 -2
- package/lib/folderReads.mjs +96 -0
- package/lib/followUps.mjs +170 -0
- package/lib/hosted.mjs +13 -4
- package/lib/init-connect.mjs +29 -10
- package/lib/lateResume.mjs +135 -0
- package/lib/logindaemon.mjs +113 -33
- package/lib/mcpjson.mjs +35 -2
- package/lib/multiwatch.mjs +25 -38
- package/lib/pagePictures.mjs +14 -11
- package/lib/paths.mjs +0 -1
- package/lib/permissionAsk.mjs +341 -58
- package/lib/procs.mjs +73 -2
- package/lib/refusal.mjs +0 -2
- package/lib/restartPass.mjs +39 -11
- package/lib/rowsAnswers.mjs +18 -34
- package/lib/rowsEvents.mjs +20 -2
- package/lib/runner-health.mjs +26 -2
- package/lib/runner.mjs +106 -1363
- package/lib/runnerAdmission.mjs +6 -12
- package/lib/runnerApi.mjs +20 -11
- package/lib/runnerBeat.mjs +384 -0
- package/lib/runnerCompletion.mjs +5 -2
- package/lib/runnerExecute.mjs +227 -0
- package/lib/runnerGates.mjs +338 -0
- package/lib/runnerLaunch.mjs +351 -0
- package/lib/runnerLease.mjs +31 -9
- package/lib/runnerOps.mjs +217 -0
- package/lib/runnerPace.mjs +10 -6
- package/lib/runnerRecovery.mjs +457 -0
- package/lib/runnerRegister.mjs +28 -7
- package/lib/runnerSettlement.mjs +29 -9
- package/lib/spawn.mjs +0 -5
- package/lib/sync.mjs +26 -14
- package/lib/viewableFolder.mjs +8 -2
- package/lib/worktree.mjs +66 -13
- package/lib/writePolicy.mjs +90 -10
- package/package.json +1 -1
package/lib/pagePictures.mjs
CHANGED
|
@@ -22,6 +22,7 @@ import { createServer } from "node:net";
|
|
|
22
22
|
import { tmpdir } from "node:os";
|
|
23
23
|
import { delimiter, join } from "node:path";
|
|
24
24
|
import { devServerEnv } from "./child.mjs";
|
|
25
|
+
import { OUT_OF_TIME } from "./codingChecks.mjs";
|
|
25
26
|
import { killTree } from "./kill.mjs";
|
|
26
27
|
import { pageOf, isScreenFile } from "./pageRoutes.mjs";
|
|
27
28
|
import { runnableCommand } from "./windows-command.mjs";
|
|
@@ -75,7 +76,7 @@ export function findBrowser({ env = process.env, platform = process.platform, ex
|
|
|
75
76
|
// ---------- the browser, over its DevTools pipe ----------
|
|
76
77
|
|
|
77
78
|
/** Start the browser headless with a fresh profile it forgets afterwards. */
|
|
78
|
-
export async function openBrowser(browser, { platform = process.platform, stopCheck, deadline = Infinity } = {}) {
|
|
79
|
+
export async function openBrowser(browser, { platform = process.platform, stopCheck, onProcess, deadline = Infinity } = {}) {
|
|
79
80
|
const profile = await mkdtemp(join(tmpdir(), "viewable-browser-"));
|
|
80
81
|
const args = [
|
|
81
82
|
...browser.args, "--headless=new", "--remote-debugging-pipe", `--user-data-dir=${profile}`,
|
|
@@ -84,7 +85,8 @@ export async function openBrowser(browser, { platform = process.platform, stopCh
|
|
|
84
85
|
`--window-size=${VIEWPORT.width},${VIEWPORT.height}`, "about:blank",
|
|
85
86
|
];
|
|
86
87
|
// The person's own browser, but not the runner's secrets.
|
|
87
|
-
const child = spawn(browser.bin, args, { stdio: ["ignore", "ignore", "ignore", "pipe", "pipe"], windowsHide: true, env: devServerEnv(process.env, platform) });
|
|
88
|
+
const child = spawn(browser.bin, args, { stdio: ["ignore", "ignore", "ignore", "pipe", "pipe"], windowsHide: true, detached: Boolean(onProcess) && platform !== "win32", env: devServerEnv(process.env, platform) });
|
|
89
|
+
onProcess?.(child.pid);
|
|
88
90
|
const waiting = new Map();
|
|
89
91
|
const listeners = new Set();
|
|
90
92
|
let nextId = 1;
|
|
@@ -254,7 +256,7 @@ async function appScript(dir) {
|
|
|
254
256
|
}
|
|
255
257
|
|
|
256
258
|
/** Start the folder's app on a free port and wait until it answers. */
|
|
257
|
-
export async function startApp(dir, { env, platform = process.platform, deadline, stopCheck, killGraceMs = 3_000, fetchImpl = fetch }) {
|
|
259
|
+
export async function startApp(dir, { env, platform = process.platform, deadline, stopCheck, killGraceMs = 3_000, onProcess, fetchImpl = fetch }) {
|
|
258
260
|
const found = await appScript(dir);
|
|
259
261
|
if (!found.script) return { ok: false, missing: found.missing };
|
|
260
262
|
const port = await freePort();
|
|
@@ -264,6 +266,7 @@ export async function startApp(dir, { env, platform = process.platform, deadline
|
|
|
264
266
|
stdio: ["ignore", "pipe", "pipe"],
|
|
265
267
|
env: { ...devServerEnv(env, platform), ...(port ? { PORT: String(port) } : {}), BROWSER: "none", NO_COLOR: "1", FORCE_COLOR: "0" },
|
|
266
268
|
});
|
|
269
|
+
onProcess?.(child.pid);
|
|
267
270
|
let log = "";
|
|
268
271
|
let exited = false;
|
|
269
272
|
const take = (chunk) => { log = (log + String(chunk)).slice(-8_000); };
|
|
@@ -330,7 +333,7 @@ async function pictureOf(dir, page, browser, options) {
|
|
|
330
333
|
* `files` are the paths the run changed. `folder` is where the app is tried
|
|
331
334
|
* when the copy's does not start: if it does not start there either, the
|
|
332
335
|
* check is skipped (not the run's doing), never failed. */
|
|
333
|
-
export async function checkPage({ cwd, folder, files, env, baseEnv = process.env, platform = process.platform, deadline, stopCheck, killGraceMs, browser: given, fetchImpl }) {
|
|
336
|
+
export async function checkPage({ cwd, folder, files, env, baseEnv = process.env, platform = process.platform, deadline, stopCheck, killGraceMs, onProcess, browser: given, fetchImpl }) {
|
|
334
337
|
// A page the run deleted has no address left to open.
|
|
335
338
|
const screens = files.filter((file) => isScreenFile(file) && existsSync(join(cwd, file)));
|
|
336
339
|
if (screens.length === 0) return null;
|
|
@@ -339,11 +342,11 @@ export async function checkPage({ cwd, folder, files, env, baseEnv = process.env
|
|
|
339
342
|
const browser = given === undefined ? findBrowser({ env: baseEnv, platform }) : given;
|
|
340
343
|
if (!browser) return { page, check: check("skipped", "No browser was found on this computer."), note: NO_BROWSER };
|
|
341
344
|
if (await stopCheck?.()) return { page, browser, stopped: true, check: check("skipped", "Stopped before this check finished.") };
|
|
342
|
-
if (Date.now() >= deadline) return { page, browser, check: check("
|
|
343
|
-
const options = { env, platform, deadline, stopCheck, killGraceMs, ...(fetchImpl ? { fetchImpl } : {}) };
|
|
345
|
+
if (Date.now() >= deadline) return { page, browser, check: check("skipped", OUT_OF_TIME) };
|
|
346
|
+
const options = { env, platform, deadline, stopCheck, killGraceMs, onProcess, ...(fetchImpl ? { fetchImpl } : {}) };
|
|
344
347
|
let opened;
|
|
345
348
|
let stoppedStarting = false;
|
|
346
|
-
try { opened = await openBrowser(browser, { platform, stopCheck, deadline }); } catch (error) { opened = null; stoppedStarting = error.stopped === true; }
|
|
349
|
+
try { opened = await openBrowser(browser, { platform, stopCheck, deadline, onProcess }); } catch (error) { opened = null; stoppedStarting = error.stopped === true; }
|
|
347
350
|
if (stoppedStarting) return { page, browser, stopped: true, check: check("skipped", "Stopped before this check finished.") };
|
|
348
351
|
if (!opened) return { page, check: check("skipped", "The browser on this computer did not start."), note: NO_BROWSER };
|
|
349
352
|
try {
|
|
@@ -352,7 +355,7 @@ export async function checkPage({ cwd, folder, files, env, baseEnv = process.env
|
|
|
352
355
|
if (after.browserGone) return { page, browser, check: check("skipped", "The browser on this computer closed."), note: BROWSER_CLOSED };
|
|
353
356
|
if (after.missing === "script") return { page, browser, check: check("skipped", "This folder has no app to start."), note: NO_APP_SCRIPT };
|
|
354
357
|
if (after.missing === "dependencies") return { page, browser, check: check("skipped", "The folder's dependencies are not installed."), note: NO_APP };
|
|
355
|
-
if (after.timedOut) return { page, browser, check: check("
|
|
358
|
+
if (after.timedOut) return { page, browser, check: check("skipped", OUT_OF_TIME) };
|
|
356
359
|
if (!after.started) {
|
|
357
360
|
const there = folder ? await startApp(folder, options) : { ok: false };
|
|
358
361
|
if (there.ok) await there.stop();
|
|
@@ -377,13 +380,13 @@ export async function checkPage({ cwd, folder, files, env, baseEnv = process.env
|
|
|
377
380
|
|
|
378
381
|
/** Before, from the folder, and the changed part of After. Pictures that do
|
|
379
382
|
* not differ mean the wrong page was opened: no pictures at all. */
|
|
380
|
-
export async function beforePicture({ folder, page, after, browser, env, platform = process.platform, deadline, stopCheck, killGraceMs, fetchImpl }) {
|
|
383
|
+
export async function beforePicture({ folder, page, after, browser, env, platform = process.platform, deadline, stopCheck, killGraceMs, onProcess, fetchImpl }) {
|
|
381
384
|
if (!after || !browser) return {};
|
|
382
385
|
if (!folder || await stopCheck?.() || Date.now() >= deadline) return { after };
|
|
383
386
|
let opened;
|
|
384
|
-
try { opened = await openBrowser(browser, { platform, stopCheck, deadline }); } catch { return { after }; }
|
|
387
|
+
try { opened = await openBrowser(browser, { platform, stopCheck, deadline, onProcess }); } catch { return { after }; }
|
|
385
388
|
try {
|
|
386
|
-
const before = await pictureOf(folder, page, opened, { env, platform, deadline, stopCheck, killGraceMs, ...(fetchImpl ? { fetchImpl } : {}) });
|
|
389
|
+
const before = await pictureOf(folder, page, opened, { env, platform, deadline, stopCheck, killGraceMs, onProcess, ...(fetchImpl ? { fetchImpl } : {}) });
|
|
387
390
|
if (!before.started || !before.ok || !before.image) return { after };
|
|
388
391
|
let changed = null;
|
|
389
392
|
try { changed = await opened.changedArea(before.image, after); } catch { return { before: before.image, after }; }
|
package/lib/paths.mjs
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
// Historical request files and the repo-map cache still live under SPAWN_DIR.
|
|
3
3
|
|
|
4
4
|
export const BOARD_DIR = ".viewable";
|
|
5
|
-
export const INBOX_DIR = `${BOARD_DIR}/inbox`;
|
|
6
5
|
// Kept on purpose: the sweep reads receipts written by old runners.
|
|
7
6
|
export const SPAWN_DIR = ".glytch/inbox/spawn";
|
|
8
7
|
|