@nac3/runtime 2.5.0-alpha.4 → 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/dist/cli.js CHANGED
@@ -1,71 +1,265 @@
1
1
  #!/usr/bin/env node
2
- // NAC CLI v2.3.0-alpha.2
3
- // Usage:
4
- // nac validate <url-or-dir> [--severity=error|warn|info]
5
- // nac --version
6
- //
7
- // Modes:
8
- // - URL: spawn headless Chromium, load URL, run NAC.validate_global(),
9
- // report findings.
10
- // - Directory: static lint of HTML/PHP files for data-nac-id /
11
- // data-nac-role coherence.
2
+ /* =====================================================================
3
+ NAC CLI v2.5.0 -- the entry point.
4
+
5
+ Two modes, and they do not pretend to be each other:
6
+
7
+ URL loads the page in a real browser, asks the runtime what
8
+ it registered, and REPORTS A CONFORMANCE LEVEL against
9
+ the identifiers published in levels.json. Needs
10
+ Playwright, which is optional and resolved at call
11
+ time. Add --drive to let it click, which is what
12
+ decides the two behavioural requirements of level 1.
13
+
14
+ directory static lint of HTML/PHP files for data-nac-id /
15
+ data-nac-role coherence. It CANNOT decide a level --
16
+ not one requirement of section 8 is decidable from
17
+ files on disk -- and it says so instead of printing a
18
+ number nobody measured.
19
+
20
+ Audit N-18: before 2.5.0 the URL mode aborted with exit 2 and no
21
+ mode ever printed a level, while SPEC.md section 8 promised this
22
+ command "reports the highest level a page reaches".
23
+
24
+ The version in the banner is substituted by runtime/build.mjs from
25
+ the authoritative constant in js/nac.js. Do not type it here: that
26
+ is audit N-17, and scripts/check-version-coherence.mjs refuses it.
27
+
28
+ ASCII only.
29
+ ===================================================================== */
12
30
 
13
31
  import fs from 'node:fs';
14
32
  import path from 'node:path';
15
33
  import { staticLint } from './cli-lint.mjs';
16
34
 
35
+ const VERSION = '2.5.0';
36
+ const SPEC_VERSION = '2.5';
37
+
17
38
  const args = process.argv.slice(2);
18
39
  const cmd = args[0];
19
40
 
41
+ function flag(name) {
42
+ return args.indexOf('--' + name) >= 0;
43
+ }
44
+ function opt(name, dflt) {
45
+ const hit = args.find((a) => a.startsWith('--' + name + '='));
46
+ return hit ? hit.slice(name.length + 3) : dflt;
47
+ }
48
+
20
49
  function showHelp() {
21
- console.log('NAC CLI v2.3.0-alpha.2');
50
+ console.log('NAC CLI v' + VERSION);
22
51
  console.log('');
23
52
  console.log('Usage:');
24
- console.log(' nac validate <url-or-dir> [--severity=error|warn|info]');
53
+ console.log(' nac validate <url> [options] load the page and report a conformance level');
54
+ console.log(' nac validate <dir> [options] static lint of files (cannot decide a level)');
25
55
  console.log(' nac --version');
26
56
  console.log(' nac --help');
57
+ console.log('');
58
+ console.log('Options:');
59
+ console.log(' --severity=error|warn|info lowest severity that fails the exit code (default error)');
60
+ console.log(' --drive CLICK the advertised controls. Decides the two');
61
+ console.log(' behavioural requirements of level 1. NOT read-only:');
62
+ console.log(' never point it at a production page you care about.');
63
+ console.log(' --drive-roles=a,b | all which roles to click (default action)');
64
+ console.log(' --drive-limit=N click at most N ids (default 0 = all)');
65
+ console.log(' --timeout=MS page load / settle budget (default 30000)');
66
+ console.log(' --json emit the whole report as JSON instead of prose');
67
+ console.log('');
68
+ console.log('URL mode needs Playwright, which is NOT a dependency of this package:');
69
+ console.log(' npm i -D playwright && npx playwright install chromium');
27
70
  }
28
71
 
29
72
  function showVersion() {
30
- console.log('@nac3/runtime CLI 2.3.0-alpha.2 (Native Agent Contract v2.3)');
73
+ console.log('@nac3/runtime CLI ' + VERSION + ' (Native Agent Contract v' + SPEC_VERSION + ')');
31
74
  }
32
75
 
33
76
  if (!cmd || cmd === '--help' || cmd === '-h') { showHelp(); process.exit(0); }
34
- if (cmd === '--version' || cmd === '-v') { showVersion(); process.exit(0); }
77
+ if (cmd === '--version' || cmd === '-v') { showVersion(); process.exit(0); }
78
+
79
+ if (cmd !== 'validate') {
80
+ console.error('error: unknown command: ' + cmd);
81
+ showHelp();
82
+ process.exit(2);
83
+ }
35
84
 
36
- if (cmd === 'validate') {
37
- const target = args[1];
38
- if (!target) {
39
- console.error('error: validate requires a URL or directory argument');
85
+ const target = args[1];
86
+ if (!target || target.startsWith('--')) {
87
+ console.error('error: validate requires a URL or directory argument');
88
+ process.exit(2);
89
+ }
90
+
91
+ const sevRank = { info: 0, warn: 1, error: 2 };
92
+ const minSev = opt('severity', 'error');
93
+ if (!(minSev in sevRank)) {
94
+ console.error('error: --severity must be one of error, warn, info (got "' + minSev + '")');
95
+ process.exit(2);
96
+ }
97
+
98
+ /* ---- URL mode ------------------------------------------------------- */
99
+
100
+ function verdictTag(v) {
101
+ if (v === 'pass') return 'PASS';
102
+ if (v === 'fail') return 'FAIL';
103
+ return 'UNVERIFIED';
104
+ }
105
+
106
+ async function runUrl(url) {
107
+ const mod = await import('./cli-url.mjs');
108
+ let report;
109
+ try {
110
+ report = await mod.validateUrl(url, {
111
+ drive: flag('drive'),
112
+ driveRoles: opt('drive-roles', 'action').split(',').map((s) => s.trim()).filter(Boolean),
113
+ driveLimit: Number(opt('drive-limit', '0')) || 0,
114
+ timeoutMs: Number(opt('timeout', '30000')) || 30000,
115
+ onProgress: (m) => { if (!flag('json')) console.error(' ... ' + m); },
116
+ });
117
+ } catch (e) {
118
+ if (e instanceof mod.PlaywrightMissing) {
119
+ console.error('error: URL mode needs a Playwright chromium launcher and none resolved.');
120
+ for (const t of (e.tried || [])) console.error(' tried ' + t);
121
+ console.error('');
122
+ console.error('Playwright is deliberately NOT a dependency of @nac3/runtime: a runtime that');
123
+ console.error('pulled a browser into every install would charge every adopter for a tool most');
124
+ console.error('of them never run. Install it where you need it:');
125
+ console.error(' npm i -D playwright');
126
+ console.error(' npx playwright install chromium');
127
+ console.error('');
128
+ console.error('Static lint of a directory needs nothing and works now: nac validate <dir>');
129
+ process.exit(3);
130
+ }
131
+ console.error('error: ' + ((e && e.message) || e));
40
132
  process.exit(2);
41
133
  }
42
- const sevArg = args.find(a => a.startsWith('--severity='));
43
- const minSev = sevArg ? sevArg.split('=')[1] : 'error';
44
-
45
- const isUrl = /^https?:\/\//.test(target);
46
- if (isUrl) {
47
- console.error('error: URL validation requires Playwright. Run:');
48
- console.error(' npm install --save-dev @playwright/test');
49
- console.error(' npx playwright install chromium');
50
- console.error('then re-run. Static lint of a directory works without Playwright.');
51
- process.exit(2);
134
+
135
+ if (flag('json')) {
136
+ console.log(JSON.stringify(report, null, 2));
137
+ } else {
138
+ printUrlReport(report);
52
139
  }
53
140
 
54
- const dir = path.resolve(target);
55
- if (!fs.existsSync(dir)) { console.error('error: not found:', dir); process.exit(2); }
141
+ if (!report.nac) process.exit(1);
142
+ /* What the exit code means, stated once so nobody has to infer it:
143
+ a page AT level N necessarily fails something at level N+1 -- that
144
+ is what "level N" means. So a failing requirement above the level
145
+ reported is the expected shape of a pass, not an error. Exit 1 is
146
+ for a page that reaches no level at all, for a requirement failing
147
+ at or below the level claimed, and for findings at or above the
148
+ severity threshold the caller asked about. */
149
+ const level = report.report.level;
150
+ const failing = report.findings.filter(
151
+ (f) => (sevRank[f.severity] === undefined ? 2 : sevRank[f.severity]) >= sevRank[minSev]);
152
+ const failedAtOrBelow = report.verdicts.filter(
153
+ (v) => v.verdict === 'fail' && level !== null && v.level <= level);
154
+ process.exit(level === null || failing.length > 0 || failedAtOrBelow.length > 0 ? 1 : 0);
155
+ }
156
+
157
+ function printUrlReport(r) {
158
+ console.log('');
159
+ console.log('NAC3 validation -- ' + r.url);
160
+ if (!r.nac) {
161
+ console.log(' ' + r.error);
162
+ if (r.console_errors.length) {
163
+ console.log(' console errors: ' + r.console_errors.length);
164
+ for (const c of r.console_errors.slice(0, 5)) console.log(' ' + c);
165
+ }
166
+ return;
167
+ }
168
+ console.log(' runtime on the page ' + r.runtime_version + ' (spec v' + r.spec_version + ')');
169
+ console.log(' validator ' + r.validator_version + ' (spec v' + r.validator_spec_version + ')');
170
+ /* A tier is not a level, and the only way a reader stops conflating
171
+ them is to see them labelled differently in the same breath
172
+ (audit N-29). */
173
+ console.log(' conformance_tier ' + r.conformance_tier + ' [tier != level: the tier is what the RUNTIME implements]');
174
+ console.log(' manifests registered ' + r.plugin_count
175
+ + ' | ids declared ' + r.declared_ids + ' | ids in the DOM ' + r.dom_ids);
176
+ if (r.console_errors.length) {
177
+ console.log(' console errors ' + r.console_errors.length + ' (first: ' + r.console_errors[0] + ')');
178
+ }
179
+
180
+ if (r.warnings && r.warnings.length) {
181
+ console.log('');
182
+ for (const w of r.warnings) {
183
+ console.log('WARNING: ' + w);
184
+ }
185
+ }
186
+
187
+ console.log('');
188
+ console.log('Requirements (SPEC.md section 8, as published in levels.json)');
189
+ let lastLevel = null;
190
+ for (const v of r.verdicts) {
191
+ if (v.level !== lastLevel) {
192
+ lastLevel = v.level;
193
+ console.log(' -- nac3-conformance-level-' + v.level + ' --');
194
+ }
195
+ console.log(' [' + verdictTag(v.verdict).padEnd(10) + '] ' + v.requirement_id
196
+ + (v.machine_checkable ? '' : ' (human)'));
197
+ console.log(' ' + v.text);
198
+ console.log(' ' + v.detail);
199
+ }
200
+
201
+ console.log('');
202
+ const rep = r.report;
203
+ if (rep.level === null) {
204
+ console.log('Conformance level: NONE ASSERTED');
205
+ if (rep.blocked_by.length) {
206
+ console.log(' measured and failing: ' + rep.blocked_by.join(', '));
207
+ }
208
+ if (rep.blocked_by_unverified.length) {
209
+ console.log(' not measured: ' + rep.blocked_by_unverified.join(', ')
210
+ + (r.drive ? '' : ' (add --drive to decide the behavioural ones)'));
211
+ }
212
+ } else {
213
+ console.log('Conformance level: ' + rep.level_id);
214
+ console.log(' display name: ' + rep.display_name
215
+ + ' (pre-2.5.0 alias: ' + rep.legacy_display_name + ')');
216
+ console.log(' asserted on ' + rep.decided + ' of ' + rep.total + ' requirements at this level');
217
+ if (rep.undecided.length) {
218
+ console.log(' NOT decided by this tool: ' + rep.undecided.join(', '));
219
+ }
220
+ console.log(' This is a MEASUREMENT, not a certification. ' + rep.undecided.length
221
+ + ' requirement(s) at this level were not decided by any tool.');
222
+ }
223
+ if (!r.drive) {
224
+ console.log('');
225
+ console.log(' Read-only run: nothing on the page was clicked. The two behavioural');
226
+ console.log(' requirements of level 1 stay unverified until you add --drive.');
227
+ } else {
228
+ console.log('');
229
+ console.log(' Driven run: ' + r.drive_results.length + ' id(s) clicked.');
230
+ }
231
+ }
232
+
233
+ /* ---- directory mode ------------------------------------------------- */
234
+
235
+ function runDir(dir) {
236
+ if (!fs.existsSync(dir)) { console.error('error: not found: ' + dir); process.exit(2); }
56
237
  const findings = staticLint(dir);
57
- const sevRank = { info: 0, warn: 1, error: 2 };
58
- const min = sevRank[minSev] ?? 2;
59
- const failing = findings.filter(f => (sevRank[f.severity] ?? 2) >= min);
238
+ const min = sevRank[minSev];
239
+ const failing = findings.filter((f) => (sevRank[f.severity] ?? 2) >= min);
60
240
  for (const f of findings) {
61
- const tag = '[' + f.severity.toUpperCase() + ']';
62
- console.log(tag, f.code, '--', f.message, f.file ? '(' + f.file + ')' : '');
241
+ console.log('[' + f.severity.toUpperCase() + ']', f.code, '--', f.message, f.file ? '(' + f.file + ')' : '');
63
242
  }
64
243
  console.log('');
65
244
  console.log('Total findings:', findings.length, '|', 'Failing at severity >=', minSev + ':', failing.length);
245
+ console.log('');
246
+ /* Saying this out loud is the point. The old CLI printed a finding
247
+ count and stopped, and a reader could reasonably take a clean lint
248
+ for a conformance result. Not one requirement of section 8 is
249
+ decidable from files on disk: three of the eleven need the page
250
+ driven, and the rest need the runtime's own view of what it
251
+ registered. */
252
+ console.log('Conformance level: NOT DECIDABLE IN THIS MODE');
253
+ console.log(' A static lint reads files; every requirement of SPEC.md section 8 is about');
254
+ console.log(' what the RUNTIME registered and what the page DOES. Point this at a URL to');
255
+ console.log(' get a level: nac validate <url> --drive');
66
256
  process.exit(failing.length > 0 ? 1 : 0);
67
257
  }
68
258
 
69
- console.error('error: unknown command:', cmd);
70
- showHelp();
71
- process.exit(2);
259
+ /* ---- dispatch ------------------------------------------------------- */
260
+
261
+ if (/^https?:\/\//.test(target)) {
262
+ runUrl(target);
263
+ } else {
264
+ runDir(path.resolve(target));
265
+ }
@@ -1,80 +1,10 @@
1
- // Generated by build.mjs -- do not edit.
2
- // Type fidelity is permissive in v2.2; full types ship in v2.2.
1
+ // Generated by build.mjs -- do not edit. Source: js/nac-chat-client.js
2
+ // Reference chat client (voice + LLM + dispatcher) for @nac3/runtime.
3
3
 
4
- export interface NACError extends Error {
5
- code: 'not_found' | 'invalid' | 'timeout' | string;
6
- }
7
-
8
- export interface ManifestElement {
9
- id: string;
10
- role: string;
11
- label_i18n?: Record<string, string>;
12
- actions?: Array<{ verb: string; label_i18n?: Record<string, string> }>;
13
- [k: string]: unknown;
14
- }
15
-
16
- export interface Manifest {
17
- plugin_slug: string;
18
- version?: string;
19
- nac_version?: string;
20
- elements?: ManifestElement[];
21
- tabs?: ManifestElement[];
22
- fields?: ManifestElement[];
23
- actions?: ManifestElement[];
24
- data_tables?: unknown[];
25
- provenance?: { signed_at: string; signed_by: string; signature: string };
4
+ export interface NacChatClient {
26
5
  [k: string]: unknown;
27
6
  }
28
7
 
29
- export interface NACRuntime {
30
- click(nac_id: string, opts?: object): Promise<{ ok: true }>;
31
- click_by_verb(plugin: string | null, verb: string, opts?: object): Promise<{ ok: true }>;
32
- fill(nac_id: string, value: string | number | boolean): Promise<{ ok: true }>;
33
- select(nac_id: string, value: string): Promise<{ ok: true }>;
34
- tab(plugin: string, tab_key: string): Promise<{ ok: true }>;
35
- tab_by_label(plugin: string | null, label: string): Promise<{ ok: true }>;
36
- go_to_section(nac_id: string): Promise<{ ok: true }>;
37
- drag_drop(source_id: string, target_id: string, opts?: { to_index?: number }): Promise<{ ok: true }>;
38
- set_mode(mode: 'modal' | 'maximized' | 'new_tab' | 'new_window'): void;
39
- screenshot(): Promise<string>;
40
- register(manifest: Manifest): void;
41
- manifest(plugin_slug: string): Manifest | null;
42
- describe(): { active: string | null; plugins: unknown[] };
43
- describe_v2?(): { v2_scope_entries: unknown[]; sitemap?: unknown; data_tables?: unknown[] };
44
- validate_global(opts?: { probe?: boolean }): Array<{
45
- severity: 'error' | 'warn' | 'info';
46
- code: string;
47
- nac_id: string | null;
48
- message: string;
49
- detail: Record<string, unknown>;
50
- }>;
51
- set_provenance_secret(secret: string): void;
52
- setTenantPrefix(prefix: string): void;
53
- setAutoRTL(on: boolean): void;
54
- registerDataTable(spec: object): void;
55
- registerDataTableComputed(table_id: string, column: string, fn: (row: Record<string, unknown>) => unknown): void;
56
- dt_add_row(table_id: string, values: Record<string, unknown>): { ok: true; row_id: string } | { ok: false; error: string; column?: string };
57
- dt_remove_row(table_id: string, row_id: string): { ok: true };
58
- dt_edit_cell(table_id: string, row_id: string, column: string, value: unknown): { ok: true } | { ok: false; error: string };
59
- dt_set_cell(table_id: string, row: number | string, col: number | string, value: unknown): { ok: true } | { ok: false; error: string };
60
- dt_select(table_id: string, target: unknown): { ok: true };
61
- dt_commit(table_id: string): { ok: true; final_state: unknown } | { ok: false; errors: Array<{ code: string }> };
62
- dt_discard(table_id: string): { ok: true };
63
- dt_state(table_id: string): unknown;
64
- dt_read_aggregate(table_id: string, agg_key: string, column: string): number | null;
65
- [k: string]: unknown;
66
- }
67
-
68
- declare global {
69
- interface Window {
70
- NAC?: NACRuntime;
71
- NACv2?: unknown;
72
- NacChat?: unknown;
73
- }
74
- }
75
-
76
- declare const _default: NACRuntime;
8
+ declare const _default: NacChatClient;
77
9
  export default _default;
78
- export const NAC: NACRuntime;
79
- export const NACv2: unknown;
80
- export const NacChat: unknown;
10
+ export const NacChat: NacChatClient;
@@ -1,80 +1,83 @@
1
- // Generated by build.mjs -- do not edit.
2
- // Type fidelity is permissive in v2.2; full types ship in v2.2.
1
+ // Generated by build.mjs -- do not edit. Source: js/nac-v2-extensions.js
2
+ // Brownfield + data-table extensions for @nac3/runtime v2.5.0.
3
+ // This module MUST load AFTER the core runtime; it attaches every
4
+ // member below onto the same window.NAC object. Import as:
5
+ // import '@nac3/runtime';
6
+ // import '@nac3/runtime/extensions';
3
7
 
4
- export interface NACError extends Error {
5
- code: 'not_found' | 'invalid' | 'timeout' | string;
6
- }
7
-
8
- export interface ManifestElement {
9
- id: string;
10
- role: string;
11
- label_i18n?: Record<string, string>;
12
- actions?: Array<{ verb: string; label_i18n?: Record<string, string> }>;
8
+ export interface DataTableSpec {
9
+ table_id: string;
10
+ subkind?: 'collection' | 'matrix' | 'readonly' | 'matrix-singletree';
11
+ columns?: unknown[];
12
+ row_id_field?: string;
13
+ row_axis?: unknown;
14
+ column_axis?: unknown;
13
15
  [k: string]: unknown;
14
16
  }
15
17
 
16
- export interface Manifest {
17
- plugin_slug: string;
18
- version?: string;
19
- nac_version?: string;
20
- elements?: ManifestElement[];
21
- tabs?: ManifestElement[];
22
- fields?: ManifestElement[];
23
- actions?: ManifestElement[];
24
- data_tables?: unknown[];
25
- provenance?: { signed_at: string; signed_by: string; signature: string };
26
- [k: string]: unknown;
18
+ export interface DataTableValidation {
19
+ valid: boolean;
20
+ errors: Array<{ code: string; row_id?: string; column?: string; message_i18n?: Record<string, string> }>;
27
21
  }
28
22
 
29
- export interface NACRuntime {
30
- click(nac_id: string, opts?: object): Promise<{ ok: true }>;
31
- click_by_verb(plugin: string | null, verb: string, opts?: object): Promise<{ ok: true }>;
32
- fill(nac_id: string, value: string | number | boolean): Promise<{ ok: true }>;
33
- select(nac_id: string, value: string): Promise<{ ok: true }>;
34
- tab(plugin: string, tab_key: string): Promise<{ ok: true }>;
35
- tab_by_label(plugin: string | null, label: string): Promise<{ ok: true }>;
36
- go_to_section(nac_id: string): Promise<{ ok: true }>;
37
- drag_drop(source_id: string, target_id: string, opts?: { to_index?: number }): Promise<{ ok: true }>;
38
- set_mode(mode: 'modal' | 'maximized' | 'new_tab' | 'new_window'): void;
39
- screenshot(): Promise<string>;
40
- register(manifest: Manifest): void;
41
- manifest(plugin_slug: string): Manifest | null;
42
- describe(): { active: string | null; plugins: unknown[] };
43
- describe_v2?(): { v2_scope_entries: unknown[]; sitemap?: unknown; data_tables?: unknown[] };
44
- validate_global(opts?: { probe?: boolean }): Array<{
45
- severity: 'error' | 'warn' | 'info';
46
- code: string;
47
- nac_id: string | null;
48
- message: string;
49
- detail: Record<string, unknown>;
50
- }>;
51
- set_provenance_secret(secret: string): void;
52
- setTenantPrefix(prefix: string): void;
53
- setAutoRTL(on: boolean): void;
54
- registerDataTable(spec: object): void;
55
- registerDataTableComputed(table_id: string, column: string, fn: (row: Record<string, unknown>) => unknown): void;
56
- dt_add_row(table_id: string, values: Record<string, unknown>): { ok: true; row_id: string } | { ok: false; error: string; column?: string };
57
- dt_remove_row(table_id: string, row_id: string): { ok: true };
58
- dt_edit_cell(table_id: string, row_id: string, column: string, value: unknown): { ok: true } | { ok: false; error: string };
59
- dt_set_cell(table_id: string, row: number | string, col: number | string, value: unknown): { ok: true } | { ok: false; error: string };
60
- dt_select(table_id: string, target: unknown): { ok: true };
61
- dt_commit(table_id: string): { ok: true; final_state: unknown } | { ok: false; errors: Array<{ code: string }> };
62
- dt_discard(table_id: string): { ok: true };
63
- dt_state(table_id: string): unknown;
23
+ /** Members the extensions module attaches onto window.NAC. */
24
+ export interface NACExtensions {
25
+ version_v2: string;
26
+ spec_version_v2: string;
27
+
28
+ /* v2.0 brownfield primitives */
29
+ scope(spec: { slug: string; label_i18n?: Record<string, string> }): unknown;
30
+ autoRegister: ((el: Element, opts?: object) => unknown | null) & {
31
+ watch(containerEl: Element, opts?: object): MutationObserver;
32
+ };
33
+ adopt(rule: { selector: string; parent?: unknown; observe?: unknown; derive?: unknown; containerEl?: Element }): unknown;
34
+ bridgeShadowRoot(host: Element, depth?: number): void;
35
+ bridgeIframe(iframeEl: Element, opts?: { postMessageNamespace?: string; trusted_origins?: string[]; timeout_ms?: number; nac_level?: number }): Promise<{ iframeId: string; version: string; signed: boolean; nac_level: number }>;
36
+ declareVirtual(spec: { slug_pattern: string; count: number | (() => number); resolver: (i: number) => unknown }): unknown;
37
+ captureEphemeral(opts?: { duration_ms?: number; ring_size?: number; on_capture?: (...a: unknown[]) => void }): MutationObserver;
38
+ setTenantPrefix(slug: string): void;
39
+ getTenantPrefix(): string | null;
40
+ attestUserGesture(opts?: { trusted?: boolean; type?: 'script' | 'agent' }): void;
41
+ setMobileWebViewAttestation(fn: ((e: unknown) => boolean) | null): void;
42
+ gcIntermediateScopes(activePaths?: Set<string> | string[]): number;
43
+ declareSitemap(spec: { paths: unknown[] } | null): void;
44
+ getSitemap(): { paths: unknown[] } | null;
45
+ describe_v2(): Record<string, unknown>;
46
+ validate_global_v2(opts?: { i18n_strict?: boolean; i18n_strict_severity?: string; autoderived_action_severity?: string }): { errors: unknown[]; warnings: unknown[] };
47
+
48
+ /* i18n catalog */
49
+ t(key: string, opts?: { locale?: string; fallback?: string }): string;
50
+ registerCatalog(obj: Record<string, Record<string, string>>): void;
51
+ locale(code?: string): string | void;
52
+ setSupportedLocales(arr: string[]): void;
53
+ setRTLLocales(arr: string[]): void;
54
+ setAutoRTL(enabled: boolean): void;
55
+
56
+ /* provenance secrets (overrides the core no-op) */
57
+ set_provenance_secret(s: string | string[] | null): void;
58
+
59
+ /* v2.1 -- data tables (sec 5.3). Present ONLY when this module loaded. */
60
+ registerDataTable(spec: DataTableSpec): string;
61
+ unregisterDataTable(table_id: string): void;
62
+ registerDataTableComputed(table_id: string, column: string, fn: (row: Record<string, unknown>, allRows: unknown[]) => unknown): void;
63
+ dt_state(table_id: string): unknown | null;
64
+ dt_add_row(table_id: string, values?: Record<string, unknown>): { ok: true; row_id: string } | { ok: false; row_id: null; error: string; column: string };
65
+ dt_remove_row(table_id: string, row_id: string): void;
66
+ dt_edit_cell(table_id: string, row_id: string, column: string, value: unknown): { ok: true; unchanged?: true } | { ok: false; error: string };
64
67
  dt_read_aggregate(table_id: string, agg_key: string, column: string): number | null;
68
+ dt_validate(table_id: string): DataTableValidation;
69
+ dt_select(table_id: string, target: null | 'none' | 'all' | 'visible' | string | string[] | { column: string; op: string; value: unknown }): { selected_count: number };
70
+ dt_set_cell(table_id: string, row: string, col: string, value: unknown): { ok: true; unchanged?: true } | { ok: false; error: string };
71
+ dt_get_cell(table_id: string, row: string, col: string): unknown | undefined;
72
+ dt_commit(table_id: string): { ok: true; final_state: unknown } | { ok: false; errors?: unknown[]; error?: string };
73
+ dt_discard(table_id: string): void;
74
+
65
75
  [k: string]: unknown;
66
76
  }
67
77
 
68
- declare global {
69
- interface Window {
70
- NAC?: NACRuntime;
71
- NACv2?: unknown;
72
- NacChat?: unknown;
73
- }
74
- }
78
+ /** The merged global once both modules load. */
79
+ export type NACWithExtensions = import('./nac').NACRuntime & NACExtensions;
75
80
 
76
- declare const _default: NACRuntime;
81
+ declare const _default: NACExtensions;
77
82
  export default _default;
78
- export const NAC: NACRuntime;
79
- export const NACv2: unknown;
80
- export const NacChat: unknown;
83
+ export const NACv2: NACExtensions;