@booki-aui/readiness 0.0.0-stage → 0.2.0
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 +27 -0
- package/LICENSE +21 -0
- package/README.md +295 -2
- package/dist/chunk-5SCOA3ZP.js +108 -0
- package/dist/chunk-IZ57MB25.js +29 -0
- package/dist/chunk-SSFV5SRX.js +1158 -0
- package/dist/cli.js +107 -0
- package/dist/conformance.d.ts +67 -0
- package/dist/conformance.js +329 -0
- package/dist/index.d.ts +229 -0
- package/dist/index.js +48 -0
- package/dist/reference.d.ts +33 -0
- package/dist/reference.js +175 -0
- package/dist/types-Ba_gnEks.d.ts +49 -0
- package/package.json +62 -3
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# @booki/readiness
|
|
2
|
+
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#93](https://github.com/Walgermo/booki/pull/93) [`ec89785`](https://github.com/Walgermo/booki/commit/ec8978566d2a81ee14eb94cc5163a2490ea824a9) Thanks [@Walgermo](https://github.com/Walgermo)! - The packages are now named `@booki-aui/*` and are published to npm (the `@booki` scope on npm belongs to someone else). Install with `pnpm add @booki-aui/core @booki-aui/react @booki-aui/styles`, and replace `@booki/` with `@booki-aui/` in your imports, for example `import { createBookiAgent } from "@booki-aui/react"` and `import "@booki-aui/styles"`. Nothing else changed.
|
|
8
|
+
|
|
9
|
+
## 0.1.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#65](https://github.com/Walgermo/booki/pull/65) [`201f7c9`](https://github.com/Walgermo/booki/commit/201f7c9d1aa843ab3a7c75ebbeb87df831110c08) Thanks [@Walgermo](https://github.com/Walgermo)! - Two controls for sales and customer work. `DealPipeline` is a board of deals in stages with each stage's totals per currency and a weighted forecast: an agent moves open deals, records a value with its source (`setValue`), and sets the expected close date and the owner; a value without a source is shown and never summed; marking a deal won or lost, and reopening it, are a person's buttons. `ActivityTimeline` is a customer's history and next steps: an agent logs calls, emails, meetings and notes, and schedules, reschedules and completes tasks, each recorded as the agent's; removing an entry is a person's. Rules in `@booki/core/pipeline` and `@booki/core/activity`, the `deal.close` and `activity.remove` permissions, a `sales` starter role, and `guardCloseDeal` for the server. `deal.close` is a person's decision: `PERSON_ONLY` and the readiness check now list it.
|
|
14
|
+
|
|
15
|
+
## 0.1.0
|
|
16
|
+
|
|
17
|
+
The first release. It is not on npm: run it from a clone with
|
|
18
|
+
`pnpm --dir <booki clone> readiness <url>`.
|
|
19
|
+
|
|
20
|
+
- Scores how ready a page is for an agent, from 0 to 100, and names what stops one:
|
|
21
|
+
unnamed or shared field names, fields missing from the agent bridge, irreversible
|
|
22
|
+
buttons without `data-agent-confirm`, secrets in the snapshot. It only reads.
|
|
23
|
+
- `--storage-state` or `--profile` for a screen behind a sign-in; the report says when
|
|
24
|
+
the page sent the browser on to another page. `--timeout` for a dev server that
|
|
25
|
+
compiles on first load. `check(page)` for a page you open with your own Playwright
|
|
26
|
+
steps.
|
|
27
|
+
- The Agent Contract conformance suite and a reference implementation.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Stian Walgermo
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,296 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @booki-aui/readiness
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
What stops an AI agent on your screen, scored 0–100, with the fix for each
|
|
4
|
+
finding.
|
|
5
|
+
|
|
6
|
+
Point it at any screen of your accounting or auditing product: a URL (signed
|
|
7
|
+
in through your browser profile or a saved session) or a saved HTML page. It
|
|
8
|
+
opens the page in Chrome, reads it the way a browser agent does (the
|
|
9
|
+
accessibility snapshot Playwright gives a model) and the way a bridge agent
|
|
10
|
+
does (`window.agent` or WebMCP tools), and reports every place an agent has to
|
|
11
|
+
guess, read pixels, see a secret or press an irreversible button unchecked.
|
|
12
|
+
Each check enforces a rule of the [Agent Contract](https://github.com/Walgermo/booki/blob/main/spec/agent-contract.md).
|
|
13
|
+
The package also has two subpaths: `@booki-aui/readiness/conformance`, a suite that
|
|
14
|
+
tests a bridge against the contract in-process ([Conformance suite](#conformance-suite)),
|
|
15
|
+
and `@booki-aui/readiness/reference`, a small reference implementation of the contract.
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npx @booki-aui/readiness https://app.example.com/vouchers/new --storage-state session.json --out report.html
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
Agent readiness https://app.example.com/vouchers/new
|
|
23
|
+
29/100 not ready · 11 findings · snapshot ≈ 536 tokens · bridge: none
|
|
24
|
+
|
|
25
|
+
● Field without an accessible name (§3.1, §4.1) −30 ×6
|
|
26
|
+
A listbox with no name, near "Debet (+)". main > div > section:nth-of-type(2) > … > a[role="listbox"]
|
|
27
|
+
A textbox with no name, near "Beløp (NOK)". main > div > section:nth-of-type(2) > … > input
|
|
28
|
+
…
|
|
29
|
+
✖ No agent bridge on the page (§2 Bridge, §4.1) −25 ×1
|
|
30
|
+
✖ Irreversible button without a gate (§5.2) −10 ×1
|
|
31
|
+
"Opprett" takes an irreversible step with no data-agent-confirm and no person gate.
|
|
32
|
+
● Button named by an icon font (§3.1, §4.1) −6 ×3
|
|
33
|
+
A button named "close", the icon's ligature.
|
|
34
|
+
|
|
35
|
+
Report: /…/report.html
|
|
36
|
+
JSON: /…/report.json
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Usage
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
npx @booki-aui/readiness <url | file.html> [options]
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
| Option | What it does |
|
|
46
|
+
| --- | --- |
|
|
47
|
+
| `--storage-state <file>` | A Playwright storage state (cookies and local storage) of a signed-in session. |
|
|
48
|
+
| `--profile <dir>` | Run in a browser profile that is signed in already. Close that browser first: Chrome will not share a profile. |
|
|
49
|
+
| `--out <file>` | The HTML report. Default `readiness-report.html`. The JSON goes next to it with `.json`. |
|
|
50
|
+
| `--json <file>` | The JSON report somewhere else. |
|
|
51
|
+
| `--no-report` | Print the summary only. |
|
|
52
|
+
| `--browser <channel>` | `chrome` (default), `msedge` or `chromium`. |
|
|
53
|
+
| `--executable <path>` | A Chromium-based browser binary, instead of a channel. |
|
|
54
|
+
| `--wait <ms>` | Wait this long after the page has loaded (default 500), for screens that render late. |
|
|
55
|
+
| `--wait-for <selector>` | Wait until this selector is on the page. |
|
|
56
|
+
| `--timeout <ms>` | How long to wait for the page to load, and for `--wait-for`, before giving up (default 30000; `0` for no limit). Raise it for a dev server that compiles a page on its first request. |
|
|
57
|
+
| `--headed` | Show the browser. |
|
|
58
|
+
| `--fail-under <score>` | Exit with code 1 when the score is below this, for CI. |
|
|
59
|
+
| `--snapshot` | Put the full accessibility snapshot in the JSON (the HTML always has it, folded). |
|
|
60
|
+
|
|
61
|
+
### Signing in
|
|
62
|
+
|
|
63
|
+
The tool only reads. It opens the page, waits, and inspects it: it never
|
|
64
|
+
clicks, types or submits, so it is safe to run against a live company.
|
|
65
|
+
|
|
66
|
+
- **A saved session.** Sign in once with Playwright's code generator and save
|
|
67
|
+
the session, then pass it:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
npx playwright codegen --save-storage=session.json https://app.example.com
|
|
71
|
+
npx @booki-aui/readiness https://app.example.com/vouchers/new --storage-state session.json
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
- **Your browser profile.** Pass a copy of a Chrome profile directory with
|
|
75
|
+
`--profile`. Use a separate profile for this; Chrome locks a profile that is
|
|
76
|
+
open.
|
|
77
|
+
- **A saved page.** Save the screen from the browser ("Save page as…, webpage,
|
|
78
|
+
complete") and pass the `.html` file. Scripts that need your server will not
|
|
79
|
+
run, so a bridge set up by the app may be missing.
|
|
80
|
+
|
|
81
|
+
Because nothing is clicked, a check sees the screen as it loads: a dialog, a
|
|
82
|
+
drop-down or a cell editor that opens on click is not inspected. Save or open
|
|
83
|
+
those states and check them as their own pages, or open them in your own script
|
|
84
|
+
([A form behind a button](#a-form-behind-a-button)).
|
|
85
|
+
|
|
86
|
+
### From code
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
import { audit, toHtml, toJson } from "@booki-aui/readiness"
|
|
90
|
+
|
|
91
|
+
const report = await audit("https://app.example.com/vouchers/new", { storageState: "session.json" })
|
|
92
|
+
console.log(report.score, report.findings.length)
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
`check(page)` runs the checks on a Playwright `Page` you already drive, for a
|
|
96
|
+
test suite that signs in and opens dialogs first.
|
|
97
|
+
|
|
98
|
+
### A form behind a button
|
|
99
|
+
|
|
100
|
+
The CLI only reads, so it never sees a form that opens on a click: a "New
|
|
101
|
+
voucher" dialog, a drawer, the second step of a wizard. Open it yourself with
|
|
102
|
+
Playwright, then hand the page to `check`:
|
|
103
|
+
|
|
104
|
+
```ts
|
|
105
|
+
import { chromium } from "playwright-core"
|
|
106
|
+
import { check, toConsole } from "@booki-aui/readiness"
|
|
107
|
+
|
|
108
|
+
const browser = await chromium.launch({ channel: "chrome" })
|
|
109
|
+
const page = await browser.newPage({ storageState: "session.json" })
|
|
110
|
+
await page.goto("https://app.example.com/vouchers")
|
|
111
|
+
await page.getByRole("button", { name: "New voucher" }).click()
|
|
112
|
+
await page.getByRole("dialog").waitFor()
|
|
113
|
+
|
|
114
|
+
console.log(toConsole(await check(page)))
|
|
115
|
+
await browser.close()
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
`check` reads the page as it is when you call it and changes nothing; the
|
|
119
|
+
click is your step, not the tool's. It needs no setup in the page.
|
|
120
|
+
|
|
121
|
+
## Conformance suite
|
|
122
|
+
|
|
123
|
+
`@booki-aui/readiness/conformance` tests the bridge of a screen against the
|
|
124
|
+
[Agent Contract](https://github.com/Walgermo/booki/blob/main/spec/agent-contract.md)
|
|
125
|
+
(sections 2 to 7). It is in-process: it calls `act()`, so run it on test data,
|
|
126
|
+
never on a live company. The browser audit above only reads a page; this suite
|
|
127
|
+
changes state. `@booki-aui/readiness/reference` is a small implementation of the
|
|
128
|
+
contract without Booki or ui-sdk, which the suite passes.
|
|
129
|
+
|
|
130
|
+
```ts
|
|
131
|
+
import { runConformance, formatConformance } from '@booki-aui/readiness/conformance'
|
|
132
|
+
import { createReference } from '@booki-aui/readiness/reference'
|
|
133
|
+
|
|
134
|
+
const { bridge, server } = createReference()
|
|
135
|
+
const report = await runConformance({ bridge, server, drive: { ref: 'Amount', action: 'setMinor', args: [155000] } })
|
|
136
|
+
console.log(formatConformance(report))
|
|
137
|
+
expect(report.conforms).toBe(true) // in vitest
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
`bridge` is an object with `snapshot()` (returns the components), `act({ steps })`
|
|
141
|
+
(returns `{ ok, error?: { message } }`) and `subscribe(listener)` (returns an
|
|
142
|
+
unsubscribe function). With ui-sdk, the bridge is the `agent` from
|
|
143
|
+
`createAgent` or `createBookiAgent`, which already has this shape.
|
|
144
|
+
|
|
145
|
+
The target takes these options, all optional:
|
|
146
|
+
|
|
147
|
+
| Option | What it is for |
|
|
148
|
+
| --- | --- |
|
|
149
|
+
| `drive` | One safe, successful step, for the recording check (6.1). |
|
|
150
|
+
| `secrets` | Literal test values, such as a test IBAN, that must not appear in the snapshot (3.5). |
|
|
151
|
+
| `closedList` | `{ step, valid }`: a bad value and every valid choice its refusal must name (4.3). |
|
|
152
|
+
| `personOnly` | Steps only a person may take, which the agent must be refused (5.1). |
|
|
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
|
+
| `normalizeEvent` | Maps your bridge's event to `{ source, actor }` when it is not that shape already (6.1). |
|
|
155
|
+
|
|
156
|
+
The checks, with the section each enforces:
|
|
157
|
+
|
|
158
|
+
| Id | § | Level | What it checks |
|
|
159
|
+
| --- | --- | --- | --- |
|
|
160
|
+
| `bridge-shape` | 2 | MUST | `snapshot`, `act` and `subscribe` are functions, and `snapshot` returns an array. |
|
|
161
|
+
| `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). |
|
|
164
|
+
| `act-never-throws` | 4.5 | MUST | `act()` refuses an unknown ref and an unknown action with `ok: false` and a message, without throwing. |
|
|
165
|
+
| `amount-minor-only` | 4.2 | MUST | `setMinor` refuses fractions and formatted text. |
|
|
166
|
+
| `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 exactly one event whose actor starts with `agent:`. |
|
|
169
|
+
| `server-person-only` | 5.1 | MUST | The `server` refuses an agent for every person-only permission. |
|
|
170
|
+
| `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
|
+
| `server-unsigned` | 7.3 | SHOULD | An unsigned request to the `server` gets 401. |
|
|
172
|
+
|
|
173
|
+
Each check returns `pass`, `fail` or `skip`. A **skip** means the suite had no
|
|
174
|
+
input for the check, not that the check passed: no `drive`, `closedList`,
|
|
175
|
+
`server` or `secrets` option was given, or the bridge has no components to
|
|
176
|
+
probe. `conforms` is `false` only when a MUST check fails. The report lists the
|
|
177
|
+
passes, failures and skips, so give every option you can.
|
|
178
|
+
|
|
179
|
+
The suite does not yet cover the per-language refusals (spec 10.4) or the
|
|
180
|
+
ergonomics rules (12) beyond naming the valid choices. Passing it is necessary,
|
|
181
|
+
not sufficient.
|
|
182
|
+
|
|
183
|
+
## Output
|
|
184
|
+
|
|
185
|
+
- **Console:** the score, then each rule that found something, with up to six
|
|
186
|
+
of its elements, the fix and the Booki control for it.
|
|
187
|
+
- **HTML report:** the score and how it was reached, then each finding with
|
|
188
|
+
its element (role and name as the agent sees them, nearby text such as the
|
|
189
|
+
column header, a CSS selector and the element's HTML), why it matters to an
|
|
190
|
+
agent, the fix, and Booki's control for it when one exists. It ends with the
|
|
191
|
+
bridge's controls and actions and the full snapshot a browser agent reads.
|
|
192
|
+
- **JSON:** the same data: `score`, `grade`, `deductions`, `findings`,
|
|
193
|
+
`metrics`, `bridge`. The raw snapshot is left out unless you pass
|
|
194
|
+
`--snapshot`.
|
|
195
|
+
|
|
196
|
+
Secrets the tool finds are masked (`86•••••••47`) everywhere in the output,
|
|
197
|
+
the snapshot included.
|
|
198
|
+
|
|
199
|
+
## The checks
|
|
200
|
+
|
|
201
|
+
Each check names the Agent Contract section it enforces.
|
|
202
|
+
|
|
203
|
+
| Check | Contract | What it finds | Points (each / most) |
|
|
204
|
+
| --- | --- | --- | --- |
|
|
205
|
+
| No agent bridge | §2, §4.1 | No `window.agent` with controls and no WebMCP tools of the page's own. The agent can only read the tree and click. | 25 / 25 |
|
|
206
|
+
| Bridge control without a name | §3.1 | A control in the bridge's snapshot with no label. | 4 / 12 |
|
|
207
|
+
| A person's decision offered to the agent | §5.1 | A bridge action named approve, reject, escalate, release, sign off, finalize, submit, closePeriod, lockPeriod or dispose. | 15 / 30 |
|
|
208
|
+
| Field without an accessible name | §3.1, §4.1 | A textbox, searchbox, combobox, listbox, spinbutton, checkbox, radio, switch or slider with no name in the snapshot: the agent can find it only by its position. Inputs no one can reach are skipped: `aria-hidden` or `inert` on the input or an ancestor, `type="hidden"`, not rendered, or visually hidden and out of the tab order (the native input Base UI and Radix render beside a custom select, radio group or checkbox). The two checks below skip them too. | 5 / 30 |
|
|
209
|
+
| Field named by a rendering bug | §3.1 | A name such as `[object Object] (Ikke valgt)`, `undefined` or `NaN`. | 5 / 15 |
|
|
210
|
+
| Fields that share one name | §3.1, §4.1 | Two or more fields of one role with the same name (one finding per group): the agent has to count. | 2 / 8 |
|
|
211
|
+
| Field missing from the bridge | §3.1, §4.1 | On a page whose bridge has a snapshot: a named field a person can use (textbox, searchbox, combobox, listbox, spinbutton, checkbox, radio group, switch, slider) that no bridge entry covers, so an agent on the bridge cannot operate it. A field is covered when its name equals an entry's `label`, or when it sits inside the element of a bridge component: ui-sdk marks a component's root with `data-slot="<component>"` and its other parts with `data-slot="<component>-<part>"`, so the outermost such element of each kind counts. When the page has more of those elements than the snapshot has entries of that kind, only one named by an entry's label counts. A radio is covered by its group's name and reported once, as the group. Disabled fields, fields inside `data-agent-hidden` and the hidden inputs above are skipped, and the check does not run when the snapshot was cut short (a `more` entry). | 5 / 30 |
|
|
212
|
+
| Focusable element that is not a control | §3.1, §4.1 | An element with `tabindex` ≥ 0 that the tree calls a cell or plain text, such as a grid cell that opens an editor on click. | 3 / 12 |
|
|
213
|
+
| Button without a name | §3.1, §4.1 | A button whose name is empty. | 3 / 12 |
|
|
214
|
+
| Button named by an icon font | §3.1, §4.1 | A button whose name is an icon ligature (`close`, `content_copy`, `more_vert`, any snake_case word), or any single lowercase word drawn in an icon font. | 2 / 10 |
|
|
215
|
+
| Figures only in pixels | §3.3 | A canvas or SVG chart, visible to the agent, whose name, description, fallback content and the table in its figure hold fewer than two numbers. Icons (small, inside a button or link, or fewer than three shapes) and `aria-hidden` charts are skipped. | 10 / 30 |
|
|
216
|
+
| Irreversible button without a gate | §5.2 | A button or link that posts, pays, sends, approves, creates, submits, releases or signs (Bokfør, Opprett, Godkjenn, Betal, Send, Attester, Signer, Overfør, Post, Pay, Approve, Submit, Release, Sign off, …) with no `data-agent-confirm` on it or an ancestor, and no `confirm` on its bridge button. | 10 / 20 |
|
|
217
|
+
| Secret readable by the agent | §3.5 | A Norwegian account number (mod 11), an IBAN (mod 97), a KID next to the word KID (mod 10 or 11), a US routing number next to "routing" (ABA) or a card number next to "card"/"kort" (Luhn) in the accessibility snapshot or the bridge's snapshot. Only numbers with valid check digits count, so amounts, dates and invoice numbers do not. A value inside `data-agent-secret` on a page with a bridge is redacted by the bridge and not reported. | 8 / 16 |
|
|
218
|
+
| Large accessibility snapshot | §1 | The snapshot is over 6,000 tokens (5 points) or over 15,000 (10). | 5 / 10 |
|
|
219
|
+
|
|
220
|
+
Names, roles and the snapshot come from Playwright's AI-mode aria snapshot,
|
|
221
|
+
the text a model gets from browser tools, so a name is exactly what the agent
|
|
222
|
+
reads. The size is characters ÷ 4, a rough token count; the agent reads the
|
|
223
|
+
snapshot again after most steps, so it is paid for on every step of a task.
|
|
224
|
+
|
|
225
|
+
## The score
|
|
226
|
+
|
|
227
|
+
The score starts at 100. Each finding takes off its check's points, and each
|
|
228
|
+
check takes off at most its cap, so one kind of problem cannot hide the
|
|
229
|
+
others: a page whose only problem is forty unnamed fields scores 70. The score
|
|
230
|
+
never goes below 0.
|
|
231
|
+
|
|
232
|
+
| Score | Grade |
|
|
233
|
+
| --- | --- |
|
|
234
|
+
| 85–100 | ready |
|
|
235
|
+
| 60–84 | partly ready |
|
|
236
|
+
| 0–59 | not ready |
|
|
237
|
+
|
|
238
|
+
A page without a bridge can reach at most 75: the contract's bridge is what
|
|
239
|
+
lets an agent act through named actions instead of guessing. A page with a
|
|
240
|
+
bridge loses 5 points for each field the bridge leaves out, up to 30, so a
|
|
241
|
+
bridge that offers only part of the screen no longer scores 100.
|
|
242
|
+
|
|
243
|
+
## Reference scores
|
|
244
|
+
|
|
245
|
+
Measured on this repository's benchmark pages (`apps/www`, built and served
|
|
246
|
+
with `vite preview`), with this version. The replicas are rebuilt by hand from
|
|
247
|
+
read-only maps of screens ERP products ship today, with invented data; what
|
|
248
|
+
each keeps is listed in [benchmarks/agent/METHOD.md](https://github.com/Walgermo/booki/blob/main/benchmarks/agent/METHOD.md).
|
|
249
|
+
The Booki pages do the same tasks with Booki controls and the ui-sdk bridge.
|
|
250
|
+
|
|
251
|
+
| Page | Score | Grade | Snapshot | What it found |
|
|
252
|
+
| --- | ---: | --- | ---: | --- |
|
|
253
|
+
| `/bench/voucher-raw` | 29 | not ready | 536 tokens | no bridge; 4 unnamed pickers (`<a role="listbox">`) and 2 unnamed inputs (amount, reference); "Opprett" posts with no gate; 3 icon-font buttons (`calendar_month`, `close`, `content_copy`) |
|
|
254
|
+
| `/bench/voucher-grid` | 49 | not ready | 368 tokens | no bridge; 7 focusable table cells that open an editor on click, with no control role; "Lagre og bokfør" ungated; 2 icon-font buttons |
|
|
255
|
+
| `/bench/supplier-invoice-raw` | 10 | not ready | 1,051 tokens | no bridge; 6 pickers named "[object Object] …"; 8 unnamed fields (line inputs, a native select, a `button role="combobox"`, checkboxes); 7 icon-font buttons; "Opprett" ungated |
|
|
256
|
+
| `/bench/sales-invoice-raw` | 21 | not ready | 852 tokens | no bridge; 4 pickers named "[object Object] …"; 5 unnamed line inputs; 2 icon-font buttons; "Opprett" ungated |
|
|
257
|
+
| `/bench/dashboard-raw` | 40 | not ready | 752 tokens | no bridge; 3 SVG charts (`role="application"`, empty title) with no figures in the DOM; an unnamed year select |
|
|
258
|
+
| `/bench/dashboard-grid` | 33 | not ready | 1,266 tokens | no bridge; 4 canvas charts with no name or fallback; "Opprett huskelapp" ungated; a `refresh` icon button |
|
|
259
|
+
| `/bench/semantic` | 65 | partly ready | 375 tokens | well-labelled HTML: no bridge, and "Betal faktura" ungated |
|
|
260
|
+
| `/bench/voucher-acc` | 100 | ready | 309 tokens | — |
|
|
261
|
+
| `/bench/supplier-invoice-acc` | 98 | ready | 578 tokens | the two account pickers' inputs are both named "Konto" |
|
|
262
|
+
| `/bench/sales-invoice-acc` | 100 | ready | 355 tokens | — |
|
|
263
|
+
| `/bench/dashboard-acc` | 100 | ready | 1,839 tokens | — |
|
|
264
|
+
| `/bench/acc` | 100 | ready | 273 tokens | — |
|
|
265
|
+
|
|
266
|
+
To measure them again:
|
|
267
|
+
|
|
268
|
+
```bash
|
|
269
|
+
pnpm build
|
|
270
|
+
pnpm --filter @booki-aui/www exec vite preview --port 4317 --strictPort &
|
|
271
|
+
pnpm readiness http://localhost:4317/bench/voucher-raw --no-report
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
## What it does not check
|
|
275
|
+
|
|
276
|
+
- Anything behind a click: dialogs, menus, cell editors, the next step of a
|
|
277
|
+
wizard. Check those states as pages of their own, or call `check(page)` from
|
|
278
|
+
your own Playwright script after opening them.
|
|
279
|
+
- The server. Contract §7 (the server re-runs every rule and refuses
|
|
280
|
+
person-only decisions from agents) needs a request against your API, not a
|
|
281
|
+
page.
|
|
282
|
+
- Whether the bridge's actions refuse what they should (§4.2–4.5). That needs
|
|
283
|
+
the actions run; this tool never acts.
|
|
284
|
+
- Recording (§6). The audit trail is not on the page.
|
|
285
|
+
|
|
286
|
+
## Development
|
|
287
|
+
|
|
288
|
+
```bash
|
|
289
|
+
pnpm --filter @booki-aui/readiness test # fixtures of small pages with known problems
|
|
290
|
+
pnpm --filter @booki-aui/readiness typecheck
|
|
291
|
+
pnpm --filter @booki-aui/readiness build
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
The tests open each fixture in `test/fixtures/` in Chrome and assert that each
|
|
295
|
+
check finds exactly the problems put there and nothing else. Chrome must be
|
|
296
|
+
installed (or pass a channel or executable in `audit()` options).
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
// src/person-action.ts
|
|
2
|
+
var PERSON_ACTION = /^(approve|reject|escalate|release|sign[_-]?off|finali[sz]e|submit|closePeriod|lockPeriod|dispose)/i;
|
|
3
|
+
|
|
4
|
+
// src/secrets.ts
|
|
5
|
+
var digits = (value) => value.replace(/\D/g, "");
|
|
6
|
+
function isKontonummer(value) {
|
|
7
|
+
const d = digits(value);
|
|
8
|
+
if (d.length !== 11) return false;
|
|
9
|
+
const weights = [5, 4, 3, 2, 7, 6, 5, 4, 3, 2];
|
|
10
|
+
const sum = weights.reduce((total, weight, i) => total + weight * Number(d[i]), 0);
|
|
11
|
+
const rest = sum % 11;
|
|
12
|
+
const check = rest === 0 ? 0 : 11 - rest;
|
|
13
|
+
return check !== 10 && check === Number(d[10]);
|
|
14
|
+
}
|
|
15
|
+
function isIban(value) {
|
|
16
|
+
const v = value.replace(/\s/g, "").toUpperCase();
|
|
17
|
+
if (!/^[A-Z]{2}\d{2}[A-Z0-9]{11,30}$/.test(v)) return false;
|
|
18
|
+
const moved = v.slice(4) + v.slice(0, 4);
|
|
19
|
+
let rest = 0;
|
|
20
|
+
for (const ch of moved) {
|
|
21
|
+
const n = /\d/.test(ch) ? ch : String(ch.charCodeAt(0) - 55);
|
|
22
|
+
for (const digit of n) rest = (rest * 10 + Number(digit)) % 97;
|
|
23
|
+
}
|
|
24
|
+
return rest === 1;
|
|
25
|
+
}
|
|
26
|
+
function mod10(body) {
|
|
27
|
+
let sum = 0;
|
|
28
|
+
for (let i = 0; i < body.length; i++) {
|
|
29
|
+
let n = Number(body[body.length - 1 - i]) * (i % 2 === 0 ? 2 : 1);
|
|
30
|
+
if (n > 9) n -= 9;
|
|
31
|
+
sum += n;
|
|
32
|
+
}
|
|
33
|
+
return (10 - sum % 10) % 10;
|
|
34
|
+
}
|
|
35
|
+
function isLuhn(value) {
|
|
36
|
+
const d = digits(value);
|
|
37
|
+
return d.length >= 2 && mod10(d.slice(0, -1)) === Number(d.at(-1));
|
|
38
|
+
}
|
|
39
|
+
function isKid(value) {
|
|
40
|
+
const d = digits(value);
|
|
41
|
+
if (d.length < 2 || d.length > 25) return false;
|
|
42
|
+
if (isLuhn(d)) return true;
|
|
43
|
+
const body = d.slice(0, -1);
|
|
44
|
+
let sum = 0;
|
|
45
|
+
for (let i = 0; i < body.length; i++) sum += Number(body[body.length - 1 - i]) * (i % 6 + 2);
|
|
46
|
+
const rest = sum % 11;
|
|
47
|
+
const check = rest === 0 ? "0" : rest === 1 ? "-" : String(11 - rest);
|
|
48
|
+
return check === d.at(-1);
|
|
49
|
+
}
|
|
50
|
+
function isRoutingNumber(value) {
|
|
51
|
+
const d = digits(value);
|
|
52
|
+
if (d.length !== 9) return false;
|
|
53
|
+
const w = [3, 7, 1, 3, 7, 1, 3, 7, 1];
|
|
54
|
+
return w.reduce((sum, weight, i) => sum + weight * Number(d[i]), 0) % 10 === 0;
|
|
55
|
+
}
|
|
56
|
+
function mask(value) {
|
|
57
|
+
const v = value.replace(/[^0-9A-Za-z]/g, "");
|
|
58
|
+
if (v.length <= 4) return "\u2022".repeat(v.length);
|
|
59
|
+
return `${v.slice(0, 2)}${"\u2022".repeat(v.length - 4)}${v.slice(-2)}`;
|
|
60
|
+
}
|
|
61
|
+
function findSecrets(text) {
|
|
62
|
+
const hits = [];
|
|
63
|
+
const seen = /* @__PURE__ */ new Set();
|
|
64
|
+
const add = (kind, value, index) => {
|
|
65
|
+
const key = `${kind}:${value.replace(/\s/g, "")}:${index}`;
|
|
66
|
+
if (seen.has(key)) return;
|
|
67
|
+
seen.add(key);
|
|
68
|
+
hits.push({ kind, value: value.trim(), masked: mask(value), index });
|
|
69
|
+
};
|
|
70
|
+
for (const m of text.matchAll(/\b[A-Z]{2}\d{2}(?: ?[A-Z0-9]{4}){2,7}(?: ?[A-Z0-9]{1,4})?\b/g)) {
|
|
71
|
+
if (isIban(m[0])) add("iban", m[0], m.index);
|
|
72
|
+
}
|
|
73
|
+
for (const m of text.matchAll(/(?<!\d|\d[.,])\d{4}[ .]?\d{2}[ .]?\d{5}(?!\d|[.,]\d)/g)) {
|
|
74
|
+
if (hits.some((hit) => hit.kind === "iban" && m.index >= hit.index && m.index < hit.index + hit.value.length))
|
|
75
|
+
continue;
|
|
76
|
+
if (isKontonummer(m[0])) add("bank-account", m[0], m.index);
|
|
77
|
+
}
|
|
78
|
+
for (const m of text.matchAll(
|
|
79
|
+
/\bKID\b[^\n\d]{0,40}?(\d[\d ]{2,30}\d)(?![\d–-])(?!\s*(?:tegn|siffer|chars?|characters|digits)\b)/gi
|
|
80
|
+
)) {
|
|
81
|
+
if (isKid(m[1])) add("kid", m[1], m.index + m[0].length - m[1].length);
|
|
82
|
+
}
|
|
83
|
+
for (const m of text.matchAll(/\brouting\b[^\n\d]{0,40}?(\d{9})(?!\d)/gi)) {
|
|
84
|
+
if (isRoutingNumber(m[1])) add("routing-number", m[1], m.index + m[0].length - m[1].length);
|
|
85
|
+
}
|
|
86
|
+
for (const m of text.matchAll(/\b(?:card|kort)[^\n\d]{0,40}?((?:\d[ -]?){12,18}\d)(?!\d)/gi)) {
|
|
87
|
+
if (isLuhn(m[1])) add("card", m[1], m.index + m[0].length - m[1].length);
|
|
88
|
+
}
|
|
89
|
+
return hits.sort((a, b) => a.index - b.index);
|
|
90
|
+
}
|
|
91
|
+
var SECRET_LABEL = {
|
|
92
|
+
"bank-account": "Bank account number",
|
|
93
|
+
iban: "IBAN",
|
|
94
|
+
kid: "Payment reference (KID)",
|
|
95
|
+
"routing-number": "Routing number",
|
|
96
|
+
card: "Card number"
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
export {
|
|
100
|
+
PERSON_ACTION,
|
|
101
|
+
isKontonummer,
|
|
102
|
+
isIban,
|
|
103
|
+
isLuhn,
|
|
104
|
+
isKid,
|
|
105
|
+
isRoutingNumber,
|
|
106
|
+
findSecrets,
|
|
107
|
+
SECRET_LABEL
|
|
108
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// src/conformance/permissions.ts
|
|
2
|
+
var PERSON_ONLY_PERMISSIONS = [
|
|
3
|
+
"approval.decide",
|
|
4
|
+
"supplier-invoice.approve",
|
|
5
|
+
"expense.approve",
|
|
6
|
+
"payment.approve",
|
|
7
|
+
"payment.release",
|
|
8
|
+
"reconciliation.approve",
|
|
9
|
+
"period.close",
|
|
10
|
+
"period.adjust-closed",
|
|
11
|
+
"close.sign-off",
|
|
12
|
+
"invoice.finalize",
|
|
13
|
+
"vat.submit",
|
|
14
|
+
"asset.dispose",
|
|
15
|
+
"audit.sign-off",
|
|
16
|
+
"audit.review",
|
|
17
|
+
"audit.conclude",
|
|
18
|
+
"audit.eqcr",
|
|
19
|
+
"audit.freeze",
|
|
20
|
+
"finding.confirm",
|
|
21
|
+
"finding.withdraw",
|
|
22
|
+
"request.send",
|
|
23
|
+
"request.decide",
|
|
24
|
+
"deal.close"
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
export {
|
|
28
|
+
PERSON_ONLY_PERMISSIONS
|
|
29
|
+
};
|