@six5536/smllm-wasm 0.0.0 → 0.4.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 +137 -2
- package/dist/bundler.d.ts +8 -0
- package/dist/bundler.js +9 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +11 -0
- package/dist/node/host.d.ts +12 -0
- package/dist/node/host.js +106 -0
- package/dist/node/index.d.ts +2 -0
- package/dist/node/index.js +4 -0
- package/dist/node/storage.d.ts +9 -0
- package/dist/node/storage.js +75 -0
- package/dist/storage.d.ts +5 -0
- package/dist/storage.js +26 -0
- package/dist/types.d.ts +109 -0
- package/dist/types.js +4 -0
- package/dist/wrap.d.ts +64 -0
- package/dist/wrap.js +104 -0
- package/package.json +60 -5
- package/wasm/bundler/smllm_wasm.d.ts +70 -0
- package/wasm/bundler/smllm_wasm.js +9 -0
- package/wasm/bundler/smllm_wasm_bg.js +560 -0
- package/wasm/bundler/smllm_wasm_bg.wasm +0 -0
- package/wasm/bundler/smllm_wasm_bg.wasm.d.ts +22 -0
- package/wasm/web/smllm_wasm.d.ts +117 -0
- package/wasm/web/smllm_wasm.js +663 -0
- package/wasm/web/smllm_wasm_bg.wasm +0 -0
- package/wasm/web/smllm_wasm_bg.wasm.d.ts +22 -0
|
@@ -0,0 +1,560 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An smllm engine with an in-memory store.
|
|
3
|
+
*/
|
|
4
|
+
export class Engine {
|
|
5
|
+
__destroy_into_raw() {
|
|
6
|
+
const ptr = this.__wbg_ptr;
|
|
7
|
+
this.__wbg_ptr = 0;
|
|
8
|
+
EngineFinalization.unregister(this);
|
|
9
|
+
return ptr;
|
|
10
|
+
}
|
|
11
|
+
free() {
|
|
12
|
+
const ptr = this.__destroy_into_raw();
|
|
13
|
+
wasm.__wbg_engine_free(ptr, 0);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Bind a session; returns the reply JSON (its `session` is the key).
|
|
17
|
+
* @param {string} harness
|
|
18
|
+
* @param {string | null | undefined} host_session
|
|
19
|
+
* @param {string} cwd
|
|
20
|
+
* @returns {string}
|
|
21
|
+
*/
|
|
22
|
+
bind(harness, host_session, cwd) {
|
|
23
|
+
let deferred5_0;
|
|
24
|
+
let deferred5_1;
|
|
25
|
+
try {
|
|
26
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
27
|
+
const ptr0 = passStringToWasm0(harness, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
28
|
+
const len0 = WASM_VECTOR_LEN;
|
|
29
|
+
var ptr1 = isLikeNone(host_session) ? 0 : passStringToWasm0(host_session, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
30
|
+
var len1 = WASM_VECTOR_LEN;
|
|
31
|
+
const ptr2 = passStringToWasm0(cwd, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
32
|
+
const len2 = WASM_VECTOR_LEN;
|
|
33
|
+
wasm.engine_bind(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
34
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
35
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
36
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
37
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
38
|
+
var ptr4 = r0;
|
|
39
|
+
var len4 = r1;
|
|
40
|
+
if (r3) {
|
|
41
|
+
ptr4 = 0; len4 = 0;
|
|
42
|
+
throw takeObject(r2);
|
|
43
|
+
}
|
|
44
|
+
deferred5_0 = ptr4;
|
|
45
|
+
deferred5_1 = len4;
|
|
46
|
+
return getStringFromWasm0(ptr4, len4);
|
|
47
|
+
} finally {
|
|
48
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
49
|
+
wasm.__wbindgen_export4(deferred5_0, deferred5_1, 1);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* A tool call: the agent's arguments as JSON, answered as the MCP
|
|
54
|
+
* server answers them (HOST-13). A malformed call or an engine error is
|
|
55
|
+
* a reply with `ok: false` and `error: …`, never a throw: the agent
|
|
56
|
+
* sees its mistake as the tool's answer.
|
|
57
|
+
* @param {string} args
|
|
58
|
+
* @returns {string}
|
|
59
|
+
*/
|
|
60
|
+
callTool(args) {
|
|
61
|
+
let deferred2_0;
|
|
62
|
+
let deferred2_1;
|
|
63
|
+
try {
|
|
64
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
65
|
+
const ptr0 = passStringToWasm0(args, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
66
|
+
const len0 = WASM_VECTOR_LEN;
|
|
67
|
+
wasm.engine_callTool(retptr, this.__wbg_ptr, ptr0, len0);
|
|
68
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
69
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
70
|
+
deferred2_0 = r0;
|
|
71
|
+
deferred2_1 = r1;
|
|
72
|
+
return getStringFromWasm0(r0, r1);
|
|
73
|
+
} finally {
|
|
74
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
75
|
+
wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* The events list.
|
|
80
|
+
* @param {string} key
|
|
81
|
+
* @returns {string}
|
|
82
|
+
*/
|
|
83
|
+
events(key) {
|
|
84
|
+
let deferred3_0;
|
|
85
|
+
let deferred3_1;
|
|
86
|
+
try {
|
|
87
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
88
|
+
const ptr0 = passStringToWasm0(key, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
89
|
+
const len0 = WASM_VECTOR_LEN;
|
|
90
|
+
wasm.engine_events(retptr, this.__wbg_ptr, ptr0, len0);
|
|
91
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
92
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
93
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
94
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
95
|
+
var ptr2 = r0;
|
|
96
|
+
var len2 = r1;
|
|
97
|
+
if (r3) {
|
|
98
|
+
ptr2 = 0; len2 = 0;
|
|
99
|
+
throw takeObject(r2);
|
|
100
|
+
}
|
|
101
|
+
deferred3_0 = ptr2;
|
|
102
|
+
deferred3_1 = len2;
|
|
103
|
+
return getStringFromWasm0(ptr2, len2);
|
|
104
|
+
} finally {
|
|
105
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
106
|
+
wasm.__wbindgen_export4(deferred3_0, deferred3_1, 1);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Sessions, bindings and instances as JSON (history went to the host).
|
|
111
|
+
* @returns {string}
|
|
112
|
+
*/
|
|
113
|
+
exportState() {
|
|
114
|
+
let deferred1_0;
|
|
115
|
+
let deferred1_1;
|
|
116
|
+
try {
|
|
117
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
118
|
+
wasm.engine_exportState(retptr, this.__wbg_ptr);
|
|
119
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
120
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
121
|
+
deferred1_0 = r0;
|
|
122
|
+
deferred1_1 = r1;
|
|
123
|
+
return getStringFromWasm0(r0, r1);
|
|
124
|
+
} finally {
|
|
125
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
126
|
+
wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Fire an event; `params` is a JSON object of strings.
|
|
131
|
+
* @param {string | null | undefined} key
|
|
132
|
+
* @param {string} event
|
|
133
|
+
* @param {string} params
|
|
134
|
+
* @returns {string}
|
|
135
|
+
*/
|
|
136
|
+
fire(key, event, params) {
|
|
137
|
+
let deferred5_0;
|
|
138
|
+
let deferred5_1;
|
|
139
|
+
try {
|
|
140
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
141
|
+
var ptr0 = isLikeNone(key) ? 0 : passStringToWasm0(key, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
142
|
+
var len0 = WASM_VECTOR_LEN;
|
|
143
|
+
const ptr1 = passStringToWasm0(event, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
144
|
+
const len1 = WASM_VECTOR_LEN;
|
|
145
|
+
const ptr2 = passStringToWasm0(params, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
146
|
+
const len2 = WASM_VECTOR_LEN;
|
|
147
|
+
wasm.engine_fire(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
148
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
149
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
150
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
151
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
152
|
+
var ptr4 = r0;
|
|
153
|
+
var len4 = r1;
|
|
154
|
+
if (r3) {
|
|
155
|
+
ptr4 = 0; len4 = 0;
|
|
156
|
+
throw takeObject(r2);
|
|
157
|
+
}
|
|
158
|
+
deferred5_0 = ptr4;
|
|
159
|
+
deferred5_1 = len4;
|
|
160
|
+
return getStringFromWasm0(ptr4, len4);
|
|
161
|
+
} finally {
|
|
162
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
163
|
+
wasm.__wbindgen_export4(deferred5_0, deferred5_1, 1);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Replace the store from [`Engine::export_state`] JSON.
|
|
168
|
+
* @param {string} state
|
|
169
|
+
*/
|
|
170
|
+
importState(state) {
|
|
171
|
+
try {
|
|
172
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
173
|
+
const ptr0 = passStringToWasm0(state, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
174
|
+
const len0 = WASM_VECTOR_LEN;
|
|
175
|
+
wasm.engine_importState(retptr, this.__wbg_ptr, ptr0, len0);
|
|
176
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
177
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
178
|
+
if (r1) {
|
|
179
|
+
throw takeObject(r0);
|
|
180
|
+
}
|
|
181
|
+
} finally {
|
|
182
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Load compiled machines (`smllm compile` output).
|
|
187
|
+
* @param {string} compiled
|
|
188
|
+
* @param {any} host
|
|
189
|
+
*/
|
|
190
|
+
constructor(compiled, host) {
|
|
191
|
+
try {
|
|
192
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
193
|
+
const ptr0 = passStringToWasm0(compiled, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
194
|
+
const len0 = WASM_VECTOR_LEN;
|
|
195
|
+
wasm.engine_new(retptr, ptr0, len0, addHeapObject(host));
|
|
196
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
197
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
198
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
199
|
+
if (r2) {
|
|
200
|
+
throw takeObject(r1);
|
|
201
|
+
}
|
|
202
|
+
this.__wbg_ptr = r0;
|
|
203
|
+
EngineFinalization.register(this, this.__wbg_ptr, this);
|
|
204
|
+
return this;
|
|
205
|
+
} finally {
|
|
206
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* A user prompt arrived.
|
|
211
|
+
* @param {string} key
|
|
212
|
+
*/
|
|
213
|
+
promptSubmitted(key) {
|
|
214
|
+
try {
|
|
215
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
216
|
+
const ptr0 = passStringToWasm0(key, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
217
|
+
const len0 = WASM_VECTOR_LEN;
|
|
218
|
+
wasm.engine_promptSubmitted(retptr, this.__wbg_ptr, ptr0, len0);
|
|
219
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
220
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
221
|
+
if (r1) {
|
|
222
|
+
throw takeObject(r0);
|
|
223
|
+
}
|
|
224
|
+
} finally {
|
|
225
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Where the session is, as the `smllm statusline --json` object (STL-8).
|
|
230
|
+
* @param {string} key
|
|
231
|
+
* @returns {string}
|
|
232
|
+
*/
|
|
233
|
+
status(key) {
|
|
234
|
+
let deferred3_0;
|
|
235
|
+
let deferred3_1;
|
|
236
|
+
try {
|
|
237
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
238
|
+
const ptr0 = passStringToWasm0(key, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
239
|
+
const len0 = WASM_VECTOR_LEN;
|
|
240
|
+
wasm.engine_status(retptr, this.__wbg_ptr, ptr0, len0);
|
|
241
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
242
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
243
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
244
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
245
|
+
var ptr2 = r0;
|
|
246
|
+
var len2 = r1;
|
|
247
|
+
if (r3) {
|
|
248
|
+
ptr2 = 0; len2 = 0;
|
|
249
|
+
throw takeObject(r2);
|
|
250
|
+
}
|
|
251
|
+
deferred3_0 = ptr2;
|
|
252
|
+
deferred3_1 = len2;
|
|
253
|
+
return getStringFromWasm0(ptr2, len2);
|
|
254
|
+
} finally {
|
|
255
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
256
|
+
wasm.__wbindgen_export4(deferred3_0, deferred3_1, 1);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* The stop decision as JSON (TURN-4..6): `{"decision": "allow"}` = may
|
|
261
|
+
* stop; `{"decision": "block", "text"}` = hold the agent with the events
|
|
262
|
+
* list; `{"decision": "runaway", "text"}` = let it stop, showing the
|
|
263
|
+
* list to the user (the harness was already continuing because of a
|
|
264
|
+
* block, and no event was fired since).
|
|
265
|
+
* @param {string} key
|
|
266
|
+
* @param {boolean} stop_hook_active
|
|
267
|
+
* @returns {string}
|
|
268
|
+
*/
|
|
269
|
+
stop(key, stop_hook_active) {
|
|
270
|
+
let deferred3_0;
|
|
271
|
+
let deferred3_1;
|
|
272
|
+
try {
|
|
273
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
274
|
+
const ptr0 = passStringToWasm0(key, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
275
|
+
const len0 = WASM_VECTOR_LEN;
|
|
276
|
+
wasm.engine_stop(retptr, this.__wbg_ptr, ptr0, len0, stop_hook_active);
|
|
277
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
278
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
279
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
280
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
281
|
+
var ptr2 = r0;
|
|
282
|
+
var len2 = r1;
|
|
283
|
+
if (r3) {
|
|
284
|
+
ptr2 = 0; len2 = 0;
|
|
285
|
+
throw takeObject(r2);
|
|
286
|
+
}
|
|
287
|
+
deferred3_0 = ptr2;
|
|
288
|
+
deferred3_1 = len2;
|
|
289
|
+
return getStringFromWasm0(ptr2, len2);
|
|
290
|
+
} finally {
|
|
291
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
292
|
+
wasm.__wbindgen_export4(deferred3_0, deferred3_1, 1);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* The agent-facing tool, as JSON `{name, description, inputSchema}`:
|
|
297
|
+
* the core's definition, as the MCP server offers it (HOST-13).
|
|
298
|
+
* @returns {string}
|
|
299
|
+
*/
|
|
300
|
+
tool() {
|
|
301
|
+
let deferred1_0;
|
|
302
|
+
let deferred1_1;
|
|
303
|
+
try {
|
|
304
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
305
|
+
wasm.engine_tool(retptr, this.__wbg_ptr);
|
|
306
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
307
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
308
|
+
deferred1_0 = r0;
|
|
309
|
+
deferred1_1 = r1;
|
|
310
|
+
return getStringFromWasm0(r0, r1);
|
|
311
|
+
} finally {
|
|
312
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
313
|
+
wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Guard and action kinds this host cannot run, as a JSON array.
|
|
318
|
+
* @returns {string}
|
|
319
|
+
*/
|
|
320
|
+
unsupported() {
|
|
321
|
+
let deferred1_0;
|
|
322
|
+
let deferred1_1;
|
|
323
|
+
try {
|
|
324
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
325
|
+
wasm.engine_unsupported(retptr, this.__wbg_ptr);
|
|
326
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
327
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
328
|
+
deferred1_0 = r0;
|
|
329
|
+
deferred1_1 = r1;
|
|
330
|
+
return getStringFromWasm0(r0, r1);
|
|
331
|
+
} finally {
|
|
332
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
333
|
+
wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Read-only view.
|
|
338
|
+
* @param {string} key
|
|
339
|
+
* @returns {string}
|
|
340
|
+
*/
|
|
341
|
+
view(key) {
|
|
342
|
+
let deferred3_0;
|
|
343
|
+
let deferred3_1;
|
|
344
|
+
try {
|
|
345
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
346
|
+
const ptr0 = passStringToWasm0(key, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
347
|
+
const len0 = WASM_VECTOR_LEN;
|
|
348
|
+
wasm.engine_view(retptr, this.__wbg_ptr, ptr0, len0);
|
|
349
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
350
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
351
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
352
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
353
|
+
var ptr2 = r0;
|
|
354
|
+
var len2 = r1;
|
|
355
|
+
if (r3) {
|
|
356
|
+
ptr2 = 0; len2 = 0;
|
|
357
|
+
throw takeObject(r2);
|
|
358
|
+
}
|
|
359
|
+
deferred3_0 = ptr2;
|
|
360
|
+
deferred3_1 = len2;
|
|
361
|
+
return getStringFromWasm0(ptr2, len2);
|
|
362
|
+
} finally {
|
|
363
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
364
|
+
wasm.__wbindgen_export4(deferred3_0, deferred3_1, 1);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
if (Symbol.dispose) Engine.prototype[Symbol.dispose] = Engine.prototype.free;
|
|
369
|
+
export function __wbg_Error_30c8987f7c2ed4e2(arg0, arg1) {
|
|
370
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
371
|
+
return addHeapObject(ret);
|
|
372
|
+
}
|
|
373
|
+
export function __wbg_String_50e8e7e5340432bd(arg0, arg1) {
|
|
374
|
+
const ret = String(getObject(arg1));
|
|
375
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
376
|
+
const len1 = WASM_VECTOR_LEN;
|
|
377
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
378
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
379
|
+
}
|
|
380
|
+
export function __wbg___wbindgen_throw_41e9ee4f547fc59a(arg0, arg1) {
|
|
381
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
382
|
+
}
|
|
383
|
+
export function __wbg_check_50c1a220e37a7313() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) {
|
|
384
|
+
const ret = getObject(arg0).check(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4), getStringFromWasm0(arg5, arg6), getStringFromWasm0(arg7, arg8));
|
|
385
|
+
return ret;
|
|
386
|
+
}, arguments); }
|
|
387
|
+
export function __wbg_history_96f90f47fe48bff5() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6) {
|
|
388
|
+
getObject(arg0).history(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4), getStringFromWasm0(arg5, arg6));
|
|
389
|
+
}, arguments); }
|
|
390
|
+
export function __wbg_isMatch_6fae7431ba8c03f8() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
|
|
391
|
+
const ret = getObject(arg0).isMatch(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
|
|
392
|
+
return ret;
|
|
393
|
+
}, arguments); }
|
|
394
|
+
export function __wbg_now_fc028ce4f381e65e() { return handleError(function (arg0) {
|
|
395
|
+
const ret = getObject(arg0).now();
|
|
396
|
+
return ret;
|
|
397
|
+
}, arguments); }
|
|
398
|
+
export function __wbg_put_d358a9a844a38014() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6) {
|
|
399
|
+
getObject(arg0).put(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4), getStringFromWasm0(arg5, arg6));
|
|
400
|
+
}, arguments); }
|
|
401
|
+
export function __wbg_random_00b1f6c7178bf1c0() { return handleError(function (arg0) {
|
|
402
|
+
const ret = getObject(arg0).random();
|
|
403
|
+
return ret;
|
|
404
|
+
}, arguments); }
|
|
405
|
+
export function __wbg_read_1bd3096dfdac8efb() { return handleError(function (arg0, arg1, arg2, arg3) {
|
|
406
|
+
const ret = getObject(arg1).read(getStringFromWasm0(arg2, arg3));
|
|
407
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
408
|
+
var len1 = WASM_VECTOR_LEN;
|
|
409
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
410
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
411
|
+
}, arguments); }
|
|
412
|
+
export function __wbg_run_a559624047f1d933() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) {
|
|
413
|
+
const ret = getObject(arg1).run(getStringFromWasm0(arg2, arg3), getStringFromWasm0(arg4, arg5), getStringFromWasm0(arg6, arg7), getStringFromWasm0(arg8, arg9));
|
|
414
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
415
|
+
const len1 = WASM_VECTOR_LEN;
|
|
416
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
417
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
418
|
+
}, arguments); }
|
|
419
|
+
export function __wbg_supports_e8118f6f4e42b431() { return handleError(function (arg0, arg1, arg2) {
|
|
420
|
+
const ret = getObject(arg0).supports(getStringFromWasm0(arg1, arg2));
|
|
421
|
+
return ret;
|
|
422
|
+
}, arguments); }
|
|
423
|
+
export function __wbindgen_object_drop_ref(arg0) {
|
|
424
|
+
takeObject(arg0);
|
|
425
|
+
}
|
|
426
|
+
const EngineFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
427
|
+
? { register: () => {}, unregister: () => {} }
|
|
428
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_engine_free(ptr, 1));
|
|
429
|
+
|
|
430
|
+
function addHeapObject(obj) {
|
|
431
|
+
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
432
|
+
const idx = heap_next;
|
|
433
|
+
heap_next = heap[idx];
|
|
434
|
+
|
|
435
|
+
heap[idx] = obj;
|
|
436
|
+
return idx;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
function dropObject(idx) {
|
|
440
|
+
if (idx < 1028) return;
|
|
441
|
+
heap[idx] = heap_next;
|
|
442
|
+
heap_next = idx;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
let cachedDataViewMemory0 = null;
|
|
446
|
+
function getDataViewMemory0() {
|
|
447
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
448
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
449
|
+
}
|
|
450
|
+
return cachedDataViewMemory0;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
function getStringFromWasm0(ptr, len) {
|
|
454
|
+
return decodeText(ptr >>> 0, len);
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
let cachedUint8ArrayMemory0 = null;
|
|
458
|
+
function getUint8ArrayMemory0() {
|
|
459
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
460
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
461
|
+
}
|
|
462
|
+
return cachedUint8ArrayMemory0;
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
function getObject(idx) { return heap[idx]; }
|
|
466
|
+
|
|
467
|
+
function handleError(f, args) {
|
|
468
|
+
try {
|
|
469
|
+
return f.apply(this, args);
|
|
470
|
+
} catch (e) {
|
|
471
|
+
wasm.__wbindgen_export3(addHeapObject(e));
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
let heap = new Array(1024).fill(undefined);
|
|
476
|
+
heap.push(undefined, null, true, false);
|
|
477
|
+
|
|
478
|
+
let heap_next = heap.length;
|
|
479
|
+
|
|
480
|
+
function isLikeNone(x) {
|
|
481
|
+
return x === undefined || x === null;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
485
|
+
if (realloc === undefined) {
|
|
486
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
487
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
488
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
489
|
+
WASM_VECTOR_LEN = buf.length;
|
|
490
|
+
return ptr;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
let len = arg.length;
|
|
494
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
495
|
+
|
|
496
|
+
const mem = getUint8ArrayMemory0();
|
|
497
|
+
|
|
498
|
+
let offset = 0;
|
|
499
|
+
|
|
500
|
+
for (; offset < len; offset++) {
|
|
501
|
+
const code = arg.charCodeAt(offset);
|
|
502
|
+
if (code > 0x7F) break;
|
|
503
|
+
mem[ptr + offset] = code;
|
|
504
|
+
}
|
|
505
|
+
if (offset !== len) {
|
|
506
|
+
if (offset !== 0) {
|
|
507
|
+
arg = arg.slice(offset);
|
|
508
|
+
}
|
|
509
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
510
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
511
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
512
|
+
|
|
513
|
+
offset += ret.written;
|
|
514
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
WASM_VECTOR_LEN = offset;
|
|
518
|
+
return ptr;
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
function takeObject(idx) {
|
|
522
|
+
const ret = getObject(idx);
|
|
523
|
+
dropObject(idx);
|
|
524
|
+
return ret;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
528
|
+
cachedTextDecoder.decode();
|
|
529
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
530
|
+
let numBytesDecoded = 0;
|
|
531
|
+
function decodeText(ptr, len) {
|
|
532
|
+
numBytesDecoded += len;
|
|
533
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
534
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
535
|
+
cachedTextDecoder.decode();
|
|
536
|
+
numBytesDecoded = len;
|
|
537
|
+
}
|
|
538
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
const cachedTextEncoder = new TextEncoder();
|
|
542
|
+
|
|
543
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
544
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
545
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
546
|
+
view.set(buf);
|
|
547
|
+
return {
|
|
548
|
+
read: arg.length,
|
|
549
|
+
written: buf.length
|
|
550
|
+
};
|
|
551
|
+
};
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
let WASM_VECTOR_LEN = 0;
|
|
555
|
+
|
|
556
|
+
|
|
557
|
+
let wasm;
|
|
558
|
+
export function __wbg_set_wasm(val) {
|
|
559
|
+
wasm = val;
|
|
560
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const __wbg_engine_free: (a: number, b: number) => void;
|
|
5
|
+
export const engine_bind: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
|
|
6
|
+
export const engine_callTool: (a: number, b: number, c: number, d: number) => void;
|
|
7
|
+
export const engine_events: (a: number, b: number, c: number, d: number) => void;
|
|
8
|
+
export const engine_exportState: (a: number, b: number) => void;
|
|
9
|
+
export const engine_fire: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
|
|
10
|
+
export const engine_importState: (a: number, b: number, c: number, d: number) => void;
|
|
11
|
+
export const engine_new: (a: number, b: number, c: number, d: number) => void;
|
|
12
|
+
export const engine_promptSubmitted: (a: number, b: number, c: number, d: number) => void;
|
|
13
|
+
export const engine_status: (a: number, b: number, c: number, d: number) => void;
|
|
14
|
+
export const engine_stop: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
15
|
+
export const engine_tool: (a: number, b: number) => void;
|
|
16
|
+
export const engine_unsupported: (a: number, b: number) => void;
|
|
17
|
+
export const engine_view: (a: number, b: number, c: number, d: number) => void;
|
|
18
|
+
export const __wbindgen_export: (a: number, b: number) => number;
|
|
19
|
+
export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
20
|
+
export const __wbindgen_export3: (a: number) => void;
|
|
21
|
+
export const __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
22
|
+
export const __wbindgen_export4: (a: number, b: number, c: number) => void;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* An smllm engine with an in-memory store.
|
|
6
|
+
*/
|
|
7
|
+
export class Engine {
|
|
8
|
+
free(): void;
|
|
9
|
+
[Symbol.dispose](): void;
|
|
10
|
+
/**
|
|
11
|
+
* Bind a session; returns the reply JSON (its `session` is the key).
|
|
12
|
+
*/
|
|
13
|
+
bind(harness: string, host_session: string | null | undefined, cwd: string): string;
|
|
14
|
+
/**
|
|
15
|
+
* A tool call: the agent's arguments as JSON, answered as the MCP
|
|
16
|
+
* server answers them (HOST-13). A malformed call or an engine error is
|
|
17
|
+
* a reply with `ok: false` and `error: …`, never a throw: the agent
|
|
18
|
+
* sees its mistake as the tool's answer.
|
|
19
|
+
*/
|
|
20
|
+
callTool(args: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* The events list.
|
|
23
|
+
*/
|
|
24
|
+
events(key: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* Sessions, bindings and instances as JSON (history went to the host).
|
|
27
|
+
*/
|
|
28
|
+
exportState(): string;
|
|
29
|
+
/**
|
|
30
|
+
* Fire an event; `params` is a JSON object of strings.
|
|
31
|
+
*/
|
|
32
|
+
fire(key: string | null | undefined, event: string, params: string): string;
|
|
33
|
+
/**
|
|
34
|
+
* Replace the store from [`Engine::export_state`] JSON.
|
|
35
|
+
*/
|
|
36
|
+
importState(state: string): void;
|
|
37
|
+
/**
|
|
38
|
+
* Load compiled machines (`smllm compile` output).
|
|
39
|
+
*/
|
|
40
|
+
constructor(compiled: string, host: any);
|
|
41
|
+
/**
|
|
42
|
+
* A user prompt arrived.
|
|
43
|
+
*/
|
|
44
|
+
promptSubmitted(key: string): void;
|
|
45
|
+
/**
|
|
46
|
+
* Where the session is, as the `smllm statusline --json` object (STL-8).
|
|
47
|
+
*/
|
|
48
|
+
status(key: string): string;
|
|
49
|
+
/**
|
|
50
|
+
* The stop decision as JSON (TURN-4..6): `{"decision": "allow"}` = may
|
|
51
|
+
* stop; `{"decision": "block", "text"}` = hold the agent with the events
|
|
52
|
+
* list; `{"decision": "runaway", "text"}` = let it stop, showing the
|
|
53
|
+
* list to the user (the harness was already continuing because of a
|
|
54
|
+
* block, and no event was fired since).
|
|
55
|
+
*/
|
|
56
|
+
stop(key: string, stop_hook_active: boolean): string;
|
|
57
|
+
/**
|
|
58
|
+
* The agent-facing tool, as JSON `{name, description, inputSchema}`:
|
|
59
|
+
* the core's definition, as the MCP server offers it (HOST-13).
|
|
60
|
+
*/
|
|
61
|
+
tool(): string;
|
|
62
|
+
/**
|
|
63
|
+
* Guard and action kinds this host cannot run, as a JSON array.
|
|
64
|
+
*/
|
|
65
|
+
unsupported(): string;
|
|
66
|
+
/**
|
|
67
|
+
* Read-only view.
|
|
68
|
+
*/
|
|
69
|
+
view(key: string): string;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
73
|
+
|
|
74
|
+
export interface InitOutput {
|
|
75
|
+
readonly memory: WebAssembly.Memory;
|
|
76
|
+
readonly __wbg_engine_free: (a: number, b: number) => void;
|
|
77
|
+
readonly engine_bind: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
|
|
78
|
+
readonly engine_callTool: (a: number, b: number, c: number, d: number) => void;
|
|
79
|
+
readonly engine_events: (a: number, b: number, c: number, d: number) => void;
|
|
80
|
+
readonly engine_exportState: (a: number, b: number) => void;
|
|
81
|
+
readonly engine_fire: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
|
|
82
|
+
readonly engine_importState: (a: number, b: number, c: number, d: number) => void;
|
|
83
|
+
readonly engine_new: (a: number, b: number, c: number, d: number) => void;
|
|
84
|
+
readonly engine_promptSubmitted: (a: number, b: number, c: number, d: number) => void;
|
|
85
|
+
readonly engine_status: (a: number, b: number, c: number, d: number) => void;
|
|
86
|
+
readonly engine_stop: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
87
|
+
readonly engine_tool: (a: number, b: number) => void;
|
|
88
|
+
readonly engine_unsupported: (a: number, b: number) => void;
|
|
89
|
+
readonly engine_view: (a: number, b: number, c: number, d: number) => void;
|
|
90
|
+
readonly __wbindgen_export: (a: number, b: number) => number;
|
|
91
|
+
readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
92
|
+
readonly __wbindgen_export3: (a: number) => void;
|
|
93
|
+
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
94
|
+
readonly __wbindgen_export4: (a: number, b: number, c: number) => void;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
101
|
+
* a precompiled `WebAssembly.Module`.
|
|
102
|
+
*
|
|
103
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
104
|
+
*
|
|
105
|
+
* @returns {InitOutput}
|
|
106
|
+
*/
|
|
107
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
111
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
112
|
+
*
|
|
113
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
114
|
+
*
|
|
115
|
+
* @returns {Promise<InitOutput>}
|
|
116
|
+
*/
|
|
117
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|