@nac3/runtime 2.5.0-alpha.5 → 2.5.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 +1017 -887
- package/README.md +145 -145
- package/SPEC.md +1761 -1442
- package/contract-head.json +16 -0
- package/dist/cli-levels.json +214 -0
- package/dist/cli-url.mjs +751 -0
- package/dist/cli.js +232 -38
- package/dist/nac-chat-client.d.ts +5 -75
- package/dist/nac-v2-extensions.d.ts +71 -68
- package/dist/nac.browser.js +118 -31
- package/dist/nac.cjs +118 -31
- package/dist/nac.d.ts +140 -34
- package/dist/nac.mjs +118 -31
- package/package.json +19 -19
package/README.md
CHANGED
|
@@ -1,145 +1,145 @@
|
|
|
1
|
-
# @nac3/runtime
|
|
2
|
-
|
|
3
|
-
**Native Agent Contract** -- a small public spec + reference runtime
|
|
4
|
-
that lets web UIs be driven by AI assistants, voice runners, and
|
|
5
|
-
accessibility tools without per-app glue code.
|
|
6
|
-
|
|
7
|
-
```
|
|
8
|
-
npm install @nac3/runtime
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## What you get
|
|
12
|
-
|
|
13
|
-
- The reference runtime (`window.NAC` API).
|
|
14
|
-
- The v2.0 brownfield extensions (scope tree, ephemeral capture,
|
|
15
|
-
HMAC, isTrusted).
|
|
16
|
-
- A reference chat client that wires voice + LLM + dispatcher.
|
|
17
|
-
- A CLI (`npx nac validate <dir>`) that statically lints HTML/PHP
|
|
18
|
-
for NAC contract violations.
|
|
19
|
-
- TypeScript types.
|
|
20
|
-
|
|
21
|
-
## Hello world (vanilla)
|
|
22
|
-
|
|
23
|
-
```html
|
|
24
|
-
<script type="module">
|
|
25
|
-
import '@nac3/runtime';
|
|
26
|
-
// Now window.NAC is ready.
|
|
27
|
-
NAC.register({
|
|
28
|
-
plugin_slug: 'demo',
|
|
29
|
-
nac_version: '2.1',
|
|
30
|
-
elements: [
|
|
31
|
-
{ id: 'demo.greet', role: 'action',
|
|
32
|
-
actions: [{ verb: 'greet',
|
|
33
|
-
label_i18n: { es: 'Saludar', en: 'Greet',
|
|
34
|
-
pt: 'Saudar', fr: 'Saluer',
|
|
35
|
-
it: 'Saluta', de: 'Begrussen',
|
|
36
|
-
ja: '挨拶', zh: '问候',
|
|
37
|
-
hi: 'namaste', ar: 'حيي' } }] }
|
|
38
|
-
]
|
|
39
|
-
});
|
|
40
|
-
</script>
|
|
41
|
-
|
|
42
|
-
<button data-nac-id="demo.greet" data-nac-role="action"
|
|
43
|
-
data-nac-action="greet" onclick="alert('hi')">
|
|
44
|
-
Greet
|
|
45
|
-
</button>
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
Now any agent can drive the button:
|
|
49
|
-
|
|
50
|
-
```js
|
|
51
|
-
await NAC.click('demo.greet');
|
|
52
|
-
// or by verb:
|
|
53
|
-
await NAC.click_by_verb('demo', 'greet');
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
## React
|
|
57
|
-
|
|
58
|
-
See `guides/REACT.md` in the spec repo for the full story; minimal
|
|
59
|
-
shape:
|
|
60
|
-
|
|
61
|
-
```jsx
|
|
62
|
-
import { useEffect } from 'react';
|
|
63
|
-
import '@nac3/runtime';
|
|
64
|
-
|
|
65
|
-
export function Greet() {
|
|
66
|
-
useEffect(() => {
|
|
67
|
-
window.NAC.register({
|
|
68
|
-
plugin_slug: 'demo', nac_version: '2.1',
|
|
69
|
-
elements: [{ id: 'demo.greet', role: 'action',
|
|
70
|
-
actions: [{ verb: 'greet', label_i18n: {/* ...10 locales... */} }] }]
|
|
71
|
-
});
|
|
72
|
-
}, []);
|
|
73
|
-
|
|
74
|
-
return (
|
|
75
|
-
<button
|
|
76
|
-
data-nac-id="demo.greet"
|
|
77
|
-
data-nac-role="action"
|
|
78
|
-
data-nac-action="greet"
|
|
79
|
-
onClick={() => alert('hi')}
|
|
80
|
-
>
|
|
81
|
-
Greet
|
|
82
|
-
</button>
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
## CLI
|
|
88
|
-
|
|
89
|
-
```
|
|
90
|
-
npx @nac3/runtime validate ./src
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
Static lint over your HTML/PHP. Reports:
|
|
94
|
-
|
|
95
|
-
- `tab_role_drift` -- a `data-nac-id="tab.X"` without
|
|
96
|
-
`data-nac-role="tab"`.
|
|
97
|
-
- `manifest_role_unknown` -- a manifest element with a role outside
|
|
98
|
-
the canonical set.
|
|
99
|
-
- `manifest_dom_role_mismatch` -- the manifest declares a role that
|
|
100
|
-
contradicts the DOM role on the same id.
|
|
101
|
-
- `tab_id_manifest_role_drift` -- manifest entry id like `tab.X`
|
|
102
|
-
but the entry's role isn't `'tab'`.
|
|
103
|
-
|
|
104
|
-
Exit codes:
|
|
105
|
-
|
|
106
|
-
- `0` -- no findings at the configured severity (default `error`).
|
|
107
|
-
- `1` -- findings at or above the configured severity.
|
|
108
|
-
- `2` -- target not found / argument error.
|
|
109
|
-
|
|
110
|
-
## Subpath imports
|
|
111
|
-
|
|
112
|
-
```js
|
|
113
|
-
import NAC from '@nac3/runtime';
|
|
114
|
-
import '@nac3/runtime/extensions'; // v2.0 brownfield primitives
|
|
115
|
-
import '@nac3/runtime/chat-client'; // reference voice + chat client
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
## Status
|
|
119
|
-
|
|
120
|
-
- **v2.4.0 stable** (2026-05-21). Zero-silent-damage strict resolution
|
|
121
|
-
+ disambiguation contract: `click_by_verb` / `tab` / `tab_by_label`
|
|
122
|
-
throw `NacError` with `err.candidates` and emit
|
|
123
|
-
`nac:disambiguation_requested` instead of guessing the wrong element.
|
|
124
|
-
See `CHANGELOG.md` for the full migration note.
|
|
125
|
-
- Previous stable: v2.3.1 (payload-bearing actions, F1-F7).
|
|
126
|
-
- Earlier: v2.2 (strict validator, bindAction), v2.1 (data-table),
|
|
127
|
-
v2.0 (scope tree + ephemeral capture).
|
|
128
|
-
|
|
129
|
-
## Spec
|
|
130
|
-
|
|
131
|
-
`SPEC.md` is included in the package. The canonical spec lives at
|
|
132
|
-
[yujin.app/nac-spec](https://yujin.app/nac-spec/).
|
|
133
|
-
|
|
134
|
-
## License
|
|
135
|
-
|
|
136
|
-
Apache-2.0. See `LICENSE`.
|
|
137
|
-
|
|
138
|
-
## Repository
|
|
139
|
-
|
|
140
|
-
[github.com/yujinapp/nac-spec](https://github.com/yujinapp/nac-spec)
|
|
141
|
-
(directory: `runtime/`)
|
|
142
|
-
|
|
143
|
-
## Author
|
|
144
|
-
|
|
145
|
-
[Yujin](https://yujin.app)
|
|
1
|
+
# @nac3/runtime
|
|
2
|
+
|
|
3
|
+
**Native Agent Contract** -- a small public spec + reference runtime
|
|
4
|
+
that lets web UIs be driven by AI assistants, voice runners, and
|
|
5
|
+
accessibility tools without per-app glue code.
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
npm install @nac3/runtime
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## What you get
|
|
12
|
+
|
|
13
|
+
- The reference runtime (`window.NAC` API).
|
|
14
|
+
- The v2.0 brownfield extensions (scope tree, ephemeral capture,
|
|
15
|
+
HMAC, isTrusted).
|
|
16
|
+
- A reference chat client that wires voice + LLM + dispatcher.
|
|
17
|
+
- A CLI (`npx nac validate <dir>`) that statically lints HTML/PHP
|
|
18
|
+
for NAC contract violations.
|
|
19
|
+
- TypeScript types.
|
|
20
|
+
|
|
21
|
+
## Hello world (vanilla)
|
|
22
|
+
|
|
23
|
+
```html
|
|
24
|
+
<script type="module">
|
|
25
|
+
import '@nac3/runtime';
|
|
26
|
+
// Now window.NAC is ready.
|
|
27
|
+
NAC.register({
|
|
28
|
+
plugin_slug: 'demo',
|
|
29
|
+
nac_version: '2.1',
|
|
30
|
+
elements: [
|
|
31
|
+
{ id: 'demo.greet', role: 'action',
|
|
32
|
+
actions: [{ verb: 'greet',
|
|
33
|
+
label_i18n: { es: 'Saludar', en: 'Greet',
|
|
34
|
+
pt: 'Saudar', fr: 'Saluer',
|
|
35
|
+
it: 'Saluta', de: 'Begrussen',
|
|
36
|
+
ja: '挨拶', zh: '问候',
|
|
37
|
+
hi: 'namaste', ar: 'حيي' } }] }
|
|
38
|
+
]
|
|
39
|
+
});
|
|
40
|
+
</script>
|
|
41
|
+
|
|
42
|
+
<button data-nac-id="demo.greet" data-nac-role="action"
|
|
43
|
+
data-nac-action="greet" onclick="alert('hi')">
|
|
44
|
+
Greet
|
|
45
|
+
</button>
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Now any agent can drive the button:
|
|
49
|
+
|
|
50
|
+
```js
|
|
51
|
+
await NAC.click('demo.greet');
|
|
52
|
+
// or by verb:
|
|
53
|
+
await NAC.click_by_verb('demo', 'greet');
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## React
|
|
57
|
+
|
|
58
|
+
See `guides/REACT.md` in the spec repo for the full story; minimal
|
|
59
|
+
shape:
|
|
60
|
+
|
|
61
|
+
```jsx
|
|
62
|
+
import { useEffect } from 'react';
|
|
63
|
+
import '@nac3/runtime';
|
|
64
|
+
|
|
65
|
+
export function Greet() {
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
window.NAC.register({
|
|
68
|
+
plugin_slug: 'demo', nac_version: '2.1',
|
|
69
|
+
elements: [{ id: 'demo.greet', role: 'action',
|
|
70
|
+
actions: [{ verb: 'greet', label_i18n: {/* ...10 locales... */} }] }]
|
|
71
|
+
});
|
|
72
|
+
}, []);
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
<button
|
|
76
|
+
data-nac-id="demo.greet"
|
|
77
|
+
data-nac-role="action"
|
|
78
|
+
data-nac-action="greet"
|
|
79
|
+
onClick={() => alert('hi')}
|
|
80
|
+
>
|
|
81
|
+
Greet
|
|
82
|
+
</button>
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## CLI
|
|
88
|
+
|
|
89
|
+
```
|
|
90
|
+
npx @nac3/runtime validate ./src
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Static lint over your HTML/PHP. Reports:
|
|
94
|
+
|
|
95
|
+
- `tab_role_drift` -- a `data-nac-id="tab.X"` without
|
|
96
|
+
`data-nac-role="tab"`.
|
|
97
|
+
- `manifest_role_unknown` -- a manifest element with a role outside
|
|
98
|
+
the canonical set.
|
|
99
|
+
- `manifest_dom_role_mismatch` -- the manifest declares a role that
|
|
100
|
+
contradicts the DOM role on the same id.
|
|
101
|
+
- `tab_id_manifest_role_drift` -- manifest entry id like `tab.X`
|
|
102
|
+
but the entry's role isn't `'tab'`.
|
|
103
|
+
|
|
104
|
+
Exit codes:
|
|
105
|
+
|
|
106
|
+
- `0` -- no findings at the configured severity (default `error`).
|
|
107
|
+
- `1` -- findings at or above the configured severity.
|
|
108
|
+
- `2` -- target not found / argument error.
|
|
109
|
+
|
|
110
|
+
## Subpath imports
|
|
111
|
+
|
|
112
|
+
```js
|
|
113
|
+
import NAC from '@nac3/runtime';
|
|
114
|
+
import '@nac3/runtime/extensions'; // v2.0 brownfield primitives
|
|
115
|
+
import '@nac3/runtime/chat-client'; // reference voice + chat client
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## Status
|
|
119
|
+
|
|
120
|
+
- **v2.4.0 stable** (2026-05-21). Zero-silent-damage strict resolution
|
|
121
|
+
+ disambiguation contract: `click_by_verb` / `tab` / `tab_by_label`
|
|
122
|
+
throw `NacError` with `err.candidates` and emit
|
|
123
|
+
`nac:disambiguation_requested` instead of guessing the wrong element.
|
|
124
|
+
See `CHANGELOG.md` for the full migration note.
|
|
125
|
+
- Previous stable: v2.3.1 (payload-bearing actions, F1-F7).
|
|
126
|
+
- Earlier: v2.2 (strict validator, bindAction), v2.1 (data-table),
|
|
127
|
+
v2.0 (scope tree + ephemeral capture).
|
|
128
|
+
|
|
129
|
+
## Spec
|
|
130
|
+
|
|
131
|
+
`SPEC.md` is included in the package. The canonical spec lives at
|
|
132
|
+
[yujin.app/nac-spec](https://yujin.app/nac-spec/).
|
|
133
|
+
|
|
134
|
+
## License
|
|
135
|
+
|
|
136
|
+
Apache-2.0. See `LICENSE`.
|
|
137
|
+
|
|
138
|
+
## Repository
|
|
139
|
+
|
|
140
|
+
[github.com/yujinapp/nac-spec](https://github.com/yujinapp/nac-spec)
|
|
141
|
+
(directory: `runtime/`)
|
|
142
|
+
|
|
143
|
+
## Author
|
|
144
|
+
|
|
145
|
+
[Yujin](https://yujin.app)
|