@yodaos-pkg/aix 0.2.1 → 0.3.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 CHANGED
@@ -1,50 +1,149 @@
1
- # @yodaos-jsar/aix
1
+ # @yodaos-pkg/aix
2
2
 
3
- `@yodaos-jsar/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.
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
4
 
5
- ## Library Usage (JS/TS)
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @yodaos-pkg/aix
9
+ ```
10
+
11
+ ## Quick Start
6
12
 
7
- You can use this library in your JavaScript or TypeScript project to read `.aix` files.
13
+ Here is a quick example of how to load an `.aix` package:
8
14
 
9
15
  ```typescript
10
- import { AIX } from '@yodaos-jsar/aix';
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
+ ## API Reference
34
+
35
+ ### `AIX` Class
36
+
37
+ The main class to interact with an AIX package.
11
38
 
12
- // Load the .aix file as a Uint8Array
13
- const response = await fetch('path/to/your.aix');
14
- const buffer = await response.arrayBuffer();
15
- const data = new Uint8Array(buffer);
39
+ #### `static async From(data: Uint8Array | File): Promise<AIX>`
40
+ 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.
41
+ ```typescript
42
+ // From Uint8Array
43
+ const aix = await AIX.From(new Uint8Array(buffer));
16
44
 
17
- // Create an AIX instance
18
- const aix = await AIX.from(data);
45
+ // From File (Web API)
46
+ const aix = await AIX.From(file);
47
+ ```
19
48
 
20
- // List files
49
+ #### `list(): AixEntry[]`
50
+ Lists all files in the AIX package.
51
+ ```typescript
21
52
  const files = aix.list();
22
- console.log('Files in package:', files);
53
+ // [{ name: "app.json", size: 123, compressed_size: 45 }, ...]
54
+ ```
23
55
 
24
- // Get version metadata
56
+ #### `readFile(name: string): Uint8Array`
57
+ Reads the raw content of a specific file from the package.
58
+ ```typescript
59
+ const content = aix.readFile('app.json');
60
+ const text = new TextDecoder().decode(content);
61
+ ```
62
+
63
+ #### `getVersion(): string | undefined`
64
+ Returns the version metadata from the `VERSION` file in the package.
65
+ ```typescript
25
66
  const version = aix.getVersion();
26
- console.log('Package version:', version);
67
+ ```
27
68
 
28
- // Read a specific file
29
- const appJson = aix.readFile('app.json');
30
- const content = new TextDecoder().decode(appJson);
31
- console.log('app.json content:', JSON.parse(content));
69
+ #### `getTitle(): string | undefined`
70
+ Extracts the navigation bar title from the `app.json`.
71
+ ```typescript
72
+ const title = aix.getTitle();
32
73
  ```
33
74
 
34
- ## Installation
75
+ #### `getPages(): PageInfo[]`
76
+ Returns information about all pages defined in the package, including their paths, titles, and data schemas.
77
+ ```typescript
78
+ const pages = aix.getPages();
79
+ /*
80
+ [{
81
+ name: "pages/index/index",
82
+ title: "Home",
83
+ data_schema: { ... }
84
+ }]
85
+ */
86
+ ```
35
87
 
36
- ```bash
37
- npm install @yodaos-jsar/aix
88
+ #### `getTools(): Tool[]`
89
+ Generates a list of OpenAI-compatible tool definitions based on the pages and their schemas.
90
+ ```typescript
91
+ const tools = aix.getTools();
92
+ /*
93
+ [{
94
+ type: "function",
95
+ function: {
96
+ name: "pages_index_index",
97
+ description: "Home",
98
+ parameters: { ... }
99
+ }
100
+ }]
101
+ */
102
+ ```
103
+
104
+ ## Data Types
105
+
106
+ ### `AixEntry`
107
+ ```typescript
108
+ interface AixEntry {
109
+ name: string;
110
+ size: number;
111
+ compressed_size: number;
112
+ }
113
+ ```
114
+
115
+ ### `PageInfo`
116
+ ```typescript
117
+ interface PageInfo {
118
+ name: string;
119
+ title?: string;
120
+ data_schema: any;
121
+ }
122
+ ```
123
+
124
+ ### `Tool`
125
+ OpenAI compatible tool format.
126
+ ```typescript
127
+ interface Tool {
128
+ type: string;
129
+ function: {
130
+ name: string;
131
+ description?: string;
132
+ parameters: any;
133
+ };
134
+ }
38
135
  ```
39
136
 
40
137
  ## Build
41
138
 
42
- To build the WASM and TS code:
139
+ To build the library for distribution:
43
140
 
44
141
  ```bash
45
142
  npm run build
46
143
  ```
47
144
 
48
- ## Core Library
145
+ The output will be generated in the `dist` directory, including WASM binaries and TypeScript definitions.
146
+
147
+ ## License
49
148
 
50
- The core Rust logic is provided by the [aix](../aix) package.
149
+ MIT
package/index.d.ts CHANGED
@@ -21,9 +21,9 @@ export declare class AIX {
21
21
  private constructor();
22
22
  /**
23
23
  * Initialize the WASM module and create an AIX instance from the given data.
24
- * @param data The .aix file content as Uint8Array
24
+ * @param data The .aix file content as Uint8Array or File
25
25
  */
26
- static from(data: Uint8Array): Promise<AIX>;
26
+ static From(data: Uint8Array | File): Promise<AIX>;
27
27
  /**
28
28
  * List all files in the AIX package.
29
29
  */
package/index.js CHANGED
@@ -5,11 +5,19 @@ export class AIX {
5
5
  }
6
6
  /**
7
7
  * Initialize the WASM module and create an AIX instance from the given data.
8
- * @param data The .aix file content as Uint8Array
8
+ * @param data The .aix file content as Uint8Array or File
9
9
  */
10
- static async from(data) {
10
+ static async From(data) {
11
11
  await init();
12
- const reader = new AixReaderWasm(data);
12
+ let buffer;
13
+ if (data instanceof Uint8Array) {
14
+ buffer = data;
15
+ }
16
+ else {
17
+ const arrayBuffer = await data.arrayBuffer();
18
+ buffer = new Uint8Array(arrayBuffer);
19
+ }
20
+ const reader = new AixReaderWasm(buffer);
13
21
  return new AIX(reader);
14
22
  }
15
23
  /**
package/jsr.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@yodaos-pkg/aix",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "exports": "./index.js"
5
5
  }
package/package.json CHANGED
@@ -1,16 +1,13 @@
1
1
  {
2
2
  "name": "@yodaos-pkg/aix",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "description": "Ink AIX Package Reader",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
7
7
  "files": [
8
8
  "*"
9
9
  ],
10
- "dependencies": {
11
- "react": "^18.2.0",
12
- "react-dom": "^18.2.0"
13
- },
10
+ "dependencies": {},
14
11
  "publishConfig": {
15
12
  "access": "public",
16
13
  "registry": "https://registry.npmjs.org/"
package/pkg/README.md CHANGED
@@ -1,50 +1,149 @@
1
- # @yodaos-jsar/aix
1
+ # @yodaos-pkg/aix
2
2
 
3
- `@yodaos-jsar/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.
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
4
 
5
- ## Library Usage (JS/TS)
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @yodaos-pkg/aix
9
+ ```
10
+
11
+ ## Quick Start
6
12
 
7
- You can use this library in your JavaScript or TypeScript project to read `.aix` files.
13
+ Here is a quick example of how to load an `.aix` package:
8
14
 
9
15
  ```typescript
10
- import { AIX } from '@yodaos-jsar/aix';
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
+ ## API Reference
34
+
35
+ ### `AIX` Class
36
+
37
+ The main class to interact with an AIX package.
11
38
 
12
- // Load the .aix file as a Uint8Array
13
- const response = await fetch('path/to/your.aix');
14
- const buffer = await response.arrayBuffer();
15
- const data = new Uint8Array(buffer);
39
+ #### `static async From(data: Uint8Array | File): Promise<AIX>`
40
+ 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.
41
+ ```typescript
42
+ // From Uint8Array
43
+ const aix = await AIX.From(new Uint8Array(buffer));
16
44
 
17
- // Create an AIX instance
18
- const aix = await AIX.from(data);
45
+ // From File (Web API)
46
+ const aix = await AIX.From(file);
47
+ ```
19
48
 
20
- // List files
49
+ #### `list(): AixEntry[]`
50
+ Lists all files in the AIX package.
51
+ ```typescript
21
52
  const files = aix.list();
22
- console.log('Files in package:', files);
53
+ // [{ name: "app.json", size: 123, compressed_size: 45 }, ...]
54
+ ```
23
55
 
24
- // Get version metadata
56
+ #### `readFile(name: string): Uint8Array`
57
+ Reads the raw content of a specific file from the package.
58
+ ```typescript
59
+ const content = aix.readFile('app.json');
60
+ const text = new TextDecoder().decode(content);
61
+ ```
62
+
63
+ #### `getVersion(): string | undefined`
64
+ Returns the version metadata from the `VERSION` file in the package.
65
+ ```typescript
25
66
  const version = aix.getVersion();
26
- console.log('Package version:', version);
67
+ ```
27
68
 
28
- // Read a specific file
29
- const appJson = aix.readFile('app.json');
30
- const content = new TextDecoder().decode(appJson);
31
- console.log('app.json content:', JSON.parse(content));
69
+ #### `getTitle(): string | undefined`
70
+ Extracts the navigation bar title from the `app.json`.
71
+ ```typescript
72
+ const title = aix.getTitle();
32
73
  ```
33
74
 
34
- ## Installation
75
+ #### `getPages(): PageInfo[]`
76
+ Returns information about all pages defined in the package, including their paths, titles, and data schemas.
77
+ ```typescript
78
+ const pages = aix.getPages();
79
+ /*
80
+ [{
81
+ name: "pages/index/index",
82
+ title: "Home",
83
+ data_schema: { ... }
84
+ }]
85
+ */
86
+ ```
35
87
 
36
- ```bash
37
- npm install @yodaos-jsar/aix
88
+ #### `getTools(): Tool[]`
89
+ Generates a list of OpenAI-compatible tool definitions based on the pages and their schemas.
90
+ ```typescript
91
+ const tools = aix.getTools();
92
+ /*
93
+ [{
94
+ type: "function",
95
+ function: {
96
+ name: "pages_index_index",
97
+ description: "Home",
98
+ parameters: { ... }
99
+ }
100
+ }]
101
+ */
102
+ ```
103
+
104
+ ## Data Types
105
+
106
+ ### `AixEntry`
107
+ ```typescript
108
+ interface AixEntry {
109
+ name: string;
110
+ size: number;
111
+ compressed_size: number;
112
+ }
113
+ ```
114
+
115
+ ### `PageInfo`
116
+ ```typescript
117
+ interface PageInfo {
118
+ name: string;
119
+ title?: string;
120
+ data_schema: any;
121
+ }
122
+ ```
123
+
124
+ ### `Tool`
125
+ OpenAI compatible tool format.
126
+ ```typescript
127
+ interface Tool {
128
+ type: string;
129
+ function: {
130
+ name: string;
131
+ description?: string;
132
+ parameters: any;
133
+ };
134
+ }
38
135
  ```
39
136
 
40
137
  ## Build
41
138
 
42
- To build the WASM and TS code:
139
+ To build the library for distribution:
43
140
 
44
141
  ```bash
45
142
  npm run build
46
143
  ```
47
144
 
48
- ## Core Library
145
+ The output will be generated in the `dist` directory, including WASM binaries and TypeScript definitions.
146
+
147
+ ## License
49
148
 
50
- The core Rust logic is provided by the [aix](../aix) package.
149
+ MIT
package/pkg/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aix-web",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "files": [
5
5
  "aix_web_bg.wasm",
6
6
  "aix_web.js",