@nac3/runtime 2.3.1 → 2.5.0-alpha.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,73 +1,457 @@
1
1
  # Changelog
2
2
 
3
- ## 2.3.0 -- 2026-05-20
4
-
5
- ### Added
6
-
7
- - **`NAC.syncPlugin(spec)`** -- idempotent plugin registration.
8
- Replaces the manifest for a plugin instead of appending, fixing the
9
- stale-snapshot class of bugs where repeated `register()` calls on
10
- dynamic re-renders accumulated duplicate manifest entries. Counterpart
11
- to the existing `syncDataTable`. Recommended path for SPA hosts.
12
- - **`data-nac-plugin-id`** -- explicit plugin instance identifier for
13
- pages with multiple roots sharing a plugin slug. When a slug appears
14
- more than once in the DOM, every root MUST carry a unique
15
- `data-nac-plugin-id`. `validate_global` flags violations.
16
-
17
- ### Fixed
18
-
19
- - Manifest accumulation on repeated `register()` calls. `syncPlugin` is
20
- the recommended migration path for hosts that re-render.
21
- - `validate_global` now flags duplicate plugin manifest entries.
22
-
23
- ### Benchmark
24
-
25
- This release ships the runtime that was validated across **600 runs**
26
- (5 models x 3 protocols x 4 tasks x 10 iterations) published at
27
- <https://github.com/yujinapp/nac-spec/tree/main/benchmark/>. Highlights:
28
-
29
- - **95.5% success rate** under NAC3 (191 / 200 runs).
30
- - **Zero phantom-selector silent damage** in NAC3 (0 / 200) vs
31
- **15%** in Raw DOM (30 / 200).
32
- - **1.0 round-trip per task** in NAC3 vs 3.5 in MCP.
33
- - Cheap models (Gemini Flash Lite, GPT-4o-mini) reached
34
- **100% success** under NAC3 -- matching frontier models in Raw DOM.
35
-
36
- Full reproducibility: every JSONL row carries `runtime_version`,
37
- `bench_version`, `manifest_checksum`. Bundle downloadable from the
38
- benchmark page. Cost to re-run: ~US$15.
39
-
40
- ### Experimental (not yet GA)
41
-
42
- The runtime contains code merged for the V24-04 RFC (snapshot
43
- versioning + optimistic concurrency control). This release ships it as
44
- **implementation present, enforcement opt-in**:
45
-
46
- - `plugin_version` and `element_state_hash` are present in
47
- `NAC.describe()` output by default. Shape is stable; semantics may
48
- tighten in v2.4.
49
- - `expected_plugin_version` and `expected_tree_version` parameters on
50
- dispatch are accepted, but enforcement (throwing `snapshot_stale`)
51
- is gated behind `NAC.STRICT_VERSIONING = true`. Default is `false`.
52
- - `markHydrationComplete()` is exported and active. SSR hosts may call
53
- it; SPA hosts get a 100ms auto-fallback.
54
-
55
- The 2.3 benchmark ran with `STRICT_VERSIONING=false` and did not
56
- exercise the OCC enforcement. V24-04 will move from "experimental
57
- opt-in" to "SHIPPED" in v2.4, validated by a dedicated concurrency
58
- benchmark. See `/rfcs/README.md` for status.
59
-
60
- V24-05 (agent authority + interposition: `confirm_action`,
61
- `request_authority`) is RFC draft only -- not in this runtime.
62
-
63
- ### Spec changes
64
-
65
- - `SPEC.md` header bumped to v2.3.
66
- - New `/rfcs/` directory separates spec-shipped features from open
67
- proposals. Index in `/rfcs/README.md` documents status per RFC.
68
- - `docs/BENCHMARK_PROVENANCE.md` ties dataset (which reads
69
- `runtime_version=2.2.1` per JSONL field) to the npm release
70
- (`2.3.0`) via the shared commit hash.
3
+ ## 2.5.0-alpha.1 -- 2026-05-23
4
+
5
+ NAC3 v2.5.0-alpha.1 is a **consolidation release**. Two parallel
6
+ development lines that diverged during May 2026 are unified here.
7
+ The yujinapp/nac-spec repository becomes the SOLE source of truth
8
+ for NAC3 from this commit forward; the prior development copies
9
+ under rpaforce-crm (`packages/nac/`, `yujin.app/nac-spec/`) are
10
+ deleted in that monorepo's history.
11
+
12
+ ### Lines unified
13
+
14
+ - **Line A** (was on this repo, RFC track): V24-01 plugin slug
15
+ uniqueness, V24-02 idempotent syncPlugin (was announced in
16
+ 2.3.x changelog but never landed in code -- now implemented
17
+ for the first time with full test coverage), V24-04 snapshot
18
+ versioning + OCC (in flight, see "Pending" below), V24-05
19
+ agent authority + sudo (was DRAFT, ships SHIPPED here).
20
+ - **Line B** (was on rpaforce-crm, contract track): V25-01 plugin
21
+ extension contract for canvas+API surfaces (Block A: 8 backends
22
+ complete + tests).
23
+
24
+ ### Added (V25-01 -- NEW)
25
+
26
+ - `NAC.registerPlugin(slug, manifest)` declarative plugin
27
+ registration for surfaces where verbs / state / events route
28
+ through something other than direct DOM (postMessage to iframe,
29
+ plugin SDK call, script bridge, DOM mirror, same-origin window,
30
+ synthesised events).
31
+ - `NAC.call(plugin, verb_path, args)` abstract verb dispatch.
32
+ - `NAC.read(plugin, state_path)` abstract state read with declared
33
+ fallback chain semantics.
34
+ - `NAC.subscribe(plugin, event_path, cb) / unsubscribe(handle)`
35
+ event subscription with backend routing.
36
+ - 8 backend kinds in fixed vocabulary: `postmessage`,
37
+ `postmessage-listen`, `sdk-call`, `script-bridge`, `dom-mirror`,
38
+ `same-origin-window`, `synthetic-mutation`, `synthetic-poll`.
39
+ - Declarative extractor mini-DSL (`text` / `value` / `present` /
40
+ `attribute:NAME` / `classList.contains:CLASS` / dotted-path).
41
+ - Provenance event family: `nac:plugin:invoked` / `:read` / `:event`
42
+ with `{plugin, backend, request_id, source, trusted, duration_ms,
43
+ ok, error}` payload.
44
+
45
+ ### Added (V24-02 -- NEW IMPLEMENTATION)
46
+
47
+ - `NAC.syncPlugin(manifest)` / `NAC.syncPlugin(slug, manifest)`
48
+ -- idempotent registration. Replaces the manifest for a slug
49
+ instead of appending; SPA hosts call this on remount without
50
+ accumulating stale entries.
51
+ - Returns `{ replaced: boolean, slug, version }`.
52
+ - Emits `nac:plugin:invalidated` on REPLACE (not on first-add),
53
+ detail `{plugin_slug, plugin_instance_id, from_version,
54
+ to_version, trigger: 'syncPlugin'}`.
55
+
56
+ ### Added (V24-05 -- NEW)
57
+
58
+ - `NAC.set_confirm_handler(fn)` -- register async (req) => boolean.
59
+ - `NAC.confirm_action(action_id, message, opts?)` -- Promise<boolean>.
60
+ Sudo bypass: short-circuits true if elevation already granted
61
+ for the requested scope (or higher).
62
+ - `NAC.request_authority(scope, ttl_ms, opts?)` -- sudo-style
63
+ time-bounded elevation. Scope rank: high > medium > low.
64
+ - `NAC.has_authority(scope) -> bool`.
65
+ - `NAC.revoke_authority(scope) -> void` (idempotent).
66
+ - Provenance event family:
67
+ `nac:authority:requested / :granted / :denied / :revoked / :expired`,
68
+ `nac:action:confirmed / :rejected`.
69
+ - SUPERSEDES the v1.9 confirm_action mechanism (removed: it was
70
+ unused + had a strictly narrower contract).
71
+
72
+ ### Added (V24-01 -- CONSOLIDATED + ENFORCED)
73
+
74
+ - `NAC.HARD_DEDUP` flag (default true). Gates the synchronous
75
+ throw in `NAC.register` + the boot-time pass.
76
+ - `NAC.register` throws `NacError('duplicate_plugin_no_instance_id',
77
+ ...)` synchronously when the DOM already contains multiple roots
78
+ for the registered slug and any of them omits / duplicates
79
+ `data-nac-plugin-id`.
80
+ - Boot-time pass on `DOMContentLoaded` runs the same check across
81
+ every `[data-nac-plugin]` root. On first violation: dispatches
82
+ `nac:fatal` event + paints a fixed-position red banner
83
+ (`#__nac_fatal_banner__`) + re-throws asynchronously so test
84
+ harnesses + browsers catch it.
85
+ - `validate_global()` extended with `plugin_instance_violations`
86
+ array -- structured findings for CI gates.
87
+ - Migration: `NAC.HARD_DEDUP = false` BEFORE any `register()`
88
+ call opts out for one release window. Flag removed in v2.6.
89
+
90
+ ### New: PROJECT.md at repo root
91
+
92
+ PROJECT.md documents the post-migration topology, the RFC process
93
+ states (Proposed / In implementation / Implemented / Alpha /
94
+ Production), the doc-update invariant (every RFC transition
95
+ touches SPEC + CHANGELOG + USER_MANUAL + TECHNICAL_DESIGN + demos
96
+ list + benchmark numbers + Sumi KB), and the programming +
97
+ architecture norms. Read it FIRST before any contribution.
98
+
99
+ ### Tests
100
+
101
+ `runtime/test/` suite now has 13 stages:
102
+
103
+ smoke + v22 + v23-{invoke,shadow,capabilities,editor,interop}
104
+ + stage2-disambiguation + stage7-strict-resolution + stage8-plugin-extension
105
+ + stage9-sync-plugin + stage10-authority-sudo + stage11-plugin-id-dedup
106
+
107
+ `npm test` exit code 0, 349 PASS / 0 FAIL.
108
+
109
+ ### Pending for 2.5.0-alpha.2
110
+
111
+ - V24-04 snapshot versioning + OCC -- in implementation, code in
112
+ flight. Targets `NAC.STRICT_VERSIONING=true` by default, with
113
+ `expected_plugin_version` / `expected_tree_version` enforcement
114
+ on every mutating API. The `plugin_version` + `element_state_hash`
115
+ fields will appear in `describe()` output.
116
+ - V25-02 tree navigation (`context`, `tree`, `data-nac-opens`)
117
+ -- DRAFT, target 2.5.x.
118
+ - V25-03 asistive labels (`narrate`) -- DRAFT, target 2.5.x.
119
+ - V25-04 effect detection (`expect`, `diff`) -- DRAFT, target 2.5.x.
120
+
121
+ ### Migration notes
122
+
123
+ - Code that ran fine under 2.4.0 (strict resolution + disambiguation)
124
+ continues to work unchanged in 2.5; that contract is stable.
125
+ - Code that called the pre-existing v1.9 `confirm_action` must
126
+ migrate to V24-05 (`confirm_action` + `set_confirm_handler` +
127
+ `request_authority`). The argument shape changed
128
+ (`(action_id, opts)` -> `(action_id, message, opts)`). Audit
129
+ callers; no automatic migration tool.
130
+ - Code that registered the same plugin slug on multiple DOM roots
131
+ WITHOUT `data-nac-plugin-id` now throws at register time. Either
132
+ add the attribute, OR set `NAC.HARD_DEDUP=false` before
133
+ registering for a one-release migration window.
134
+
135
+ ---
136
+
137
+ ## 2.4.0 -- 2026-05-21
138
+
139
+ NAC3 v2.4.0 is a **behavior-of-contract change**: id / verb / qualifier
140
+ resolution becomes strict. Backwards-compatible with code paths that
141
+ already supplied unambiguous arguments, **NOT** backwards-compatible
142
+ with code paths that depended on the previous lenient (`indexOf`)
143
+ fallback to resolve to the first near-match.
144
+
145
+ ### Why this changed (the principle, not a feature)
146
+
147
+ The lenient resolution in 2.3.x violated the spec's 0-silent-damage
148
+ invariant. Specifically, `click_by_verb(plugin, verb, { qualifier })`
149
+ would, on a no-exact-suffix match, fall through to an `indexOf(qualifier)`
150
+ substring search and resolve silently to whatever element happened to
151
+ contain the qualifier string anywhere in its id. The H4 benchmark on the
152
+ Conduit case study (2026-05-21) showed that **12 of 18 "model failures"
153
+ on the canonical flows were actually silent runtime damage** — the
154
+ agent emitted an invalid qualifier, the runtime sent it to the wrong
155
+ element, the agent looped against the wrong page state. Strict
156
+ resolution rescues those 12 (see `nac-spec/conduit/H4_STRICT_NAC_REPORT.md`).
157
+
158
+ For an assistive-software use case (the principal driver of this
159
+ project), a silent dispatch to the wrong element with no recovery path
160
+ is a safety blocker. Strict resolution closes that gap.
161
+
162
+ ### New error model — disambiguation contract
163
+
164
+ When `click_by_verb` / `tab` / `tab_by_label` cannot resolve a request
165
+ unambiguously, the runtime now:
166
+
167
+ 1. Emits `nac:disambiguation_requested` on `document` with a
168
+ structured detail payload (see below).
169
+ 2. Throws `NacError` with `err.code` ∈ `{no_matching_instance,
170
+ ambiguous_qualifier, ambiguous_tab, ambiguous_label}` AND
171
+ `err.candidates: [{nac_id, label}, ...]` pre-validated against the
172
+ live DOM.
173
+
174
+ Detail / candidates payload:
175
+ ```js
176
+ {
177
+ method: 'click_by_verb' | 'tab' | 'tab_by_label',
178
+ plugin: string | null,
179
+ query: { verb?, qualifier?, label?, id? },
180
+ reason: 'no_matching_instance' | 'ambiguous_qualifier' | 'ambiguous_tab' |
181
+ 'ambiguous_label' | 'ambiguous_label_exact' | 'ambiguous_label_fuzzy' |
182
+ 'no_matching_label',
183
+ candidates: [{ nac_id: string, label: string }, ...]
184
+ }
185
+ ```
186
+
187
+ A reactive host (chat UI / voice agent / screen-reader) can listen
188
+ on the event and present the options to the user as *"did you
189
+ mean A or B?"*. A synchronous catcher can read `err.candidates`
190
+ directly. An autonomous agent (Pilot, etc.) can inject the candidates
191
+ into the next turn's prompt so the LLM picks from a DOM-validated
192
+ list instead of re-guessing a qualifier.
193
+
194
+ ### What changed in the resolvers
195
+
196
+ - **`click_by_verb` with qualifier:** only exact-equality or anchored
197
+ suffix (`id === qualifier || id.endsWith('__' + qualifier)`)
198
+ resolves. Multiple matches → `ambiguous_qualifier`. Zero matches →
199
+ `no_matching_instance`. **The `indexOf` substring fallback is
200
+ removed.**
201
+ - **`tab` single-arg form:** bare id resolves to exact match in DOM. If
202
+ no exact, exactly one anchored-prefix instance
203
+ (`id.startsWith(bare + '__')`) resolves; multiple → `ambiguous_tab`;
204
+ zero → `no_matching_instance`.
205
+ - **`tab_by_label`:** two-tier strict — exact label match first
206
+ (errors if multiple), then substring match (errors if multiple).
207
+ Fuzzy match preserved for voice/assistive use case; ambiguity
208
+ caught.
209
+
210
+ ### Verification
211
+
212
+ - `packages/nac/test/stage2-disambiguation.mjs` — pre-existing
213
+ tab_by_label cases still PASS (B1–B4).
214
+ - `packages/nac/test/stage7-strict-resolution.mjs` (new) — 9/9
215
+ invariants pass under JSDOM shim.
216
+ - `nac3-bench/bench/scripts/stage7_strict_nac.mjs` (new) — 9/9
217
+ invariants pass under Playwright against a live page.
218
+ - `nac3-bench/bench/h4_results/h4_2026-05-21T19-01-19-040Z.json` —
219
+ cheap-model benchmark with strict NAC: 48/54 = 89% (vs 36/54 = 67%
220
+ under lenient).
221
+
222
+ ### Migration guide
223
+
224
+ If your code was passing fuzzy qualifiers and depending on the runtime
225
+ to pick "something close", the upgrade requires you to:
226
+ - Either supply the full `nac_id` directly (always unambiguous), OR
227
+ - Pass the exact `__suffix` of the instance you want, OR
228
+ - Listen for `nac:disambiguation_requested` / catch `NacError` with
229
+ `err.candidates` and pick from the returned list.
230
+
231
+ Most users won't be affected — the only callers that broke during the
232
+ internal regression were the ones that were already broken silently in
233
+ 2.3.x but happened to land on the wrong-but-related element instead of
234
+ failing.
235
+
236
+ ---
237
+
238
+ ## 2.3.1 -- 2026-05-13 (stable, blank republish)
239
+
240
+ Identical source to 2.3.0. The 2.3.0 tag had already been published to
241
+ npm as a preview; 2.3.1 is the first installable stable version. No
242
+ behavioural changes.
243
+
244
+ ---
245
+
246
+ ## 2.3.0 -- 2026-05-13 (stable)
247
+
248
+ NAC3 v2.3.0 is the first stable release of the payload-bearing
249
+ contract. Everything in 2.3.0-alpha.1 and 2.3.0-alpha.2 is rolled
250
+ in; the alpha tags are deprecated. New in stable (beyond the alpha
251
+ preview):
252
+
253
+ ### New primitives
254
+
255
+ - **`NAC.invoke(action_id, payload, opts?)`** -- payload-bearing
256
+ action. Dispatches `nac:action:requested`, awaits the host's
257
+ `nac:action:succeeded` / `:failed` with the same `request_id`.
258
+ Default timeout 30 s. (Promoted from 2.3.0-alpha.1.)
259
+ - **`NAC.utter(action_id, {text, lang?, voice?})`** -- ergonomic
260
+ shortcut for `verb='utter'`. (Promoted from 2.3.0-alpha.1.)
261
+ - **`NAC.bindTab(el, handler, ctx, opts?)`** -- tab companion to
262
+ `bindAction`. Emits `nac:tab:activated` / `:activation_failed`
263
+ for you. Sister of v2.2's `bindAction`.
264
+ - **`NAC.edit_field(nac_id)`** -- field editor primitive promoted
265
+ from preview to GA. Selection, replace, AI syntax correction,
266
+ save/cancel verbs. Modal mounts the `nac_editor` plugin
267
+ idempotently with all 10 locales.
268
+
269
+ ### Shadow DOM resolution (F1 + F6)
270
+
271
+ - **Open shadow DOM**: the runtime walks `el.shadowRoot`
272
+ recursively up to depth 10. Any element with `data-nac-id`
273
+ inside an open shadow root is now resolvable by `NAC.click`,
274
+ `NAC.fill`, `NAC.invoke`, etc. with no glue code.
275
+ - **Closed shadow DOM**: voluntary exposure contract. A
276
+ component MAY expose a `nac3` getter on the host element
277
+ implementing `query(selector)` (mandatory),
278
+ `queryAll(selector)` (recommended), and `describe()` (optional).
279
+ The runtime delegates to those methods.
280
+ - **Error events** for closed shadow:
281
+ - `nac:shadow_blocked` -- emitted once per host with
282
+ `detail.reason` in `'exposure_threw'`, `'not_exposed'`.
283
+ - `nac:shadow_protocol_violation` -- emitted when an exposed
284
+ method returns a non-Element value.
285
+ - All events use `composed: true` so they correctly cross shadow
286
+ boundaries to document-level listeners.
287
+
288
+ ### Auth-aware capabilities (F7)
289
+
290
+ - Manifest entries MAY declare `requires_capability: 'verb_slug'`
291
+ at the element level or per `action.verb`. Array values use
292
+ OR semantics ("at least one cap matches passes").
293
+ - `NAC.setCapabilities([...])`, `NAC.grantCapability(cap)`,
294
+ `NAC.revokeCapability(cap)`, `NAC.userCapabilities()` manage
295
+ the user's capability set.
296
+ - `NAC.click` and `NAC.invoke` gate against the set before
297
+ dispatch. Missing cap -> reject with `code='capability_required'`
298
+ + emit `nac:command:rejected`.
299
+
300
+ ### Strict validation default (F3)
301
+
302
+ - `NAC.STRICT_VALIDATION` default flipped from `false` to **`true`**
303
+ in v2.3 stable, per the v2.2 migration promise.
304
+ `NAC.register` now throws `code='strict_validation'` on
305
+ `manifest_role_unknown` / `tab_id_manifest_role_drift` /
306
+ `manifest_dom_role_mismatch` findings.
307
+ - Opt-out: set `NAC.STRICT_VALIDATION = false` BEFORE any
308
+ `register()` call in your bootstrap. See
309
+ `guides/MIGRATION_v2.2_to_v2.3.md` for the playbook.
310
+
311
+ ### Hotfix carryover from alpha.2
312
+
313
+ - `NAC.invoke` does NOT reject with `code='disabled'` on elements
314
+ with `disabled` or `aria-disabled='true'`. `invoke` is a logical
315
+ payload-bearing request, not a synthetic click. `NAC.click` still
316
+ rejects on disabled (click semantics preserved). Pinned down by
317
+ test v23-invoke.mjs T7/T8/T9 so the relaxation cannot silently
318
+ regress.
319
+
320
+ ### Test surface
321
+
322
+ `npm test` now chains 7 suites (75+ assertions):
323
+ smoke, v22, v23-invoke, v23-shadow, v23-capabilities, v23-editor,
324
+ v23-interop. Plus 5 stage suites + live Playwright E2E
325
+ (`atlas-pro-v23-utter-e2e.mjs` 16/16 GREEN against the deployed
326
+ demo).
327
+
328
+ ### Spec text
329
+
330
+ SPEC.md updated:
331
+ - Section 5.1.4 -- `NAC.invoke` + `NAC.utter` final wording.
332
+ - Section 5.1.5 -- Shadow DOM resolution (open, cap 10).
333
+ - Section 5.1.6 -- Closed shadow DOM exposure API (voluntary).
334
+ - Section 5.1.7 -- Auth-aware capabilities.
335
+ - Section 13 -- `edit_field` promoted from preview to GA.
336
+
337
+ ### Reference adopters
338
+
339
+ - Atlas Pro voice ad (`ads-demo/atlas-pro/`) -- production live,
340
+ uses `NAC.utter` + payload schema.
341
+ - React demo (`packages/nac-react-demo/`) -- adopts payload-bearing
342
+ pattern for the chat-to-todos flow.
343
+ - Angular demo (`packages/nac-angular-demo/`) -- mirror of React.
344
+ - Web Component demos: `example-v23-shadow-open.html` and
345
+ `example-v23-shadow-closed.html`.
346
+
347
+ ## 2.3.0-alpha.2 -- 2026-05-13 (superseded by 2.3.0)
348
+
349
+ Hotfix on top of 2.3.0-alpha.1:
350
+
351
+ - `NAC.invoke` no longer rejects with `code='disabled'` when the
352
+ target element has `disabled` or `aria-disabled='true'` set. The
353
+ `disabled` HTML attribute is a click-event UX guard; `invoke` is
354
+ a logical payload-bearing request, not a synthetic click. Hosts
355
+ that need to refuse an invoke based on UI state should do it in
356
+ their `nac:action:requested` listener and emit
357
+ `nac:action:failed` with a meaningful code. This was hitting the
358
+ Atlas Pro mic which gets `disabled = true` during /parse +
359
+ /tts processing, blocking subsequent NAC.utter calls from
360
+ external agents mid-conversation. Reproduced in the video-gen
361
+ pipeline (every turn after the demo's first state-transition).
362
+ - Bumped CLI version + smoke test assertions to match.
363
+
364
+ ## 2.3.0-alpha.1 -- 2026-05-12
365
+
366
+ ### New: payload-bearing actions via `NAC.invoke` + `NAC.utter`
367
+
368
+ The NAC v2.2 contract was click-and-go: an agent triggers
369
+ `NAC.click(id)` or `NAC.click_by_verb(plugin, verb)` and the host
370
+ does whatever it does. That works for verb-and-state actions
371
+ (`save`, `cancel`, `submit`, `delete`) but breaks down when the
372
+ action needs **data** from the agent: `utter(text)`,
373
+ `search(query)`, `send_message(body)`, `upload(file)`,
374
+ `schedule(date)`. Hosts had no way to receive an agent's payload
375
+ via a synthetic click.
376
+
377
+ v2.3 adds the missing primitive:
378
+
379
+ ```ts
380
+ NAC.invoke(action_id, payload, opts?): Promise<{ok, request_id, ack}>
381
+ NAC.utter(action_id, {text, lang?, voice?}): Promise<...>
382
+ ```
383
+
384
+ `NAC.invoke` dispatches a `nac:action:requested` CustomEvent on
385
+ the host element (bubbles) with the agent's `payload` + a
386
+ runtime-issued `request_id`. The host listens, processes, emits
387
+ `nac:action:succeeded` (or `:failed`) echoing the same
388
+ `request_id`. The runtime correlates and resolves the Promise.
389
+
390
+ Default timeout 30 s (vs 5 s for click). On timeout the Promise
391
+ rejects with `code='timeout'`.
392
+
393
+ `NAC.utter(id, opts)` is the ergonomic shortcut for `verb='utter'`
394
+ -- equivalent to `NAC.invoke(id, {verb:'utter', text, lang, voice})`.
395
+
396
+ Manifest entries for payload-bearing actions can declare an
397
+ informational `payload_schema`:
398
+
399
+ ```js
400
+ { id: 'atlas_pro_ad.mic', role: 'action',
401
+ actions: [
402
+ { verb: 'listen' },
403
+ { verb: 'utter',
404
+ payload_schema: {
405
+ text: { type: 'string', required: true, max: 4000 },
406
+ lang: { type: 'string', enum: ['en','es','pt','fr','it','de','ja','zh','hi','ar'] }
407
+ }
408
+ }
409
+ ]
410
+ }
411
+ ```
412
+
413
+ Click-style verbs (`NAC.click`, `NAC.click_by_verb`) continue to
414
+ work unchanged. The new contract is purely additive; no demo
415
+ behaviour regresses.
416
+
417
+ #### First adopter
418
+
419
+ Atlas Pro (`https://yujin.app/nac-spec/ads-demo/atlas-pro/`)
420
+ declares both `listen` (click-only, existing) and `utter`
421
+ (payload-bearing) on its `atlas_pro_ad.mic` action. The same
422
+ `/ad-orchestrator/parse` + `/ad-orchestrator/tts` loop drives
423
+ either path -- agents with their own STT call `listen`, agents
424
+ with their own LM call `utter` with the recognised text.
425
+
426
+ #### Test coverage
427
+
428
+ - `test/v23-invoke.mjs` (new) -- 22 assertions covering happy
429
+ path, ack echo, host-failed path, invalid args, not-found,
430
+ custom timeout. PASS.
431
+ - `test/v22.mjs` -- amended to accept v2.3.x in addition to
432
+ v2.2.x. PASS.
433
+ - `test/smoke.mjs` -- updated version assertions. PASS.
434
+
435
+ #### Files touched
436
+
437
+ - `yujin.app/nac-spec/js/nac.js` -- `invoke()` + `utter()` (~150
438
+ LOC additive). Public API surface +2 functions. NAC.version
439
+ bumped to '2.3.0-alpha.1', spec_version to '2.3'.
440
+ - `yujin.app/nac-spec/SPEC.md` -- new section 5.1.4 + header
441
+ version line.
442
+ - `yujin.app/nac-spec/ads-demo/atlas-pro/index.html` -- manifest
443
+ declares the `utter` verb + DOM listener routes into the demo's
444
+ existing `handleUtterance(text)`.
445
+ - `packages/nac/package.json`, `build.mjs`, `test/smoke.mjs` --
446
+ version bumps + new test in `npm test`.
447
+
448
+ #### Not yet wired
449
+
450
+ - `STRICT_VALIDATION` enforcement of `payload_schema` (alpha:
451
+ schema is informational).
452
+ - A `NAC.search` / `NAC.upload` / `NAC.send_message` ergonomic
453
+ shortcut sibling to `NAC.utter`. The generic `NAC.invoke` works
454
+ today; concrete shortcuts can be added without re-spec.
71
455
 
72
456
  ## 2.2.1 -- 2026-05-12
73
457