@nac3/runtime 2.4.0 → 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 +134 -0
- package/SPEC.md +321 -5
- package/dist/nac.browser.js +1231 -113
- package/dist/nac.cjs +1231 -113
- package/dist/nac.mjs +1231 -113
- package/package.json +6 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,139 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
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
|
+
|
|
3
137
|
## 2.4.0 -- 2026-05-21
|
|
4
138
|
|
|
5
139
|
NAC3 v2.4.0 is a **behavior-of-contract change**: id / verb / qualifier
|
package/SPEC.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# NAC3 -- Native Agent Contract
|
|
2
2
|
|
|
3
|
-
**Version:** 2.
|
|
4
|
-
**Status:** v2.
|
|
3
|
+
**Version:** 2.5.0-alpha.1 (consolidation alpha: Block A canvas+API + V24-01/02/05 RFCs alongside v2.4 strict resolution)
|
|
4
|
+
**Status:** v2.5.0-alpha.1 alpha -- consolidates parallel dev lines, V24-04 OCC still in implementation for alpha.2
|
|
5
5
|
**License:** Apache-2.0
|
|
6
|
-
**Editor:** Yujin (
|
|
6
|
+
**Editor:** Yujin (yujin.app)
|
|
7
7
|
|
|
8
8
|
---
|
|
9
9
|
|
|
@@ -1050,6 +1050,322 @@ code, is the authority.
|
|
|
1050
1050
|
|
|
1051
1051
|
---
|
|
1052
1052
|
|
|
1053
|
-
|
|
1054
|
-
|
|
1053
|
+
## 15. Plugin extension contract -- canvas + API surfaces (v2.5)
|
|
1054
|
+
|
|
1055
|
+
Sections 1-14 assume the agent-relevant surface is **DOM**. Every
|
|
1056
|
+
addressable element has a `data-nac-id` attribute, every verb fires
|
|
1057
|
+
through `el.click()`, every state read comes from
|
|
1058
|
+
`el.getAttribute(...)`. This works for apps whose chrome AND
|
|
1059
|
+
content live in DOM nodes.
|
|
1060
|
+
|
|
1061
|
+
It does not work for apps where part of the surface is **canvas**
|
|
1062
|
+
(LibreOffice / Collabora Online, Figma, Excalidraw, Miro, every
|
|
1063
|
+
custom WebGL editor). The chrome may still be DOM (toolbars,
|
|
1064
|
+
dialogs), but commands often need to flow through the app's own
|
|
1065
|
+
public API (postMessage, plugin SDK, script bridge), and state may
|
|
1066
|
+
not be readable from the DOM at all.
|
|
1067
|
+
|
|
1068
|
+
v2.5 adds a small set of primitives that let a NAC3 plugin declare
|
|
1069
|
+
its own routing contract to such surfaces. The runtime stays
|
|
1070
|
+
agnostic of any specific app -- it learns how to talk to one only
|
|
1071
|
+
by reading the plugin's manifest.
|
|
1072
|
+
|
|
1073
|
+
### 15.1 Why a new primitive set
|
|
1074
|
+
|
|
1075
|
+
DOM-only `NAC.click(id)` cannot:
|
|
1076
|
+
|
|
1077
|
+
- Send a `Send_UNO_Command` postMessage to a sandboxed Collabora
|
|
1078
|
+
iframe.
|
|
1079
|
+
- Call `figma.currentPage.selection = [...]` inside the Figma
|
|
1080
|
+
plugin sandbox.
|
|
1081
|
+
- Invoke `excalidrawAPI.setElements(...)` on a React ref.
|
|
1082
|
+
- Read whether Bold is active on the current Collabora selection
|
|
1083
|
+
(the toolbar reflects it; the canvas hides it).
|
|
1084
|
+
|
|
1085
|
+
The fix is **not** to extend `NAC.click` with backend-detection
|
|
1086
|
+
heuristics. The fix is to add an explicit, agnostic verb that
|
|
1087
|
+
takes a plugin slug and a verb path, and lets the plugin's
|
|
1088
|
+
manifest declare how that verb is routed.
|
|
1089
|
+
|
|
1090
|
+
### 15.2 The three primitives
|
|
1091
|
+
|
|
1092
|
+
```ts
|
|
1093
|
+
NAC.registerPlugin(slug: string, manifest: PluginManifest): void
|
|
1094
|
+
NAC.call(plugin: string, verb_path: string, args?: object): Promise<any>
|
|
1095
|
+
NAC.read(plugin: string, state_path: string): Promise<any>
|
|
1096
|
+
NAC.subscribe(plugin: string, event_path: string,
|
|
1097
|
+
cb: (data: any) => void): SubscriptionHandle
|
|
1098
|
+
NAC.unsubscribe(handle: SubscriptionHandle): void
|
|
1099
|
+
```
|
|
1100
|
+
|
|
1101
|
+
- `registerPlugin(slug, manifest)` registers a v2.5 plugin. A given
|
|
1102
|
+
`slug` MAY appear in both the DOM manifest registry (section 5)
|
|
1103
|
+
and the v2.5 extension registry; the two coexist. v2.5 calls
|
|
1104
|
+
resolve only through the v2.5 registry.
|
|
1105
|
+
- `call` invokes a declared verb. Routing is chosen by the
|
|
1106
|
+
manifest, not by the agent. Resolves with whatever the backend
|
|
1107
|
+
returned (often `undefined` / `{ok: true}`); rejects with
|
|
1108
|
+
`NacError` if the verb is unknown, the backend fails, or the
|
|
1109
|
+
response shape is invalid.
|
|
1110
|
+
- `read` returns a declared state value. The runtime walks the
|
|
1111
|
+
state's fallback chain in declared order and returns the first
|
|
1112
|
+
source that resolves; rejects only when every source in the
|
|
1113
|
+
chain failed.
|
|
1114
|
+
- `subscribe` attaches a listener to a declared event. Returns a
|
|
1115
|
+
handle that the caller passes to `unsubscribe` to clean up.
|
|
1116
|
+
Events MAY be backed by a real upstream event source or
|
|
1117
|
+
synthesised via polling / MutationObserver -- the manifest
|
|
1118
|
+
declares which.
|
|
1119
|
+
|
|
1120
|
+
All four functions are async (Promise-returning) except
|
|
1121
|
+
`unsubscribe`, which is synchronous and idempotent.
|
|
1122
|
+
|
|
1123
|
+
### 15.3 Plugin manifest shape
|
|
1124
|
+
|
|
1125
|
+
```ts
|
|
1126
|
+
interface PluginManifest {
|
|
1127
|
+
slug: string;
|
|
1128
|
+
verbs: { [verb_path: string]: VerbBinding };
|
|
1129
|
+
state: { [state_path: string]: StateBinding[] };
|
|
1130
|
+
events: { [event_path: string]: EventBinding };
|
|
1131
|
+
}
|
|
1132
|
+
|
|
1133
|
+
interface VerbBinding {
|
|
1134
|
+
backend: BackendKind;
|
|
1135
|
+
/* backend-specific fields (see 15.4) */
|
|
1136
|
+
[k: string]: any;
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
interface StateBinding {
|
|
1140
|
+
backend: BackendKind;
|
|
1141
|
+
/* backend-specific fields (see 15.4) */
|
|
1142
|
+
extract?: string; /* extractor DSL string (see 15.5) */
|
|
1143
|
+
[k: string]: any;
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1146
|
+
interface EventBinding {
|
|
1147
|
+
backend: BackendKind;
|
|
1148
|
+
/* backend-specific fields */
|
|
1149
|
+
[k: string]: any;
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1152
|
+
type BackendKind =
|
|
1153
|
+
| 'postmessage'
|
|
1154
|
+
| 'postmessage-listen'
|
|
1155
|
+
| 'sdk-call'
|
|
1156
|
+
| 'script-bridge'
|
|
1157
|
+
| 'dom-mirror'
|
|
1158
|
+
| 'same-origin-window'
|
|
1159
|
+
| 'synthetic-mutation'
|
|
1160
|
+
| 'synthetic-poll';
|
|
1161
|
+
```
|
|
1162
|
+
|
|
1163
|
+
Manifests are pure JSON (no JS callbacks). Forge, Sumi, and any
|
|
1164
|
+
future tooling generates them as data; the runtime interprets the
|
|
1165
|
+
backend names from a fixed vocabulary.
|
|
1166
|
+
|
|
1167
|
+
Verbs and events have **exactly one** binding. State has an
|
|
1168
|
+
**ordered array** of bindings: the runtime walks the chain in
|
|
1169
|
+
order, returning the first source that successfully resolved.
|
|
1170
|
+
|
|
1171
|
+
### 15.4 Backend vocabulary
|
|
1172
|
+
|
|
1173
|
+
| Kind | Used for | Required fields |
|
|
1174
|
+
|------|----------|-----------------|
|
|
1175
|
+
| `postmessage` | Verb: post a message to an iframe via `postMessage`. | `target` (CSS selector of the iframe to send to), `message` (MessageId string), `values` (object literal interpolated with args), `values_from_args` (optional array of arg keys to forward verbatim) |
|
|
1176
|
+
| `postmessage-listen` | Event: listen for a specific incoming `MessageId` on `window.message`. | `source` (CSS selector of the iframe to filter origin by; if omitted, accept any source), `message` (MessageId to match), `extract` (extractor DSL into the message data) |
|
|
1177
|
+
| `sdk-call` | Verb: call a globally-exposed JS function (e.g. Figma plugin, Excalidraw API). | `path` (dotted path into `window`, e.g. `figma.currentPage.selection`), `mode` (`assign` to set the path to the args value, `invoke` to call it as a function with the args object) |
|
|
1178
|
+
| `script-bridge` | Verb or state: invoke an app's scripting bridge (Collabora's `CallPythonScript`, LibreOffice UNO bridge, Google Apps Script). | `bridge` (a backend-specific identifier like `collabora.python`), `script` (script identifier), `function` (function name to run), `args` (object literal interpolated with the call args), `response_match` (for state: the response MessageId to wait on), `timeout_ms` (optional, default 5000) |
|
|
1179
|
+
| `dom-mirror` | State: read from a DOM element whose attribute / class / text mirrors a canvas-internal state (e.g. a toolbar button highlighted when its formatting is active on the current selection). | `selector` (CSS selector to query), `extract` (extractor DSL, see 15.5) |
|
|
1180
|
+
| `same-origin-window` | State: read from `iframe.contentWindow.<path>` when the iframe is same-origin. The runtime detects cross-origin and falls through. | `target` (CSS selector of the iframe), `path` (dotted path into `contentWindow`) |
|
|
1181
|
+
| `synthetic-mutation` | Event: synthesise an event by observing DOM mutations on one or more state sources and re-emitting when the observed value changes. | `observe` (array of state paths to watch; the runtime calls `read` on each and diffs across mutations), `throttle_ms` (optional, default 100) |
|
|
1182
|
+
| `synthetic-poll` | Event: synthesise an event by polling state sources. | `observe` (array of state paths), `interval_ms` (default 250) |
|
|
1183
|
+
|
|
1184
|
+
Each backend MUST be implemented by the runtime as a self-contained
|
|
1185
|
+
dispatcher (`dispatch(binding, args, context) -> Promise<value>`).
|
|
1186
|
+
Adding a new backend type to the spec requires bumping the spec
|
|
1187
|
+
version; runtimes ignoring unknown backends MUST reject manifests
|
|
1188
|
+
that declare them (no silent skip).
|
|
1189
|
+
|
|
1190
|
+
### 15.5 Extractor mini-DSL
|
|
1191
|
+
|
|
1192
|
+
State backends and the `postmessage-listen` event backend often
|
|
1193
|
+
need to pluck a field out of a larger object. The runtime ships
|
|
1194
|
+
a tiny declarative DSL so manifests stay JSON-only:
|
|
1195
|
+
|
|
1196
|
+
| Syntax | Meaning | Example input -> output |
|
|
1197
|
+
|--------|---------|-------------------------|
|
|
1198
|
+
| `field.path.to.value` | Dotted path traversal. | `{a:{b:1}}` with `a.b` -> `1` |
|
|
1199
|
+
| `attribute:NAME` | DOM only: read `el.getAttribute(NAME)`. | `<i data-x="hi">` with `attribute:data-x` -> `'hi'` |
|
|
1200
|
+
| `text` | DOM only: read `el.textContent`. | `<span>hi</span>` with `text` -> `'hi'` |
|
|
1201
|
+
| `classList.contains:CLASS` | DOM only: `el.classList.contains(CLASS)` -> boolean. | `<button class="active">` with `classList.contains:active` -> `true` |
|
|
1202
|
+
| `value` | DOM only: read `el.value`. | `<input value="x">` with `value` -> `'x'` |
|
|
1203
|
+
| `present` | DOM only: returns `true` if the selector resolved an element, `false` otherwise. | selector matched -> `true` |
|
|
1204
|
+
|
|
1205
|
+
Composition is not supported in v2.5; an extractor is exactly one
|
|
1206
|
+
of the rows above. A manifest needing complex transformation
|
|
1207
|
+
declares a `script-bridge` instead.
|
|
1208
|
+
|
|
1209
|
+
### 15.6 Fallback chain semantics for `state`
|
|
1210
|
+
|
|
1211
|
+
`state[path]` is an array of bindings. `NAC.read(plugin, path)` walks
|
|
1212
|
+
the array in order. For each binding:
|
|
1213
|
+
|
|
1214
|
+
1. The runtime invokes the backend's dispatcher.
|
|
1215
|
+
2. If the dispatcher resolves with a value (including `false`, `0`,
|
|
1216
|
+
empty string, but NOT `undefined`), `read` returns that value.
|
|
1217
|
+
3. If the dispatcher rejects, or resolves with `undefined`, the
|
|
1218
|
+
runtime advances to the next binding in the array.
|
|
1219
|
+
4. If no binding produced a value, `read` rejects with
|
|
1220
|
+
`NacError('state_unreadable', ...)` whose `err.attempts: [...]`
|
|
1221
|
+
carries one entry per attempted backend with `{backend, reason}`.
|
|
1222
|
+
|
|
1223
|
+
Rationale: the chain encodes the manifest author's preference
|
|
1224
|
+
order. The fastest, cheapest, freshest source is declared first;
|
|
1225
|
+
fallbacks degrade gracefully. The runtime never silently picks an
|
|
1226
|
+
inferior source first.
|
|
1227
|
+
|
|
1228
|
+
### 15.7 Provenance for synthetic actions
|
|
1229
|
+
|
|
1230
|
+
Every `NAC.call` dispatch emits a `nac:plugin:invoked` event on
|
|
1231
|
+
`document` after the backend returns. The detail payload:
|
|
1232
|
+
|
|
1233
|
+
```js
|
|
1234
|
+
{
|
|
1235
|
+
plugin: 'collabora.writer',
|
|
1236
|
+
verb_path: 'uno.Bold',
|
|
1237
|
+
backend: 'postmessage',
|
|
1238
|
+
request_id: 'pi_<random hex>',
|
|
1239
|
+
source: 'agent', // see sec 7
|
|
1240
|
+
trusted: false,
|
|
1241
|
+
duration_ms: 12,
|
|
1242
|
+
ok: true,
|
|
1243
|
+
error: null,
|
|
1244
|
+
}
|
|
1245
|
+
```
|
|
1246
|
+
|
|
1247
|
+
Same shape for `nac:plugin:read` (after a `read`) and
|
|
1248
|
+
`nac:plugin:event` (synthesised event re-emit). `source` defaults
|
|
1249
|
+
to `'agent'`; hosts that wrap the runtime in a user-facing UI MAY
|
|
1250
|
+
override via the existing `NAC.set_source(...)` mechanism (sec 7).
|
|
1251
|
+
|
|
1252
|
+
### 15.8 Worked example -- Collabora Writer
|
|
1253
|
+
|
|
1254
|
+
```json
|
|
1255
|
+
{
|
|
1256
|
+
"slug": "collabora.writer",
|
|
1257
|
+
"verbs": {
|
|
1258
|
+
"uno.Bold": {
|
|
1259
|
+
"backend": "postmessage",
|
|
1260
|
+
"target": "iframe[data-collabora-frame]",
|
|
1261
|
+
"message": "Send_UNO_Command",
|
|
1262
|
+
"values": { "Command": ".uno:Bold" }
|
|
1263
|
+
},
|
|
1264
|
+
"doc.save": {
|
|
1265
|
+
"backend": "postmessage",
|
|
1266
|
+
"target": "iframe[data-collabora-frame]",
|
|
1267
|
+
"message": "Action_Save",
|
|
1268
|
+
"values_from_args": ["DontTerminateEdit", "Notify"]
|
|
1269
|
+
}
|
|
1270
|
+
},
|
|
1271
|
+
"state": {
|
|
1272
|
+
"selection.isBold": [
|
|
1273
|
+
{ "backend": "dom-mirror",
|
|
1274
|
+
"selector": "[data-nac-id='toolbar.bold']",
|
|
1275
|
+
"extract": "classList.contains:selected" },
|
|
1276
|
+
{ "backend": "script-bridge",
|
|
1277
|
+
"bridge": "collabora.python",
|
|
1278
|
+
"script": "yujin_state.py",
|
|
1279
|
+
"function": "GetSelectionState",
|
|
1280
|
+
"response_match": "CallPythonScript-Result",
|
|
1281
|
+
"extract": "Values.is_bold" }
|
|
1282
|
+
],
|
|
1283
|
+
"doc.modified": [
|
|
1284
|
+
{ "backend": "same-origin-window",
|
|
1285
|
+
"target": "iframe[data-collabora-frame]",
|
|
1286
|
+
"path": "app.file.modified" }
|
|
1287
|
+
]
|
|
1288
|
+
},
|
|
1289
|
+
"events": {
|
|
1290
|
+
"doc.modified": {
|
|
1291
|
+
"backend": "postmessage-listen",
|
|
1292
|
+
"source": "iframe[data-collabora-frame]",
|
|
1293
|
+
"message": "Doc_ModifiedStatus",
|
|
1294
|
+
"extract": "Values.Modified"
|
|
1295
|
+
},
|
|
1296
|
+
"selection.changed": {
|
|
1297
|
+
"backend": "synthetic-mutation",
|
|
1298
|
+
"observe": ["selection.isBold", "selection.isItalic"],
|
|
1299
|
+
"throttle_ms": 100
|
|
1300
|
+
}
|
|
1301
|
+
}
|
|
1302
|
+
}
|
|
1303
|
+
```
|
|
1304
|
+
|
|
1305
|
+
The agent calls `NAC.call('collabora.writer', 'uno.Bold')`; the
|
|
1306
|
+
runtime routes through the `postmessage` backend, posts
|
|
1307
|
+
`Send_UNO_Command` to the iframe. To confirm the effect occurred
|
|
1308
|
+
(see sec 17), the agent calls
|
|
1309
|
+
`await NAC.read('collabora.writer', 'selection.isBold')`; the
|
|
1310
|
+
runtime tries the toolbar mirror first (fast, free), falls back to
|
|
1311
|
+
the Python script bridge if the mirror is unavailable. The agent
|
|
1312
|
+
never knows or cares which source answered.
|
|
1313
|
+
|
|
1314
|
+
### 15.9 Errors
|
|
1315
|
+
|
|
1316
|
+
`NAC.call` / `read` / `subscribe` reject with `NacError` whose `code`
|
|
1317
|
+
is one of:
|
|
1318
|
+
|
|
1319
|
+
- `plugin_not_registered` -- the slug has no v2.5 manifest.
|
|
1320
|
+
- `verb_not_declared` -- the verb path is not in the manifest.
|
|
1321
|
+
- `state_not_declared` -- the state path is not in the manifest.
|
|
1322
|
+
- `event_not_declared` -- the event path is not in the manifest.
|
|
1323
|
+
- `backend_unknown` -- the manifest declares a backend the runtime
|
|
1324
|
+
does not implement. Manifest MUST be rejected at register time;
|
|
1325
|
+
this error only surfaces if a runtime accepts a future manifest
|
|
1326
|
+
format it then cannot dispatch.
|
|
1327
|
+
- `backend_target_missing` -- the backend's target (iframe, JS
|
|
1328
|
+
path, DOM selector) is not findable.
|
|
1329
|
+
- `cross_origin_blocked` -- `same-origin-window` was attempted
|
|
1330
|
+
against a cross-origin iframe.
|
|
1331
|
+
- `state_unreadable` -- every binding in a state chain failed; see
|
|
1332
|
+
15.6.
|
|
1333
|
+
- `timeout` -- a backend did not respond within its declared
|
|
1334
|
+
`timeout_ms` (default 5000 for verbs, 1000 for state reads).
|
|
1335
|
+
- `invalid` -- argument shape is wrong (bad slug, malformed
|
|
1336
|
+
manifest at register time, etc).
|
|
1337
|
+
|
|
1338
|
+
---
|
|
1339
|
+
|
|
1340
|
+
## 16. Tree navigation (v2.5 -- PLANNED, see sec 17 & 18 below)
|
|
1341
|
+
|
|
1342
|
+
*Drafting pending. Captures `NAC.context(plugin)` (current
|
|
1343
|
+
breadcrumb) + `NAC.tree(plugin, rootId?)` (enumerate hijos
|
|
1344
|
+
navegables) + the `data-nac-opens` / `data-nac-leaf` attributes
|
|
1345
|
+
that let the chrome declare hierarchical relationships explicitly.*
|
|
1346
|
+
|
|
1347
|
+
---
|
|
1348
|
+
|
|
1349
|
+
## 17. Asistive labels (v2.5 -- PLANNED)
|
|
1350
|
+
|
|
1351
|
+
*Drafting pending. Captures `NAC.narrate(plugin, nodeId)` (return
|
|
1352
|
+
the canonical human-readable label for screen reader / TTS),
|
|
1353
|
+
validation warnings for ordinal-shaped ids and for nodes that
|
|
1354
|
+
have no readable label.*
|
|
1355
|
+
|
|
1356
|
+
---
|
|
1357
|
+
|
|
1358
|
+
## 18. Effect detection (v2.5 -- PLANNED)
|
|
1359
|
+
|
|
1360
|
+
*Drafting pending. Captures `NAC.expect(plugin, statePath, value,
|
|
1361
|
+
opts?)` (Promise that resolves when a state matches an expected
|
|
1362
|
+
value within a timeout) and `NAC.diff(plugin, statePath, beforeFn,
|
|
1363
|
+
afterFn)` (snapshot a state pre- and post- an action).*
|
|
1364
|
+
|
|
1365
|
+
---
|
|
1366
|
+
|
|
1367
|
+
*This document is the canonical NAC3 v2.5-draft specification.
|
|
1368
|
+
Sections 0-14 are unchanged from v2.4 stable. Section 15 is GA
|
|
1369
|
+
in v2.5; sections 16-18 are in active drafting. Edits to this
|
|
1370
|
+
file constitute spec changes and require an RFC; see
|
|
1055
1371
|
`CONTRIBUTING.md`.*
|