@nac3/runtime 2.2.1 → 2.3.0-alpha.2
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 +92 -0
- package/SPEC.md +147 -2
- package/dist/cli.js +3 -3
- package/dist/nac.browser.js +156 -2
- package/dist/nac.cjs +156 -2
- package/dist/nac.mjs +156 -2
- package/package.json +5 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,97 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.3.0-alpha.1 -- 2026-05-12
|
|
4
|
+
|
|
5
|
+
### New: payload-bearing actions via `NAC.invoke` + `NAC.utter`
|
|
6
|
+
|
|
7
|
+
The NAC v2.2 contract was click-and-go: an agent triggers
|
|
8
|
+
`NAC.click(id)` or `NAC.click_by_verb(plugin, verb)` and the host
|
|
9
|
+
does whatever it does. That works for verb-and-state actions
|
|
10
|
+
(`save`, `cancel`, `submit`, `delete`) but breaks down when the
|
|
11
|
+
action needs **data** from the agent: `utter(text)`,
|
|
12
|
+
`search(query)`, `send_message(body)`, `upload(file)`,
|
|
13
|
+
`schedule(date)`. Hosts had no way to receive an agent's payload
|
|
14
|
+
via a synthetic click.
|
|
15
|
+
|
|
16
|
+
v2.3 adds the missing primitive:
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
NAC.invoke(action_id, payload, opts?): Promise<{ok, request_id, ack}>
|
|
20
|
+
NAC.utter(action_id, {text, lang?, voice?}): Promise<...>
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
`NAC.invoke` dispatches a `nac:action:requested` CustomEvent on
|
|
24
|
+
the host element (bubbles) with the agent's `payload` + a
|
|
25
|
+
runtime-issued `request_id`. The host listens, processes, emits
|
|
26
|
+
`nac:action:succeeded` (or `:failed`) echoing the same
|
|
27
|
+
`request_id`. The runtime correlates and resolves the Promise.
|
|
28
|
+
|
|
29
|
+
Default timeout 30 s (vs 5 s for click). On timeout the Promise
|
|
30
|
+
rejects with `code='timeout'`.
|
|
31
|
+
|
|
32
|
+
`NAC.utter(id, opts)` is the ergonomic shortcut for `verb='utter'`
|
|
33
|
+
-- equivalent to `NAC.invoke(id, {verb:'utter', text, lang, voice})`.
|
|
34
|
+
|
|
35
|
+
Manifest entries for payload-bearing actions can declare an
|
|
36
|
+
informational `payload_schema`:
|
|
37
|
+
|
|
38
|
+
```js
|
|
39
|
+
{ id: 'atlas_pro_ad.mic', role: 'action',
|
|
40
|
+
actions: [
|
|
41
|
+
{ verb: 'listen' },
|
|
42
|
+
{ verb: 'utter',
|
|
43
|
+
payload_schema: {
|
|
44
|
+
text: { type: 'string', required: true, max: 4000 },
|
|
45
|
+
lang: { type: 'string', enum: ['en','es','pt','fr','it','de','ja','zh','hi','ar'] }
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Click-style verbs (`NAC.click`, `NAC.click_by_verb`) continue to
|
|
53
|
+
work unchanged. The new contract is purely additive; no demo
|
|
54
|
+
behaviour regresses.
|
|
55
|
+
|
|
56
|
+
#### First adopter
|
|
57
|
+
|
|
58
|
+
Atlas Pro (`https://yujin.app/nac-spec/ads-demo/atlas-pro/`)
|
|
59
|
+
declares both `listen` (click-only, existing) and `utter`
|
|
60
|
+
(payload-bearing) on its `atlas_pro_ad.mic` action. The same
|
|
61
|
+
`/ad-orchestrator/parse` + `/ad-orchestrator/tts` loop drives
|
|
62
|
+
either path -- agents with their own STT call `listen`, agents
|
|
63
|
+
with their own LM call `utter` with the recognised text.
|
|
64
|
+
|
|
65
|
+
#### Test coverage
|
|
66
|
+
|
|
67
|
+
- `test/v23-invoke.mjs` (new) -- 22 assertions covering happy
|
|
68
|
+
path, ack echo, host-failed path, invalid args, not-found,
|
|
69
|
+
custom timeout. PASS.
|
|
70
|
+
- `test/v22.mjs` -- amended to accept v2.3.x in addition to
|
|
71
|
+
v2.2.x. PASS.
|
|
72
|
+
- `test/smoke.mjs` -- updated version assertions. PASS.
|
|
73
|
+
|
|
74
|
+
#### Files touched
|
|
75
|
+
|
|
76
|
+
- `yujin.app/nac-spec/js/nac.js` -- `invoke()` + `utter()` (~150
|
|
77
|
+
LOC additive). Public API surface +2 functions. NAC.version
|
|
78
|
+
bumped to '2.3.0-alpha.1', spec_version to '2.3'.
|
|
79
|
+
- `yujin.app/nac-spec/SPEC.md` -- new section 5.1.4 + header
|
|
80
|
+
version line.
|
|
81
|
+
- `yujin.app/nac-spec/ads-demo/atlas-pro/index.html` -- manifest
|
|
82
|
+
declares the `utter` verb + DOM listener routes into the demo's
|
|
83
|
+
existing `handleUtterance(text)`.
|
|
84
|
+
- `packages/nac/package.json`, `build.mjs`, `test/smoke.mjs` --
|
|
85
|
+
version bumps + new test in `npm test`.
|
|
86
|
+
|
|
87
|
+
#### Not yet wired
|
|
88
|
+
|
|
89
|
+
- `STRICT_VALIDATION` enforcement of `payload_schema` (alpha:
|
|
90
|
+
schema is informational).
|
|
91
|
+
- A `NAC.search` / `NAC.upload` / `NAC.send_message` ergonomic
|
|
92
|
+
shortcut sibling to `NAC.utter`. The generic `NAC.invoke` works
|
|
93
|
+
today; concrete shortcuts can be added without re-spec.
|
|
94
|
+
|
|
3
95
|
## 2.2.1 -- 2026-05-12
|
|
4
96
|
|
|
5
97
|
### Bug fix: importable in Node / SSR / test contexts
|
package/SPEC.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# NAC3 -- Native Agent Contract
|
|
2
2
|
|
|
3
|
-
**Version:** 2.
|
|
4
|
-
**Status:**
|
|
3
|
+
**Version:** 2.3.0-alpha.1 (preview; payload-bearing actions land here)
|
|
4
|
+
**Status:** v2.2.x stable + v2.3 preview
|
|
5
5
|
**License:** Apache-2.0
|
|
6
6
|
**Editor:** Yujin (rpaforce.com)
|
|
7
7
|
|
|
@@ -232,6 +232,151 @@ NAC.edit_field('invoice.client_name');
|
|
|
232
232
|
NAC.click_by_verb('myplugin', 'edit_field', { nac_id: 'invoice.client_name' });
|
|
233
233
|
```
|
|
234
234
|
|
|
235
|
+
### 5.1.4 Action payload + invoke (v2.3 preview)
|
|
236
|
+
|
|
237
|
+
NAC v2.2 actions are click-and-go: an agent triggers `NAC.click(id)`
|
|
238
|
+
or `NAC.click_by_verb(plugin, verb)` and the host runs whatever it
|
|
239
|
+
does. This works for verb-and-state actions (`save`, `cancel`,
|
|
240
|
+
`submit`, `delete`) but collapses when an action needs **data**
|
|
241
|
+
from the agent -- `utter(text)`, `search(query)`,
|
|
242
|
+
`send_message(body)`, `upload(file)`, `schedule(date)`,
|
|
243
|
+
`translate(text, target_lang)`. The host has no way to receive
|
|
244
|
+
the agent's payload via a synthetic click.
|
|
245
|
+
|
|
246
|
+
v2.3 closes this gap. The contract is additive: click-style
|
|
247
|
+
verbs continue to work unchanged.
|
|
248
|
+
|
|
249
|
+
```ts
|
|
250
|
+
NAC.invoke(action_id: string, payload: object, opts?: { timeout?: number })
|
|
251
|
+
: Promise<{ok: true, request_id: string, ack: object|null}>
|
|
252
|
+
|
|
253
|
+
NAC.utter(action_id: string,
|
|
254
|
+
opts: { text: string, lang?: string, voice?: string, metadata?: object })
|
|
255
|
+
: Promise<{ok: true, request_id: string, ack: object|null}>
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
`NAC.invoke` dispatches a `nac:action:requested` `CustomEvent`
|
|
259
|
+
on the host element (bubbles to document) with:
|
|
260
|
+
|
|
261
|
+
```ts
|
|
262
|
+
detail: {
|
|
263
|
+
action_id: string, // canonical nac_id of the host element
|
|
264
|
+
verb: string, // payload.verb || el's data-nac-action
|
|
265
|
+
payload: object, // arbitrary, action-specific
|
|
266
|
+
plugin: string|null,
|
|
267
|
+
request_id: string, // correlation token assigned by the runtime
|
|
268
|
+
ts: number, // Date.now()
|
|
269
|
+
}
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
The host listens for `nac:action:requested`, processes the
|
|
273
|
+
payload, and emits `nac:action:succeeded` (or `nac:action:failed`)
|
|
274
|
+
with the same `request_id` in the detail. The runtime correlates
|
|
275
|
+
by `request_id` and resolves the agent's Promise.
|
|
276
|
+
|
|
277
|
+
Default timeout is **30 seconds** (vs 5 s for click). Override
|
|
278
|
+
with `opts.timeout`. On timeout, the Promise rejects with
|
|
279
|
+
`NacError('timeout', ...)`. As with click, a timeout means real
|
|
280
|
+
failure: callers MUST treat it as such unless they have side-
|
|
281
|
+
effect proof via another channel.
|
|
282
|
+
|
|
283
|
+
`NAC.utter(id, opts)` is the ergonomic shortcut for the most
|
|
284
|
+
common payload-bearing verb. It is equivalent to:
|
|
285
|
+
|
|
286
|
+
```js
|
|
287
|
+
NAC.invoke(id, { verb: 'utter', text: opts.text, lang: opts.lang });
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
#### Manifest declaration
|
|
291
|
+
|
|
292
|
+
A payload-bearing action declares its payload schema in the
|
|
293
|
+
manifest entry for traceability and tooling:
|
|
294
|
+
|
|
295
|
+
```js
|
|
296
|
+
NAC.register({
|
|
297
|
+
plugin_slug: 'atlas_pro_ad',
|
|
298
|
+
version: '2.1.0',
|
|
299
|
+
nac_version: '2.3',
|
|
300
|
+
elements: [
|
|
301
|
+
{ id: 'atlas_pro_ad.mic', role: 'action',
|
|
302
|
+
actions: [
|
|
303
|
+
{ verb: 'listen' },
|
|
304
|
+
{ verb: 'utter',
|
|
305
|
+
payload_schema: {
|
|
306
|
+
text: { type: 'string', required: true, max: 4000 },
|
|
307
|
+
lang: { type: 'string',
|
|
308
|
+
enum: ['en','es','pt','fr','it','de','ja','zh','hi','ar'] }
|
|
309
|
+
},
|
|
310
|
+
label_i18n: { es:'Decir', en:'Utter', /* ... 10 locales */ } }
|
|
311
|
+
],
|
|
312
|
+
label_i18n: { /* ... */ } }
|
|
313
|
+
]
|
|
314
|
+
});
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
`payload_schema` is informational in v2.3-alpha. Agents MAY
|
|
318
|
+
validate before sending; runtimes MAY enforce it when
|
|
319
|
+
`STRICT_VALIDATION` is `true`. Schemas are intentionally simple
|
|
320
|
+
(JSON-Schema-shaped subset) so a runtime can validate without
|
|
321
|
+
shipping a full JSON-Schema validator. v2.4 will formalise the
|
|
322
|
+
schema grammar.
|
|
323
|
+
|
|
324
|
+
#### Conformance: hosts that support invoke MUST
|
|
325
|
+
|
|
326
|
+
1. Declare `actions[].payload_schema` in the manifest entry.
|
|
327
|
+
2. Listen for `nac:action:requested` (or use a generic listener
|
|
328
|
+
that filters by `detail.action_id` + `detail.verb`).
|
|
329
|
+
3. Emit `nac:action:succeeded` -- with `detail.request_id`
|
|
330
|
+
echoed back -- after processing, or `nac:action:failed`
|
|
331
|
+
(with `detail.error` code) on failure.
|
|
332
|
+
4. NEVER emit a `:succeeded` event with a `request_id` they did
|
|
333
|
+
not receive (prevents cross-talk between concurrent invocations).
|
|
334
|
+
|
|
335
|
+
Hosts that do NOT support invoke continue to operate normally
|
|
336
|
+
under `NAC.click()` and `NAC.click_by_verb()`. Agents that call
|
|
337
|
+
`NAC.invoke()` against a host without an `actions[].payload_schema`
|
|
338
|
+
entry will still receive a `request_id` but the runtime cannot
|
|
339
|
+
guarantee delivery; the timeout fires after 30 s.
|
|
340
|
+
|
|
341
|
+
#### Why this matters
|
|
342
|
+
|
|
343
|
+
The full agentic surface stops being "list of buttons" and
|
|
344
|
+
becomes "list of buttons + structured inputs". A voice ad becomes
|
|
345
|
+
NAC.invoke-able. A search bar becomes NAC.invoke-able. A
|
|
346
|
+
file upload becomes NAC.invoke-able. Same protocol, same
|
|
347
|
+
provenance, same ack semantics.
|
|
348
|
+
|
|
349
|
+
The first reference adopter is **Atlas Pro** -- its
|
|
350
|
+
`atlas_pro_ad.mic` element declares both `listen` (click-only,
|
|
351
|
+
existing) and `utter` (payload-bearing) verbs. The same
|
|
352
|
+
`/parse` + `/tts` conversational loop drives in either case;
|
|
353
|
+
agents that have STT call `listen`, agents that have their own
|
|
354
|
+
language model call `utter`.
|
|
355
|
+
|
|
356
|
+
#### Forward modalities (anticipated, no spec change required)
|
|
357
|
+
|
|
358
|
+
`invoke` is intentionally modality-agnostic so future input
|
|
359
|
+
families plug in without breaking the contract:
|
|
360
|
+
|
|
361
|
+
| Modality | Verb (sketch) | Payload (sketch) |
|
|
362
|
+
|----------|-----------------------|--------------------------------------------------|
|
|
363
|
+
| Text | `utter` | `{text, lang?}` |
|
|
364
|
+
| Search | `search` | `{query, scope?, limit?}` |
|
|
365
|
+
| File | `upload` | `{filename, mime, data_url \| stream_id}` |
|
|
366
|
+
| Image | `analyze_image` | `{image_url \| data_url, prompt?}` |
|
|
367
|
+
| Video | `analyze_stream` | `{stream_url, frame_window_ms?, return?}` |
|
|
368
|
+
| Schedule | `schedule` | `{datetime, duration_min, attendees?}` |
|
|
369
|
+
| Code | `apply_diff` | `{file_path, unified_diff}` |
|
|
370
|
+
| Voice | `transcribe` | `{audio_url \| data_url, lang?}` |
|
|
371
|
+
|
|
372
|
+
Each modality follows the same `nac:action:requested` ->
|
|
373
|
+
`nac:action:succeeded` / `:failed` event protocol, the same
|
|
374
|
+
`request_id` correlation, the same timeout semantics. The
|
|
375
|
+
runtime stays small; the verb vocabulary grows by convention
|
|
376
|
+
between hosts and agents. Ergonomic shortcuts (`NAC.utter`,
|
|
377
|
+
`NAC.search`, `NAC.watch`, etc.) can be added later without
|
|
378
|
+
re-spec because each is a thin wrapper over `invoke`.
|
|
379
|
+
|
|
235
380
|
### 5.1.2 Strict validation flag (v2.2)
|
|
236
381
|
|
|
237
382
|
`NAC.STRICT_VALIDATION` (boolean, default `false` in v2.2). When
|
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// NAC CLI v2.2
|
|
2
|
+
// NAC CLI v2.3.0-alpha.2
|
|
3
3
|
// Usage:
|
|
4
4
|
// nac validate <url-or-dir> [--severity=error|warn|info]
|
|
5
5
|
// nac --version
|
|
@@ -18,7 +18,7 @@ const args = process.argv.slice(2);
|
|
|
18
18
|
const cmd = args[0];
|
|
19
19
|
|
|
20
20
|
function showHelp() {
|
|
21
|
-
console.log('NAC CLI v2.2
|
|
21
|
+
console.log('NAC CLI v2.3.0-alpha.2');
|
|
22
22
|
console.log('');
|
|
23
23
|
console.log('Usage:');
|
|
24
24
|
console.log(' nac validate <url-or-dir> [--severity=error|warn|info]');
|
|
@@ -27,7 +27,7 @@ function showHelp() {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
function showVersion() {
|
|
30
|
-
console.log('@nac3/runtime CLI 2.2
|
|
30
|
+
console.log('@nac3/runtime CLI 2.3.0-alpha.2 (Native Agent Contract v2.3)');
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
if (!cmd || cmd === '--help' || cmd === '-h') { showHelp(); process.exit(0); }
|
package/dist/nac.browser.js
CHANGED
|
@@ -2208,6 +2208,151 @@
|
|
|
2208
2208
|
targetPlugin ? { plugin: targetPlugin } : {}));
|
|
2209
2209
|
}
|
|
2210
2210
|
|
|
2211
|
+
/* ============================================================
|
|
2212
|
+
v2.3.0 -- NAC.invoke / NAC.utter (action payload contract)
|
|
2213
|
+
============================================================
|
|
2214
|
+
NAC v2.2 actions are click-and-go: NAC.click(id) /
|
|
2215
|
+
NAC.click_by_verb(plugin, verb) trigger a click; the host
|
|
2216
|
+
handles it; the runtime polls for nac:action:succeeded.
|
|
2217
|
+
|
|
2218
|
+
This works for verb-and-state actions (save, cancel, delete)
|
|
2219
|
+
but collapses when the action needs DATA from the agent:
|
|
2220
|
+
utter(text), search(query), send_message(body), upload(file),
|
|
2221
|
+
schedule(date), translate(text, target_lang). The host has
|
|
2222
|
+
no way to receive the agent's payload via a synthetic click.
|
|
2223
|
+
|
|
2224
|
+
v2.3 closes this gap. NAC.invoke(action_id, payload) dispatches
|
|
2225
|
+
a 'nac:action:requested' CustomEvent on the host element with
|
|
2226
|
+
the payload + a correlation request_id. The host listens,
|
|
2227
|
+
processes, and emits 'nac:action:succeeded' (or :failed) with
|
|
2228
|
+
the matching request_id. The runtime resolves the Promise.
|
|
2229
|
+
|
|
2230
|
+
Click-style verbs continue to work unchanged via click() /
|
|
2231
|
+
click_by_verb(). invoke is purely additive.
|
|
2232
|
+
|
|
2233
|
+
Atlas Pro is the reference adopter: its 'utter' verb on
|
|
2234
|
+
'atlas_pro_ad.mic' accepts {text, lang} and routes into the
|
|
2235
|
+
existing /parse + /tts conversational loop. */
|
|
2236
|
+
|
|
2237
|
+
async function invoke(action_id, payload, opts) {
|
|
2238
|
+
if (!action_id || typeof action_id !== 'string') {
|
|
2239
|
+
throw NacError('invalid', 'invoke requires an action_id');
|
|
2240
|
+
}
|
|
2241
|
+
if (payload == null || typeof payload !== 'object') {
|
|
2242
|
+
throw NacError('invalid', 'invoke requires a payload object');
|
|
2243
|
+
}
|
|
2244
|
+
const el = _findElement(action_id, opts);
|
|
2245
|
+
if (!el) {
|
|
2246
|
+
_emitCommandRejected({
|
|
2247
|
+
command_method: 'invoke',
|
|
2248
|
+
command_target: action_id,
|
|
2249
|
+
reason: 'not_found',
|
|
2250
|
+
message: 'No element with nac_id=' + action_id,
|
|
2251
|
+
source: (opts && opts.source) || undefined,
|
|
2252
|
+
});
|
|
2253
|
+
throw NacError('not_found', 'No element with nac_id=' + action_id);
|
|
2254
|
+
}
|
|
2255
|
+
/* invoke deliberately does NOT enforce visibility OR disabled --
|
|
2256
|
+
the canonical use case is a mic / search / upload widget
|
|
2257
|
+
that may live outside the visible viewport or be visually
|
|
2258
|
+
disabled while a previous request is processing, but is
|
|
2259
|
+
still a valid NAC target (the agent's request is a logical
|
|
2260
|
+
message, not a synthetic click). Hosts that need to refuse
|
|
2261
|
+
an invoke based on UI state should do it in their
|
|
2262
|
+
nac:action:requested listener and emit nac:action:failed
|
|
2263
|
+
with a meaningful error code. */
|
|
2264
|
+
const verb = (payload && payload.verb)
|
|
2265
|
+
|| el.getAttribute('data-nac-action')
|
|
2266
|
+
|| '';
|
|
2267
|
+
const pluginRoot = el.closest('[data-nac-plugin]');
|
|
2268
|
+
const plugin = pluginRoot
|
|
2269
|
+
? pluginRoot.getAttribute('data-nac-plugin')
|
|
2270
|
+
: null;
|
|
2271
|
+
const request_id = 'nac_inv_'
|
|
2272
|
+
+ Math.random().toString(36).slice(2, 12)
|
|
2273
|
+
+ '_' + Date.now();
|
|
2274
|
+
const timeout_ms = (opts && opts.timeout) || 30000;
|
|
2275
|
+
|
|
2276
|
+
const result = new Promise(function (resolve, reject) {
|
|
2277
|
+
let settled = false;
|
|
2278
|
+
function matchesReq(e) {
|
|
2279
|
+
return e && e.detail && e.detail.request_id === request_id;
|
|
2280
|
+
}
|
|
2281
|
+
function onSucceeded(e) {
|
|
2282
|
+
if (settled) return;
|
|
2283
|
+
if (!matchesReq(e)) return;
|
|
2284
|
+
settled = true;
|
|
2285
|
+
cleanup();
|
|
2286
|
+
resolve({
|
|
2287
|
+
ok: true,
|
|
2288
|
+
request_id: request_id,
|
|
2289
|
+
ack: e.detail || null,
|
|
2290
|
+
});
|
|
2291
|
+
}
|
|
2292
|
+
function onFailed(e) {
|
|
2293
|
+
if (settled) return;
|
|
2294
|
+
if (!matchesReq(e)) return;
|
|
2295
|
+
settled = true;
|
|
2296
|
+
cleanup();
|
|
2297
|
+
const code = (e.detail && e.detail.error) || 'failed';
|
|
2298
|
+
reject(NacError(code,
|
|
2299
|
+
'invoke failed for ' + action_id
|
|
2300
|
+
+ ((e.detail && e.detail.message) ? ': ' + e.detail.message : '')));
|
|
2301
|
+
}
|
|
2302
|
+
const timer = setTimeout(function () {
|
|
2303
|
+
if (settled) return;
|
|
2304
|
+
settled = true;
|
|
2305
|
+
cleanup();
|
|
2306
|
+
reject(NacError('timeout',
|
|
2307
|
+
'invoke timeout after ' + timeout_ms + 'ms for ' + action_id));
|
|
2308
|
+
}, timeout_ms);
|
|
2309
|
+
function cleanup() {
|
|
2310
|
+
document.removeEventListener('nac:action:succeeded', onSucceeded);
|
|
2311
|
+
document.removeEventListener('nac:action:failed', onFailed);
|
|
2312
|
+
clearTimeout(timer);
|
|
2313
|
+
}
|
|
2314
|
+
document.addEventListener('nac:action:succeeded', onSucceeded);
|
|
2315
|
+
document.addEventListener('nac:action:failed', onFailed);
|
|
2316
|
+
});
|
|
2317
|
+
|
|
2318
|
+
/* Dispatch the request event. Bubbles so the host can listen
|
|
2319
|
+
on document if it prefers a single handler for all actions
|
|
2320
|
+
(matches how the existing :succeeded / :failed contracts
|
|
2321
|
+
work today). detail.payload is opaque to the runtime; only
|
|
2322
|
+
the host knows what shape to expect for its own verb. */
|
|
2323
|
+
el.dispatchEvent(new CustomEvent('nac:action:requested', {
|
|
2324
|
+
bubbles: true,
|
|
2325
|
+
detail: {
|
|
2326
|
+
action_id: action_id,
|
|
2327
|
+
verb: verb,
|
|
2328
|
+
payload: payload,
|
|
2329
|
+
plugin: plugin,
|
|
2330
|
+
request_id: request_id,
|
|
2331
|
+
ts: Date.now(),
|
|
2332
|
+
},
|
|
2333
|
+
}));
|
|
2334
|
+
|
|
2335
|
+
return result;
|
|
2336
|
+
}
|
|
2337
|
+
|
|
2338
|
+
/* Ergonomic shortcut for the most common payload-bearing verb.
|
|
2339
|
+
Equivalent to invoke(id, {verb:'utter', text, lang, voice}). */
|
|
2340
|
+
async function utter(action_id, opts) {
|
|
2341
|
+
if (!opts || typeof opts !== 'object') {
|
|
2342
|
+
throw NacError('invalid', 'utter requires an opts object with at least "text"');
|
|
2343
|
+
}
|
|
2344
|
+
if (!opts.text || typeof opts.text !== 'string') {
|
|
2345
|
+
throw NacError('invalid', 'utter requires opts.text (string)');
|
|
2346
|
+
}
|
|
2347
|
+
return await invoke(action_id, {
|
|
2348
|
+
verb: 'utter',
|
|
2349
|
+
text: opts.text,
|
|
2350
|
+
lang: opts.lang || null,
|
|
2351
|
+
voice: opts.voice || null,
|
|
2352
|
+
metadata: opts.metadata || null,
|
|
2353
|
+
}, opts);
|
|
2354
|
+
}
|
|
2355
|
+
|
|
2211
2356
|
async function tab_by_label(plugin, label, opts) {
|
|
2212
2357
|
if (!label) throw NacError('invalid', 'tab_by_label requires a label');
|
|
2213
2358
|
const targetPlugin = plugin || _activePlugin();
|
|
@@ -5007,8 +5152,8 @@
|
|
|
5007
5152
|
|
|
5008
5153
|
global.NAC = {
|
|
5009
5154
|
__nac_v1_installed: true,
|
|
5010
|
-
version: '2.2
|
|
5011
|
-
spec_version: '2.
|
|
5155
|
+
version: '2.3.0-alpha.2',
|
|
5156
|
+
spec_version: '2.3',
|
|
5012
5157
|
/* v2.2.0 (V22-01) -- strict validation toggle. When true,
|
|
5013
5158
|
NAC.register throws on findings (manifest_role_unknown,
|
|
5014
5159
|
tab_id_manifest_role_drift, manifest_dom_role_mismatch).
|
|
@@ -5055,6 +5200,15 @@
|
|
|
5055
5200
|
/* v1.4.1 -- voice/agent ergonomic helpers */
|
|
5056
5201
|
click_by_verb: click_by_verb,
|
|
5057
5202
|
tab_by_label: tab_by_label,
|
|
5203
|
+
/* v2.3.0 -- payload-bearing actions. invoke() is the generic
|
|
5204
|
+
primitive: dispatches nac:action:requested with the agent's
|
|
5205
|
+
payload and resolves on nac:action:succeeded/:failed matching
|
|
5206
|
+
the request_id. utter() is the ergonomic shortcut for the
|
|
5207
|
+
conversational verb pattern (the first concrete adopter is
|
|
5208
|
+
Atlas Pro's mic). Both are additive on top of click()/click_by_verb()
|
|
5209
|
+
and do not change existing demo behaviour. */
|
|
5210
|
+
invoke: invoke,
|
|
5211
|
+
utter: utter,
|
|
5058
5212
|
/* utility */
|
|
5059
5213
|
wait_for: wait_for,
|
|
5060
5214
|
screenshot: screenshot,
|
package/dist/nac.cjs
CHANGED
|
@@ -2209,6 +2209,151 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
|
|
|
2209
2209
|
targetPlugin ? { plugin: targetPlugin } : {}));
|
|
2210
2210
|
}
|
|
2211
2211
|
|
|
2212
|
+
/* ============================================================
|
|
2213
|
+
v2.3.0 -- NAC.invoke / NAC.utter (action payload contract)
|
|
2214
|
+
============================================================
|
|
2215
|
+
NAC v2.2 actions are click-and-go: NAC.click(id) /
|
|
2216
|
+
NAC.click_by_verb(plugin, verb) trigger a click; the host
|
|
2217
|
+
handles it; the runtime polls for nac:action:succeeded.
|
|
2218
|
+
|
|
2219
|
+
This works for verb-and-state actions (save, cancel, delete)
|
|
2220
|
+
but collapses when the action needs DATA from the agent:
|
|
2221
|
+
utter(text), search(query), send_message(body), upload(file),
|
|
2222
|
+
schedule(date), translate(text, target_lang). The host has
|
|
2223
|
+
no way to receive the agent's payload via a synthetic click.
|
|
2224
|
+
|
|
2225
|
+
v2.3 closes this gap. NAC.invoke(action_id, payload) dispatches
|
|
2226
|
+
a 'nac:action:requested' CustomEvent on the host element with
|
|
2227
|
+
the payload + a correlation request_id. The host listens,
|
|
2228
|
+
processes, and emits 'nac:action:succeeded' (or :failed) with
|
|
2229
|
+
the matching request_id. The runtime resolves the Promise.
|
|
2230
|
+
|
|
2231
|
+
Click-style verbs continue to work unchanged via click() /
|
|
2232
|
+
click_by_verb(). invoke is purely additive.
|
|
2233
|
+
|
|
2234
|
+
Atlas Pro is the reference adopter: its 'utter' verb on
|
|
2235
|
+
'atlas_pro_ad.mic' accepts {text, lang} and routes into the
|
|
2236
|
+
existing /parse + /tts conversational loop. */
|
|
2237
|
+
|
|
2238
|
+
async function invoke(action_id, payload, opts) {
|
|
2239
|
+
if (!action_id || typeof action_id !== 'string') {
|
|
2240
|
+
throw NacError('invalid', 'invoke requires an action_id');
|
|
2241
|
+
}
|
|
2242
|
+
if (payload == null || typeof payload !== 'object') {
|
|
2243
|
+
throw NacError('invalid', 'invoke requires a payload object');
|
|
2244
|
+
}
|
|
2245
|
+
const el = _findElement(action_id, opts);
|
|
2246
|
+
if (!el) {
|
|
2247
|
+
_emitCommandRejected({
|
|
2248
|
+
command_method: 'invoke',
|
|
2249
|
+
command_target: action_id,
|
|
2250
|
+
reason: 'not_found',
|
|
2251
|
+
message: 'No element with nac_id=' + action_id,
|
|
2252
|
+
source: (opts && opts.source) || undefined,
|
|
2253
|
+
});
|
|
2254
|
+
throw NacError('not_found', 'No element with nac_id=' + action_id);
|
|
2255
|
+
}
|
|
2256
|
+
/* invoke deliberately does NOT enforce visibility OR disabled --
|
|
2257
|
+
the canonical use case is a mic / search / upload widget
|
|
2258
|
+
that may live outside the visible viewport or be visually
|
|
2259
|
+
disabled while a previous request is processing, but is
|
|
2260
|
+
still a valid NAC target (the agent's request is a logical
|
|
2261
|
+
message, not a synthetic click). Hosts that need to refuse
|
|
2262
|
+
an invoke based on UI state should do it in their
|
|
2263
|
+
nac:action:requested listener and emit nac:action:failed
|
|
2264
|
+
with a meaningful error code. */
|
|
2265
|
+
const verb = (payload && payload.verb)
|
|
2266
|
+
|| el.getAttribute('data-nac-action')
|
|
2267
|
+
|| '';
|
|
2268
|
+
const pluginRoot = el.closest('[data-nac-plugin]');
|
|
2269
|
+
const plugin = pluginRoot
|
|
2270
|
+
? pluginRoot.getAttribute('data-nac-plugin')
|
|
2271
|
+
: null;
|
|
2272
|
+
const request_id = 'nac_inv_'
|
|
2273
|
+
+ Math.random().toString(36).slice(2, 12)
|
|
2274
|
+
+ '_' + Date.now();
|
|
2275
|
+
const timeout_ms = (opts && opts.timeout) || 30000;
|
|
2276
|
+
|
|
2277
|
+
const result = new Promise(function (resolve, reject) {
|
|
2278
|
+
let settled = false;
|
|
2279
|
+
function matchesReq(e) {
|
|
2280
|
+
return e && e.detail && e.detail.request_id === request_id;
|
|
2281
|
+
}
|
|
2282
|
+
function onSucceeded(e) {
|
|
2283
|
+
if (settled) return;
|
|
2284
|
+
if (!matchesReq(e)) return;
|
|
2285
|
+
settled = true;
|
|
2286
|
+
cleanup();
|
|
2287
|
+
resolve({
|
|
2288
|
+
ok: true,
|
|
2289
|
+
request_id: request_id,
|
|
2290
|
+
ack: e.detail || null,
|
|
2291
|
+
});
|
|
2292
|
+
}
|
|
2293
|
+
function onFailed(e) {
|
|
2294
|
+
if (settled) return;
|
|
2295
|
+
if (!matchesReq(e)) return;
|
|
2296
|
+
settled = true;
|
|
2297
|
+
cleanup();
|
|
2298
|
+
const code = (e.detail && e.detail.error) || 'failed';
|
|
2299
|
+
reject(NacError(code,
|
|
2300
|
+
'invoke failed for ' + action_id
|
|
2301
|
+
+ ((e.detail && e.detail.message) ? ': ' + e.detail.message : '')));
|
|
2302
|
+
}
|
|
2303
|
+
const timer = setTimeout(function () {
|
|
2304
|
+
if (settled) return;
|
|
2305
|
+
settled = true;
|
|
2306
|
+
cleanup();
|
|
2307
|
+
reject(NacError('timeout',
|
|
2308
|
+
'invoke timeout after ' + timeout_ms + 'ms for ' + action_id));
|
|
2309
|
+
}, timeout_ms);
|
|
2310
|
+
function cleanup() {
|
|
2311
|
+
document.removeEventListener('nac:action:succeeded', onSucceeded);
|
|
2312
|
+
document.removeEventListener('nac:action:failed', onFailed);
|
|
2313
|
+
clearTimeout(timer);
|
|
2314
|
+
}
|
|
2315
|
+
document.addEventListener('nac:action:succeeded', onSucceeded);
|
|
2316
|
+
document.addEventListener('nac:action:failed', onFailed);
|
|
2317
|
+
});
|
|
2318
|
+
|
|
2319
|
+
/* Dispatch the request event. Bubbles so the host can listen
|
|
2320
|
+
on document if it prefers a single handler for all actions
|
|
2321
|
+
(matches how the existing :succeeded / :failed contracts
|
|
2322
|
+
work today). detail.payload is opaque to the runtime; only
|
|
2323
|
+
the host knows what shape to expect for its own verb. */
|
|
2324
|
+
el.dispatchEvent(new CustomEvent('nac:action:requested', {
|
|
2325
|
+
bubbles: true,
|
|
2326
|
+
detail: {
|
|
2327
|
+
action_id: action_id,
|
|
2328
|
+
verb: verb,
|
|
2329
|
+
payload: payload,
|
|
2330
|
+
plugin: plugin,
|
|
2331
|
+
request_id: request_id,
|
|
2332
|
+
ts: Date.now(),
|
|
2333
|
+
},
|
|
2334
|
+
}));
|
|
2335
|
+
|
|
2336
|
+
return result;
|
|
2337
|
+
}
|
|
2338
|
+
|
|
2339
|
+
/* Ergonomic shortcut for the most common payload-bearing verb.
|
|
2340
|
+
Equivalent to invoke(id, {verb:'utter', text, lang, voice}). */
|
|
2341
|
+
async function utter(action_id, opts) {
|
|
2342
|
+
if (!opts || typeof opts !== 'object') {
|
|
2343
|
+
throw NacError('invalid', 'utter requires an opts object with at least "text"');
|
|
2344
|
+
}
|
|
2345
|
+
if (!opts.text || typeof opts.text !== 'string') {
|
|
2346
|
+
throw NacError('invalid', 'utter requires opts.text (string)');
|
|
2347
|
+
}
|
|
2348
|
+
return await invoke(action_id, {
|
|
2349
|
+
verb: 'utter',
|
|
2350
|
+
text: opts.text,
|
|
2351
|
+
lang: opts.lang || null,
|
|
2352
|
+
voice: opts.voice || null,
|
|
2353
|
+
metadata: opts.metadata || null,
|
|
2354
|
+
}, opts);
|
|
2355
|
+
}
|
|
2356
|
+
|
|
2212
2357
|
async function tab_by_label(plugin, label, opts) {
|
|
2213
2358
|
if (!label) throw NacError('invalid', 'tab_by_label requires a label');
|
|
2214
2359
|
const targetPlugin = plugin || _activePlugin();
|
|
@@ -5008,8 +5153,8 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
|
|
|
5008
5153
|
|
|
5009
5154
|
global.NAC = {
|
|
5010
5155
|
__nac_v1_installed: true,
|
|
5011
|
-
version: '2.2
|
|
5012
|
-
spec_version: '2.
|
|
5156
|
+
version: '2.3.0-alpha.2',
|
|
5157
|
+
spec_version: '2.3',
|
|
5013
5158
|
/* v2.2.0 (V22-01) -- strict validation toggle. When true,
|
|
5014
5159
|
NAC.register throws on findings (manifest_role_unknown,
|
|
5015
5160
|
tab_id_manifest_role_drift, manifest_dom_role_mismatch).
|
|
@@ -5056,6 +5201,15 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
|
|
|
5056
5201
|
/* v1.4.1 -- voice/agent ergonomic helpers */
|
|
5057
5202
|
click_by_verb: click_by_verb,
|
|
5058
5203
|
tab_by_label: tab_by_label,
|
|
5204
|
+
/* v2.3.0 -- payload-bearing actions. invoke() is the generic
|
|
5205
|
+
primitive: dispatches nac:action:requested with the agent's
|
|
5206
|
+
payload and resolves on nac:action:succeeded/:failed matching
|
|
5207
|
+
the request_id. utter() is the ergonomic shortcut for the
|
|
5208
|
+
conversational verb pattern (the first concrete adopter is
|
|
5209
|
+
Atlas Pro's mic). Both are additive on top of click()/click_by_verb()
|
|
5210
|
+
and do not change existing demo behaviour. */
|
|
5211
|
+
invoke: invoke,
|
|
5212
|
+
utter: utter,
|
|
5059
5213
|
/* utility */
|
|
5060
5214
|
wait_for: wait_for,
|
|
5061
5215
|
screenshot: screenshot,
|
package/dist/nac.mjs
CHANGED
|
@@ -2209,6 +2209,151 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
|
|
|
2209
2209
|
targetPlugin ? { plugin: targetPlugin } : {}));
|
|
2210
2210
|
}
|
|
2211
2211
|
|
|
2212
|
+
/* ============================================================
|
|
2213
|
+
v2.3.0 -- NAC.invoke / NAC.utter (action payload contract)
|
|
2214
|
+
============================================================
|
|
2215
|
+
NAC v2.2 actions are click-and-go: NAC.click(id) /
|
|
2216
|
+
NAC.click_by_verb(plugin, verb) trigger a click; the host
|
|
2217
|
+
handles it; the runtime polls for nac:action:succeeded.
|
|
2218
|
+
|
|
2219
|
+
This works for verb-and-state actions (save, cancel, delete)
|
|
2220
|
+
but collapses when the action needs DATA from the agent:
|
|
2221
|
+
utter(text), search(query), send_message(body), upload(file),
|
|
2222
|
+
schedule(date), translate(text, target_lang). The host has
|
|
2223
|
+
no way to receive the agent's payload via a synthetic click.
|
|
2224
|
+
|
|
2225
|
+
v2.3 closes this gap. NAC.invoke(action_id, payload) dispatches
|
|
2226
|
+
a 'nac:action:requested' CustomEvent on the host element with
|
|
2227
|
+
the payload + a correlation request_id. The host listens,
|
|
2228
|
+
processes, and emits 'nac:action:succeeded' (or :failed) with
|
|
2229
|
+
the matching request_id. The runtime resolves the Promise.
|
|
2230
|
+
|
|
2231
|
+
Click-style verbs continue to work unchanged via click() /
|
|
2232
|
+
click_by_verb(). invoke is purely additive.
|
|
2233
|
+
|
|
2234
|
+
Atlas Pro is the reference adopter: its 'utter' verb on
|
|
2235
|
+
'atlas_pro_ad.mic' accepts {text, lang} and routes into the
|
|
2236
|
+
existing /parse + /tts conversational loop. */
|
|
2237
|
+
|
|
2238
|
+
async function invoke(action_id, payload, opts) {
|
|
2239
|
+
if (!action_id || typeof action_id !== 'string') {
|
|
2240
|
+
throw NacError('invalid', 'invoke requires an action_id');
|
|
2241
|
+
}
|
|
2242
|
+
if (payload == null || typeof payload !== 'object') {
|
|
2243
|
+
throw NacError('invalid', 'invoke requires a payload object');
|
|
2244
|
+
}
|
|
2245
|
+
const el = _findElement(action_id, opts);
|
|
2246
|
+
if (!el) {
|
|
2247
|
+
_emitCommandRejected({
|
|
2248
|
+
command_method: 'invoke',
|
|
2249
|
+
command_target: action_id,
|
|
2250
|
+
reason: 'not_found',
|
|
2251
|
+
message: 'No element with nac_id=' + action_id,
|
|
2252
|
+
source: (opts && opts.source) || undefined,
|
|
2253
|
+
});
|
|
2254
|
+
throw NacError('not_found', 'No element with nac_id=' + action_id);
|
|
2255
|
+
}
|
|
2256
|
+
/* invoke deliberately does NOT enforce visibility OR disabled --
|
|
2257
|
+
the canonical use case is a mic / search / upload widget
|
|
2258
|
+
that may live outside the visible viewport or be visually
|
|
2259
|
+
disabled while a previous request is processing, but is
|
|
2260
|
+
still a valid NAC target (the agent's request is a logical
|
|
2261
|
+
message, not a synthetic click). Hosts that need to refuse
|
|
2262
|
+
an invoke based on UI state should do it in their
|
|
2263
|
+
nac:action:requested listener and emit nac:action:failed
|
|
2264
|
+
with a meaningful error code. */
|
|
2265
|
+
const verb = (payload && payload.verb)
|
|
2266
|
+
|| el.getAttribute('data-nac-action')
|
|
2267
|
+
|| '';
|
|
2268
|
+
const pluginRoot = el.closest('[data-nac-plugin]');
|
|
2269
|
+
const plugin = pluginRoot
|
|
2270
|
+
? pluginRoot.getAttribute('data-nac-plugin')
|
|
2271
|
+
: null;
|
|
2272
|
+
const request_id = 'nac_inv_'
|
|
2273
|
+
+ Math.random().toString(36).slice(2, 12)
|
|
2274
|
+
+ '_' + Date.now();
|
|
2275
|
+
const timeout_ms = (opts && opts.timeout) || 30000;
|
|
2276
|
+
|
|
2277
|
+
const result = new Promise(function (resolve, reject) {
|
|
2278
|
+
let settled = false;
|
|
2279
|
+
function matchesReq(e) {
|
|
2280
|
+
return e && e.detail && e.detail.request_id === request_id;
|
|
2281
|
+
}
|
|
2282
|
+
function onSucceeded(e) {
|
|
2283
|
+
if (settled) return;
|
|
2284
|
+
if (!matchesReq(e)) return;
|
|
2285
|
+
settled = true;
|
|
2286
|
+
cleanup();
|
|
2287
|
+
resolve({
|
|
2288
|
+
ok: true,
|
|
2289
|
+
request_id: request_id,
|
|
2290
|
+
ack: e.detail || null,
|
|
2291
|
+
});
|
|
2292
|
+
}
|
|
2293
|
+
function onFailed(e) {
|
|
2294
|
+
if (settled) return;
|
|
2295
|
+
if (!matchesReq(e)) return;
|
|
2296
|
+
settled = true;
|
|
2297
|
+
cleanup();
|
|
2298
|
+
const code = (e.detail && e.detail.error) || 'failed';
|
|
2299
|
+
reject(NacError(code,
|
|
2300
|
+
'invoke failed for ' + action_id
|
|
2301
|
+
+ ((e.detail && e.detail.message) ? ': ' + e.detail.message : '')));
|
|
2302
|
+
}
|
|
2303
|
+
const timer = setTimeout(function () {
|
|
2304
|
+
if (settled) return;
|
|
2305
|
+
settled = true;
|
|
2306
|
+
cleanup();
|
|
2307
|
+
reject(NacError('timeout',
|
|
2308
|
+
'invoke timeout after ' + timeout_ms + 'ms for ' + action_id));
|
|
2309
|
+
}, timeout_ms);
|
|
2310
|
+
function cleanup() {
|
|
2311
|
+
document.removeEventListener('nac:action:succeeded', onSucceeded);
|
|
2312
|
+
document.removeEventListener('nac:action:failed', onFailed);
|
|
2313
|
+
clearTimeout(timer);
|
|
2314
|
+
}
|
|
2315
|
+
document.addEventListener('nac:action:succeeded', onSucceeded);
|
|
2316
|
+
document.addEventListener('nac:action:failed', onFailed);
|
|
2317
|
+
});
|
|
2318
|
+
|
|
2319
|
+
/* Dispatch the request event. Bubbles so the host can listen
|
|
2320
|
+
on document if it prefers a single handler for all actions
|
|
2321
|
+
(matches how the existing :succeeded / :failed contracts
|
|
2322
|
+
work today). detail.payload is opaque to the runtime; only
|
|
2323
|
+
the host knows what shape to expect for its own verb. */
|
|
2324
|
+
el.dispatchEvent(new CustomEvent('nac:action:requested', {
|
|
2325
|
+
bubbles: true,
|
|
2326
|
+
detail: {
|
|
2327
|
+
action_id: action_id,
|
|
2328
|
+
verb: verb,
|
|
2329
|
+
payload: payload,
|
|
2330
|
+
plugin: plugin,
|
|
2331
|
+
request_id: request_id,
|
|
2332
|
+
ts: Date.now(),
|
|
2333
|
+
},
|
|
2334
|
+
}));
|
|
2335
|
+
|
|
2336
|
+
return result;
|
|
2337
|
+
}
|
|
2338
|
+
|
|
2339
|
+
/* Ergonomic shortcut for the most common payload-bearing verb.
|
|
2340
|
+
Equivalent to invoke(id, {verb:'utter', text, lang, voice}). */
|
|
2341
|
+
async function utter(action_id, opts) {
|
|
2342
|
+
if (!opts || typeof opts !== 'object') {
|
|
2343
|
+
throw NacError('invalid', 'utter requires an opts object with at least "text"');
|
|
2344
|
+
}
|
|
2345
|
+
if (!opts.text || typeof opts.text !== 'string') {
|
|
2346
|
+
throw NacError('invalid', 'utter requires opts.text (string)');
|
|
2347
|
+
}
|
|
2348
|
+
return await invoke(action_id, {
|
|
2349
|
+
verb: 'utter',
|
|
2350
|
+
text: opts.text,
|
|
2351
|
+
lang: opts.lang || null,
|
|
2352
|
+
voice: opts.voice || null,
|
|
2353
|
+
metadata: opts.metadata || null,
|
|
2354
|
+
}, opts);
|
|
2355
|
+
}
|
|
2356
|
+
|
|
2212
2357
|
async function tab_by_label(plugin, label, opts) {
|
|
2213
2358
|
if (!label) throw NacError('invalid', 'tab_by_label requires a label');
|
|
2214
2359
|
const targetPlugin = plugin || _activePlugin();
|
|
@@ -5008,8 +5153,8 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
|
|
|
5008
5153
|
|
|
5009
5154
|
global.NAC = {
|
|
5010
5155
|
__nac_v1_installed: true,
|
|
5011
|
-
version: '2.2
|
|
5012
|
-
spec_version: '2.
|
|
5156
|
+
version: '2.3.0-alpha.2',
|
|
5157
|
+
spec_version: '2.3',
|
|
5013
5158
|
/* v2.2.0 (V22-01) -- strict validation toggle. When true,
|
|
5014
5159
|
NAC.register throws on findings (manifest_role_unknown,
|
|
5015
5160
|
tab_id_manifest_role_drift, manifest_dom_role_mismatch).
|
|
@@ -5056,6 +5201,15 @@ const _g = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== '
|
|
|
5056
5201
|
/* v1.4.1 -- voice/agent ergonomic helpers */
|
|
5057
5202
|
click_by_verb: click_by_verb,
|
|
5058
5203
|
tab_by_label: tab_by_label,
|
|
5204
|
+
/* v2.3.0 -- payload-bearing actions. invoke() is the generic
|
|
5205
|
+
primitive: dispatches nac:action:requested with the agent's
|
|
5206
|
+
payload and resolves on nac:action:succeeded/:failed matching
|
|
5207
|
+
the request_id. utter() is the ergonomic shortcut for the
|
|
5208
|
+
conversational verb pattern (the first concrete adopter is
|
|
5209
|
+
Atlas Pro's mic). Both are additive on top of click()/click_by_verb()
|
|
5210
|
+
and do not change existing demo behaviour. */
|
|
5211
|
+
invoke: invoke,
|
|
5212
|
+
utter: utter,
|
|
5059
5213
|
/* utility */
|
|
5060
5214
|
wait_for: wait_for,
|
|
5061
5215
|
screenshot: screenshot,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nac3/runtime",
|
|
3
|
-
"version": "2.2
|
|
3
|
+
"version": "2.3.0-alpha.2",
|
|
4
4
|
"description": "Native Agent Contract -- spec + reference runtime that lets web UIs be driven by AI agents, voice runners, and accessibility tools.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"nac",
|
|
@@ -66,9 +66,10 @@
|
|
|
66
66
|
],
|
|
67
67
|
"scripts": {
|
|
68
68
|
"build": "node ./build.mjs",
|
|
69
|
-
"test": "node ./test/smoke.mjs && node ./test/v22.mjs",
|
|
70
|
-
"test:smoke":
|
|
71
|
-
"test:v22":
|
|
69
|
+
"test": "node ./test/smoke.mjs && node ./test/v22.mjs && node ./test/v23-invoke.mjs",
|
|
70
|
+
"test:smoke": "node ./test/smoke.mjs",
|
|
71
|
+
"test:v22": "node ./test/v22.mjs",
|
|
72
|
+
"test:v23": "node ./test/v23-invoke.mjs",
|
|
72
73
|
"prepublishOnly": "npm run build && npm test"
|
|
73
74
|
},
|
|
74
75
|
"engines": {
|