@mrevanzak/witness 1.0.0 → 1.0.1
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/bin/witness.mjs +253 -137
- package/dist/computer/control/dist/control.mjs +5 -0
- package/dist/computer/start.sh +1 -1
- package/package.json +1 -1
package/dist/bin/witness.mjs
CHANGED
|
@@ -77,6 +77,11 @@ var CHROME_FLAGS = [
|
|
|
77
77
|
"--no-sandbox",
|
|
78
78
|
"--test-type",
|
|
79
79
|
"--disable-gpu",
|
|
80
|
+
// No GPU in the container: software WebGL (SwiftShader) so three.js/canvas apps render.
|
|
81
|
+
"--use-gl=angle",
|
|
82
|
+
"--use-angle=swiftshader",
|
|
83
|
+
"--enable-unsafe-swiftshader",
|
|
84
|
+
"--ignore-gpu-blocklist",
|
|
80
85
|
"--hide-crash-restore-bubble",
|
|
81
86
|
"--disable-features=Translate,MediaRouter"
|
|
82
87
|
];
|
|
@@ -881,7 +886,7 @@ var StepTool = Schema5.Literals([
|
|
|
881
886
|
"begin_criterion",
|
|
882
887
|
"end_criterion",
|
|
883
888
|
"still",
|
|
884
|
-
/** A Playwright `test.step()` title
|
|
889
|
+
/** A caption only: a Playwright `test.step()` title, or a person taking over in the live view. */
|
|
885
890
|
"step"
|
|
886
891
|
]);
|
|
887
892
|
var Step = class extends Schema5.Class("@witness/Step")({
|
|
@@ -1984,6 +1989,10 @@ var makeRecorder = Effect10.fn("makeRecorder")(function* (computer, config, crit
|
|
|
1984
1989
|
yield* step({ at: beganAt, label: `${id}: ${c.description}`, tool: "begin_criterion" });
|
|
1985
1990
|
return { screen: Option8.none(), text: `Started ${id}.` };
|
|
1986
1991
|
}),
|
|
1992
|
+
Caption: ({ label }) => Effect10.gen(function* () {
|
|
1993
|
+
yield* step({ at: yield* now, label, tool: "step" });
|
|
1994
|
+
return { screen: Option8.none(), text: "Noted." };
|
|
1995
|
+
}),
|
|
1987
1996
|
Click: ({ button, label, x, y }) => {
|
|
1988
1997
|
const p = { x: space.toScreen(x), y: space.toScreen(y) };
|
|
1989
1998
|
return visible({ type: button, ...p }, { label, tool: button, ...p }).pipe(Effect10.map(screenOf));
|
|
@@ -4189,7 +4198,7 @@ var renderRun = Effect18.fn("renderRun")(function* (runDirIn, opts = {}) {
|
|
|
4189
4198
|
});
|
|
4190
4199
|
|
|
4191
4200
|
// src/main.ts
|
|
4192
|
-
import { Config as Config6, Console as Console7, Effect as Effect29, Layer as Layer8, Option as
|
|
4201
|
+
import { Config as Config6, Console as Console7, Effect as Effect29, Layer as Layer8, Option as Option27, Path as Path13, Schema as Schema27 } from "effect";
|
|
4193
4202
|
import { Argument, Command, Flag as Flag2 } from "effect/cli";
|
|
4194
4203
|
import { FetchHttpClient } from "effect/http";
|
|
4195
4204
|
import { ChildProcess as ChildProcess5, ChildProcessSpawner as ChildProcessSpawner5 } from "effect/process";
|
|
@@ -4197,7 +4206,7 @@ import { ChildProcess as ChildProcess5, ChildProcessSpawner as ChildProcessSpawn
|
|
|
4197
4206
|
// package.json
|
|
4198
4207
|
var package_default = {
|
|
4199
4208
|
name: "@mrevanzak/witness",
|
|
4200
|
-
version: "1.0.
|
|
4209
|
+
version: "1.0.1",
|
|
4201
4210
|
description: "Independent, recorded QA for code changes: boots the app in a fresh Linux desktop, checks the change, and hands back a verdict, stills and video",
|
|
4202
4211
|
keywords: [
|
|
4203
4212
|
"qa",
|
|
@@ -4614,8 +4623,8 @@ Next, prove it boots:
|
|
|
4614
4623
|
// src/live.ts
|
|
4615
4624
|
import { createServer } from "node:http";
|
|
4616
4625
|
import { NodeHttpServer } from "@effect/platform-node";
|
|
4617
|
-
import { Effect as Effect21, Layer as Layer7, PubSub, Ref as Ref5, Stream as Stream2 } from "effect";
|
|
4618
|
-
import { HttpRouter, HttpServer, HttpServerResponse } from "effect/http";
|
|
4626
|
+
import { Effect as Effect21, Layer as Layer7, Option as Option19, PubSub, Ref as Ref5, Schema as Schema22, Stream as Stream2 } from "effect";
|
|
4627
|
+
import { HttpRouter, HttpServer, HttpServerRequest, HttpServerResponse } from "effect/http";
|
|
4619
4628
|
|
|
4620
4629
|
// src/live-page.ts
|
|
4621
4630
|
var LIVE_PAGE = `<!doctype html>
|
|
@@ -4645,6 +4654,13 @@ var LIVE_PAGE = `<!doctype html>
|
|
|
4645
4654
|
.screen iframe { position: absolute; left: 0; top: -25px; width: 100%; height: calc(100% + 25px); border: 0; }
|
|
4646
4655
|
.screen .empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font: 14px var(--mono); padding: 24px; text-align: center; }
|
|
4647
4656
|
.live { position: absolute; top: 12px; left: 12px; font: 500 12px var(--mono); letter-spacing: .1em; color: var(--paper); background: #0e0f10d9; border: 1px solid var(--hairline); border-radius: 4px; padding: 2px 8px; display: none; }
|
|
4657
|
+
.screen.human { box-shadow: 0 0 0 2px var(--blocked); }
|
|
4658
|
+
.screen.human .live { color: var(--blocked); border-color: var(--blocked); }
|
|
4659
|
+
.takeover { font: 500 12px var(--mono); letter-spacing: .06em; color: var(--paper); background: transparent; border: 1px solid var(--hairline); border-radius: 4px; padding: 3px 10px; cursor: pointer; }
|
|
4660
|
+
.takeover:hover { border-color: var(--paper); }
|
|
4661
|
+
.takeover:focus-visible { outline: 2px solid var(--paper); outline-offset: 2px; }
|
|
4662
|
+
.takeover.human { color: var(--ink); background: var(--blocked); border-color: var(--blocked); }
|
|
4663
|
+
.control-note { font: 13px var(--mono); color: var(--blocked); }
|
|
4648
4664
|
.live::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--fail); margin-right: 7px; vertical-align: 1px; }
|
|
4649
4665
|
aside { display: flex; flex-direction: column; min-height: 0; }
|
|
4650
4666
|
h2 { font: 500 12px var(--mono); letter-spacing: .12em; color: var(--muted); margin: 0; padding-bottom: 10px; border-bottom: 1px solid var(--hairline); }
|
|
@@ -4671,6 +4687,8 @@ var LIVE_PAGE = `<!doctype html>
|
|
|
4671
4687
|
<span class="brand">witness</span>
|
|
4672
4688
|
<span class="meta" id="meta">waiting for the run\u2026</span>
|
|
4673
4689
|
<span class="phase" id="phase"></span>
|
|
4690
|
+
<span class="control-note" id="control-note" role="status" hidden></span>
|
|
4691
|
+
<button type="button" class="takeover" id="takeover" hidden>Take over</button>
|
|
4674
4692
|
<span class="chip" id="overall">running</span>
|
|
4675
4693
|
</header>
|
|
4676
4694
|
<main>
|
|
@@ -4741,18 +4759,22 @@ var LIVE_PAGE = `<!doctype html>
|
|
|
4741
4759
|
const f = document.querySelector(".screen iframe");
|
|
4742
4760
|
if (f) f.remove();
|
|
4743
4761
|
$("live").style.display = "none";
|
|
4762
|
+
$("takeover").hidden = true;
|
|
4744
4763
|
if (!$("screen-empty")) { const empty = document.createElement("div"); empty.className = "empty"; empty.id = "screen-empty"; document.querySelector(".screen").prepend(empty); }
|
|
4745
4764
|
$("screen-empty").textContent = "Starting the computer\u2026";
|
|
4746
4765
|
}
|
|
4747
4766
|
if (e.event === "computer.created") {
|
|
4748
4767
|
if (d.liveView) {
|
|
4749
4768
|
if ($("screen-empty")) $("screen-empty").remove();
|
|
4769
|
+
liveView = d.liveView;
|
|
4750
4770
|
const f = document.createElement("iframe");
|
|
4751
|
-
f.src =
|
|
4771
|
+
f.src = desktopSrc(); f.title = "The computer's desktop";
|
|
4752
4772
|
document.querySelector(".screen").prepend(f);
|
|
4753
4773
|
$("live").style.display = "inline-block";
|
|
4774
|
+
$("takeover").hidden = false;
|
|
4754
4775
|
}
|
|
4755
4776
|
}
|
|
4777
|
+
if (e.event === "takeover") { human = !!d.human; paused = !!d.paused; renderControl(); }
|
|
4756
4778
|
if (e.event === "plan.done" && Array.isArray(d.criteria)) d.criteria.forEach(declare);
|
|
4757
4779
|
if (e.event === "criterion.declared") declare(d);
|
|
4758
4780
|
if (side === "before" && (e.event === "verdict" || e.event === "run.blocked" || e.event === "boot.blocked")) {
|
|
@@ -4768,10 +4790,39 @@ var LIVE_PAGE = `<!doctype html>
|
|
|
4768
4790
|
}
|
|
4769
4791
|
}
|
|
4770
4792
|
|
|
4793
|
+
// The desktop opens watching (noVNC view_only); taking over reconnects it with input on.
|
|
4794
|
+
// noVNC lite reads any view_only value, even "false", as on: drop the parameter instead.
|
|
4795
|
+
let liveView = "";
|
|
4796
|
+
let human = false;
|
|
4797
|
+
let paused = false;
|
|
4798
|
+
const desktopSrc = () => {
|
|
4799
|
+
if (!human) return liveView;
|
|
4800
|
+
const u = new URL(liveView);
|
|
4801
|
+
u.searchParams.delete("view_only");
|
|
4802
|
+
return u.href;
|
|
4803
|
+
};
|
|
4804
|
+
function renderControl() {
|
|
4805
|
+
const f = document.querySelector(".screen iframe");
|
|
4806
|
+
if (f && f.src !== desktopSrc()) { f.src = desktopSrc(); if (human) f.addEventListener("load", () => f.focus(), { once: true }); }
|
|
4807
|
+
document.querySelector(".screen").classList.toggle("human", human);
|
|
4808
|
+
$("live").textContent = human ? "YOU HAVE CONTROL" : "LIVE";
|
|
4809
|
+
$("takeover").textContent = human ? "Hand back" : "Take over";
|
|
4810
|
+
$("takeover").classList.toggle("human", human);
|
|
4811
|
+
$("takeover").setAttribute("aria-pressed", String(human));
|
|
4812
|
+
$("control-note").hidden = !human;
|
|
4813
|
+
$("control-note").textContent = paused ? "the driver waits until you hand back" : "the run keeps acting too";
|
|
4814
|
+
}
|
|
4815
|
+
$("takeover").onclick = async () => {
|
|
4816
|
+
const res = await fetch("/takeover", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ human: !human }) }).catch(() => null);
|
|
4817
|
+
if (!res || !res.ok) $("phase").textContent = "could not switch control (is the run still going?)";
|
|
4818
|
+
};
|
|
4819
|
+
|
|
4771
4820
|
// The computer is torn down after the verdict: show where the evidence is instead of a dead stream.
|
|
4772
4821
|
function finish(text) {
|
|
4773
4822
|
const f = document.querySelector(".screen iframe");
|
|
4774
4823
|
if (f) f.remove();
|
|
4824
|
+
$("takeover").hidden = true; $("control-note").hidden = true;
|
|
4825
|
+
document.querySelector(".screen").classList.remove("human");
|
|
4775
4826
|
let empty = $("screen-empty");
|
|
4776
4827
|
if (!empty) { empty = document.createElement("div"); empty.className = "empty"; empty.id = "screen-empty"; document.querySelector(".screen").prepend(empty); }
|
|
4777
4828
|
empty.textContent = text + (runDir ? "\\n" + runDir : "");
|
|
@@ -4783,7 +4834,7 @@ var LIVE_PAGE = `<!doctype html>
|
|
|
4783
4834
|
|
|
4784
4835
|
const source = new EventSource("/events");
|
|
4785
4836
|
source.onmessage = (m) => onEvent(JSON.parse(m.data));
|
|
4786
|
-
source.onerror = () => { $("phase").textContent = "run finished (live view closed)"; $("live").style.display = "none"; source.close(); };
|
|
4837
|
+
source.onerror = () => { $("phase").textContent = "run finished (live view closed)"; $("live").style.display = "none"; $("takeover").hidden = true; source.close(); };
|
|
4787
4838
|
</script>
|
|
4788
4839
|
</body>
|
|
4789
4840
|
</html>
|
|
@@ -4799,13 +4850,44 @@ var encoder = new TextEncoder();
|
|
|
4799
4850
|
var sse = (data) => encoder.encode(`data: ${JSON.stringify(data)}
|
|
4800
4851
|
|
|
4801
4852
|
`);
|
|
4802
|
-
var
|
|
4853
|
+
var TakeoverRequest = Schema22.Struct({ human: Schema22.Boolean });
|
|
4854
|
+
var LOOPBACK_HOST = /^127\.0\.0\.1:\d+$/;
|
|
4855
|
+
var sameLoopbackOrigin = (headers) => {
|
|
4856
|
+
const host = headers.host ?? "";
|
|
4857
|
+
return LOOPBACK_HOST.test(host) && headers.origin === `http://${host}`;
|
|
4858
|
+
};
|
|
4859
|
+
var startLive = Effect21.fn("startLive")(function* (onTakeover) {
|
|
4803
4860
|
const events = yield* PubSub.unbounded();
|
|
4804
4861
|
const history = yield* Ref5.make([]);
|
|
4805
4862
|
const publish2 = (event) => Ref5.update(history, (h) => [...h, event]).pipe(Effect21.andThen(PubSub.publish(events, event)), Effect21.asVoid);
|
|
4806
4863
|
const origin = yield* serveLoopback(
|
|
4807
4864
|
Layer7.mergeAll(
|
|
4808
4865
|
HttpRouter.add("GET", "/", HttpServerResponse.html(LIVE_PAGE)),
|
|
4866
|
+
HttpRouter.add(
|
|
4867
|
+
"POST",
|
|
4868
|
+
"/takeover",
|
|
4869
|
+
Effect21.gen(function* () {
|
|
4870
|
+
const req = yield* HttpServerRequest.HttpServerRequest;
|
|
4871
|
+
if (!sameLoopbackOrigin(req.headers)) {
|
|
4872
|
+
return yield* HttpServerResponse.json({ error: "forbidden" }, { status: 403 });
|
|
4873
|
+
}
|
|
4874
|
+
const body = yield* HttpServerRequest.schemaBodyJson(TakeoverRequest).pipe(Effect21.option);
|
|
4875
|
+
if (Option19.isNone(body)) {
|
|
4876
|
+
return yield* HttpServerResponse.json({ error: "bad request" }, { status: 400 });
|
|
4877
|
+
}
|
|
4878
|
+
const { human } = body.value;
|
|
4879
|
+
if (onTakeover) {
|
|
4880
|
+
yield* onTakeover(human);
|
|
4881
|
+
}
|
|
4882
|
+
yield* publish2({
|
|
4883
|
+
at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4884
|
+
data: { human, paused: onTakeover !== void 0 },
|
|
4885
|
+
event: "takeover",
|
|
4886
|
+
type: "log"
|
|
4887
|
+
});
|
|
4888
|
+
return yield* HttpServerResponse.json({ ok: true });
|
|
4889
|
+
}).pipe(Effect21.orDie)
|
|
4890
|
+
),
|
|
4809
4891
|
HttpRouter.add(
|
|
4810
4892
|
"GET",
|
|
4811
4893
|
"/events",
|
|
@@ -4828,12 +4910,12 @@ var startLive = Effect21.fn("startLive")(function* () {
|
|
|
4828
4910
|
});
|
|
4829
4911
|
|
|
4830
4912
|
// src/publish.ts
|
|
4831
|
-
import { Console as Console3, Effect as Effect22, FileSystem as FileSystem9, Option as
|
|
4913
|
+
import { Console as Console3, Effect as Effect22, FileSystem as FileSystem9, Option as Option20, Path as Path8, Schema as Schema23, Stream as Stream3 } from "effect";
|
|
4832
4914
|
import { ChildProcess as ChildProcess4, ChildProcessSpawner as ChildProcessSpawner4 } from "effect/process";
|
|
4833
4915
|
var START = "<!-- witness:start -->";
|
|
4834
4916
|
var END = "<!-- witness:end -->";
|
|
4835
4917
|
var MEDIA = /\.\/[A-Za-z0-9._/-]+\.(?:jpe?g|png|gif|mp4|mov|webm)/g;
|
|
4836
|
-
var PublishError = class extends
|
|
4918
|
+
var PublishError = class extends Schema23.TaggedError()("PublishError", { message: Schema23.String }) {
|
|
4837
4919
|
};
|
|
4838
4920
|
var placeSection = (body, section) => {
|
|
4839
4921
|
const trimmed = body.replace(/\s+$/, "");
|
|
@@ -4889,7 +4971,7 @@ try {
|
|
|
4889
4971
|
await page.close().catch(() => {});
|
|
4890
4972
|
}
|
|
4891
4973
|
`;
|
|
4892
|
-
var Uploaded =
|
|
4974
|
+
var Uploaded = Schema23.Record(Schema23.String, Schema23.String);
|
|
4893
4975
|
var publish = Effect22.fn("publish")(function* (o) {
|
|
4894
4976
|
const fs = yield* FileSystem9.FileSystem;
|
|
4895
4977
|
const path = yield* Path8.Path;
|
|
@@ -4922,10 +5004,10 @@ ${files.map((f) => ` ${f.ref}`).join("\n")}`
|
|
|
4922
5004
|
);
|
|
4923
5005
|
}
|
|
4924
5006
|
const cache = path.join(base, "upload-result.json");
|
|
4925
|
-
let urls = (yield* fs.exists(cache)) ? yield*
|
|
5007
|
+
let urls = (yield* fs.exists(cache)) ? yield* Schema23.decodeUnknownEffect(Schema23.fromJsonString(Uploaded))(yield* fs.readFileString(cache)) : {};
|
|
4926
5008
|
const todo = files.filter((f) => !urls[f.abs]);
|
|
4927
5009
|
if (todo.length) {
|
|
4928
|
-
if (
|
|
5010
|
+
if (Option20.isNone(o.egoSpace)) {
|
|
4929
5011
|
return yield* new PublishError({
|
|
4930
5012
|
message: "--ego-space <id> is required to upload (an Ego task space signed in to GitHub)"
|
|
4931
5013
|
});
|
|
@@ -4948,7 +5030,7 @@ ${output.slice(-1500)}` });
|
|
|
4948
5030
|
}
|
|
4949
5031
|
urls = {
|
|
4950
5032
|
...urls,
|
|
4951
|
-
...yield*
|
|
5033
|
+
...yield* Schema23.decodeUnknownEffect(Schema23.fromJsonString(Uploaded))(line.slice("UPLOADED ".length))
|
|
4952
5034
|
};
|
|
4953
5035
|
yield* fs.writeFileString(cache, JSON.stringify(urls, null, 2));
|
|
4954
5036
|
}
|
|
@@ -4969,18 +5051,18 @@ ${output.slice(-1500)}` });
|
|
|
4969
5051
|
});
|
|
4970
5052
|
|
|
4971
5053
|
// src/report.ts
|
|
4972
|
-
import { Effect as Effect23, FileSystem as FileSystem10, Option as
|
|
4973
|
-
var ReportError = class extends
|
|
5054
|
+
import { Effect as Effect23, FileSystem as FileSystem10, Option as Option21, Path as Path9, Schema as Schema24 } from "effect";
|
|
5055
|
+
var ReportError = class extends Schema24.TaggedError()("ReportError", { message: Schema24.String }) {
|
|
4974
5056
|
};
|
|
4975
5057
|
var noReportOptions = {
|
|
4976
|
-
intro:
|
|
5058
|
+
intro: Option21.none(),
|
|
4977
5059
|
notes: [],
|
|
4978
|
-
pr:
|
|
4979
|
-
preview:
|
|
4980
|
-
repo:
|
|
4981
|
-
title:
|
|
5060
|
+
pr: Option21.none(),
|
|
5061
|
+
preview: Option21.none(),
|
|
5062
|
+
repo: Option21.none(),
|
|
5063
|
+
title: Option21.none()
|
|
4982
5064
|
};
|
|
4983
|
-
var nonEmpty = (s) => s ?
|
|
5065
|
+
var nonEmpty = (s) => s ? Option21.some(s) : Option21.none();
|
|
4984
5066
|
var sectionOf = Effect23.fnUntraced(function* (run2, label, media) {
|
|
4985
5067
|
const path = yield* Path9.Path;
|
|
4986
5068
|
if (!isVerdict(run2.result)) {
|
|
@@ -4993,18 +5075,18 @@ var sectionOf = Effect23.fnUntraced(function* (run2, label, media) {
|
|
|
4993
5075
|
const cut = yield* readRenderedCut(run2.dir).pipe(Effect23.mapError((e) => new ReportError({ message: e.message })));
|
|
4994
5076
|
return new ReportSection({
|
|
4995
5077
|
label,
|
|
4996
|
-
seek:
|
|
5078
|
+
seek: Option21.match(cut, { onNone: () => ({}), onSome: (c) => c.seek }),
|
|
4997
5079
|
sha: run2.info.sha,
|
|
4998
5080
|
stills: evidenceStills(run2).map(
|
|
4999
5081
|
(s) => new ReportStill({ ...s, file: add(s.file, `${label}-${path.basename(s.file)}`) })
|
|
5000
5082
|
),
|
|
5001
5083
|
verdict: run2.result,
|
|
5002
|
-
...
|
|
5084
|
+
...Option21.match(run2.media.polished, {
|
|
5003
5085
|
onNone: () => ({}),
|
|
5004
5086
|
onSome: (f) => ({ video: add(f, `${label}-video.mp4`) })
|
|
5005
5087
|
}),
|
|
5006
|
-
...
|
|
5007
|
-
...
|
|
5088
|
+
...Option21.match(run2.media.gif, { onNone: () => ({}), onSome: (f) => ({ gif: add(f, `${label}-preview.gif`) }) }),
|
|
5089
|
+
...Option21.match(run2.media.captions, {
|
|
5008
5090
|
onNone: () => ({}),
|
|
5009
5091
|
onSome: (f) => ({ captions: add(f, `${label}-captions.vtt`) })
|
|
5010
5092
|
})
|
|
@@ -5016,31 +5098,31 @@ var buildReport = Effect23.fn("buildReport")(function* (pair, o) {
|
|
|
5016
5098
|
const sides = pairSides(pair);
|
|
5017
5099
|
const sections = yield* Effect23.forEach([...sides].reverse(), (s) => sectionOf(s.run, s.label, media));
|
|
5018
5100
|
const after = pair.after;
|
|
5019
|
-
const walks = sides.flatMap((s) =>
|
|
5101
|
+
const walks = sides.flatMap((s) => Option21.toArray(s.run.walk)).reverse();
|
|
5020
5102
|
const shortSha = (r) => r.info.sha.slice(0, 7);
|
|
5021
|
-
const defaultPreview =
|
|
5103
|
+
const defaultPreview = Option21.match(pair.before, {
|
|
5022
5104
|
onNone: () => `production build of \`${shortSha(after)}\` in a fresh Witness computer (run \`${path.basename(after.dir)}\`).`,
|
|
5023
5105
|
onSome: (b) => `before = ${shortSha(b)}; after = ${shortSha(after)}`
|
|
5024
5106
|
});
|
|
5025
|
-
const verdictNotes =
|
|
5107
|
+
const verdictNotes = Option21.isNone(after.walk) && isVerdict(after.result) ? Option21.toArray(nonEmpty(after.result.notes)) : [];
|
|
5026
5108
|
const manifest = new ReportManifest({
|
|
5027
5109
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
5028
|
-
intro:
|
|
5110
|
+
intro: Option21.getOrElse(o.intro, () => Option21.match(after.walk, { onNone: () => "", onSome: (w) => w.intro })),
|
|
5029
5111
|
notes: [.../* @__PURE__ */ new Set([...walks.flatMap((w) => w.notes), ...verdictNotes, ...pair.notes, ...o.notes])],
|
|
5030
|
-
preview:
|
|
5031
|
-
|
|
5112
|
+
preview: Option21.getOrElse(
|
|
5113
|
+
Option21.orElse(o.preview, () => Option21.firstSomeOf(walks.map((w) => nonEmpty(w.preview)))),
|
|
5032
5114
|
() => defaultPreview
|
|
5033
5115
|
),
|
|
5034
5116
|
sections: [sections[0], ...sections.slice(1)],
|
|
5035
|
-
title:
|
|
5036
|
-
...
|
|
5037
|
-
|
|
5117
|
+
title: Option21.getOrElse(o.title, () => reportTitle(after.info.task)),
|
|
5118
|
+
...Option21.match(
|
|
5119
|
+
Option21.orElse(o.repo, () => Option21.some(path.basename(after.info.repo))),
|
|
5038
5120
|
{
|
|
5039
5121
|
onNone: () => ({}),
|
|
5040
5122
|
onSome: (repo) => ({ repo })
|
|
5041
5123
|
}
|
|
5042
5124
|
),
|
|
5043
|
-
...
|
|
5125
|
+
...Option21.match(o.pr, { onNone: () => ({}), onSome: (pr) => ({ pr }) })
|
|
5044
5126
|
});
|
|
5045
5127
|
return { manifest, media };
|
|
5046
5128
|
});
|
|
@@ -5143,7 +5225,7 @@ var writeReport = Effect23.fn("writeReport")(function* (pair, outDir, o) {
|
|
|
5143
5225
|
});
|
|
5144
5226
|
|
|
5145
5227
|
// src/runs.ts
|
|
5146
|
-
import { Effect as Effect24, FileSystem as FileSystem11, Option as
|
|
5228
|
+
import { Effect as Effect24, FileSystem as FileSystem11, Option as Option22, Path as Path10 } from "effect";
|
|
5147
5229
|
import { Flag } from "effect/cli";
|
|
5148
5230
|
var runsDirFlag = Flag.String("runs-dir").pipe(
|
|
5149
5231
|
Flag.withDescription("Where run folders are (default: .witness/runs at the current git root)"),
|
|
@@ -5154,7 +5236,7 @@ var witnessHome = Effect24.fnUntraced(function* (dir) {
|
|
|
5154
5236
|
const path = yield* Path10.Path;
|
|
5155
5237
|
const root = yield* Git.use((g) => g.toplevel(dir)).pipe(Effect24.option);
|
|
5156
5238
|
const home = path.join(
|
|
5157
|
-
|
|
5239
|
+
Option22.getOrElse(root, () => dir),
|
|
5158
5240
|
".witness"
|
|
5159
5241
|
);
|
|
5160
5242
|
yield* fs.makeDirectory(home, { recursive: true });
|
|
@@ -5166,7 +5248,7 @@ var witnessHome = Effect24.fnUntraced(function* (dir) {
|
|
|
5166
5248
|
});
|
|
5167
5249
|
var runsDirFor = Effect24.fnUntraced(function* (flag) {
|
|
5168
5250
|
const path = yield* Path10.Path;
|
|
5169
|
-
if (
|
|
5251
|
+
if (Option22.isSome(flag)) {
|
|
5170
5252
|
return path.resolve(flag.value);
|
|
5171
5253
|
}
|
|
5172
5254
|
return path.join(yield* witnessHome(path.resolve(".")), "runs");
|
|
@@ -5182,10 +5264,10 @@ import {
|
|
|
5182
5264
|
Deferred,
|
|
5183
5265
|
Effect as Effect27,
|
|
5184
5266
|
FileSystem as FileSystem12,
|
|
5185
|
-
Option as
|
|
5267
|
+
Option as Option25,
|
|
5186
5268
|
Path as Path11,
|
|
5187
5269
|
Ref as Ref6,
|
|
5188
|
-
Schema as
|
|
5270
|
+
Schema as Schema26,
|
|
5189
5271
|
Semaphore,
|
|
5190
5272
|
Stream as Stream4,
|
|
5191
5273
|
SubscriptionRef
|
|
@@ -5195,12 +5277,12 @@ import {
|
|
|
5195
5277
|
HttpClientRequest as HttpClientRequest2,
|
|
5196
5278
|
HttpClientResponse,
|
|
5197
5279
|
HttpRouter as HttpRouter2,
|
|
5198
|
-
HttpServerRequest,
|
|
5280
|
+
HttpServerRequest as HttpServerRequest2,
|
|
5199
5281
|
HttpServerResponse as HttpServerResponse2
|
|
5200
5282
|
} from "effect/http";
|
|
5201
5283
|
|
|
5202
5284
|
// src/session-actions.ts
|
|
5203
|
-
import { Effect as Effect25, Option as
|
|
5285
|
+
import { Effect as Effect25, Option as Option23, Schema as Schema25 } from "effect";
|
|
5204
5286
|
var bad = (message) => Effect25.fail(new ActionFailed({ message }));
|
|
5205
5287
|
var need = (action, args, i, name) => args[i] === void 0 ? bad(`${action}: missing <${name}>`) : Effect25.succeed(args[i]);
|
|
5206
5288
|
var int2 = (action, args, i, name) => need(action, args, i, name).pipe(
|
|
@@ -5221,14 +5303,14 @@ var ACTION_SPECS = {
|
|
|
5221
5303
|
const x = yield* int2("click", args, 0, "x");
|
|
5222
5304
|
const y = yield* int2("click", args, 1, "y");
|
|
5223
5305
|
return [
|
|
5224
|
-
ToolCall.Click({ button: "click", label:
|
|
5306
|
+
ToolCall.Click({ button: "click", label: Option23.getOrElse(label, () => `Click at (${x}, ${y})`), x, y })
|
|
5225
5307
|
];
|
|
5226
5308
|
}),
|
|
5227
5309
|
usage: "click <x> <y>"
|
|
5228
5310
|
},
|
|
5229
5311
|
"click-ref": {
|
|
5230
5312
|
parse: (args, label) => need("click-ref", args, 0, "ref").pipe(
|
|
5231
|
-
Effect25.map((ref) => [ToolCall.ClickRef({ label:
|
|
5313
|
+
Effect25.map((ref) => [ToolCall.ClickRef({ label: Option23.getOrElse(label, () => ""), ref })])
|
|
5232
5314
|
),
|
|
5233
5315
|
usage: "click-ref <ref>"
|
|
5234
5316
|
},
|
|
@@ -5236,7 +5318,7 @@ var ACTION_SPECS = {
|
|
|
5236
5318
|
parse: (args, label) => text2(
|
|
5237
5319
|
"click-text",
|
|
5238
5320
|
"text",
|
|
5239
|
-
(t) => ToolCall.ClickText({ label:
|
|
5321
|
+
(t) => ToolCall.ClickText({ label: Option23.getOrElse(label, () => `Click "${t.slice(0, 40)}"`), text: t })
|
|
5240
5322
|
)(args, label),
|
|
5241
5323
|
usage: "click-text <text>"
|
|
5242
5324
|
},
|
|
@@ -5245,7 +5327,7 @@ var ACTION_SPECS = {
|
|
|
5245
5327
|
parse: (args) => Effect25.gen(function* () {
|
|
5246
5328
|
const id = yield* need("criterion", args, 0, "id");
|
|
5247
5329
|
const kind = yield* need("criterion", args, 1, "feature|regression");
|
|
5248
|
-
if (!
|
|
5330
|
+
if (!Schema25.is(CriterionKind)(kind)) {
|
|
5249
5331
|
return yield* bad("kind must be feature or regression");
|
|
5250
5332
|
}
|
|
5251
5333
|
const description = rest(args, 2);
|
|
@@ -5260,14 +5342,14 @@ var ACTION_SPECS = {
|
|
|
5260
5342
|
parse: (args) => Effect25.gen(function* () {
|
|
5261
5343
|
const id = yield* need("end", args, 0, "id");
|
|
5262
5344
|
const status = yield* need("end", args, 1, "pass|fail|blocked");
|
|
5263
|
-
if (!
|
|
5345
|
+
if (!Schema25.is(CriterionStatus)(status)) {
|
|
5264
5346
|
return yield* bad("status must be pass, fail or blocked");
|
|
5265
5347
|
}
|
|
5266
5348
|
const notes = rest(args, 2);
|
|
5267
5349
|
if (!notes) {
|
|
5268
5350
|
return yield* bad("end: missing <notes> (what you did and saw)");
|
|
5269
5351
|
}
|
|
5270
|
-
return [ToolCall.End({ forced:
|
|
5352
|
+
return [ToolCall.End({ forced: Option23.none(), id, notes, status })];
|
|
5271
5353
|
}),
|
|
5272
5354
|
usage: "end <id> pass|fail|blocked <notes>"
|
|
5273
5355
|
},
|
|
@@ -5276,7 +5358,7 @@ var ACTION_SPECS = {
|
|
|
5276
5358
|
intro: { parse: text2("intro", "line", (line) => ToolCall.Intro({ line })), usage: "intro <line>" },
|
|
5277
5359
|
key: {
|
|
5278
5360
|
parse: (args, label) => need("key", args, 0, "combo").pipe(
|
|
5279
|
-
Effect25.map((combo) => [ToolCall.Key({ combo, label:
|
|
5361
|
+
Effect25.map((combo) => [ToolCall.Key({ combo, label: Option23.getOrElse(label, () => `Press ${combo}`) })])
|
|
5280
5362
|
),
|
|
5281
5363
|
usage: "key <combo>"
|
|
5282
5364
|
},
|
|
@@ -5286,7 +5368,7 @@ var ACTION_SPECS = {
|
|
|
5286
5368
|
},
|
|
5287
5369
|
navigate: {
|
|
5288
5370
|
parse: (args, label) => need("navigate", args, 0, "url").pipe(
|
|
5289
|
-
Effect25.map((url) => [ToolCall.Navigate({ label:
|
|
5371
|
+
Effect25.map((url) => [ToolCall.Navigate({ label: Option23.getOrElse(label, () => `Open ${url}`), url })])
|
|
5290
5372
|
),
|
|
5291
5373
|
usage: "navigate <url>"
|
|
5292
5374
|
},
|
|
@@ -5295,9 +5377,9 @@ var ACTION_SPECS = {
|
|
|
5295
5377
|
scroll: {
|
|
5296
5378
|
parse: (args, label) => Effect25.gen(function* () {
|
|
5297
5379
|
const dy = yield* int2("scroll", args, 0, "dy");
|
|
5298
|
-
const at = args.length >= 3 ?
|
|
5380
|
+
const at = args.length >= 3 ? Option23.some({ x: yield* int2("scroll", args, 1, "x"), y: yield* int2("scroll", args, 2, "y") }) : Option23.none();
|
|
5299
5381
|
return [
|
|
5300
|
-
ToolCall.Scroll({ at, dy, label:
|
|
5382
|
+
ToolCall.Scroll({ at, dy, label: Option23.getOrElse(label, () => dy > 0 ? "Scroll down" : "Scroll up") })
|
|
5301
5383
|
];
|
|
5302
5384
|
}),
|
|
5303
5385
|
usage: "scroll <dy> [x y]"
|
|
@@ -5317,12 +5399,12 @@ var ACTION_SPECS = {
|
|
|
5317
5399
|
},
|
|
5318
5400
|
type: {
|
|
5319
5401
|
parse: (args, label) => one(
|
|
5320
|
-
ToolCall.Type({ label:
|
|
5402
|
+
ToolCall.Type({ label: Option23.getOrElse(label, () => `Type "${rest(args).slice(0, 30)}"`), text: rest(args) })
|
|
5321
5403
|
),
|
|
5322
5404
|
usage: "type <text>"
|
|
5323
5405
|
},
|
|
5324
5406
|
"type-secret": {
|
|
5325
|
-
parse: (_args, label) => one(ToolCall.TypeSecret({ label:
|
|
5407
|
+
parse: (_args, label) => one(ToolCall.TypeSecret({ label: Option23.getOrElse(label, () => "Type the password") })),
|
|
5326
5408
|
usage: "type-secret"
|
|
5327
5409
|
},
|
|
5328
5410
|
wait: {
|
|
@@ -5333,7 +5415,7 @@ var ACTION_SPECS = {
|
|
|
5333
5415
|
var ACTIONS = Object.keys(ACTION_SPECS);
|
|
5334
5416
|
|
|
5335
5417
|
// src/verdict-text.ts
|
|
5336
|
-
import { Console as Console4, Effect as Effect26, Option as
|
|
5418
|
+
import { Console as Console4, Effect as Effect26, Option as Option24 } from "effect";
|
|
5337
5419
|
var printVerdict = Effect26.fnUntraced(function* (heading, v) {
|
|
5338
5420
|
if (!isVerdict(v)) {
|
|
5339
5421
|
yield* Console4.log(`${heading}BLOCKED (${v.reason}): ${v.notes}`);
|
|
@@ -5347,7 +5429,7 @@ ${v.log_tail}`);
|
|
|
5347
5429
|
${heading}${v.overall.toUpperCase()}`);
|
|
5348
5430
|
for (const c of v.criteria) {
|
|
5349
5431
|
yield* Console4.log(
|
|
5350
|
-
` ${c.id} ${c.status.padEnd(7)} ${c.description}${
|
|
5432
|
+
` ${c.id} ${c.status.padEnd(7)} ${c.description}${Option24.match(c.video_ts, { onNone: () => "", onSome: ([a, b]) => ` [${a}s-${b}s]` })}`
|
|
5351
5433
|
);
|
|
5352
5434
|
}
|
|
5353
5435
|
if (v.usage.usd > 0) {
|
|
@@ -5356,40 +5438,41 @@ ${heading}${v.overall.toUpperCase()}`);
|
|
|
5356
5438
|
});
|
|
5357
5439
|
|
|
5358
5440
|
// src/session.ts
|
|
5359
|
-
var DriverInfo =
|
|
5360
|
-
var DriverInfoJson =
|
|
5361
|
-
var SessionStatus =
|
|
5362
|
-
|
|
5363
|
-
|
|
5364
|
-
carried:
|
|
5441
|
+
var DriverInfo = Schema26.Struct({ token: Schema26.String, url: Schema26.String });
|
|
5442
|
+
var DriverInfoJson = Schema26.fromJsonString(DriverInfo);
|
|
5443
|
+
var SessionStatus = Schema26.Union([
|
|
5444
|
+
Schema26.TaggedStruct("Booting", { seq: Schema26.Int }),
|
|
5445
|
+
Schema26.TaggedStruct("Ready", {
|
|
5446
|
+
carried: Schema26.Array(Schema26.String),
|
|
5365
5447
|
/** That side's run folder. */
|
|
5366
|
-
runDir:
|
|
5367
|
-
seq:
|
|
5368
|
-
sha:
|
|
5369
|
-
side:
|
|
5448
|
+
runDir: Schema26.String,
|
|
5449
|
+
seq: Schema26.Int,
|
|
5450
|
+
sha: Schema26.String,
|
|
5451
|
+
side: Schema26.Literals(["before", "after", "single"])
|
|
5370
5452
|
}),
|
|
5371
|
-
|
|
5453
|
+
Schema26.TaggedStruct("Finished", { seq: Schema26.Int })
|
|
5372
5454
|
]);
|
|
5373
|
-
var SessionError = class extends
|
|
5455
|
+
var SessionError = class extends Schema26.TaggedError()("SessionError", { message: Schema26.String }) {
|
|
5374
5456
|
};
|
|
5375
|
-
var ActRequest2 =
|
|
5376
|
-
action:
|
|
5377
|
-
args:
|
|
5378
|
-
label:
|
|
5457
|
+
var ActRequest2 = Schema26.Struct({
|
|
5458
|
+
action: Schema26.Literals(ACTIONS),
|
|
5459
|
+
args: Schema26.Array(Schema26.String),
|
|
5460
|
+
label: Schema26.optionalKey(Schema26.String)
|
|
5379
5461
|
});
|
|
5380
|
-
var ActResponse =
|
|
5381
|
-
error:
|
|
5382
|
-
ok:
|
|
5383
|
-
shot:
|
|
5384
|
-
text:
|
|
5462
|
+
var ActResponse = Schema26.Struct({
|
|
5463
|
+
error: Schema26.optionalKey(Schema26.String),
|
|
5464
|
+
ok: Schema26.Boolean,
|
|
5465
|
+
shot: Schema26.optionalKey(Schema26.String),
|
|
5466
|
+
text: Schema26.optionalKey(Schema26.String)
|
|
5385
5467
|
});
|
|
5386
5468
|
var sessionHost = Effect27.fnUntraced(function* (runDir, idleMs) {
|
|
5387
5469
|
const fs = yield* FileSystem12.FileSystem;
|
|
5388
5470
|
const path = yield* Path11.Path;
|
|
5389
5471
|
const status = yield* SubscriptionRef.make({ _tag: "Booting", seq: 0 });
|
|
5390
|
-
const current = yield* Ref6.make(
|
|
5472
|
+
const current = yield* Ref6.make(Option25.none());
|
|
5391
5473
|
const lock = yield* Semaphore.make(1);
|
|
5392
5474
|
const shotNo = yield* Ref6.make(0);
|
|
5475
|
+
const humanSince = yield* Ref6.make(Option25.none());
|
|
5393
5476
|
const setStatus = (next) => SubscriptionRef.update(status, (s) => next(s.seq + 1));
|
|
5394
5477
|
const look = (data) => Effect27.gen(function* () {
|
|
5395
5478
|
const n = yield* Ref6.updateAndGet(shotNo, (x) => x + 1);
|
|
@@ -5400,8 +5483,13 @@ var sessionHost = Effect27.fnUntraced(function* (runDir, idleMs) {
|
|
|
5400
5483
|
return file;
|
|
5401
5484
|
});
|
|
5402
5485
|
const act2 = (req) => Effect27.gen(function* () {
|
|
5486
|
+
if (Option25.isSome(yield* Ref6.get(humanSince))) {
|
|
5487
|
+
return yield* bad(
|
|
5488
|
+
"a person has taken over the computer in the live view; wait until they hand it back, then `witness act shot` to see where they left it"
|
|
5489
|
+
);
|
|
5490
|
+
}
|
|
5403
5491
|
const side = yield* Ref6.get(current);
|
|
5404
|
-
if (
|
|
5492
|
+
if (Option25.isNone(side)) {
|
|
5405
5493
|
return yield* bad("no side is ready yet (the app is booting); try again in a moment");
|
|
5406
5494
|
}
|
|
5407
5495
|
const { done, lastAt, recorder } = side.value;
|
|
@@ -5410,13 +5498,13 @@ var sessionHost = Effect27.fnUntraced(function* (runDir, idleMs) {
|
|
|
5410
5498
|
yield* Deferred.succeed(done, void 0);
|
|
5411
5499
|
return { ok: true, text: "finishing" };
|
|
5412
5500
|
}
|
|
5413
|
-
const calls = yield* ACTION_SPECS[req.action].parse(req.args,
|
|
5501
|
+
const calls = yield* ACTION_SPECS[req.action].parse(req.args, Option25.fromUndefinedOr(req.label));
|
|
5414
5502
|
const texts = [];
|
|
5415
5503
|
let shot;
|
|
5416
5504
|
for (const call of calls) {
|
|
5417
5505
|
const r = yield* recorder.perform(call);
|
|
5418
5506
|
texts.push(r.text);
|
|
5419
|
-
if (
|
|
5507
|
+
if (Option25.isSome(r.screen)) {
|
|
5420
5508
|
shot = yield* look(r.screen.value.data).pipe(Effect27.mapError((e) => new ActionFailed({ message: e.message })));
|
|
5421
5509
|
}
|
|
5422
5510
|
}
|
|
@@ -5426,8 +5514,29 @@ var sessionHost = Effect27.fnUntraced(function* (runDir, idleMs) {
|
|
|
5426
5514
|
Effect27.catch((e) => Effect27.succeed({ error: e.message, ok: false })),
|
|
5427
5515
|
Semaphore.withPermit(lock)
|
|
5428
5516
|
);
|
|
5517
|
+
const takeover = (human) => Effect27.gen(function* () {
|
|
5518
|
+
const at = yield* Clock6.currentTimeMillis;
|
|
5519
|
+
const since = yield* Ref6.getAndSet(humanSince, human ? Option25.some(at) : Option25.none());
|
|
5520
|
+
const side = yield* Ref6.get(current);
|
|
5521
|
+
if (Option25.isNone(side) || Option25.isSome(since) === human) {
|
|
5522
|
+
return;
|
|
5523
|
+
}
|
|
5524
|
+
yield* Ref6.set(side.value.lastAt, at);
|
|
5525
|
+
const { recorder } = side.value;
|
|
5526
|
+
if (human) {
|
|
5527
|
+
yield* recorder.perform(ToolCall.Caption({ label: "A person took over the computer" }));
|
|
5528
|
+
return;
|
|
5529
|
+
}
|
|
5530
|
+
yield* recorder.perform(ToolCall.Caption({ label: "The person handed control back" }));
|
|
5531
|
+
const secs = Math.round((at - Option25.getOrElse(since, () => at)) / 1e3);
|
|
5532
|
+
yield* recorder.perform(
|
|
5533
|
+
ToolCall.Note({
|
|
5534
|
+
line: `A person took over the computer from the live view for ${secs} s; the steps between "A person took over the computer" and "The person handed control back" are theirs.`
|
|
5535
|
+
})
|
|
5536
|
+
);
|
|
5537
|
+
}).pipe(Effect27.ignore, Semaphore.withPermit(lock));
|
|
5429
5538
|
const token = randomBytes3(24).toString("hex");
|
|
5430
|
-
const authorized =
|
|
5539
|
+
const authorized = HttpServerRequest2.HttpServerRequest.pipe(
|
|
5431
5540
|
Effect27.map((r) => r.headers.authorization === `Bearer ${token}`)
|
|
5432
5541
|
);
|
|
5433
5542
|
const unauthorized = HttpServerResponse2.json({ error: "unauthorized", ok: false }, { status: 401 });
|
|
@@ -5440,8 +5549,8 @@ var sessionHost = Effect27.fnUntraced(function* (runDir, idleMs) {
|
|
|
5440
5549
|
if (!(yield* authorized)) {
|
|
5441
5550
|
return yield* unauthorized;
|
|
5442
5551
|
}
|
|
5443
|
-
const body = yield*
|
|
5444
|
-
return yield*
|
|
5552
|
+
const body = yield* HttpServerRequest2.schemaBodyJson(ActRequest2).pipe(Effect27.option);
|
|
5553
|
+
return yield* Option25.match(body, {
|
|
5445
5554
|
onNone: () => HttpServerResponse2.json({ error: "bad request", ok: false }, { status: 400 }),
|
|
5446
5555
|
onSome: (b) => act2(b).pipe(Effect27.flatMap((r) => HttpServerResponse2.json(r)))
|
|
5447
5556
|
});
|
|
@@ -5455,39 +5564,39 @@ var sessionHost = Effect27.fnUntraced(function* (runDir, idleMs) {
|
|
|
5455
5564
|
if (!(yield* authorized)) {
|
|
5456
5565
|
return yield* unauthorized;
|
|
5457
5566
|
}
|
|
5458
|
-
const query = yield*
|
|
5459
|
-
|
|
5567
|
+
const query = yield* HttpServerRequest2.schemaSearchParams(
|
|
5568
|
+
Schema26.Struct({ since: Schema26.optionalKey(Schema26.NumberFromString) })
|
|
5460
5569
|
);
|
|
5461
5570
|
const since = query.since ?? -1;
|
|
5462
5571
|
const next = yield* SubscriptionRef.changes(status).pipe(
|
|
5463
5572
|
Stream4.filter((s) => s.seq > since),
|
|
5464
5573
|
Stream4.runHead,
|
|
5465
5574
|
Effect27.timeout("20 seconds"),
|
|
5466
|
-
Effect27.catchTag("TimeoutError", () => Effect27.succeed(
|
|
5467
|
-
Effect27.flatMap(
|
|
5575
|
+
Effect27.catchTag("TimeoutError", () => Effect27.succeed(Option25.none())),
|
|
5576
|
+
Effect27.flatMap(Option25.match({ onNone: () => SubscriptionRef.get(status), onSome: Effect27.succeed }))
|
|
5468
5577
|
);
|
|
5469
|
-
return yield* HttpServerResponse2.json(
|
|
5578
|
+
return yield* HttpServerResponse2.json(Schema26.encodeSync(SessionStatus)(next));
|
|
5470
5579
|
}).pipe(Effect27.orDie)
|
|
5471
5580
|
)
|
|
5472
5581
|
])
|
|
5473
5582
|
);
|
|
5474
5583
|
const driverFile = path.join(runDir, RUN_FILES.driver);
|
|
5475
5584
|
yield* Effect27.acquireRelease(
|
|
5476
|
-
fs.writeFileString(driverFile,
|
|
5585
|
+
fs.writeFileString(driverFile, Schema26.encodeSync(DriverInfoJson)({ token, url: origin })),
|
|
5477
5586
|
() => fs.remove(driverFile).pipe(Effect27.ignore)
|
|
5478
5587
|
);
|
|
5479
5588
|
const program = (side) => Effect27.gen(function* () {
|
|
5480
5589
|
const recorder = yield* Recorder;
|
|
5481
5590
|
const done = yield* Deferred.make();
|
|
5482
5591
|
const lastAt = yield* Ref6.make(yield* Clock6.currentTimeMillis);
|
|
5483
|
-
yield* Ref6.set(current,
|
|
5592
|
+
yield* Ref6.set(current, Option25.some({ done, lastAt, recorder }));
|
|
5484
5593
|
yield* setStatus((seq) => ({
|
|
5485
5594
|
_tag: "Ready",
|
|
5486
5595
|
carried: side.carried.map((c) => c.id),
|
|
5487
5596
|
runDir: recorder.runDir,
|
|
5488
5597
|
seq,
|
|
5489
5598
|
sha: side.sha,
|
|
5490
|
-
side:
|
|
5599
|
+
side: Option25.getOrElse(side.state, () => "single")
|
|
5491
5600
|
}));
|
|
5492
5601
|
yield* Console5.log(`session ready: ${recorder.runDir}`);
|
|
5493
5602
|
const idle = Effect27.gen(function* () {
|
|
@@ -5501,19 +5610,20 @@ var sessionHost = Effect27.fnUntraced(function* (runDir, idleMs) {
|
|
|
5501
5610
|
yield* Effect27.raceFirst(Deferred.await(done), idle);
|
|
5502
5611
|
}).pipe(
|
|
5503
5612
|
Effect27.ensuring(
|
|
5504
|
-
Ref6.set(current,
|
|
5613
|
+
Ref6.set(current, Option25.none()).pipe(Effect27.andThen(setStatus((seq) => ({ _tag: "Booting", seq }))))
|
|
5505
5614
|
)
|
|
5506
5615
|
);
|
|
5507
5616
|
return {
|
|
5508
5617
|
/** Tells waiting drivers the run is over, and gives them a moment to hear it. */
|
|
5509
5618
|
finished: setStatus((seq) => ({ _tag: "Finished", seq })).pipe(Effect27.andThen(Effect27.sleep("1 second"))),
|
|
5510
|
-
program
|
|
5619
|
+
program,
|
|
5620
|
+
takeover
|
|
5511
5621
|
};
|
|
5512
5622
|
});
|
|
5513
5623
|
var findSession = Effect27.fnUntraced(function* (run2, runsDir) {
|
|
5514
5624
|
const fs = yield* FileSystem12.FileSystem;
|
|
5515
5625
|
const path = yield* Path11.Path;
|
|
5516
|
-
if (
|
|
5626
|
+
if (Option25.isSome(run2)) {
|
|
5517
5627
|
return path.resolve(run2.value);
|
|
5518
5628
|
}
|
|
5519
5629
|
const root = path.resolve(runsDir);
|
|
@@ -5536,7 +5646,7 @@ var connect = Effect27.fnUntraced(function* (runDir) {
|
|
|
5536
5646
|
const fs = yield* FileSystem12.FileSystem;
|
|
5537
5647
|
const path = yield* Path11.Path;
|
|
5538
5648
|
const info = yield* fs.readFileString(path.join(runDir, RUN_FILES.driver)).pipe(
|
|
5539
|
-
Effect27.flatMap(
|
|
5649
|
+
Effect27.flatMap(Schema26.decodeUnknownEffect(DriverInfoJson)),
|
|
5540
5650
|
Effect27.mapError(() => new SessionError({ message: `no open session in ${runDir}` }))
|
|
5541
5651
|
);
|
|
5542
5652
|
const client = (yield* HttpClient3.HttpClient).pipe(
|
|
@@ -5592,14 +5702,14 @@ var followSession = Effect27.fnUntraced(function* (runDir, client, since, ended)
|
|
|
5592
5702
|
if (s._tag === "Booting") {
|
|
5593
5703
|
continue;
|
|
5594
5704
|
}
|
|
5595
|
-
if (
|
|
5705
|
+
if (Option25.isSome(ended)) {
|
|
5596
5706
|
yield* verdictIn(ended.value.runDir);
|
|
5597
5707
|
}
|
|
5598
5708
|
if (s._tag === "Ready") {
|
|
5599
5709
|
yield* Console5.log(readyText(s));
|
|
5600
5710
|
return 0;
|
|
5601
5711
|
}
|
|
5602
|
-
if (
|
|
5712
|
+
if (Option25.exists(ended, (e) => e.side !== "before")) {
|
|
5603
5713
|
return exitCodeOf(yield* requireRunFile(runDir, RUN_FILES.verdict, VerdictFile));
|
|
5604
5714
|
}
|
|
5605
5715
|
return yield* verdictIn(runDir);
|
|
@@ -5612,7 +5722,7 @@ var act = Effect27.fn("act")(function* (opts) {
|
|
|
5612
5722
|
const res = yield* client.act({
|
|
5613
5723
|
action: opts.action,
|
|
5614
5724
|
args: opts.args,
|
|
5615
|
-
...
|
|
5725
|
+
...Option25.match(opts.label, { onNone: () => ({}), onSome: (label) => ({ label }) })
|
|
5616
5726
|
});
|
|
5617
5727
|
if (!res.ok) {
|
|
5618
5728
|
yield* Console5.error(`error: ${res.error ?? "unknown"}`);
|
|
@@ -5627,8 +5737,8 @@ var act = Effect27.fn("act")(function* (opts) {
|
|
|
5627
5737
|
if (!before) {
|
|
5628
5738
|
return 0;
|
|
5629
5739
|
}
|
|
5630
|
-
const ended = before._tag === "Ready" ?
|
|
5631
|
-
if (
|
|
5740
|
+
const ended = before._tag === "Ready" ? Option25.some(before) : Option25.none();
|
|
5741
|
+
if (Option25.exists(ended, (e) => e.side === "before")) {
|
|
5632
5742
|
yield* Console5.log(`
|
|
5633
5743
|
recording the base commit, then booting the change (log: ${runDir}/session.log)`);
|
|
5634
5744
|
}
|
|
@@ -5674,19 +5784,19 @@ booting (log: ${logFile})`);
|
|
|
5674
5784
|
yield* Effect27.sleep("500 millis");
|
|
5675
5785
|
}
|
|
5676
5786
|
const client = yield* connect(dir);
|
|
5677
|
-
const watched = followSession(dir, client, 0,
|
|
5787
|
+
const watched = followSession(dir, client, 0, Option25.none()).pipe(
|
|
5678
5788
|
Effect27.raceFirst(Effect27.forever(follow.pipe(Effect27.andThen(Effect27.sleep("500 millis")))))
|
|
5679
5789
|
);
|
|
5680
5790
|
return yield* watched.pipe(Effect27.tap(() => follow));
|
|
5681
5791
|
});
|
|
5682
5792
|
|
|
5683
5793
|
// src/upload.ts
|
|
5684
|
-
import { Config as Config5, Console as Console6, Effect as Effect28, FileSystem as FileSystem13, Option as
|
|
5794
|
+
import { Config as Config5, Console as Console6, Effect as Effect28, FileSystem as FileSystem13, Option as Option26, Path as Path12, Redacted as Redacted3 } from "effect";
|
|
5685
5795
|
import { HttpClient as HttpClient4, HttpClientRequest as HttpClientRequest3 } from "effect/http";
|
|
5686
5796
|
import { HttpApiClient as HttpApiClient2, HttpApiMiddleware as HttpApiMiddleware3 } from "effect/http-api";
|
|
5687
5797
|
var warnAboutRender = Effect28.fnUntraced(function* (dir) {
|
|
5688
5798
|
const cut = yield* readRenderedCut(dir);
|
|
5689
|
-
if (
|
|
5799
|
+
if (Option26.isNone(cut)) {
|
|
5690
5800
|
yield* Console6.error(
|
|
5691
5801
|
`warning: ${dir} has no render/rendered.json (not rendered, or by an older witness), so the page cannot seek to each criterion; render it with \`witness render --layout hosted\``
|
|
5692
5802
|
);
|
|
@@ -5729,7 +5839,7 @@ var upload = Effect28.fn("upload")(function* (pair, o) {
|
|
|
5729
5839
|
});
|
|
5730
5840
|
|
|
5731
5841
|
// src/main.ts
|
|
5732
|
-
var UsageError = class extends
|
|
5842
|
+
var UsageError = class extends Schema27.TaggedError()("UsageError", { message: Schema27.String }) {
|
|
5733
5843
|
};
|
|
5734
5844
|
var setExit = (code) => Effect29.sync(() => {
|
|
5735
5845
|
process.exitCode = code;
|
|
@@ -5796,7 +5906,12 @@ var runFlags = {
|
|
|
5796
5906
|
),
|
|
5797
5907
|
task: Flag2.String("task").pipe(Flag2.withDescription("What the change is supposed to do"), Flag2.optional),
|
|
5798
5908
|
taskFile: Flag2.FileText("task-file").pipe(Flag2.withDescription("Read the task from a file"), Flag2.optional),
|
|
5799
|
-
vnc: Flag2.Boolean("vnc").pipe(
|
|
5909
|
+
vnc: Flag2.Boolean("vnc").pipe(
|
|
5910
|
+
Flag2.withDescription(
|
|
5911
|
+
"Print the computer's noVNC URL (with --no-live; it opens watching, drop view_only=true to take over)"
|
|
5912
|
+
),
|
|
5913
|
+
Flag2.withDefault(false)
|
|
5914
|
+
),
|
|
5800
5915
|
walkthrough: Flag2.String("walkthrough").pipe(
|
|
5801
5916
|
Flag2.withDescription(
|
|
5802
5917
|
"Walkthrough mode: a Playwright spec drives the app (one of the app's own, run at the exact commit, or a file outside the repo)"
|
|
@@ -5810,15 +5925,15 @@ var runModeOf = Effect29.fnUntraced(function* (f) {
|
|
|
5810
5925
|
const chosen = [
|
|
5811
5926
|
f.bootOnly && "--boot-only",
|
|
5812
5927
|
f.session && "--session",
|
|
5813
|
-
|
|
5928
|
+
Option27.isSome(f.walkthrough) && "--walkthrough"
|
|
5814
5929
|
];
|
|
5815
5930
|
if (chosen.filter(Boolean).length > 1) {
|
|
5816
5931
|
return yield* usage(`${chosen.filter(Boolean).join(" and ")} are different modes; pick one`);
|
|
5817
5932
|
}
|
|
5818
5933
|
const onlyFor = (flag, given, mode, ok) => given && !ok ? usage(`${flag} only applies to ${mode}`) : Effect29.void;
|
|
5819
|
-
yield* onlyFor("--slow-mo",
|
|
5820
|
-
yield* onlyFor("--spec-timeout",
|
|
5821
|
-
yield* onlyFor("--session-idle",
|
|
5934
|
+
yield* onlyFor("--slow-mo", Option27.isSome(f.slowMo), "--walkthrough", Option27.isSome(f.walkthrough));
|
|
5935
|
+
yield* onlyFor("--spec-timeout", Option27.isSome(f.specTimeout), "--walkthrough", Option27.isSome(f.walkthrough));
|
|
5936
|
+
yield* onlyFor("--session-idle", Option27.isSome(f.sessionIdle), "--session", f.session);
|
|
5822
5937
|
if (f.session && (f.keep || f.parallel)) {
|
|
5823
5938
|
return yield* usage(
|
|
5824
5939
|
"--session cannot be combined with --keep or --parallel (a session checks the base commit, then the change)"
|
|
@@ -5827,24 +5942,24 @@ var runModeOf = Effect29.fnUntraced(function* (f) {
|
|
|
5827
5942
|
if (f.bootOnly) {
|
|
5828
5943
|
return { _tag: "BootOnly" };
|
|
5829
5944
|
}
|
|
5830
|
-
const task =
|
|
5831
|
-
if (
|
|
5945
|
+
const task = Option27.orElse(f.task, () => f.taskFile);
|
|
5946
|
+
if (Option27.isNone(task)) {
|
|
5832
5947
|
return yield* usage("--task or --task-file is required (or --boot-only)");
|
|
5833
5948
|
}
|
|
5834
5949
|
if (f.session) {
|
|
5835
5950
|
return {
|
|
5836
5951
|
_tag: "Session",
|
|
5837
|
-
idleMs:
|
|
5952
|
+
idleMs: Option27.getOrElse(f.sessionIdle, () => 900) * 1e3,
|
|
5838
5953
|
task: task.value
|
|
5839
5954
|
};
|
|
5840
5955
|
}
|
|
5841
|
-
if (
|
|
5956
|
+
if (Option27.isSome(f.walkthrough)) {
|
|
5842
5957
|
return {
|
|
5843
5958
|
_tag: "Spec",
|
|
5844
5959
|
file: path.resolve(f.walkthrough.value),
|
|
5845
5960
|
options: {
|
|
5846
|
-
slowMo:
|
|
5847
|
-
timeoutMs:
|
|
5961
|
+
slowMo: Option27.getOrElse(f.slowMo, () => 400),
|
|
5962
|
+
timeoutMs: Option27.getOrElse(f.specTimeout, () => 900) * 1e3
|
|
5848
5963
|
},
|
|
5849
5964
|
task: task.value
|
|
5850
5965
|
};
|
|
@@ -5861,8 +5976,8 @@ var verifyModeOf = (mode) => {
|
|
|
5861
5976
|
return { _tag: "Spec", file: mode.file, options: mode.options };
|
|
5862
5977
|
}
|
|
5863
5978
|
};
|
|
5864
|
-
var openLive = Effect29.fnUntraced(function* () {
|
|
5865
|
-
const live = yield* startLive();
|
|
5979
|
+
var openLive = Effect29.fnUntraced(function* (onTakeover) {
|
|
5980
|
+
const live = yield* startLive(onTakeover);
|
|
5866
5981
|
yield* Console7.log(`live view: ${live.url}`);
|
|
5867
5982
|
const noOpen = yield* Config6.Boolean("WITNESS_NO_OPEN").pipe(Config6.withDefault(false));
|
|
5868
5983
|
const ci = yield* Config6.Boolean("CI").pipe(Config6.withDefault(false));
|
|
@@ -5891,25 +6006,26 @@ var run = Command.make(
|
|
|
5891
6006
|
const path = yield* Path13.Path;
|
|
5892
6007
|
const mode = yield* runModeOf(f);
|
|
5893
6008
|
const runsDir = yield* runsDirFor(f.runsDir);
|
|
5894
|
-
const daemonRunId =
|
|
5895
|
-
if (mode._tag === "Session" &&
|
|
6009
|
+
const daemonRunId = Option27.fromUndefinedOr(process.env[DAEMON_ENV]);
|
|
6010
|
+
if (mode._tag === "Session" && Option27.isNone(daemonRunId)) {
|
|
5896
6011
|
return yield* setExit(yield* launchSession(runsDir));
|
|
5897
6012
|
}
|
|
5898
6013
|
yield* ComputerProvider.use((p) => p.cleanupOrphans).pipe(Effect29.ignore);
|
|
5899
6014
|
const prepared = mode._tag === "Session" ? yield* sessionHost(
|
|
5900
6015
|
path.resolve(
|
|
5901
6016
|
runsDir,
|
|
5902
|
-
|
|
6017
|
+
Option27.getOrElse(daemonRunId, () => "")
|
|
5903
6018
|
),
|
|
5904
6019
|
mode.idleMs
|
|
5905
6020
|
).pipe(
|
|
5906
6021
|
Effect29.map((host) => ({
|
|
5907
6022
|
finished: host.finished,
|
|
5908
|
-
mode: { _tag: "Session", program: host.program }
|
|
6023
|
+
mode: { _tag: "Session", program: host.program },
|
|
6024
|
+
takeover: host.takeover
|
|
5909
6025
|
}))
|
|
5910
|
-
) : { finished: Effect29.void, mode: verifyModeOf(mode) };
|
|
6026
|
+
) : { finished: Effect29.void, mode: verifyModeOf(mode), takeover: void 0 };
|
|
5911
6027
|
const verifyMode = prepared.mode;
|
|
5912
|
-
const live = f.live ?
|
|
6028
|
+
const live = f.live ? Option27.some(yield* openLive(prepared.takeover)) : Option27.none();
|
|
5913
6029
|
const outcome2 = yield* verify({
|
|
5914
6030
|
base: f.base,
|
|
5915
6031
|
configPath: f.config,
|
|
@@ -5928,17 +6044,17 @@ var run = Command.make(
|
|
|
5928
6044
|
Effect29.provide(
|
|
5929
6045
|
runLayer(
|
|
5930
6046
|
runsDir,
|
|
5931
|
-
|
|
5932
|
-
|
|
6047
|
+
Option27.getOrUndefined(daemonRunId),
|
|
6048
|
+
Option27.match(live, { onNone: () => void 0, onSome: (l) => l.publish })
|
|
5933
6049
|
).pipe(Layer8.provideMerge(modelFor(verifyMode)))
|
|
5934
6050
|
)
|
|
5935
6051
|
);
|
|
5936
6052
|
yield* prepared.finished;
|
|
5937
|
-
if (
|
|
6053
|
+
if (Option27.isSome(outcome2.before)) {
|
|
5938
6054
|
yield* printOutcome(outcome2.before.value, "before (base commit): ");
|
|
5939
6055
|
yield* Console7.log("");
|
|
5940
6056
|
}
|
|
5941
|
-
yield* printOutcome(outcome2,
|
|
6057
|
+
yield* printOutcome(outcome2, Option27.isSome(outcome2.before) ? "after (the change): " : "");
|
|
5942
6058
|
yield* Console7.log(`run dir: ${outcome2.runDir}`);
|
|
5943
6059
|
yield* setExit(exitCodeOfResult(outcome2.result));
|
|
5944
6060
|
}, Effect29.scoped)
|
|
@@ -5947,7 +6063,7 @@ var headerOf = (label, sides, flag) => {
|
|
|
5947
6063
|
if (sides === 1) {
|
|
5948
6064
|
return flag;
|
|
5949
6065
|
}
|
|
5950
|
-
return label === "after" ?
|
|
6066
|
+
return label === "after" ? Option27.orElse(flag, () => Option27.some(label)) : Option27.some(label);
|
|
5951
6067
|
};
|
|
5952
6068
|
var render = Command.make(
|
|
5953
6069
|
"render",
|
|
@@ -5976,15 +6092,15 @@ var render = Command.make(
|
|
|
5976
6092
|
for (const { label, run: side } of sides) {
|
|
5977
6093
|
const header = headerOf(label, sides.length, f.label);
|
|
5978
6094
|
const r = yield* renderRun(side.dir, {
|
|
5979
|
-
animate:
|
|
5980
|
-
label:
|
|
5981
|
-
layout:
|
|
6095
|
+
animate: Option27.getOrUndefined(f.animation),
|
|
6096
|
+
label: Option27.getOrUndefined(header),
|
|
6097
|
+
layout: Option27.getOrUndefined(f.layout)
|
|
5982
6098
|
});
|
|
5983
6099
|
yield* Console7.log(
|
|
5984
6100
|
[
|
|
5985
6101
|
`${r.polished} (${r.durationSec.toFixed(1)} s, ${r.layout} layout${r.animate ? "" : ", no animation"})`,
|
|
5986
6102
|
r.gif,
|
|
5987
|
-
...
|
|
6103
|
+
...Option27.toArray(r.captions)
|
|
5988
6104
|
].join("\n")
|
|
5989
6105
|
);
|
|
5990
6106
|
}
|
|
@@ -6022,7 +6138,7 @@ var compare = Command.make(
|
|
|
6022
6138
|
...noReportOptions,
|
|
6023
6139
|
bundle: true,
|
|
6024
6140
|
intro: f.intro,
|
|
6025
|
-
notes:
|
|
6141
|
+
notes: Option27.toArray(f.note),
|
|
6026
6142
|
preview: f.preview
|
|
6027
6143
|
})
|
|
6028
6144
|
);
|
|
@@ -6076,7 +6192,7 @@ var uploadCmd = Command.make(
|
|
|
6076
6192
|
const pair = second === void 0 ? yield* loadRunPair(first) : yield* pairRuns(first, second);
|
|
6077
6193
|
yield* upload(pair, {
|
|
6078
6194
|
...noReportOptions,
|
|
6079
|
-
notes:
|
|
6195
|
+
notes: Option27.toArray(f.note),
|
|
6080
6196
|
pr: f.pr,
|
|
6081
6197
|
preview: f.preview,
|
|
6082
6198
|
repo: f.repoName,
|
|
@@ -6132,7 +6248,7 @@ var imageCmd = Command.make(
|
|
|
6132
6248
|
)
|
|
6133
6249
|
},
|
|
6134
6250
|
Effect29.fn(function* (f) {
|
|
6135
|
-
yield* buildImage(
|
|
6251
|
+
yield* buildImage(Option27.getOrUndefined(f.tag));
|
|
6136
6252
|
})
|
|
6137
6253
|
).pipe(Command.withDescription("Build the computer image runs boot (needs Docker)"));
|
|
6138
6254
|
var witness = Command.make("witness").pipe(
|
|
@@ -43531,6 +43531,11 @@ var CHROME_FLAGS = [
|
|
|
43531
43531
|
"--no-sandbox",
|
|
43532
43532
|
"--test-type",
|
|
43533
43533
|
"--disable-gpu",
|
|
43534
|
+
// No GPU in the container: software WebGL (SwiftShader) so three.js/canvas apps render.
|
|
43535
|
+
"--use-gl=angle",
|
|
43536
|
+
"--use-angle=swiftshader",
|
|
43537
|
+
"--enable-unsafe-swiftshader",
|
|
43538
|
+
"--ignore-gpu-blocklist",
|
|
43534
43539
|
"--hide-crash-restore-bubble",
|
|
43535
43540
|
"--disable-features=Translate,MediaRouter"
|
|
43536
43541
|
];
|
package/dist/computer/start.sh
CHANGED
|
@@ -45,7 +45,7 @@ fbsetroot -solid '#15171c' 2>/dev/null || true
|
|
|
45
45
|
node /opt/control/control.mjs >"$LOGS/control.log" 2>&1 & CONTROL_PID=$!
|
|
46
46
|
|
|
47
47
|
if [ "${ENABLE_VNC:-0}" = 1 ]; then
|
|
48
|
-
x11vnc -display :1 -
|
|
48
|
+
x11vnc -display :1 -shared -forever -nopw -localhost -rfbport 5900 -quiet >"$LOGS/vnc.log" 2>&1 & PIDS+=($!)
|
|
49
49
|
websockify --web /usr/share/novnc 0.0.0.0:6080 127.0.0.1:5900 >"$LOGS/novnc.log" 2>&1 & PIDS+=($!)
|
|
50
50
|
fi
|
|
51
51
|
|
package/package.json
CHANGED