@stacknyu/pi-glitch-lab 0.5.0 → 0.5.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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # pi-glitch-lab changelog
2
2
 
3
+ ## 0.5.1
4
+
5
+ - Cancel interaction approvals through the execution signal in native Pi and RPC/Pi Web dialogs; preserve explicit headless interaction/write authorization.
6
+ - Reject pre-aborted, killed or truncated browser installation attempts instead of reporting incomplete installation as success.
7
+ - Add native/RPC approval, headless authorization and browser-install cancellation regressions.
8
+
3
9
  ## 0.5.0
4
10
 
5
11
  - First independent `@stacknyu/pi-glitch-lab` npm release, with Pi-native manifest, host peers, release notes and MIT license.
@@ -34,11 +34,12 @@ const result = (text: string, ok: boolean, details: any = {}, images: any[] = []
34
34
  });
35
35
 
36
36
  export default function (pi: ExtensionAPI) {
37
- async function authorize(p: any, ctx: any) {
37
+ async function authorize(p: any, signal: AbortSignal | undefined, ctx: any) {
38
+ signal?.throwIfAborted();
38
39
  if (p.allowWrites && !p.interact) throw new Error("allowWrites requires interact=true");
39
40
  if (p.interact && ctx.hasUI && !(await ctx.ui.confirm("Glitch Lab interaction approval", p.allowWrites
40
41
  ? "Allow writes and repeated browser interactions against the approved disposable test environment? No rollback is provided."
41
- : "Allow browser interactions against the approved test environment? HTTP writes are blocked, but GET handlers and page scripts can still have side effects."))) throw new Error("Interaction approval declined");
42
+ : "Allow browser interactions against the approved test environment? HTTP writes are blocked, but GET handlers and page scripts can still have side effects.", { signal }))) throw new Error("Interaction approval declined");
42
43
  }
43
44
  async function run(script: string, args: string[], signal: AbortSignal | undefined, ctx: any) {
44
45
  signal?.throwIfAborted();
@@ -60,7 +61,7 @@ export default function (pi: ExtensionAPI) {
60
61
  attachImages: Type.Optional(Type.Integer({ minimum: 0, maximum: 4 })),
61
62
  }),
62
63
  async execute(_id, p, signal, _update, ctx) {
63
- await authorize(p, ctx);
64
+ await authorize(p, signal, ctx);
64
65
  const out = output(p, "glitch"), args = [p.mode || "nav"];
65
66
  target(args, p); policy(args, p);
66
67
  for (const k of ["journey", "items", "repeat", "cpu", "paint", "viewport"]) flag(args, k, p[k as keyof typeof p]);
@@ -94,7 +95,7 @@ export default function (pi: ExtensionAPI) {
94
95
  observeMs: number("Observation window per action, default 1000ms", 5000),
95
96
  }),
96
97
  async execute(_id, p, signal, _update, ctx) {
97
- await authorize(p, ctx);
98
+ await authorize(p, signal, ctx);
98
99
  const out = output(p, "scan"), args: string[] = [];
99
100
  target(args, p); policy(args, p); flag(args, "out", out); flag(args, "probe-clicks", p.probeClicks); flag(args, "viewport", p.viewport);
100
101
  for (const [k, v] of Object.entries({ "max-actions": p.maxActions, "max-states": p.maxStates, "max-pages": p.maxPages, "max-depth": p.maxDepth, seconds: p.seconds, "observe-ms": p.observeMs })) flag(args, k, v);
@@ -111,7 +112,7 @@ export default function (pi: ExtensionAPI) {
111
112
  baseline: optionalText("Create baseline in this new directory"), compare: optionalText("Existing baseline to compare against"),
112
113
  }),
113
114
  async execute(_id, p, signal, _update, ctx) {
114
- await authorize(p, ctx);
115
+ await authorize(p, signal, ctx);
115
116
  const out = output(p, "journeys"), args: string[] = [];
116
117
  target(args, p); policy(args, p); flag(args, "journey", p.journey);
117
118
  flag(args, "baseline", p.baseline); flag(args, "compare", p.compare); flag(args, "out", out);
@@ -132,9 +133,10 @@ export default function (pi: ExtensionAPI) {
132
133
  });
133
134
 
134
135
  async function doctor(install: boolean, signal: AbortSignal | undefined, ctx: any) {
136
+ signal?.throwIfAborted();
135
137
  if (install) {
136
138
  const r = await pi.exec(process.execPath, [path.join(path.dirname(require.resolve("playwright/package.json")), "cli.js"), "install", "chromium"], { cwd: PKG, signal, timeout: 180000 });
137
- if (r.code) return result(r.stderr || r.stdout, false);
139
+ if (r.code !== 0 || r.killed || r.truncated) return result(r.stderr || r.stdout, false);
138
140
  }
139
141
  const r = await run("doctor.mjs", [], signal, ctx);
140
142
  return result(r.stdout + r.stderr, r.ok);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stacknyu/pi-glitch-lab",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org/"