@ruvector/rvagent-wasm 0.1.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 +241 -0
- package/package.json +21 -0
- package/rvagent_wasm.d.ts +438 -0
- package/rvagent_wasm.js +1539 -0
- package/rvagent_wasm_bg.wasm +0 -0
package/README.md
ADDED
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
# rvagent-wasm
|
|
2
|
+
|
|
3
|
+
WASM bindings for rvAgent — run AI agents entirely in the browser or Node.js.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **WasmAgent** — Full agent execution in browser/Node.js with conversation history
|
|
8
|
+
- **WasmMcpServer** — MCP JSON-RPC server running in the browser (no backend required)
|
|
9
|
+
- **Virtual Filesystem** — In-memory file operations for sandboxed execution
|
|
10
|
+
- **Gallery System** — Built-in agent templates with RVF container export
|
|
11
|
+
- **Zero Dependencies** — Runs entirely client-side via WebAssembly
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
# Build from source
|
|
17
|
+
cd crates/rvAgent/rvagent-wasm
|
|
18
|
+
wasm-pack build --target web
|
|
19
|
+
|
|
20
|
+
# Or use the pre-built package
|
|
21
|
+
npm install rvagent-wasm # (Not yet published)
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
|
|
26
|
+
### WasmAgent
|
|
27
|
+
|
|
28
|
+
```javascript
|
|
29
|
+
import init, { WasmAgent } from 'rvagent-wasm';
|
|
30
|
+
|
|
31
|
+
await init();
|
|
32
|
+
|
|
33
|
+
// Create an agent
|
|
34
|
+
const agent = new WasmAgent(JSON.stringify({
|
|
35
|
+
model: "anthropic:claude-sonnet-4-20250514",
|
|
36
|
+
name: "my-agent",
|
|
37
|
+
instructions: "You are a helpful coding assistant.",
|
|
38
|
+
max_turns: 50
|
|
39
|
+
}));
|
|
40
|
+
|
|
41
|
+
// Connect a model provider (calls your LLM API)
|
|
42
|
+
agent.set_model_provider(async (messagesJson) => {
|
|
43
|
+
const messages = JSON.parse(messagesJson);
|
|
44
|
+
const response = await fetch('/api/chat', {
|
|
45
|
+
method: 'POST',
|
|
46
|
+
body: JSON.stringify({ messages })
|
|
47
|
+
});
|
|
48
|
+
return (await response.json()).content;
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// Send a prompt
|
|
52
|
+
const result = await agent.prompt("Write a hello world function");
|
|
53
|
+
console.log(result.response);
|
|
54
|
+
|
|
55
|
+
// Execute tools directly
|
|
56
|
+
agent.execute_tool('{"tool": "write_file", "path": "hello.js", "content": "console.log(\"Hello!\");"}');
|
|
57
|
+
|
|
58
|
+
// Check state
|
|
59
|
+
console.log(agent.turn_count()); // 1
|
|
60
|
+
console.log(agent.file_count()); // 1
|
|
61
|
+
console.log(agent.get_todos()); // []
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### WasmMcpServer
|
|
65
|
+
|
|
66
|
+
Run an MCP server entirely in the browser:
|
|
67
|
+
|
|
68
|
+
```javascript
|
|
69
|
+
import init, { WasmMcpServer } from 'rvagent-wasm';
|
|
70
|
+
|
|
71
|
+
await init();
|
|
72
|
+
|
|
73
|
+
const mcp = new WasmMcpServer("rvagent-wasm");
|
|
74
|
+
|
|
75
|
+
// Handle MCP JSON-RPC requests
|
|
76
|
+
const response = mcp.handle_request(JSON.stringify({
|
|
77
|
+
jsonrpc: "2.0",
|
|
78
|
+
id: 1,
|
|
79
|
+
method: "initialize",
|
|
80
|
+
params: {}
|
|
81
|
+
}));
|
|
82
|
+
|
|
83
|
+
// List available tools
|
|
84
|
+
const tools = mcp.list_tools();
|
|
85
|
+
|
|
86
|
+
// Call a tool
|
|
87
|
+
const result = mcp.call_tool("write_file", JSON.stringify({
|
|
88
|
+
path: "demo.txt",
|
|
89
|
+
content: "Hello from WASM!"
|
|
90
|
+
}));
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Gallery System
|
|
94
|
+
|
|
95
|
+
Access built-in agent templates:
|
|
96
|
+
|
|
97
|
+
```javascript
|
|
98
|
+
// List all templates
|
|
99
|
+
const templates = mcp.handle_request(JSON.stringify({
|
|
100
|
+
jsonrpc: "2.0",
|
|
101
|
+
id: 1,
|
|
102
|
+
method: "gallery/list",
|
|
103
|
+
params: {}
|
|
104
|
+
}));
|
|
105
|
+
|
|
106
|
+
// Search templates
|
|
107
|
+
const searchResults = mcp.handle_request(JSON.stringify({
|
|
108
|
+
jsonrpc: "2.0",
|
|
109
|
+
id: 2,
|
|
110
|
+
method: "gallery/search",
|
|
111
|
+
params: { query: "coding assistant" }
|
|
112
|
+
}));
|
|
113
|
+
|
|
114
|
+
// Load a template
|
|
115
|
+
const loaded = mcp.handle_request(JSON.stringify({
|
|
116
|
+
jsonrpc: "2.0",
|
|
117
|
+
id: 3,
|
|
118
|
+
method: "gallery/load",
|
|
119
|
+
params: { id: "claude-code" }
|
|
120
|
+
}));
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Available Tools
|
|
124
|
+
|
|
125
|
+
| Tool | Description |
|
|
126
|
+
|------|-------------|
|
|
127
|
+
| `read_file` | Read file from virtual filesystem |
|
|
128
|
+
| `write_file` | Write file to virtual filesystem |
|
|
129
|
+
| `edit_file` | Apply string replacement to a file |
|
|
130
|
+
| `list_files` | List all files in virtual filesystem |
|
|
131
|
+
| `write_todos` | Manage todo list |
|
|
132
|
+
|
|
133
|
+
**Note:** OS-level tools (`execute`, `glob`, `grep`) are intentionally omitted as they require system access unavailable in the browser sandbox.
|
|
134
|
+
|
|
135
|
+
## MCP Methods
|
|
136
|
+
|
|
137
|
+
| Method | Description |
|
|
138
|
+
|--------|-------------|
|
|
139
|
+
| `initialize` | Initialize MCP connection |
|
|
140
|
+
| `ping` | Health check |
|
|
141
|
+
| `tools/list` | List available tools |
|
|
142
|
+
| `tools/call` | Execute a tool |
|
|
143
|
+
| `resources/list` | List virtual filesystem as resources |
|
|
144
|
+
| `prompts/list` | List prompts from active template |
|
|
145
|
+
| `gallery/list` | List all agent templates |
|
|
146
|
+
| `gallery/search` | Search templates by query |
|
|
147
|
+
| `gallery/get` | Get template details |
|
|
148
|
+
| `gallery/load` | Load template as active config |
|
|
149
|
+
| `gallery/configure` | Apply config overrides |
|
|
150
|
+
| `gallery/categories` | List template categories |
|
|
151
|
+
|
|
152
|
+
## API Reference
|
|
153
|
+
|
|
154
|
+
### WasmAgent
|
|
155
|
+
|
|
156
|
+
| Method | Description |
|
|
157
|
+
|--------|-------------|
|
|
158
|
+
| `new(configJson)` | Create agent from JSON config |
|
|
159
|
+
| `set_model_provider(callback)` | Set JS callback for LLM calls |
|
|
160
|
+
| `prompt(input)` | Send prompt, get response (async) |
|
|
161
|
+
| `execute_tool(toolJson)` | Execute a tool directly |
|
|
162
|
+
| `get_state()` | Get conversation state as JSON |
|
|
163
|
+
| `get_todos()` | Get todo list as JSON |
|
|
164
|
+
| `get_tools()` | Get available tools |
|
|
165
|
+
| `reset()` | Clear state and start fresh |
|
|
166
|
+
| `version()` | Get crate version |
|
|
167
|
+
| `name()` | Get agent name |
|
|
168
|
+
| `model()` | Get model identifier |
|
|
169
|
+
| `turn_count()` | Get current turn count |
|
|
170
|
+
| `is_stopped()` | Check if agent is stopped |
|
|
171
|
+
| `file_count()` | Get virtual filesystem file count |
|
|
172
|
+
|
|
173
|
+
### WasmMcpServer
|
|
174
|
+
|
|
175
|
+
| Method | Description |
|
|
176
|
+
|--------|-------------|
|
|
177
|
+
| `new(name)` | Create MCP server |
|
|
178
|
+
| `handle_request(json)` | Handle JSON-RPC request |
|
|
179
|
+
| `list_tools()` | Get available tools as JSON |
|
|
180
|
+
| `call_tool(name, paramsJson)` | Call tool by name |
|
|
181
|
+
| `gallery()` | Get gallery info |
|
|
182
|
+
| `is_initialized()` | Check initialization status |
|
|
183
|
+
| `name()` | Get server name |
|
|
184
|
+
| `version()` | Get server version |
|
|
185
|
+
|
|
186
|
+
## Building
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
# Install wasm-pack
|
|
190
|
+
cargo install wasm-pack
|
|
191
|
+
|
|
192
|
+
# Build for web
|
|
193
|
+
wasm-pack build --target web
|
|
194
|
+
|
|
195
|
+
# Build for Node.js
|
|
196
|
+
wasm-pack build --target nodejs
|
|
197
|
+
|
|
198
|
+
# Run tests
|
|
199
|
+
cargo test
|
|
200
|
+
wasm-pack test --headless --chrome
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
## Security
|
|
204
|
+
|
|
205
|
+
- Request size limit: 100 KB
|
|
206
|
+
- Path length limit: 256 characters
|
|
207
|
+
- Content length limit: 1 MB
|
|
208
|
+
- Path traversal (`..`) blocked
|
|
209
|
+
- Todo count limit: 1000 items
|
|
210
|
+
|
|
211
|
+
## Architecture
|
|
212
|
+
|
|
213
|
+
```
|
|
214
|
+
rvagent-wasm/
|
|
215
|
+
├── src/
|
|
216
|
+
│ ├── lib.rs # WasmAgent — main agent type
|
|
217
|
+
│ ├── backends.rs # WasmStateBackend — virtual filesystem
|
|
218
|
+
│ ├── bridge.rs # JsModelProvider — JS interop
|
|
219
|
+
│ ├── gallery.rs # WasmGallery — template system
|
|
220
|
+
│ ├── mcp.rs # WasmMcpServer — MCP protocol
|
|
221
|
+
│ ├── rvf.rs # RVF container support
|
|
222
|
+
│ └── tools.rs # Tool definitions and executor
|
|
223
|
+
└── pkg/ # Built WASM package
|
|
224
|
+
├── rvagent_wasm.js
|
|
225
|
+
├── rvagent_wasm.d.ts
|
|
226
|
+
└── rvagent_wasm_bg.wasm
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
## Related Crates
|
|
230
|
+
|
|
231
|
+
| Crate | Description |
|
|
232
|
+
|-------|-------------|
|
|
233
|
+
| `rvagent-core` | Agent state, graph, config |
|
|
234
|
+
| `rvagent-backends` | Backend protocol + implementations |
|
|
235
|
+
| `rvagent-tools` | Full tool implementations |
|
|
236
|
+
| `rvagent-mcp` | Native MCP client/server |
|
|
237
|
+
| `rvagent-cli` | Terminal UI |
|
|
238
|
+
|
|
239
|
+
## License
|
|
240
|
+
|
|
241
|
+
MIT OR Apache-2.0
|
package/package.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ruvector/rvagent-wasm",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"description": "rvAgent WASM bindings — browser and Node.js agent execution",
|
|
5
|
+
"version": "0.1.0",
|
|
6
|
+
"license": "MIT OR Apache-2.0",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/ruvnet/RuVector"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"rvagent_wasm_bg.wasm",
|
|
13
|
+
"rvagent_wasm.js",
|
|
14
|
+
"rvagent_wasm.d.ts"
|
|
15
|
+
],
|
|
16
|
+
"main": "rvagent_wasm.js",
|
|
17
|
+
"types": "rvagent_wasm.d.ts",
|
|
18
|
+
"sideEffects": [
|
|
19
|
+
"./snippets/*"
|
|
20
|
+
]
|
|
21
|
+
}
|
|
@@ -0,0 +1,438 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A model provider that delegates to a JavaScript callback function.
|
|
6
|
+
*
|
|
7
|
+
* The JS callback receives a JSON string of messages and must return
|
|
8
|
+
* a Promise that resolves to a JSON string response.
|
|
9
|
+
*
|
|
10
|
+
* # JavaScript usage
|
|
11
|
+
* ```js
|
|
12
|
+
* const provider = new JsModelProvider(async (messagesJson) => {
|
|
13
|
+
* const messages = JSON.parse(messagesJson);
|
|
14
|
+
* const response = await callMyModel(messages);
|
|
15
|
+
* return JSON.stringify(response);
|
|
16
|
+
* });
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export class JsModelProvider {
|
|
20
|
+
free(): void;
|
|
21
|
+
[Symbol.dispose](): void;
|
|
22
|
+
/**
|
|
23
|
+
* Send messages to the JS model provider and get a response.
|
|
24
|
+
*
|
|
25
|
+
* `messages_json` is a JSON-serialized array of message objects.
|
|
26
|
+
* Returns the model's response as a JSON string.
|
|
27
|
+
*/
|
|
28
|
+
complete(messages_json: string): Promise<string>;
|
|
29
|
+
/**
|
|
30
|
+
* Create a new provider wrapping a JavaScript async function.
|
|
31
|
+
*
|
|
32
|
+
* The function must accept a JSON string and return a Promise<string>.
|
|
33
|
+
*/
|
|
34
|
+
constructor(callback: Function);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* rvAgent WASM — browser and Node.js agent execution.
|
|
39
|
+
*
|
|
40
|
+
* Create with `new WasmAgent(configJson)` from JavaScript.
|
|
41
|
+
*/
|
|
42
|
+
export class WasmAgent {
|
|
43
|
+
free(): void;
|
|
44
|
+
[Symbol.dispose](): void;
|
|
45
|
+
/**
|
|
46
|
+
* Execute a tool directly by passing a JSON tool request.
|
|
47
|
+
*/
|
|
48
|
+
execute_tool(tool_json: string): any;
|
|
49
|
+
/**
|
|
50
|
+
* Get the number of files in the virtual filesystem.
|
|
51
|
+
*/
|
|
52
|
+
file_count(): number;
|
|
53
|
+
/**
|
|
54
|
+
* Get the current agent state as JSON.
|
|
55
|
+
*/
|
|
56
|
+
get_state(): any;
|
|
57
|
+
/**
|
|
58
|
+
* Get the todo list as JSON.
|
|
59
|
+
*/
|
|
60
|
+
get_todos(): any;
|
|
61
|
+
/**
|
|
62
|
+
* Get the list of available tools.
|
|
63
|
+
*/
|
|
64
|
+
get_tools(): any;
|
|
65
|
+
/**
|
|
66
|
+
* Check whether the agent is stopped.
|
|
67
|
+
*/
|
|
68
|
+
is_stopped(): boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Get the configured model identifier.
|
|
71
|
+
*/
|
|
72
|
+
model(): string;
|
|
73
|
+
/**
|
|
74
|
+
* Get the agent name, if configured.
|
|
75
|
+
*/
|
|
76
|
+
name(): string | undefined;
|
|
77
|
+
/**
|
|
78
|
+
* Create a new WasmAgent from a JSON configuration string.
|
|
79
|
+
*
|
|
80
|
+
* # Example (JavaScript)
|
|
81
|
+
* ```js
|
|
82
|
+
* const agent = new WasmAgent('{"model": "anthropic:claude-sonnet-4-20250514"}');
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
constructor(config_json: string);
|
|
86
|
+
/**
|
|
87
|
+
* Send a prompt and get a response.
|
|
88
|
+
*
|
|
89
|
+
* If a model provider is set, the prompt is sent to the JS model.
|
|
90
|
+
* Otherwise, returns an echo response for testing.
|
|
91
|
+
*/
|
|
92
|
+
prompt(input: string): Promise<any>;
|
|
93
|
+
/**
|
|
94
|
+
* Reset the agent state, clearing messages and turn count.
|
|
95
|
+
*/
|
|
96
|
+
reset(): void;
|
|
97
|
+
/**
|
|
98
|
+
* Attach a JavaScript model provider callback.
|
|
99
|
+
*
|
|
100
|
+
* The callback receives a JSON string of messages and must return
|
|
101
|
+
* a `Promise<string>` with the model response.
|
|
102
|
+
*/
|
|
103
|
+
set_model_provider(callback: Function): void;
|
|
104
|
+
/**
|
|
105
|
+
* Get the current turn count.
|
|
106
|
+
*/
|
|
107
|
+
turn_count(): number;
|
|
108
|
+
/**
|
|
109
|
+
* Get the crate version.
|
|
110
|
+
*/
|
|
111
|
+
static version(): string;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* RVF App Gallery — browse, load, and configure agent templates.
|
|
116
|
+
*
|
|
117
|
+
* # Example (JavaScript)
|
|
118
|
+
* ```js
|
|
119
|
+
* const gallery = new WasmGallery();
|
|
120
|
+
*
|
|
121
|
+
* // List all templates
|
|
122
|
+
* const templates = gallery.list();
|
|
123
|
+
*
|
|
124
|
+
* // Search by tags
|
|
125
|
+
* const results = gallery.search("security testing");
|
|
126
|
+
*
|
|
127
|
+
* // Get template details
|
|
128
|
+
* const template = gallery.get("coder");
|
|
129
|
+
*
|
|
130
|
+
* // Load as RVF container
|
|
131
|
+
* const rvfBytes = gallery.loadRvf("coder");
|
|
132
|
+
*
|
|
133
|
+
* // Configure template
|
|
134
|
+
* gallery.configure("coder", { maxTurns: 100 });
|
|
135
|
+
* ```
|
|
136
|
+
*/
|
|
137
|
+
export class WasmGallery {
|
|
138
|
+
free(): void;
|
|
139
|
+
[Symbol.dispose](): void;
|
|
140
|
+
/**
|
|
141
|
+
* Add a custom template to the gallery.
|
|
142
|
+
*/
|
|
143
|
+
addCustom(template_json: string): void;
|
|
144
|
+
/**
|
|
145
|
+
* Configure the active template with overrides.
|
|
146
|
+
*/
|
|
147
|
+
configure(config_json: string): void;
|
|
148
|
+
/**
|
|
149
|
+
* Get the number of templates in the gallery.
|
|
150
|
+
*/
|
|
151
|
+
count(): number;
|
|
152
|
+
/**
|
|
153
|
+
* Export all custom templates as JSON.
|
|
154
|
+
*/
|
|
155
|
+
exportCustom(): any;
|
|
156
|
+
/**
|
|
157
|
+
* Get a template by ID.
|
|
158
|
+
*/
|
|
159
|
+
get(id: string): any;
|
|
160
|
+
/**
|
|
161
|
+
* Get the currently active template ID.
|
|
162
|
+
*/
|
|
163
|
+
getActive(): string | undefined;
|
|
164
|
+
/**
|
|
165
|
+
* Get all categories with template counts.
|
|
166
|
+
*/
|
|
167
|
+
getCategories(): any;
|
|
168
|
+
/**
|
|
169
|
+
* Get configuration overrides for active template.
|
|
170
|
+
*/
|
|
171
|
+
getConfig(): any;
|
|
172
|
+
/**
|
|
173
|
+
* Import custom templates from JSON.
|
|
174
|
+
*/
|
|
175
|
+
importCustom(templates_json: string): number;
|
|
176
|
+
/**
|
|
177
|
+
* List all available templates.
|
|
178
|
+
*/
|
|
179
|
+
list(): any;
|
|
180
|
+
/**
|
|
181
|
+
* List templates by category.
|
|
182
|
+
*/
|
|
183
|
+
listByCategory(category: string): any;
|
|
184
|
+
/**
|
|
185
|
+
* Load a template as an RVF container (returns Uint8Array).
|
|
186
|
+
*/
|
|
187
|
+
loadRvf(id: string): Uint8Array;
|
|
188
|
+
/**
|
|
189
|
+
* Create a new gallery with built-in templates.
|
|
190
|
+
*/
|
|
191
|
+
constructor();
|
|
192
|
+
/**
|
|
193
|
+
* Remove a custom template by ID.
|
|
194
|
+
*/
|
|
195
|
+
removeCustom(id: string): void;
|
|
196
|
+
/**
|
|
197
|
+
* Search templates by query (matches name, description, tags).
|
|
198
|
+
*/
|
|
199
|
+
search(query: string): any;
|
|
200
|
+
/**
|
|
201
|
+
* Set a template as active for use.
|
|
202
|
+
*/
|
|
203
|
+
setActive(id: string): void;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* WASM MCP Server — runs the MCP protocol entirely in the browser.
|
|
208
|
+
*
|
|
209
|
+
* This server exposes rvAgent tools via MCP JSON-RPC, enabling integration
|
|
210
|
+
* with MCP clients without requiring a separate server process.
|
|
211
|
+
*
|
|
212
|
+
* # Example (JavaScript)
|
|
213
|
+
* ```js
|
|
214
|
+
* const mcp = new WasmMcpServer("rvagent-wasm");
|
|
215
|
+
*
|
|
216
|
+
* // Handle request
|
|
217
|
+
* const response = mcp.handleRequest(JSON.stringify({
|
|
218
|
+
* jsonrpc: "2.0",
|
|
219
|
+
* id: 1,
|
|
220
|
+
* method: "tools/list",
|
|
221
|
+
* params: {}
|
|
222
|
+
* }));
|
|
223
|
+
* console.log(response);
|
|
224
|
+
* ```
|
|
225
|
+
*/
|
|
226
|
+
export class WasmMcpServer {
|
|
227
|
+
free(): void;
|
|
228
|
+
[Symbol.dispose](): void;
|
|
229
|
+
/**
|
|
230
|
+
* Execute a tool by name with JSON parameters.
|
|
231
|
+
*/
|
|
232
|
+
call_tool(name: string, params_json: string): any;
|
|
233
|
+
/**
|
|
234
|
+
* Get the gallery instance for direct access.
|
|
235
|
+
*/
|
|
236
|
+
gallery(): any;
|
|
237
|
+
/**
|
|
238
|
+
* Handle a JSON-RPC request and return a JSON-RPC response.
|
|
239
|
+
*/
|
|
240
|
+
handle_request(request_json: string): any;
|
|
241
|
+
/**
|
|
242
|
+
* Check if the server has been initialized.
|
|
243
|
+
*/
|
|
244
|
+
is_initialized(): boolean;
|
|
245
|
+
/**
|
|
246
|
+
* Get the list of available tools as JSON.
|
|
247
|
+
*/
|
|
248
|
+
list_tools(): any;
|
|
249
|
+
/**
|
|
250
|
+
* Get the server name.
|
|
251
|
+
*/
|
|
252
|
+
name(): string;
|
|
253
|
+
/**
|
|
254
|
+
* Create a new WasmMcpServer with the given name.
|
|
255
|
+
*/
|
|
256
|
+
constructor(name: string);
|
|
257
|
+
/**
|
|
258
|
+
* Get the server version.
|
|
259
|
+
*/
|
|
260
|
+
version(): string;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* RVF Container Builder for WASM.
|
|
265
|
+
*
|
|
266
|
+
* Build RVF cognitive containers that package tools, prompts, skills,
|
|
267
|
+
* orchestrator configs, MCP tools, and Ruvix capabilities.
|
|
268
|
+
*
|
|
269
|
+
* # Example (JavaScript)
|
|
270
|
+
* ```js
|
|
271
|
+
* const builder = new WasmRvfBuilder();
|
|
272
|
+
* builder.addTool({ name: "search", description: "Web search", parameters: {} });
|
|
273
|
+
* builder.addPrompt({ name: "coder", system_prompt: "You are a coder", version: "1.0" });
|
|
274
|
+
* const container = builder.build();
|
|
275
|
+
* // container is Uint8Array with RVF magic bytes
|
|
276
|
+
* ```
|
|
277
|
+
*/
|
|
278
|
+
export class WasmRvfBuilder {
|
|
279
|
+
free(): void;
|
|
280
|
+
[Symbol.dispose](): void;
|
|
281
|
+
/**
|
|
282
|
+
* Add Ruvix capability definitions.
|
|
283
|
+
*/
|
|
284
|
+
addCapabilities(caps_json: string): void;
|
|
285
|
+
/**
|
|
286
|
+
* Add MCP tool entries.
|
|
287
|
+
*/
|
|
288
|
+
addMcpTools(tools_json: string): void;
|
|
289
|
+
/**
|
|
290
|
+
* Add an agent prompt.
|
|
291
|
+
*/
|
|
292
|
+
addPrompt(prompt_json: string): void;
|
|
293
|
+
/**
|
|
294
|
+
* Add multiple prompts from JSON array.
|
|
295
|
+
*/
|
|
296
|
+
addPrompts(prompts_json: string): void;
|
|
297
|
+
/**
|
|
298
|
+
* Add a skill definition.
|
|
299
|
+
*/
|
|
300
|
+
addSkill(skill_json: string): void;
|
|
301
|
+
/**
|
|
302
|
+
* Add multiple skills from JSON array.
|
|
303
|
+
*/
|
|
304
|
+
addSkills(skills_json: string): void;
|
|
305
|
+
/**
|
|
306
|
+
* Add a tool definition.
|
|
307
|
+
*/
|
|
308
|
+
addTool(tool_json: string): void;
|
|
309
|
+
/**
|
|
310
|
+
* Add multiple tools from JSON array.
|
|
311
|
+
*/
|
|
312
|
+
addTools(tools_json: string): void;
|
|
313
|
+
/**
|
|
314
|
+
* Build the RVF container as bytes.
|
|
315
|
+
*
|
|
316
|
+
* Returns a Uint8Array containing the RVF binary:
|
|
317
|
+
* - Magic bytes: "RVF\x01" (4 bytes)
|
|
318
|
+
* - Segment count: u32 LE (4 bytes)
|
|
319
|
+
* - Segments: type(1) + tag(2) + len(4) + data
|
|
320
|
+
* - Checksum: SHA3-256 (32 bytes)
|
|
321
|
+
*/
|
|
322
|
+
build(): Uint8Array;
|
|
323
|
+
/**
|
|
324
|
+
* Get the RVF magic bytes for detection.
|
|
325
|
+
*/
|
|
326
|
+
static getMagic(): Uint8Array;
|
|
327
|
+
/**
|
|
328
|
+
* Create a new RVF container builder.
|
|
329
|
+
*/
|
|
330
|
+
constructor();
|
|
331
|
+
/**
|
|
332
|
+
* Parse an RVF container from bytes.
|
|
333
|
+
*/
|
|
334
|
+
static parse(data: Uint8Array): any;
|
|
335
|
+
/**
|
|
336
|
+
* Set orchestrator configuration.
|
|
337
|
+
*/
|
|
338
|
+
setOrchestrator(config_json: string): void;
|
|
339
|
+
/**
|
|
340
|
+
* Validate an RVF container (check magic and checksum).
|
|
341
|
+
*/
|
|
342
|
+
static validate(data: Uint8Array): boolean;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
346
|
+
|
|
347
|
+
export interface InitOutput {
|
|
348
|
+
readonly memory: WebAssembly.Memory;
|
|
349
|
+
readonly __wbg_jsmodelprovider_free: (a: number, b: number) => void;
|
|
350
|
+
readonly __wbg_wasmagent_free: (a: number, b: number) => void;
|
|
351
|
+
readonly __wbg_wasmgallery_free: (a: number, b: number) => void;
|
|
352
|
+
readonly __wbg_wasmmcpserver_free: (a: number, b: number) => void;
|
|
353
|
+
readonly __wbg_wasmrvfbuilder_free: (a: number, b: number) => void;
|
|
354
|
+
readonly jsmodelprovider_complete: (a: number, b: number, c: number) => number;
|
|
355
|
+
readonly jsmodelprovider_new: (a: number, b: number) => void;
|
|
356
|
+
readonly wasmagent_execute_tool: (a: number, b: number, c: number, d: number) => void;
|
|
357
|
+
readonly wasmagent_file_count: (a: number) => number;
|
|
358
|
+
readonly wasmagent_get_state: (a: number, b: number) => void;
|
|
359
|
+
readonly wasmagent_get_todos: (a: number, b: number) => void;
|
|
360
|
+
readonly wasmagent_get_tools: (a: number, b: number) => void;
|
|
361
|
+
readonly wasmagent_is_stopped: (a: number) => number;
|
|
362
|
+
readonly wasmagent_model: (a: number, b: number) => void;
|
|
363
|
+
readonly wasmagent_name: (a: number, b: number) => void;
|
|
364
|
+
readonly wasmagent_new: (a: number, b: number, c: number) => void;
|
|
365
|
+
readonly wasmagent_prompt: (a: number, b: number, c: number) => number;
|
|
366
|
+
readonly wasmagent_reset: (a: number) => void;
|
|
367
|
+
readonly wasmagent_set_model_provider: (a: number, b: number, c: number) => void;
|
|
368
|
+
readonly wasmagent_turn_count: (a: number) => number;
|
|
369
|
+
readonly wasmagent_version: (a: number) => void;
|
|
370
|
+
readonly wasmgallery_addCustom: (a: number, b: number, c: number, d: number) => void;
|
|
371
|
+
readonly wasmgallery_configure: (a: number, b: number, c: number, d: number) => void;
|
|
372
|
+
readonly wasmgallery_count: (a: number) => number;
|
|
373
|
+
readonly wasmgallery_exportCustom: (a: number, b: number) => void;
|
|
374
|
+
readonly wasmgallery_get: (a: number, b: number, c: number, d: number) => void;
|
|
375
|
+
readonly wasmgallery_getActive: (a: number, b: number) => void;
|
|
376
|
+
readonly wasmgallery_getCategories: (a: number, b: number) => void;
|
|
377
|
+
readonly wasmgallery_getConfig: (a: number, b: number) => void;
|
|
378
|
+
readonly wasmgallery_importCustom: (a: number, b: number, c: number, d: number) => void;
|
|
379
|
+
readonly wasmgallery_list: (a: number, b: number) => void;
|
|
380
|
+
readonly wasmgallery_listByCategory: (a: number, b: number, c: number, d: number) => void;
|
|
381
|
+
readonly wasmgallery_loadRvf: (a: number, b: number, c: number, d: number) => void;
|
|
382
|
+
readonly wasmgallery_new: () => number;
|
|
383
|
+
readonly wasmgallery_removeCustom: (a: number, b: number, c: number, d: number) => void;
|
|
384
|
+
readonly wasmgallery_search: (a: number, b: number, c: number, d: number) => void;
|
|
385
|
+
readonly wasmgallery_setActive: (a: number, b: number, c: number, d: number) => void;
|
|
386
|
+
readonly wasmmcpserver_call_tool: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
387
|
+
readonly wasmmcpserver_gallery: (a: number, b: number) => void;
|
|
388
|
+
readonly wasmmcpserver_handle_request: (a: number, b: number, c: number, d: number) => void;
|
|
389
|
+
readonly wasmmcpserver_is_initialized: (a: number) => number;
|
|
390
|
+
readonly wasmmcpserver_list_tools: (a: number, b: number) => void;
|
|
391
|
+
readonly wasmmcpserver_name: (a: number, b: number) => void;
|
|
392
|
+
readonly wasmmcpserver_new: (a: number, b: number) => number;
|
|
393
|
+
readonly wasmmcpserver_version: (a: number, b: number) => void;
|
|
394
|
+
readonly wasmrvfbuilder_addCapabilities: (a: number, b: number, c: number, d: number) => void;
|
|
395
|
+
readonly wasmrvfbuilder_addMcpTools: (a: number, b: number, c: number, d: number) => void;
|
|
396
|
+
readonly wasmrvfbuilder_addPrompt: (a: number, b: number, c: number, d: number) => void;
|
|
397
|
+
readonly wasmrvfbuilder_addPrompts: (a: number, b: number, c: number, d: number) => void;
|
|
398
|
+
readonly wasmrvfbuilder_addSkill: (a: number, b: number, c: number, d: number) => void;
|
|
399
|
+
readonly wasmrvfbuilder_addSkills: (a: number, b: number, c: number, d: number) => void;
|
|
400
|
+
readonly wasmrvfbuilder_addTool: (a: number, b: number, c: number, d: number) => void;
|
|
401
|
+
readonly wasmrvfbuilder_addTools: (a: number, b: number, c: number, d: number) => void;
|
|
402
|
+
readonly wasmrvfbuilder_build: (a: number, b: number) => void;
|
|
403
|
+
readonly wasmrvfbuilder_new: () => number;
|
|
404
|
+
readonly wasmrvfbuilder_parse: (a: number, b: number, c: number) => void;
|
|
405
|
+
readonly wasmrvfbuilder_setOrchestrator: (a: number, b: number, c: number, d: number) => void;
|
|
406
|
+
readonly wasmrvfbuilder_validate: (a: number, b: number, c: number) => void;
|
|
407
|
+
readonly wasmrvfbuilder_getMagic: () => number;
|
|
408
|
+
readonly __wasm_bindgen_func_elem_497: (a: number, b: number) => void;
|
|
409
|
+
readonly __wasm_bindgen_func_elem_498: (a: number, b: number, c: number, d: number) => void;
|
|
410
|
+
readonly __wasm_bindgen_func_elem_535: (a: number, b: number, c: number, d: number) => void;
|
|
411
|
+
readonly __wbindgen_export: (a: number, b: number) => number;
|
|
412
|
+
readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
413
|
+
readonly __wbindgen_export3: (a: number) => void;
|
|
414
|
+
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
415
|
+
readonly __wbindgen_export4: (a: number, b: number, c: number) => void;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
422
|
+
* a precompiled `WebAssembly.Module`.
|
|
423
|
+
*
|
|
424
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
425
|
+
*
|
|
426
|
+
* @returns {InitOutput}
|
|
427
|
+
*/
|
|
428
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
432
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
433
|
+
*
|
|
434
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
435
|
+
*
|
|
436
|
+
* @returns {Promise<InitOutput>}
|
|
437
|
+
*/
|
|
438
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|