@yodaos-pkg/aix 0.9.0 → 0.11.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/README.md +188 -10
- package/check/index.d.ts +7 -0
- package/check/index.js +69 -0
- package/check/types.d.ts +48 -0
- package/check/types.js +1 -0
- package/index.d.ts +80 -8
- package/index.js +78 -16
- package/jsr.json +1 -1
- package/package.json +1 -2
- package/pkg/README.md +188 -10
- package/pkg/aix_web.d.ts +47 -12
- package/pkg/aix_web.js +142 -9
- package/pkg/aix_web_bg.wasm +0 -0
- package/pkg/aix_web_bg.wasm.d.ts +15 -8
- package/pkg/package.json +1 -1
- package/pkg-reader/README.md +412 -0
- package/pkg-reader/aix_web.d.ts +75 -0
- package/pkg-reader/aix_web.js +644 -0
- package/pkg-reader/aix_web_bg.wasm +0 -0
- package/pkg-reader/aix_web_bg.wasm.d.ts +22 -0
- package/pkg-reader/package.json +15 -0
package/pkg/aix_web_bg.wasm.d.ts
CHANGED
|
@@ -2,26 +2,33 @@
|
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
4
|
export const __wbg_aixpackresultwasm_free: (a: number, b: number) => void;
|
|
5
|
-
export const __wbg_aixreaderwasm_free: (a: number, b: number) => void;
|
|
6
5
|
export const __wbg_aixsourcepackbuilderwasm_free: (a: number, b: number) => void;
|
|
7
6
|
export const aixpackresultwasm_data: (a: number) => any;
|
|
8
7
|
export const aixpackresultwasm_report: (a: number) => [number, number, number];
|
|
9
8
|
export const aixpackresultwasm_warnings: (a: number) => [number, number, number];
|
|
9
|
+
export const aixsourcepackbuilderwasm_add_file: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
10
|
+
export const aixsourcepackbuilderwasm_new: () => number;
|
|
11
|
+
export const aixsourcepackbuilderwasm_pack_from_source_with_progress: (a: number, b: number, c: number, d: number, e: number, f: any, g: any, h: number, i: number) => [number, number, number];
|
|
12
|
+
export const check_aix_from_source: (a: any) => [number, number, number];
|
|
13
|
+
export const collect_aix_source: (a: any) => [number, number, number];
|
|
14
|
+
export const optimize_aix: (a: number, b: number, c: any) => [number, number, number];
|
|
15
|
+
export const pack_aix: (a: any, b: number, c: number, d: number, e: number, f: any, g: number, h: number) => [number, number, number];
|
|
16
|
+
export const pack_aix_from_source: (a: any, b: number, c: number, d: number, e: number, f: any, g: number, h: number) => [number, number, number];
|
|
17
|
+
export const pack_aix_from_source_with_progress: (a: any, b: number, c: number, d: number, e: number, f: any, g: any, h: number, i: number) => [number, number, number];
|
|
18
|
+
export const prepare_aix_check: (a: any) => [number, number, number];
|
|
19
|
+
export const __wbg_aixreaderwasm_free: (a: number, b: number) => void;
|
|
20
|
+
export const aixreaderwasm_get_agent_id: (a: number) => [number, number, number, number];
|
|
10
21
|
export const aixreaderwasm_get_pages: (a: number) => [number, number, number];
|
|
11
22
|
export const aixreaderwasm_get_title: (a: number) => [number, number];
|
|
12
23
|
export const aixreaderwasm_get_tools: (a: number) => [number, number, number];
|
|
13
24
|
export const aixreaderwasm_get_version: (a: number) => [number, number];
|
|
25
|
+
export const aixreaderwasm_get_widgets: (a: number, b: number, c: number) => [number, number, number];
|
|
14
26
|
export const aixreaderwasm_list: (a: number) => [number, number, number];
|
|
15
27
|
export const aixreaderwasm_new: (a: number, b: number) => [number, number, number];
|
|
16
28
|
export const aixreaderwasm_read_file: (a: number, b: number, c: number) => [number, number, number, number];
|
|
29
|
+
export const aixreaderwasm_resolve_metadata: (a: number) => [number, number, number];
|
|
17
30
|
export const aixreaderwasm_supports_engine: (a: number, b: number, c: number) => [number, number, number];
|
|
18
|
-
export const
|
|
19
|
-
export const aixsourcepackbuilderwasm_new: () => number;
|
|
20
|
-
export const aixsourcepackbuilderwasm_pack_from_source_with_progress: (a: number, b: number, c: number, d: number, e: number, f: any, g: any) => [number, number, number];
|
|
21
|
-
export const optimize_aix: (a: number, b: number, c: any) => [number, number, number];
|
|
22
|
-
export const pack_aix: (a: any, b: number, c: number, d: number, e: number, f: any) => [number, number, number];
|
|
23
|
-
export const pack_aix_from_source: (a: any, b: number, c: number, d: number, e: number, f: any) => [number, number, number];
|
|
24
|
-
export const pack_aix_from_source_with_progress: (a: any, b: number, c: number, d: number, e: number, f: any, g: any) => [number, number, number];
|
|
31
|
+
export const aixreaderwasm_with_limits: (a: number, b: number, c: any) => [number, number, number];
|
|
25
32
|
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
26
33
|
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
27
34
|
export const __wbindgen_exn_store: (a: number) => void;
|
package/pkg/package.json
CHANGED
|
@@ -0,0 +1,412 @@
|
|
|
1
|
+
# @yodaos-pkg/aix
|
|
2
|
+
|
|
3
|
+
`@yodaos-pkg/aix` is a library for reading and managing **.aix** (AI eXecutable) packages in the web environment using WASM. The `.aix` format is an extension of the [Open Agent Format (OAF)](https://openagentformat.com/spec.html), designed to package AI agents with rich UI/UX capabilities powered by Ink Mini Programs.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @yodaos-pkg/aix
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
Here is a quick example of how to load an `.aix` package:
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { AIX } from '@yodaos-pkg/aix';
|
|
17
|
+
|
|
18
|
+
// Option 1: Load from a URL
|
|
19
|
+
async function fromUrl() {
|
|
20
|
+
const response = await fetch('https://example.com/my-agent.aix');
|
|
21
|
+
const buffer = await response.arrayBuffer();
|
|
22
|
+
const aix = await AIX.From(new Uint8Array(buffer));
|
|
23
|
+
console.log('App Title:', aix.getTitle());
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Option 2: Load from a File object (e.g., from an <input type="file">)
|
|
27
|
+
async function fromFile(file: File) {
|
|
28
|
+
const aix = await AIX.From(file);
|
|
29
|
+
console.log('App Title:', aix.getTitle());
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## WASM Loading
|
|
34
|
+
|
|
35
|
+
`AIX.From()` and all instance methods initialize a separate reader-only WASM.
|
|
36
|
+
They do not load image codecs, script minification, or source/schema checking.
|
|
37
|
+
The first pack, optimize, or source-check call lazily loads the full module;
|
|
38
|
+
concurrent tooling calls share initialization. Existing reader instances remain
|
|
39
|
+
valid after tooling loads, and tooling-only calls do not fetch reader WASM.
|
|
40
|
+
|
|
41
|
+
The generated distribution includes `pkg-reader/` and `pkg/`; self-host both
|
|
42
|
+
with their adjacent JS/WASM files. The existing raw `pkg/aix_web.js` exports
|
|
43
|
+
remain complete and the npm CLI keeps its synchronous full Node.js bundle.
|
|
44
|
+
Rust builds default to the `tooling` feature; `--no-default-features` produces
|
|
45
|
+
reader exports without the packer dependency. `npm run build` builds both web
|
|
46
|
+
artifacts; `npm run build:wasm:reader` builds only the reader artifact.
|
|
47
|
+
|
|
48
|
+
Local measurements reduced reader WASM from 5,514,021 to 355,365 bytes. Mixed
|
|
49
|
+
reader/tooling workflows load both binaries and retain two module memories.
|
|
50
|
+
See the repository's `docs/wasm.md` for baseline samples, timing limits, the
|
|
51
|
+
compatibility plan, and reproduction commands.
|
|
52
|
+
|
|
53
|
+
## Archive Resource Limits
|
|
54
|
+
|
|
55
|
+
Pass caller-selected budgets when reading untrusted packages:
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
const aix = await AIX.From(file, {
|
|
59
|
+
maxEntries: 1024,
|
|
60
|
+
maxEntryBytes: 8 * 1024 * 1024,
|
|
61
|
+
maxTotalBytes: 32 * 1024 * 1024,
|
|
62
|
+
});
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
All limits are inclusive non-negative safe integers. Directories and signature
|
|
66
|
+
metadata count too. Metadata is rejected before extraction if over budget;
|
|
67
|
+
extraction also bounds output and retains CRC and size checks. `maxTotalBytes`
|
|
68
|
+
is the sum of declared uncompressed sizes, not a cumulative read budget.
|
|
69
|
+
Zero allows no entries or bytes. Omitted fields and the original `AIX.From(data)`
|
|
70
|
+
call remain unlimited for compatibility; set all three limits for untrusted
|
|
71
|
+
packages. The input archive buffer, parsed objects, and retained copies need
|
|
72
|
+
separate budgets. This policy applies to readers, not `AIX.optimize`.
|
|
73
|
+
|
|
74
|
+
Direct WASM consumers can call `AixReaderWasm.with_limits(data, limits)` using
|
|
75
|
+
the same fields. The existing `new AixReaderWasm(data)` constructor is unchanged.
|
|
76
|
+
|
|
77
|
+
## Check Source Files
|
|
78
|
+
|
|
79
|
+
The Web SDK and npm CLI use the same complete in-memory check engine:
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
import { AIX, type CheckReport } from '@yodaos-pkg/aix';
|
|
83
|
+
|
|
84
|
+
const encode = (source: string) => new TextEncoder().encode(source);
|
|
85
|
+
const report: CheckReport = await AIX.checkFromSource([
|
|
86
|
+
{ path: 'app.json', data: encode('{"pages":[]}') },
|
|
87
|
+
{ path: 'main.ts', data: encode('const count: number = ;') },
|
|
88
|
+
], { onProgress: (event) => console.log(event.type) });
|
|
89
|
+
console.log(report.diagnostics); // AIX029: invalid TypeScript syntax at main.ts:1
|
|
90
|
+
|
|
91
|
+
// Files from an <input type="file" webkitdirectory> selection also work.
|
|
92
|
+
const fileReport = await AIX.checkFromFiles(Array.from(input.files ?? []));
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Checks cover JSON/config validity, Page/Widget structure, component references
|
|
96
|
+
and cycles, JS/TS syntax, statically recognizable permissions, and Page JSON Schemas. Each diagnostic has `code`, `severity`, `path`,
|
|
97
|
+
`line`, `column`, and `message`. Source errors are returned in the report;
|
|
98
|
+
invalid input paths or collection failures reject the promise.
|
|
99
|
+
|
|
100
|
+
`checkFromSource` takes paths relative to the application root. `checkFromFiles`
|
|
101
|
+
uses `webkitRelativePath`, removing the selected directory's outer folder.
|
|
102
|
+
Both apply nested `.aixignore` rules and exclude local `.aix` caches. The shared
|
|
103
|
+
check adapter loads only when checking is first requested. It uses the WASM
|
|
104
|
+
engine without a Node filesystem, Node polyfills, or dependency downloads.
|
|
105
|
+
The same API also works in a Web Worker.
|
|
106
|
+
|
|
107
|
+
Both methods accept `CheckOptions` with an optional `onProgress` callback.
|
|
108
|
+
`CheckProgressEvent` reports checker loading, source/schema validation (input
|
|
109
|
+
file count), and diagnostic collection. These are stage notifications, not a
|
|
110
|
+
percentage estimate. Browser checks are synchronous after loading; run the API
|
|
111
|
+
in a Web Worker to keep a browser progress display responsive.
|
|
112
|
+
|
|
113
|
+
`check_finished` events carry an exported `CheckResult` with `id`, `label`,
|
|
114
|
+
`status` (`passed`, `warning`, `failed`, or `skipped`), `errors`, `warnings`, and
|
|
115
|
+
an optional `detail` explaining incomplete/skipped checks. The CLI uses the same
|
|
116
|
+
results for its final checklist. The returned `CheckReport` remains a diagnostic
|
|
117
|
+
report, so JSON callers do not need to parse terminal output.
|
|
118
|
+
|
|
119
|
+
JavaScript and TypeScript are syntax-checked, including `.ts`, `.mts`, `.cts`,
|
|
120
|
+
and Ink `<script lang="ts">` blocks. Inline diagnostics retain their original
|
|
121
|
+
Ink file locations. TypeScript semantic, import-resolution, and compiler-option
|
|
122
|
+
checks are currently excluded. No type environment is loaded, and checks do not
|
|
123
|
+
emit or run code.
|
|
124
|
+
|
|
125
|
+
Page `schema.data` is validated against `$schema` (2020-12 by default), including
|
|
126
|
+
nested keywords, patterns, and local references. Missing/null schemas remain
|
|
127
|
+
accepted. External schema resources are not fetched. These checks validate
|
|
128
|
+
schema declarations, not runtime data; packing and reader semantics are unchanged.
|
|
129
|
+
|
|
130
|
+
## Using Play
|
|
131
|
+
|
|
132
|
+
The official browser lab now lives in the docs site at `/play`.
|
|
133
|
+
|
|
134
|
+
If you are developing inside this repository, install dependencies in `crates/aix-web` first:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
npm install
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
1. Build the local `aix-web` package:
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
npm run build
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
This step builds the `aix-web` WebAssembly bundle and TypeScript output into `dist/`, which is what the docs-integrated Package Lab loads.
|
|
147
|
+
|
|
148
|
+
2. Install the docs dependencies:
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
cd ../../docs
|
|
152
|
+
npm install
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
3. Start the docs site:
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
npm run dev
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
4. Open the local VitePress URL shown in the terminal, then navigate to `/play`, usually:
|
|
162
|
+
|
|
163
|
+
```text
|
|
164
|
+
http://localhost:5173/aix/play
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
5. Upload an `.aix` file in the page to inspect:
|
|
168
|
+
|
|
169
|
+
- package title and version
|
|
170
|
+
- parsed `pages`
|
|
171
|
+
- generated OpenAI-compatible `tools`
|
|
172
|
+
- package file list and raw file contents
|
|
173
|
+
|
|
174
|
+
This is useful for verifying whether `app.json`, page schemas, and `getTools()` output match expectations while developing or debugging an AIX package inside the official docs experience.
|
|
175
|
+
|
|
176
|
+
### Pack and Optimize
|
|
177
|
+
|
|
178
|
+
The Web package includes the same in-memory packer and pure Rust resource
|
|
179
|
+
optimizer used by the npm CLI:
|
|
180
|
+
|
|
181
|
+
```ts
|
|
182
|
+
const packed = await AIX.pack(
|
|
183
|
+
[{ path: "app.json", data: new TextEncoder().encode('{"pages":[]}') }],
|
|
184
|
+
{ optimize: { level: 2 } },
|
|
185
|
+
);
|
|
186
|
+
|
|
187
|
+
const optimized = await AIX.optimize(packed.data, { level: 3 });
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
Both methods return the generated `Uint8Array` and a structured per-file report.
|
|
191
|
+
|
|
192
|
+
Use `packFromSource` when the input represents an unpacked application tree.
|
|
193
|
+
It applies the same path normalization and nested `.aixignore` behavior as the
|
|
194
|
+
native and npm CLIs, and can report structured progress:
|
|
195
|
+
|
|
196
|
+
```ts
|
|
197
|
+
const packed = await AIX.packFromSource(
|
|
198
|
+
[
|
|
199
|
+
{ path: ".aixignore", data: new TextEncoder().encode("*.tmp\n") },
|
|
200
|
+
{ path: "app.json", data: new TextEncoder().encode('{"pages":[]}') },
|
|
201
|
+
{ path: "scratch.tmp", data: new Uint8Array() },
|
|
202
|
+
],
|
|
203
|
+
{
|
|
204
|
+
optimize: { level: 2 },
|
|
205
|
+
onProgress(event) {
|
|
206
|
+
console.log(event.type);
|
|
207
|
+
},
|
|
208
|
+
},
|
|
209
|
+
);
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
Use `pack` only when the caller has already normalized and filtered its input
|
|
213
|
+
files and wants to invoke the low-level packer directly.
|
|
214
|
+
|
|
215
|
+
## API Reference
|
|
216
|
+
|
|
217
|
+
### `AIX` Class
|
|
218
|
+
|
|
219
|
+
The main class to interact with an AIX package.
|
|
220
|
+
|
|
221
|
+
#### `static async From(data: Uint8Array | File): Promise<AIX>`
|
|
222
|
+
Initializes the WASM module and creates an AIX instance from the given `.aix` file content. It supports both `Uint8Array` and the standard Web `File` object.
|
|
223
|
+
```typescript
|
|
224
|
+
// From Uint8Array
|
|
225
|
+
const aix = await AIX.From(new Uint8Array(buffer));
|
|
226
|
+
|
|
227
|
+
// From File (Web API)
|
|
228
|
+
const aix = await AIX.From(file);
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
#### `list(): AixEntry[]`
|
|
232
|
+
Lists all files in the AIX package.
|
|
233
|
+
```typescript
|
|
234
|
+
const files = aix.list();
|
|
235
|
+
// [{ name: "app.json", size: 123, compressed_size: 45 }, ...]
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
#### `readFile(name: string): Uint8Array`
|
|
239
|
+
Reads the raw content of a specific file from the package.
|
|
240
|
+
```typescript
|
|
241
|
+
const content = aix.readFile('app.json');
|
|
242
|
+
const text = new TextDecoder().decode(content);
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
#### `getVersion(): string | undefined`
|
|
246
|
+
Returns the version metadata from the `VERSION` file in the package.
|
|
247
|
+
```typescript
|
|
248
|
+
const version = aix.getVersion();
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
#### `getTitle(): string | undefined`
|
|
252
|
+
Extracts the navigation bar title from the `app.json`.
|
|
253
|
+
```typescript
|
|
254
|
+
const title = aix.getTitle();
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
#### `getPages(): PageInfo[]`
|
|
258
|
+
Returns information about all pages defined in the package, including their paths, titles, and data schemas.
|
|
259
|
+
```typescript
|
|
260
|
+
const pages = aix.getPages();
|
|
261
|
+
/*
|
|
262
|
+
[{
|
|
263
|
+
name: "pages/index/index",
|
|
264
|
+
title: "Home",
|
|
265
|
+
description: null,
|
|
266
|
+
data_schema: { ... },
|
|
267
|
+
size: { width: 480, height: 168 }
|
|
268
|
+
}]
|
|
269
|
+
*/
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
#### `getWidgets(locale?): WidgetInfo[]`
|
|
273
|
+
Returns widget declarations after verifying that every path resolves to an `.ink` entry in the package. When `locale` is provided, merges `displayName` and `description` from the matching `app.<locale>.json` overlay. Throws when a declared entry is missing or the selected locale file is invalid.
|
|
274
|
+
```typescript
|
|
275
|
+
const widgets = aix.getWidgets('en-US');
|
|
276
|
+
// [{ path: "widgets/clock/index", family: "1x1", placement: "persistent", displayName: "Clock", description: "Shows the current time." }]
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
#### `resolveMetadata(): MetadataResolution`
|
|
280
|
+
|
|
281
|
+
Returns `{ pages, tools, diagnostics }` synchronously. Missing/unreadable resources,
|
|
282
|
+
UTF-8 errors, and malformed page metadata produce `{ path, message }` diagnostics,
|
|
283
|
+
one per failed page. Failed pages are excluded from both result lists; other
|
|
284
|
+
pages retain declaration order. A valid empty page list has no diagnostics;
|
|
285
|
+
invalid/unreadable `app.json.pages` produces an `app.json` diagnostic.
|
|
286
|
+
|
|
287
|
+
```typescript
|
|
288
|
+
const result = aix.resolveMetadata();
|
|
289
|
+
console.log(result.diagnostics);
|
|
290
|
+
const tools = result.tools; // only successfully resolved pages
|
|
291
|
+
// For all-or-nothing acceptance, require result.diagnostics.length === 0.
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
This API requires readable `.ink`, or both `.json` and `.wxml` for traditional
|
|
295
|
+
pages, and checks ZIP integrity and UTF-8 for resources it reads. It deserializes
|
|
296
|
+
page JSON and complete Ink `<script def>` blocks. Optional definitions, schemas,
|
|
297
|
+
and styles may be absent; present styles must be readable (`.wcss` before `.wxss`).
|
|
298
|
+
A broken Ink entry never falls back to traditional files. Use source checking
|
|
299
|
+
for full syntax, component, and JSON Schema validation. Runtime execution and
|
|
300
|
+
packing validation are unchanged.
|
|
301
|
+
|
|
302
|
+
`getPages()`/`getTools()` remain tolerant and can return default metadata/tools
|
|
303
|
+
even for missing resources. Page, Widget, and title fields are parsed separately;
|
|
304
|
+
invalid Widget fields no longer hide valid pages. `getWidgets()` still reports
|
|
305
|
+
Widget errors. Direct WASM consumers use `reader.resolve_metadata()`.
|
|
306
|
+
|
|
307
|
+
Exported `MetadataResolution` has `pages: PageInfo[]`, `tools: Tool[]`, and
|
|
308
|
+
`diagnostics: MetadataDiagnostic[]`; `MetadataDiagnostic` has `path` and `message`
|
|
309
|
+
string fields.
|
|
310
|
+
|
|
311
|
+
#### `getTools(): Tool[]`
|
|
312
|
+
Generates a list of OpenAI-compatible tool definitions based on the pages and their schemas.
|
|
313
|
+
```typescript
|
|
314
|
+
const tools = aix.getTools();
|
|
315
|
+
/*
|
|
316
|
+
[{
|
|
317
|
+
type: "function",
|
|
318
|
+
target: "_blank",
|
|
319
|
+
layout: { width: 480, height: 168 },
|
|
320
|
+
function: {
|
|
321
|
+
name: "pages_index_index",
|
|
322
|
+
description: "Home",
|
|
323
|
+
parameters: { ... }
|
|
324
|
+
}
|
|
325
|
+
}]
|
|
326
|
+
*/
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
## Data Types
|
|
330
|
+
|
|
331
|
+
### `AixEntry`
|
|
332
|
+
```typescript
|
|
333
|
+
interface AixEntry {
|
|
334
|
+
name: string;
|
|
335
|
+
size: number;
|
|
336
|
+
compressed_size: number;
|
|
337
|
+
}
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
### JSON and layout types
|
|
341
|
+
```typescript
|
|
342
|
+
type JsonValue = null | boolean | number | string | JsonValue[] | JsonObject;
|
|
343
|
+
interface JsonObject { [key: string]: JsonValue }
|
|
344
|
+
type JsonSchema = JsonValue;
|
|
345
|
+
interface PageConstraint { width: number; height: number }
|
|
346
|
+
type ToolTarget = '_current' | '_blank';
|
|
347
|
+
type WidgetPlacement = 'persistent' | 'overlay';
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
`JsonSchema` retains arbitrary JSON, including boolean schemas and unvalidated
|
|
351
|
+
legacy values. Use `AIX.checkFromSource()` for schema validation. Page `size`
|
|
352
|
+
and tool `layout` both contain numeric width/height constraints.
|
|
353
|
+
|
|
354
|
+
### `PageInfo`
|
|
355
|
+
```typescript
|
|
356
|
+
interface PageInfo {
|
|
357
|
+
name: string;
|
|
358
|
+
title: string | null;
|
|
359
|
+
description: string | null;
|
|
360
|
+
data_schema: JsonSchema;
|
|
361
|
+
size: PageConstraint;
|
|
362
|
+
}
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
### `WidgetInfo`
|
|
366
|
+
```typescript
|
|
367
|
+
interface WidgetInfo {
|
|
368
|
+
path: string;
|
|
369
|
+
family: string;
|
|
370
|
+
placement: WidgetPlacement;
|
|
371
|
+
displayName: string | null;
|
|
372
|
+
description: string | null;
|
|
373
|
+
}
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
### `Tool`
|
|
377
|
+
OpenAI compatible tool format.
|
|
378
|
+
```typescript
|
|
379
|
+
interface Tool {
|
|
380
|
+
type: string;
|
|
381
|
+
target: ToolTarget;
|
|
382
|
+
layout: PageConstraint;
|
|
383
|
+
function: FunctionDefinition;
|
|
384
|
+
}
|
|
385
|
+
interface FunctionDefinition {
|
|
386
|
+
name: string;
|
|
387
|
+
description: string | null;
|
|
388
|
+
parameters: JsonSchema;
|
|
389
|
+
}
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
Metadata fields above are always present. Missing strings and nested JSON null
|
|
393
|
+
values now remain `null` through raw WASM, SDK getters, and `resolveMetadata()`,
|
|
394
|
+
matching native Rust JSON. Earlier WASM builds returned `undefined` for these
|
|
395
|
+
values; update explicit `=== undefined` checks to `=== null` when migrating
|
|
396
|
+
metadata consumers. Standalone `getTitle()` and `getVersion()` retain their
|
|
397
|
+
`string | undefined` return type. Tools currently emit `type: "function"` and
|
|
398
|
+
underscore-prefixed targets; `current`/`blank` are input aliases only.
|
|
399
|
+
|
|
400
|
+
## Build
|
|
401
|
+
|
|
402
|
+
To build the library for distribution:
|
|
403
|
+
|
|
404
|
+
```bash
|
|
405
|
+
npm run build
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
The output will be generated in the `dist` directory, including WASM binaries and TypeScript definitions.
|
|
409
|
+
|
|
410
|
+
## License
|
|
411
|
+
|
|
412
|
+
MIT
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
export class AixReaderWasm {
|
|
5
|
+
free(): void;
|
|
6
|
+
[Symbol.dispose](): void;
|
|
7
|
+
get_agent_id(): string | undefined;
|
|
8
|
+
get_pages(): any;
|
|
9
|
+
get_title(): string | undefined;
|
|
10
|
+
get_tools(): any;
|
|
11
|
+
get_version(): string | undefined;
|
|
12
|
+
get_widgets(locale?: string | null): any;
|
|
13
|
+
list(): any;
|
|
14
|
+
/**
|
|
15
|
+
* Compatibility constructor without caller resource budgets.
|
|
16
|
+
*/
|
|
17
|
+
constructor(data: Uint8Array);
|
|
18
|
+
read_file(name: string): Uint8Array;
|
|
19
|
+
/**
|
|
20
|
+
* Resolve readable pages/tools and expose per-resource failures as diagnostics.
|
|
21
|
+
*/
|
|
22
|
+
resolve_metadata(): any;
|
|
23
|
+
supports_engine(current_version: string): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Create a reader with inclusive caller budgets. Omitted fields are unlimited.
|
|
26
|
+
*/
|
|
27
|
+
static with_limits(data: Uint8Array, limits: any): AixReaderWasm;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
31
|
+
|
|
32
|
+
export interface InitOutput {
|
|
33
|
+
readonly memory: WebAssembly.Memory;
|
|
34
|
+
readonly __wbg_aixreaderwasm_free: (a: number, b: number) => void;
|
|
35
|
+
readonly aixreaderwasm_get_agent_id: (a: number) => [number, number, number, number];
|
|
36
|
+
readonly aixreaderwasm_get_pages: (a: number) => [number, number, number];
|
|
37
|
+
readonly aixreaderwasm_get_title: (a: number) => [number, number];
|
|
38
|
+
readonly aixreaderwasm_get_tools: (a: number) => [number, number, number];
|
|
39
|
+
readonly aixreaderwasm_get_version: (a: number) => [number, number];
|
|
40
|
+
readonly aixreaderwasm_get_widgets: (a: number, b: number, c: number) => [number, number, number];
|
|
41
|
+
readonly aixreaderwasm_list: (a: number) => [number, number, number];
|
|
42
|
+
readonly aixreaderwasm_new: (a: number, b: number) => [number, number, number];
|
|
43
|
+
readonly aixreaderwasm_read_file: (a: number, b: number, c: number) => [number, number, number, number];
|
|
44
|
+
readonly aixreaderwasm_resolve_metadata: (a: number) => [number, number, number];
|
|
45
|
+
readonly aixreaderwasm_supports_engine: (a: number, b: number, c: number) => [number, number, number];
|
|
46
|
+
readonly aixreaderwasm_with_limits: (a: number, b: number, c: any) => [number, number, number];
|
|
47
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
48
|
+
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
49
|
+
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
50
|
+
readonly __externref_table_dealloc: (a: number) => void;
|
|
51
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
52
|
+
readonly __wbindgen_start: () => void;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
59
|
+
* a precompiled `WebAssembly.Module`.
|
|
60
|
+
*
|
|
61
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
62
|
+
*
|
|
63
|
+
* @returns {InitOutput}
|
|
64
|
+
*/
|
|
65
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
69
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
70
|
+
*
|
|
71
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
72
|
+
*
|
|
73
|
+
* @returns {Promise<InitOutput>}
|
|
74
|
+
*/
|
|
75
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|