@booki-aui/readiness 0.2.2 → 0.2.4
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 +22 -0
- package/README.md +9 -6
- package/dist/{chunk-5SCOA3ZP.js → chunk-PRRNS5HS.js} +1 -1
- package/dist/{chunk-2ZR5XHHK.js → chunk-ZQPEUBPL.js} +41 -18
- package/dist/cli.js +2 -2
- package/dist/conformance.d.ts +9 -0
- package/dist/conformance.js +52 -28
- package/dist/index.d.ts +11 -4
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @booki/readiness
|
|
2
2
|
|
|
3
|
+
## 0.2.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#157](https://github.com/Walgermo/booki/pull/157) [`67b9c9b`](https://github.com/Walgermo/booki/commit/67b9c9bc2226a48de5729fd620aa3a921a2bf1a5) Thanks [@Walgermo](https://github.com/Walgermo)! - `snapshot-values` checks a value read from a document (`{ value, confidence }`, a supplier invoice's fields) by the amount or date it holds instead of rejecting the wrapper. Bridge coverage lets a grid cell with `aria-readonly="false"` override its read-only grid, so an editable cell the bridge leaves out is reported.
|
|
8
|
+
|
|
9
|
+
- [#151](https://github.com/Walgermo/booki/pull/151) [`6d56262`](https://github.com/Walgermo/booki/commit/6d562622bbafec1c3b5a1d421c5ce1a6631b1e43) Thanks [@Walgermo](https://github.com/Walgermo)! - The audit and the conformance suite judge fewer things wrong:
|
|
10
|
+
|
|
11
|
+
- A WebMCP snapshot tool that answers in plain text, not a list of controls, is no longer read as an empty list, so the page's fields are not each counted missing from it.
|
|
12
|
+
- A read-only field (native `readOnly` on a text input or textarea, or inside `aria-readonly="true"`) is not counted as missing from the bridge: no one can change it.
|
|
13
|
+
- A page with no fields or charts is measured when something else was found (a focusable cell, an ungated posting button) or when it registers WebMCP tools of its own, so `--fail-under` judges its score instead of "no score".
|
|
14
|
+
- A WebMCP tool registered again with the same object and a new signal stays when the older signal aborts.
|
|
15
|
+
- `approveUnderRule`, a canonical agent action, is not reported as a person-only action.
|
|
16
|
+
- `server-person-only` asks as an agent that holds the roles granting the permission, and checks that a person with the same roles is let through; a new `serverActor` option gives those roles (default `[permission]`). A permission it cannot verify is reported as such, not passed.
|
|
17
|
+
- `snapshot-secrets` no longer reads an amount in minor units as a bank account number; `snapshot-values` checks nested lists (a voucher's lines) and a date control's `value`; `recording-agent` accepts one attributed event per change.
|
|
18
|
+
|
|
19
|
+
## 0.2.3
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- [#132](https://github.com/Walgermo/booki/pull/132) [`e4d4d0d`](https://github.com/Walgermo/booki/commit/e4d4d0d19a303ad7b27588b8045712e59d94e907) Thanks [@Walgermo](https://github.com/Walgermo)! - The JSON report's `tool.version` is the installed version of `@booki-aui/readiness`; it always said 0.1.0.
|
|
24
|
+
|
|
3
25
|
## 0.2.2
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -151,6 +151,7 @@ The target takes these options, all optional:
|
|
|
151
151
|
| `closedList` | `{ step, valid }`: a bad value and every valid choice its refusal must name (4.3). |
|
|
152
152
|
| `personOnly` | Steps only a person may take, which the agent must be refused (5.1). |
|
|
153
153
|
| `server` | Your write gate, `(actor, permission) => { status }`, asked for each person-only permission as an agent and once unsigned (5.1, 7.3). |
|
|
154
|
+
| `serverActor` | `(permission) => { id, roles }`: an actor your `server` would otherwise let do that permission. The person-only check asks as an agent with these roles and as a person with them (default roles: `[permission]`). |
|
|
154
155
|
| `normalizeEvent` | Maps your bridge's event to `{ source, actor }` when it is not that shape already (6.1). |
|
|
155
156
|
|
|
156
157
|
The checks, with the section each enforces:
|
|
@@ -159,14 +160,14 @@ The checks, with the section each enforces:
|
|
|
159
160
|
| --- | --- | --- | --- |
|
|
160
161
|
| `bridge-shape` | 2 | MUST | `snapshot`, `act` and `subscribe` are functions, and `snapshot` returns an array. |
|
|
161
162
|
| `snapshot-named` | 3.1 | MUST | Every component has a `ref`, `component`, `label` and string `actions`; labels are unique. |
|
|
162
|
-
| `snapshot-values` | 3.2 | MUST | Minor-unit values are integers or `null`; dates are `YYYY-MM-DD` or `null
|
|
163
|
-
| `snapshot-secrets` | 3.5 | MUST | The snapshot holds none of the literal `secrets` and no secret pattern (the same finder as the audit). |
|
|
163
|
+
| `snapshot-values` | 3.2 | MUST | Minor-unit values are integers or `null`; dates (and a date control's `value`) are `YYYY-MM-DD` or `null`, at every level, lists included. |
|
|
164
|
+
| `snapshot-secrets` | 3.5 | MUST | The snapshot holds none of the literal `secrets` and no secret pattern (the same finder as the audit; amounts in minor units are not read as account numbers). |
|
|
164
165
|
| `act-never-throws` | 4.5 | MUST | `act()` refuses an unknown ref and an unknown action with `ok: false` and a message, without throwing. |
|
|
165
166
|
| `amount-minor-only` | 4.2 | MUST | `setMinor` refuses fractions and formatted text. |
|
|
166
167
|
| `closed-list` | 4.3 | MUST | A bad value for a closed list is refused, and the refusal names every valid choice. |
|
|
167
|
-
| `person-only-not-offered` | 5.1 | MUST | No action named as a person's decision (approve, sign off, …) is offered, and `personOnly` steps are refused. |
|
|
168
|
-
| `recording-agent` | 6.1 | MUST | The `drive` step records
|
|
169
|
-
| `server-person-only` | 5.1 | MUST | The `server` refuses an agent for every person-only permission. |
|
|
168
|
+
| `person-only-not-offered` | 5.1 | MUST | No action named as a person's decision (approve, sign off, …) is offered, and `personOnly` steps are refused. `approveUnderRule`, which runs only under a company rule, is not one. |
|
|
169
|
+
| `recording-agent` | 6.1 | MUST | The `drive` step records at least one agent event (one per change), and every one has an actor that starts with `agent:`. |
|
|
170
|
+
| `server-person-only` | 5.1 | MUST | The `server` refuses an agent holding the granting roles (`serverActor`) for every person-only permission, and lets a person with the same roles through. A permission whose person is refused too is listed as not verified; when none can be verified, the check skips. |
|
|
170
171
|
| `refusal-names-valid` | 12.2 | MUST | A refusal for an unknown ref names the controls that exist, and a refusal for an unknown action names the valid actions. |
|
|
171
172
|
| `server-unsigned` | 7.3 | SHOULD | An unsigned request to the `server` gets 401. |
|
|
172
173
|
|
|
@@ -248,7 +249,9 @@ no controls and the page has no fields or charts for the other checks to judge.
|
|
|
248
249
|
A page without a bridge but with fields is still scored (and gets
|
|
249
250
|
`bridge-missing`). A bridge with no controls on a page that has fields of its
|
|
250
251
|
own is scored too: each field is reported as `field-not-on-bridge`, so it is
|
|
251
|
-
not a pass.
|
|
252
|
+
not a pass. So is a page with no fields or charts where a check still found
|
|
253
|
+
something (a focusable cell, an ungated posting button), or that registers
|
|
254
|
+
WebMCP tools of its own. When nothing is there to judge, the tool prints `no score` instead of a figure, the HTML report says the same,
|
|
252
255
|
and the JSON report has `measured: false`, `grade: "not measured"` and a
|
|
253
256
|
`notMeasured` text. `score` stays in the JSON so its shape does not change,
|
|
254
257
|
but it is not a pass. With `--fail-under`, an unmeasured page exits with code 1.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/person-action.ts
|
|
2
|
-
var PERSON_ACTION = /^(approve|reject|escalate|release|sign[_-]?off|finali[sz]e|submit|closePeriod|lockPeriod|dispose)/i;
|
|
2
|
+
var PERSON_ACTION = /^(?!approveUnderRule$)(approve|reject|escalate|release|sign[_-]?off|finali[sz]e|submit|closePeriod|lockPeriod|dispose)/i;
|
|
3
3
|
|
|
4
4
|
// src/secrets.ts
|
|
5
5
|
var digits = (value) => value.replace(/\D/g, "");
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
PERSON_ACTION,
|
|
3
3
|
SECRET_LABEL,
|
|
4
4
|
findSecrets
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-PRRNS5HS.js";
|
|
6
6
|
|
|
7
7
|
// src/rules.ts
|
|
8
8
|
var RULES = {
|
|
@@ -236,6 +236,7 @@ function estimateTokens(text) {
|
|
|
236
236
|
|
|
237
237
|
// src/audit.ts
|
|
238
238
|
import { existsSync } from "fs";
|
|
239
|
+
import { createRequire } from "module";
|
|
239
240
|
import path from "path";
|
|
240
241
|
import { pathToFileURL } from "url";
|
|
241
242
|
import { chromium } from "playwright-core";
|
|
@@ -247,25 +248,31 @@ function inPage(fn) {
|
|
|
247
248
|
}
|
|
248
249
|
var INIT_SCRIPT = `(() => {
|
|
249
250
|
const tools = [];
|
|
251
|
+
// The current registration of each name: an abort removes the tool only while its registration is current.
|
|
252
|
+
const current = new Map();
|
|
250
253
|
Object.defineProperty(globalThis, "__readinessTools", { value: tools, configurable: true });
|
|
254
|
+
const remove = (name) => { const i = tools.findIndex((t) => t.name === name); if (i >= 0) tools.splice(i, 1); current.delete(name); };
|
|
251
255
|
const add = (tool) => {
|
|
252
|
-
if (!tool || typeof tool !== "object") return;
|
|
256
|
+
if (!tool || typeof tool !== "object") return null;
|
|
253
257
|
const i = tools.findIndex((t) => t.name === tool.name);
|
|
254
258
|
if (i >= 0) tools.splice(i, 1, tool); else tools.push(tool);
|
|
259
|
+
const token = {};
|
|
260
|
+
current.set(tool.name, token);
|
|
261
|
+
return token;
|
|
255
262
|
};
|
|
256
263
|
const context = {
|
|
257
264
|
registerTool(tool, options) {
|
|
258
265
|
const signal = options && options.signal;
|
|
259
266
|
if (signal && signal.aborted) return Promise.resolve();
|
|
260
|
-
add(tool);
|
|
261
|
-
if (signal && typeof signal.addEventListener === "function") {
|
|
262
|
-
signal.addEventListener("abort", () => {
|
|
267
|
+
const token = add(tool);
|
|
268
|
+
if (token && signal && typeof signal.addEventListener === "function") {
|
|
269
|
+
signal.addEventListener("abort", () => { if (current.get(tool.name) === token) remove(tool.name); }, { once: true });
|
|
263
270
|
}
|
|
264
271
|
return Promise.resolve();
|
|
265
272
|
},
|
|
266
|
-
unregisterTool(name) {
|
|
267
|
-
provideContext(value) { tools.length = 0; for (const tool of (value && value.tools) || []) add(tool); return Promise.resolve(); },
|
|
268
|
-
clearContext() { tools.length = 0; return Promise.resolve(); },
|
|
273
|
+
unregisterTool(name) { remove(name); return Promise.resolve(); },
|
|
274
|
+
provideContext(value) { tools.length = 0; current.clear(); for (const tool of (value && value.tools) || []) add(tool); return Promise.resolve(); },
|
|
275
|
+
clearContext() { tools.length = 0; current.clear(); return Promise.resolve(); },
|
|
269
276
|
};
|
|
270
277
|
try { if (!document.modelContext) Object.defineProperty(document, "modelContext", { value: context, configurable: true }); } catch {}
|
|
271
278
|
try { if (!navigator.modelContext) Object.defineProperty(navigator, "modelContext", { value: context, configurable: true }); } catch {}
|
|
@@ -435,21 +442,27 @@ async function readBridge() {
|
|
|
435
442
|
try {
|
|
436
443
|
return toList(JSON.parse(text));
|
|
437
444
|
} catch {
|
|
438
|
-
return
|
|
445
|
+
return null;
|
|
439
446
|
}
|
|
440
447
|
}
|
|
441
448
|
}
|
|
442
|
-
return
|
|
449
|
+
return null;
|
|
443
450
|
};
|
|
444
451
|
try {
|
|
445
452
|
if (typeof g.agent?.snapshot === "function") {
|
|
446
|
-
const
|
|
447
|
-
return {
|
|
453
|
+
const list = toList(await g.agent.snapshot());
|
|
454
|
+
return {
|
|
455
|
+
source: "window.agent",
|
|
456
|
+
components: list ?? [],
|
|
457
|
+
tools,
|
|
458
|
+
snapshotRead: list !== null,
|
|
459
|
+
error: null
|
|
460
|
+
};
|
|
448
461
|
}
|
|
449
462
|
const snapshotTool = (g.__readinessTools ?? []).find((tool) => tool.name === "snapshot");
|
|
450
463
|
if (snapshotTool?.execute) {
|
|
451
|
-
const
|
|
452
|
-
return { source: "webmcp", components, tools, snapshotRead:
|
|
464
|
+
const list = toList(await snapshotTool.execute({}));
|
|
465
|
+
return { source: "webmcp", components: list ?? [], tools, snapshotRead: list !== null, error: null };
|
|
453
466
|
}
|
|
454
467
|
return { source: tools.length ? "webmcp" : null, components: [], tools, snapshotRead: false, error: null };
|
|
455
468
|
} catch (error) {
|
|
@@ -498,7 +511,16 @@ function bridgeCoverage(element2, entries) {
|
|
|
498
511
|
const name = host ? nameOf(host) : "";
|
|
499
512
|
if (host && name) group = { name, covered: allLabels.has(norm(name)) || inside(host) };
|
|
500
513
|
}
|
|
501
|
-
|
|
514
|
+
const textLike = element2.tagName === "TEXTAREA" || element2.tagName === "INPUT" && !["checkbox", "radio", "file", "range", "color", "hidden", "button", "submit", "reset", "image"].includes(
|
|
515
|
+
element2.type
|
|
516
|
+
);
|
|
517
|
+
const readOnly = textLike && element2.readOnly === true || element2.closest("[aria-readonly]")?.getAttribute("aria-readonly") === "true";
|
|
518
|
+
return {
|
|
519
|
+
inRoot: inside(element2),
|
|
520
|
+
agentHidden: element2.closest("[data-agent-hidden]") !== null,
|
|
521
|
+
readOnly,
|
|
522
|
+
group
|
|
523
|
+
};
|
|
502
524
|
}
|
|
503
525
|
function findFocusableNonControls() {
|
|
504
526
|
const native = "a[href], button, input, select, textarea, summary, details, iframe, audio, video, [contenteditable=''], [contenteditable=true]";
|
|
@@ -556,7 +578,7 @@ function onlyInSecrets(value) {
|
|
|
556
578
|
}
|
|
557
579
|
|
|
558
580
|
// src/audit.ts
|
|
559
|
-
var VERSION = "
|
|
581
|
+
var VERSION = createRequire(import.meta.url)("../package.json").version;
|
|
560
582
|
var FIELD_ROLES = /* @__PURE__ */ new Set([
|
|
561
583
|
"textbox",
|
|
562
584
|
"searchbox",
|
|
@@ -786,7 +808,8 @@ async function check(page, url = page.url()) {
|
|
|
786
808
|
if (!name || BROKEN_NAME.test(name) || node.flags.includes("disabled") || !node.ref) continue;
|
|
787
809
|
if (labels.has(norm(name))) continue;
|
|
788
810
|
const coverage = await page.locator(`aria-ref=${node.ref}`).evaluate(BRIDGE_COVERAGE, entries, { timeout: 2e3 }).catch(() => null);
|
|
789
|
-
if (!coverage || coverage.inRoot || coverage.agentHidden || coverage.group?.covered)
|
|
811
|
+
if (!coverage || coverage.inRoot || coverage.agentHidden || coverage.readOnly || coverage.group?.covered)
|
|
812
|
+
continue;
|
|
790
813
|
const group = coverage.group;
|
|
791
814
|
if (group) {
|
|
792
815
|
if (seenGroups.has(norm(group.name))) continue;
|
|
@@ -929,7 +952,7 @@ async function check(page, url = page.url()) {
|
|
|
929
952
|
for (const control of controls) control.label = redact(control.label);
|
|
930
953
|
const title = await page.title();
|
|
931
954
|
const result = score(findings);
|
|
932
|
-
const measured = bridge.components > 0 || fields.length > 0 || charts.length > 0;
|
|
955
|
+
const measured = bridge.components > 0 || ownTools.length > 0 || fields.length > 0 || charts.length > 0 || findings.some((f) => f.rule !== "bridge-missing");
|
|
933
956
|
return {
|
|
934
957
|
tool: { name: "@booki-aui/readiness", version: VERSION },
|
|
935
958
|
url,
|
package/dist/cli.js
CHANGED
package/dist/conformance.d.ts
CHANGED
|
@@ -31,6 +31,15 @@ type ConformanceTarget = {
|
|
|
31
31
|
personOnly?: ActStep[];
|
|
32
32
|
/** Your server's write gate; asked for every permission in section 5.1 as an agent. */
|
|
33
33
|
server?: (actor: ServerActor | null, permission: string) => ServerAnswer | Promise<ServerAnswer>;
|
|
34
|
+
/**
|
|
35
|
+
* The id and roles of an actor your server would otherwise let do `permission`. The
|
|
36
|
+
* person-only check asks as an agent with them (refused) and as a person with them (let
|
|
37
|
+
* through). Default: roles `[permission]`.
|
|
38
|
+
*/
|
|
39
|
+
serverActor?: (permission: string) => {
|
|
40
|
+
id: string;
|
|
41
|
+
roles: string[];
|
|
42
|
+
};
|
|
34
43
|
/** Map your bridge's event to {source, actor}; default is identity. */
|
|
35
44
|
normalizeEvent?: (raw: unknown) => BridgeEvent;
|
|
36
45
|
};
|
package/dist/conformance.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
PERSON_ACTION,
|
|
3
3
|
findSecrets
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-PRRNS5HS.js";
|
|
5
5
|
import {
|
|
6
6
|
PERSON_ONLY_PERMISSIONS
|
|
7
7
|
} from "./chunk-IZ57MB25.js";
|
|
@@ -24,6 +24,9 @@ var isNamed = (value) => typeof value === "string" && value.length > 0;
|
|
|
24
24
|
var isMinorKey = (key) => key === "minor" || key.endsWith("Minor");
|
|
25
25
|
var isDateKey = (key) => key === "date" || key.endsWith("Date");
|
|
26
26
|
var DATE = /^\d{4}-\d{2}-\d{2}$/;
|
|
27
|
+
var isExtracted = (value) => value !== null && typeof value === "object" && !Array.isArray(value) && "value" in value && typeof value.confidence === "number";
|
|
28
|
+
var DATE_COMPONENTS = /* @__PURE__ */ new Set(["financial-date", "field-date"]);
|
|
29
|
+
var AMOUNT_COMPONENTS = /* @__PURE__ */ new Set(["amount-field", "field-amount"]);
|
|
27
30
|
var checks = [
|
|
28
31
|
{
|
|
29
32
|
id: "bridge-shape",
|
|
@@ -66,22 +69,27 @@ var checks = [
|
|
|
66
69
|
run: async (target) => {
|
|
67
70
|
const snap = await components(target);
|
|
68
71
|
const bad = [];
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
if (isMinorKey(inner) && !(innerValue === null || Number.isInteger(innerValue))) {
|
|
80
|
-
bad.push(`${c.ref}.${key}.${inner}=${JSON.stringify(innerValue)}`);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
72
|
+
const visit = (value, path, key, dateValue) => {
|
|
73
|
+
if ((isMinorKey(key) || isDateKey(key)) && isExtracted(value)) {
|
|
74
|
+
visit(value.value, `${path}.value`, key, false);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (isMinorKey(key) && !(value === null || Number.isInteger(value)))
|
|
78
|
+
bad.push(`${path}=${JSON.stringify(value)}`);
|
|
79
|
+
const isDate = value === null || typeof value === "string" && DATE.test(value);
|
|
80
|
+
if (isDateKey(key) && !isDate || dateValue && !isDate && value !== "") {
|
|
81
|
+
bad.push(`${path}=${JSON.stringify(value)}`);
|
|
84
82
|
}
|
|
83
|
+
if (Array.isArray(value)) value.forEach((item, i) => visit(item, `${path}[${i}]`, "", false));
|
|
84
|
+
else if (value !== null && typeof value === "object") {
|
|
85
|
+
for (const [inner, innerValue] of Object.entries(value))
|
|
86
|
+
visit(innerValue, `${path}.${inner}`, inner, false);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
for (const c of snap) {
|
|
90
|
+
const dateControl = DATE_COMPONENTS.has(c.component) || c.kind === "date";
|
|
91
|
+
for (const [key, value] of Object.entries(c))
|
|
92
|
+
visit(value, `${c.ref}.${key}`, key, dateControl && key === "value");
|
|
85
93
|
}
|
|
86
94
|
if (bad.length > 0) {
|
|
87
95
|
return fail(`Minor-unit values must be integers or null, dates YYYY-MM-DD or null: ${bad.join("; ")}.`);
|
|
@@ -98,7 +106,13 @@ var checks = [
|
|
|
98
106
|
const json = JSON.stringify(snap);
|
|
99
107
|
const literal = (target.secrets ?? []).filter((s) => typeof s === "string" && s.length > 0);
|
|
100
108
|
const leaked = literal.filter((s) => json.includes(s));
|
|
101
|
-
const
|
|
109
|
+
const withoutAmounts = snap.map(
|
|
110
|
+
(c) => JSON.stringify(
|
|
111
|
+
c,
|
|
112
|
+
(key, value) => typeof value === "number" && (isMinorKey(key) || key === "value" && AMOUNT_COMPONENTS.has(c.component)) ? null : value
|
|
113
|
+
)
|
|
114
|
+
);
|
|
115
|
+
const found = findSecrets(`[${withoutAmounts.join(",")}]`).map((hit) => hit.kind);
|
|
102
116
|
if (leaked.length > 0 || found.length > 0) {
|
|
103
117
|
const parts = [];
|
|
104
118
|
if (leaked.length > 0) parts.push(`${leaked.length} literal secret(s)`);
|
|
@@ -242,14 +256,13 @@ var checks = [
|
|
|
242
256
|
return fail(`The drive step was not performed: ${result?.error?.message ?? "no message"}.`);
|
|
243
257
|
}
|
|
244
258
|
const agentEvents = events.filter((e) => e.source === "agent");
|
|
245
|
-
if (agentEvents.length
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
if (typeof event.actor !== "string" || !event.actor.startsWith("agent:")) {
|
|
250
|
-
return fail(`The agent event has actor ${JSON.stringify(event.actor)}; it must start with "agent:".`);
|
|
259
|
+
if (agentEvents.length === 0) return fail("The drive step recorded no agent event.");
|
|
260
|
+
const unattributed = agentEvents.find((e) => typeof e.actor !== "string" || !e.actor.startsWith("agent:"));
|
|
261
|
+
if (unattributed) {
|
|
262
|
+
return fail(`An agent event has actor ${JSON.stringify(unattributed.actor)}; it must start with "agent:".`);
|
|
251
263
|
}
|
|
252
|
-
|
|
264
|
+
const actors = [...new Set(agentEvents.map((e) => e.actor))].join(", ");
|
|
265
|
+
return pass(`${agentEvents.length} agent event(s) recorded, each with an agent actor (${actors}).`);
|
|
253
266
|
} finally {
|
|
254
267
|
if (typeof unsubscribe === "function") unsubscribe();
|
|
255
268
|
}
|
|
@@ -261,17 +274,28 @@ var checks = [
|
|
|
261
274
|
level: "MUST",
|
|
262
275
|
run: async (target) => {
|
|
263
276
|
if (!target.server) return skip("No server gate was given.");
|
|
264
|
-
const actor = { kind: "agent", id: "conformance", roles: ["owner"] };
|
|
265
277
|
const notRefused = [];
|
|
278
|
+
const unverified = [];
|
|
266
279
|
for (const permission of PERSON_ONLY_PERMISSIONS) {
|
|
267
|
-
const
|
|
268
|
-
|
|
280
|
+
const fixture = target.serverActor?.(permission) ?? { id: "conformance", roles: [permission] };
|
|
281
|
+
const answer = await target.server({ kind: "agent", ...fixture }, permission);
|
|
282
|
+
if (answer?.status !== 403) {
|
|
283
|
+
notRefused.push(`${permission} (${answer?.status})`);
|
|
284
|
+
continue;
|
|
285
|
+
}
|
|
286
|
+
const person = await target.server({ kind: "person", ...fixture }, permission);
|
|
287
|
+
const status = person?.status;
|
|
288
|
+
if (!(typeof status === "number" && status >= 200 && status < 300))
|
|
289
|
+
unverified.push(`${permission} (${status})`);
|
|
269
290
|
}
|
|
270
291
|
if (notRefused.length > 0) {
|
|
271
292
|
return fail(`The server did not refuse an agent for: ${notRefused.join(", ")}.`);
|
|
272
293
|
}
|
|
294
|
+
const verified = PERSON_ONLY_PERMISSIONS.length - unverified.length;
|
|
295
|
+
const note = unverified.length > 0 ? ` Not verified, because a person with the same roles was refused too (give serverActor the roles that grant each): ${unverified.join(", ")}.` : "";
|
|
296
|
+
if (verified === 0) return skip(`No person-only permission could be verified.${note}`);
|
|
273
297
|
return pass(
|
|
274
|
-
`The server refuses an agent with 403 for
|
|
298
|
+
`The server refuses an agent with 403, and lets a person with the same roles through, for ${verified} of ${PERSON_ONLY_PERMISSIONS.length} person-only permissions.${note}`
|
|
275
299
|
);
|
|
276
300
|
}
|
|
277
301
|
},
|
package/dist/index.d.ts
CHANGED
|
@@ -99,8 +99,9 @@ type Report = {
|
|
|
99
99
|
score: number;
|
|
100
100
|
grade: "ready" | "partly ready" | "not ready" | "not measured";
|
|
101
101
|
/**
|
|
102
|
-
* False when the bridge has no controls
|
|
103
|
-
* the
|
|
102
|
+
* False when the bridge has no controls or tools of the page's own, the page has
|
|
103
|
+
* no fields or charts, and nothing but the missing bridge was found: the form
|
|
104
|
+
* may not be open yet, so
|
|
104
105
|
* `score` rests on almost nothing and `grade` is "not measured".
|
|
105
106
|
*/
|
|
106
107
|
measured: boolean;
|
|
@@ -152,7 +153,8 @@ type AuditOptions = {
|
|
|
152
153
|
*/
|
|
153
154
|
timeout?: number;
|
|
154
155
|
};
|
|
155
|
-
|
|
156
|
+
/** The installed tool's own version, as the JSON report states it. */
|
|
157
|
+
declare const VERSION: string;
|
|
156
158
|
declare function looksLikeIconName(name: string, iconFont: boolean): boolean;
|
|
157
159
|
/** Buttons that post, pay, send, approve or otherwise cannot be taken back. */
|
|
158
160
|
declare const IRREVERSIBLE: RegExp;
|
|
@@ -163,7 +165,12 @@ declare function audit(input: string, options?: AuditOptions): Promise<Report>;
|
|
|
163
165
|
/** Checks an open page. Exposed for callers that drive their own browser. */
|
|
164
166
|
declare function check(page: Page, url?: string): Promise<Report>;
|
|
165
167
|
|
|
166
|
-
/**
|
|
168
|
+
/**
|
|
169
|
+
* Action names that approve, release or finalize: a person's, never offered to an agent.
|
|
170
|
+
*
|
|
171
|
+
* `approveUnderRule` is not one: it is a canonical agent action (spec/agent-contract.md),
|
|
172
|
+
* run only under a company rule the ERP set and recorded as that rule's.
|
|
173
|
+
*/
|
|
167
174
|
declare const PERSON_ACTION: RegExp;
|
|
168
175
|
|
|
169
176
|
type Scored = {
|
package/dist/index.js
CHANGED
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
toConsole,
|
|
14
14
|
toHtml,
|
|
15
15
|
toJson
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-ZQPEUBPL.js";
|
|
17
17
|
import {
|
|
18
18
|
PERSON_ACTION,
|
|
19
19
|
findSecrets,
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
isKontonummer,
|
|
23
23
|
isLuhn,
|
|
24
24
|
isRoutingNumber
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-PRRNS5HS.js";
|
|
26
26
|
export {
|
|
27
27
|
IRREVERSIBLE,
|
|
28
28
|
PERSON_ACTION,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@booki-aui/readiness",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"description": "Agent readiness check for accounting screens: what stops an AI agent on a page, scored 0-100 against the Agent Contract, with fixes.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|