@nac3/runtime 2.3.1 → 2.4.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 +318 -68
- package/LICENSE +201 -201
- package/README.md +9 -9
- package/SPEC.md +471 -82
- package/dist/cli.js +3 -3
- package/dist/nac-chat-client.browser.js +705 -705
- package/dist/nac-chat-client.cjs +705 -705
- package/dist/nac-chat-client.mjs +705 -705
- package/dist/nac-v2-extensions.browser.js +2102 -2291
- package/dist/nac-v2-extensions.cjs +2102 -2291
- package/dist/nac-v2-extensions.mjs +2102 -2291
- package/dist/nac.browser.js +6019 -6125
- package/dist/nac.cjs +6019 -6125
- package/dist/nac.mjs +6019 -6125
- package/package.json +88 -81
package/CHANGELOG.md
CHANGED
|
@@ -1,73 +1,323 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## 2.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
`
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
`
|
|
70
|
-
|
|
3
|
+
## 2.4.0 -- 2026-05-21
|
|
4
|
+
|
|
5
|
+
NAC3 v2.4.0 is a **behavior-of-contract change**: id / verb / qualifier
|
|
6
|
+
resolution becomes strict. Backwards-compatible with code paths that
|
|
7
|
+
already supplied unambiguous arguments, **NOT** backwards-compatible
|
|
8
|
+
with code paths that depended on the previous lenient (`indexOf`)
|
|
9
|
+
fallback to resolve to the first near-match.
|
|
10
|
+
|
|
11
|
+
### Why this changed (the principle, not a feature)
|
|
12
|
+
|
|
13
|
+
The lenient resolution in 2.3.x violated the spec's 0-silent-damage
|
|
14
|
+
invariant. Specifically, `click_by_verb(plugin, verb, { qualifier })`
|
|
15
|
+
would, on a no-exact-suffix match, fall through to an `indexOf(qualifier)`
|
|
16
|
+
substring search and resolve silently to whatever element happened to
|
|
17
|
+
contain the qualifier string anywhere in its id. The H4 benchmark on the
|
|
18
|
+
Conduit case study (2026-05-21) showed that **12 of 18 "model failures"
|
|
19
|
+
on the canonical flows were actually silent runtime damage** — the
|
|
20
|
+
agent emitted an invalid qualifier, the runtime sent it to the wrong
|
|
21
|
+
element, the agent looped against the wrong page state. Strict
|
|
22
|
+
resolution rescues those 12 (see `nac-spec/conduit/H4_STRICT_NAC_REPORT.md`).
|
|
23
|
+
|
|
24
|
+
For an assistive-software use case (the principal driver of this
|
|
25
|
+
project), a silent dispatch to the wrong element with no recovery path
|
|
26
|
+
is a safety blocker. Strict resolution closes that gap.
|
|
27
|
+
|
|
28
|
+
### New error model — disambiguation contract
|
|
29
|
+
|
|
30
|
+
When `click_by_verb` / `tab` / `tab_by_label` cannot resolve a request
|
|
31
|
+
unambiguously, the runtime now:
|
|
32
|
+
|
|
33
|
+
1. Emits `nac:disambiguation_requested` on `document` with a
|
|
34
|
+
structured detail payload (see below).
|
|
35
|
+
2. Throws `NacError` with `err.code` ∈ `{no_matching_instance,
|
|
36
|
+
ambiguous_qualifier, ambiguous_tab, ambiguous_label}` AND
|
|
37
|
+
`err.candidates: [{nac_id, label}, ...]` pre-validated against the
|
|
38
|
+
live DOM.
|
|
39
|
+
|
|
40
|
+
Detail / candidates payload:
|
|
41
|
+
```js
|
|
42
|
+
{
|
|
43
|
+
method: 'click_by_verb' | 'tab' | 'tab_by_label',
|
|
44
|
+
plugin: string | null,
|
|
45
|
+
query: { verb?, qualifier?, label?, id? },
|
|
46
|
+
reason: 'no_matching_instance' | 'ambiguous_qualifier' | 'ambiguous_tab' |
|
|
47
|
+
'ambiguous_label' | 'ambiguous_label_exact' | 'ambiguous_label_fuzzy' |
|
|
48
|
+
'no_matching_label',
|
|
49
|
+
candidates: [{ nac_id: string, label: string }, ...]
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
A reactive host (chat UI / voice agent / screen-reader) can listen
|
|
54
|
+
on the event and present the options to the user as *"did you
|
|
55
|
+
mean A or B?"*. A synchronous catcher can read `err.candidates`
|
|
56
|
+
directly. An autonomous agent (Pilot, etc.) can inject the candidates
|
|
57
|
+
into the next turn's prompt so the LLM picks from a DOM-validated
|
|
58
|
+
list instead of re-guessing a qualifier.
|
|
59
|
+
|
|
60
|
+
### What changed in the resolvers
|
|
61
|
+
|
|
62
|
+
- **`click_by_verb` with qualifier:** only exact-equality or anchored
|
|
63
|
+
suffix (`id === qualifier || id.endsWith('__' + qualifier)`)
|
|
64
|
+
resolves. Multiple matches → `ambiguous_qualifier`. Zero matches →
|
|
65
|
+
`no_matching_instance`. **The `indexOf` substring fallback is
|
|
66
|
+
removed.**
|
|
67
|
+
- **`tab` single-arg form:** bare id resolves to exact match in DOM. If
|
|
68
|
+
no exact, exactly one anchored-prefix instance
|
|
69
|
+
(`id.startsWith(bare + '__')`) resolves; multiple → `ambiguous_tab`;
|
|
70
|
+
zero → `no_matching_instance`.
|
|
71
|
+
- **`tab_by_label`:** two-tier strict — exact label match first
|
|
72
|
+
(errors if multiple), then substring match (errors if multiple).
|
|
73
|
+
Fuzzy match preserved for voice/assistive use case; ambiguity
|
|
74
|
+
caught.
|
|
75
|
+
|
|
76
|
+
### Verification
|
|
77
|
+
|
|
78
|
+
- `packages/nac/test/stage2-disambiguation.mjs` — pre-existing
|
|
79
|
+
tab_by_label cases still PASS (B1–B4).
|
|
80
|
+
- `packages/nac/test/stage7-strict-resolution.mjs` (new) — 9/9
|
|
81
|
+
invariants pass under JSDOM shim.
|
|
82
|
+
- `nac3-bench/bench/scripts/stage7_strict_nac.mjs` (new) — 9/9
|
|
83
|
+
invariants pass under Playwright against a live page.
|
|
84
|
+
- `nac3-bench/bench/h4_results/h4_2026-05-21T19-01-19-040Z.json` —
|
|
85
|
+
cheap-model benchmark with strict NAC: 48/54 = 89% (vs 36/54 = 67%
|
|
86
|
+
under lenient).
|
|
87
|
+
|
|
88
|
+
### Migration guide
|
|
89
|
+
|
|
90
|
+
If your code was passing fuzzy qualifiers and depending on the runtime
|
|
91
|
+
to pick "something close", the upgrade requires you to:
|
|
92
|
+
- Either supply the full `nac_id` directly (always unambiguous), OR
|
|
93
|
+
- Pass the exact `__suffix` of the instance you want, OR
|
|
94
|
+
- Listen for `nac:disambiguation_requested` / catch `NacError` with
|
|
95
|
+
`err.candidates` and pick from the returned list.
|
|
96
|
+
|
|
97
|
+
Most users won't be affected — the only callers that broke during the
|
|
98
|
+
internal regression were the ones that were already broken silently in
|
|
99
|
+
2.3.x but happened to land on the wrong-but-related element instead of
|
|
100
|
+
failing.
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## 2.3.1 -- 2026-05-13 (stable, blank republish)
|
|
105
|
+
|
|
106
|
+
Identical source to 2.3.0. The 2.3.0 tag had already been published to
|
|
107
|
+
npm as a preview; 2.3.1 is the first installable stable version. No
|
|
108
|
+
behavioural changes.
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## 2.3.0 -- 2026-05-13 (stable)
|
|
113
|
+
|
|
114
|
+
NAC3 v2.3.0 is the first stable release of the payload-bearing
|
|
115
|
+
contract. Everything in 2.3.0-alpha.1 and 2.3.0-alpha.2 is rolled
|
|
116
|
+
in; the alpha tags are deprecated. New in stable (beyond the alpha
|
|
117
|
+
preview):
|
|
118
|
+
|
|
119
|
+
### New primitives
|
|
120
|
+
|
|
121
|
+
- **`NAC.invoke(action_id, payload, opts?)`** -- payload-bearing
|
|
122
|
+
action. Dispatches `nac:action:requested`, awaits the host's
|
|
123
|
+
`nac:action:succeeded` / `:failed` with the same `request_id`.
|
|
124
|
+
Default timeout 30 s. (Promoted from 2.3.0-alpha.1.)
|
|
125
|
+
- **`NAC.utter(action_id, {text, lang?, voice?})`** -- ergonomic
|
|
126
|
+
shortcut for `verb='utter'`. (Promoted from 2.3.0-alpha.1.)
|
|
127
|
+
- **`NAC.bindTab(el, handler, ctx, opts?)`** -- tab companion to
|
|
128
|
+
`bindAction`. Emits `nac:tab:activated` / `:activation_failed`
|
|
129
|
+
for you. Sister of v2.2's `bindAction`.
|
|
130
|
+
- **`NAC.edit_field(nac_id)`** -- field editor primitive promoted
|
|
131
|
+
from preview to GA. Selection, replace, AI syntax correction,
|
|
132
|
+
save/cancel verbs. Modal mounts the `nac_editor` plugin
|
|
133
|
+
idempotently with all 10 locales.
|
|
134
|
+
|
|
135
|
+
### Shadow DOM resolution (F1 + F6)
|
|
136
|
+
|
|
137
|
+
- **Open shadow DOM**: the runtime walks `el.shadowRoot`
|
|
138
|
+
recursively up to depth 10. Any element with `data-nac-id`
|
|
139
|
+
inside an open shadow root is now resolvable by `NAC.click`,
|
|
140
|
+
`NAC.fill`, `NAC.invoke`, etc. with no glue code.
|
|
141
|
+
- **Closed shadow DOM**: voluntary exposure contract. A
|
|
142
|
+
component MAY expose a `nac3` getter on the host element
|
|
143
|
+
implementing `query(selector)` (mandatory),
|
|
144
|
+
`queryAll(selector)` (recommended), and `describe()` (optional).
|
|
145
|
+
The runtime delegates to those methods.
|
|
146
|
+
- **Error events** for closed shadow:
|
|
147
|
+
- `nac:shadow_blocked` -- emitted once per host with
|
|
148
|
+
`detail.reason` in `'exposure_threw'`, `'not_exposed'`.
|
|
149
|
+
- `nac:shadow_protocol_violation` -- emitted when an exposed
|
|
150
|
+
method returns a non-Element value.
|
|
151
|
+
- All events use `composed: true` so they correctly cross shadow
|
|
152
|
+
boundaries to document-level listeners.
|
|
153
|
+
|
|
154
|
+
### Auth-aware capabilities (F7)
|
|
155
|
+
|
|
156
|
+
- Manifest entries MAY declare `requires_capability: 'verb_slug'`
|
|
157
|
+
at the element level or per `action.verb`. Array values use
|
|
158
|
+
OR semantics ("at least one cap matches passes").
|
|
159
|
+
- `NAC.setCapabilities([...])`, `NAC.grantCapability(cap)`,
|
|
160
|
+
`NAC.revokeCapability(cap)`, `NAC.userCapabilities()` manage
|
|
161
|
+
the user's capability set.
|
|
162
|
+
- `NAC.click` and `NAC.invoke` gate against the set before
|
|
163
|
+
dispatch. Missing cap -> reject with `code='capability_required'`
|
|
164
|
+
+ emit `nac:command:rejected`.
|
|
165
|
+
|
|
166
|
+
### Strict validation default (F3)
|
|
167
|
+
|
|
168
|
+
- `NAC.STRICT_VALIDATION` default flipped from `false` to **`true`**
|
|
169
|
+
in v2.3 stable, per the v2.2 migration promise.
|
|
170
|
+
`NAC.register` now throws `code='strict_validation'` on
|
|
171
|
+
`manifest_role_unknown` / `tab_id_manifest_role_drift` /
|
|
172
|
+
`manifest_dom_role_mismatch` findings.
|
|
173
|
+
- Opt-out: set `NAC.STRICT_VALIDATION = false` BEFORE any
|
|
174
|
+
`register()` call in your bootstrap. See
|
|
175
|
+
`guides/MIGRATION_v2.2_to_v2.3.md` for the playbook.
|
|
176
|
+
|
|
177
|
+
### Hotfix carryover from alpha.2
|
|
178
|
+
|
|
179
|
+
- `NAC.invoke` does NOT reject with `code='disabled'` on elements
|
|
180
|
+
with `disabled` or `aria-disabled='true'`. `invoke` is a logical
|
|
181
|
+
payload-bearing request, not a synthetic click. `NAC.click` still
|
|
182
|
+
rejects on disabled (click semantics preserved). Pinned down by
|
|
183
|
+
test v23-invoke.mjs T7/T8/T9 so the relaxation cannot silently
|
|
184
|
+
regress.
|
|
185
|
+
|
|
186
|
+
### Test surface
|
|
187
|
+
|
|
188
|
+
`npm test` now chains 7 suites (75+ assertions):
|
|
189
|
+
smoke, v22, v23-invoke, v23-shadow, v23-capabilities, v23-editor,
|
|
190
|
+
v23-interop. Plus 5 stage suites + live Playwright E2E
|
|
191
|
+
(`atlas-pro-v23-utter-e2e.mjs` 16/16 GREEN against the deployed
|
|
192
|
+
demo).
|
|
193
|
+
|
|
194
|
+
### Spec text
|
|
195
|
+
|
|
196
|
+
SPEC.md updated:
|
|
197
|
+
- Section 5.1.4 -- `NAC.invoke` + `NAC.utter` final wording.
|
|
198
|
+
- Section 5.1.5 -- Shadow DOM resolution (open, cap 10).
|
|
199
|
+
- Section 5.1.6 -- Closed shadow DOM exposure API (voluntary).
|
|
200
|
+
- Section 5.1.7 -- Auth-aware capabilities.
|
|
201
|
+
- Section 13 -- `edit_field` promoted from preview to GA.
|
|
202
|
+
|
|
203
|
+
### Reference adopters
|
|
204
|
+
|
|
205
|
+
- Atlas Pro voice ad (`ads-demo/atlas-pro/`) -- production live,
|
|
206
|
+
uses `NAC.utter` + payload schema.
|
|
207
|
+
- React demo (`packages/nac-react-demo/`) -- adopts payload-bearing
|
|
208
|
+
pattern for the chat-to-todos flow.
|
|
209
|
+
- Angular demo (`packages/nac-angular-demo/`) -- mirror of React.
|
|
210
|
+
- Web Component demos: `example-v23-shadow-open.html` and
|
|
211
|
+
`example-v23-shadow-closed.html`.
|
|
212
|
+
|
|
213
|
+
## 2.3.0-alpha.2 -- 2026-05-13 (superseded by 2.3.0)
|
|
214
|
+
|
|
215
|
+
Hotfix on top of 2.3.0-alpha.1:
|
|
216
|
+
|
|
217
|
+
- `NAC.invoke` no longer rejects with `code='disabled'` when the
|
|
218
|
+
target element has `disabled` or `aria-disabled='true'` set. The
|
|
219
|
+
`disabled` HTML attribute is a click-event UX guard; `invoke` is
|
|
220
|
+
a logical payload-bearing request, not a synthetic click. Hosts
|
|
221
|
+
that need to refuse an invoke based on UI state should do it in
|
|
222
|
+
their `nac:action:requested` listener and emit
|
|
223
|
+
`nac:action:failed` with a meaningful code. This was hitting the
|
|
224
|
+
Atlas Pro mic which gets `disabled = true` during /parse +
|
|
225
|
+
/tts processing, blocking subsequent NAC.utter calls from
|
|
226
|
+
external agents mid-conversation. Reproduced in the video-gen
|
|
227
|
+
pipeline (every turn after the demo's first state-transition).
|
|
228
|
+
- Bumped CLI version + smoke test assertions to match.
|
|
229
|
+
|
|
230
|
+
## 2.3.0-alpha.1 -- 2026-05-12
|
|
231
|
+
|
|
232
|
+
### New: payload-bearing actions via `NAC.invoke` + `NAC.utter`
|
|
233
|
+
|
|
234
|
+
The NAC v2.2 contract was click-and-go: an agent triggers
|
|
235
|
+
`NAC.click(id)` or `NAC.click_by_verb(plugin, verb)` and the host
|
|
236
|
+
does whatever it does. That works for verb-and-state actions
|
|
237
|
+
(`save`, `cancel`, `submit`, `delete`) but breaks down when the
|
|
238
|
+
action needs **data** from the agent: `utter(text)`,
|
|
239
|
+
`search(query)`, `send_message(body)`, `upload(file)`,
|
|
240
|
+
`schedule(date)`. Hosts had no way to receive an agent's payload
|
|
241
|
+
via a synthetic click.
|
|
242
|
+
|
|
243
|
+
v2.3 adds the missing primitive:
|
|
244
|
+
|
|
245
|
+
```ts
|
|
246
|
+
NAC.invoke(action_id, payload, opts?): Promise<{ok, request_id, ack}>
|
|
247
|
+
NAC.utter(action_id, {text, lang?, voice?}): Promise<...>
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
`NAC.invoke` dispatches a `nac:action:requested` CustomEvent on
|
|
251
|
+
the host element (bubbles) with the agent's `payload` + a
|
|
252
|
+
runtime-issued `request_id`. The host listens, processes, emits
|
|
253
|
+
`nac:action:succeeded` (or `:failed`) echoing the same
|
|
254
|
+
`request_id`. The runtime correlates and resolves the Promise.
|
|
255
|
+
|
|
256
|
+
Default timeout 30 s (vs 5 s for click). On timeout the Promise
|
|
257
|
+
rejects with `code='timeout'`.
|
|
258
|
+
|
|
259
|
+
`NAC.utter(id, opts)` is the ergonomic shortcut for `verb='utter'`
|
|
260
|
+
-- equivalent to `NAC.invoke(id, {verb:'utter', text, lang, voice})`.
|
|
261
|
+
|
|
262
|
+
Manifest entries for payload-bearing actions can declare an
|
|
263
|
+
informational `payload_schema`:
|
|
264
|
+
|
|
265
|
+
```js
|
|
266
|
+
{ id: 'atlas_pro_ad.mic', role: 'action',
|
|
267
|
+
actions: [
|
|
268
|
+
{ verb: 'listen' },
|
|
269
|
+
{ verb: 'utter',
|
|
270
|
+
payload_schema: {
|
|
271
|
+
text: { type: 'string', required: true, max: 4000 },
|
|
272
|
+
lang: { type: 'string', enum: ['en','es','pt','fr','it','de','ja','zh','hi','ar'] }
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
]
|
|
276
|
+
}
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
Click-style verbs (`NAC.click`, `NAC.click_by_verb`) continue to
|
|
280
|
+
work unchanged. The new contract is purely additive; no demo
|
|
281
|
+
behaviour regresses.
|
|
282
|
+
|
|
283
|
+
#### First adopter
|
|
284
|
+
|
|
285
|
+
Atlas Pro (`https://yujin.app/nac-spec/ads-demo/atlas-pro/`)
|
|
286
|
+
declares both `listen` (click-only, existing) and `utter`
|
|
287
|
+
(payload-bearing) on its `atlas_pro_ad.mic` action. The same
|
|
288
|
+
`/ad-orchestrator/parse` + `/ad-orchestrator/tts` loop drives
|
|
289
|
+
either path -- agents with their own STT call `listen`, agents
|
|
290
|
+
with their own LM call `utter` with the recognised text.
|
|
291
|
+
|
|
292
|
+
#### Test coverage
|
|
293
|
+
|
|
294
|
+
- `test/v23-invoke.mjs` (new) -- 22 assertions covering happy
|
|
295
|
+
path, ack echo, host-failed path, invalid args, not-found,
|
|
296
|
+
custom timeout. PASS.
|
|
297
|
+
- `test/v22.mjs` -- amended to accept v2.3.x in addition to
|
|
298
|
+
v2.2.x. PASS.
|
|
299
|
+
- `test/smoke.mjs` -- updated version assertions. PASS.
|
|
300
|
+
|
|
301
|
+
#### Files touched
|
|
302
|
+
|
|
303
|
+
- `yujin.app/nac-spec/js/nac.js` -- `invoke()` + `utter()` (~150
|
|
304
|
+
LOC additive). Public API surface +2 functions. NAC.version
|
|
305
|
+
bumped to '2.3.0-alpha.1', spec_version to '2.3'.
|
|
306
|
+
- `yujin.app/nac-spec/SPEC.md` -- new section 5.1.4 + header
|
|
307
|
+
version line.
|
|
308
|
+
- `yujin.app/nac-spec/ads-demo/atlas-pro/index.html` -- manifest
|
|
309
|
+
declares the `utter` verb + DOM listener routes into the demo's
|
|
310
|
+
existing `handleUtterance(text)`.
|
|
311
|
+
- `packages/nac/package.json`, `build.mjs`, `test/smoke.mjs` --
|
|
312
|
+
version bumps + new test in `npm test`.
|
|
313
|
+
|
|
314
|
+
#### Not yet wired
|
|
315
|
+
|
|
316
|
+
- `STRICT_VALIDATION` enforcement of `payload_schema` (alpha:
|
|
317
|
+
schema is informational).
|
|
318
|
+
- A `NAC.search` / `NAC.upload` / `NAC.send_message` ergonomic
|
|
319
|
+
shortcut sibling to `NAC.utter`. The generic `NAC.invoke` works
|
|
320
|
+
today; concrete shortcuts can be added without re-spec.
|
|
71
321
|
|
|
72
322
|
## 2.2.1 -- 2026-05-12
|
|
73
323
|
|