@six5536/smllm-wasm 0.4.1 → 0.6.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 +136 -2
- package/dist/node/host.d.ts +1 -1
- package/dist/node/host.js +4 -4
- package/dist/node/storage.js +1 -2
- package/dist/storage.js +1 -2
- package/dist/types.d.ts +96 -4
- package/dist/wrap.d.ts +40 -6
- package/dist/wrap.js +55 -4
- package/package.json +1 -1
- package/wasm/bundler/smllm_wasm.d.ts +30 -5
- package/wasm/bundler/smllm_wasm_bg.js +192 -15
- package/wasm/bundler/smllm_wasm_bg.wasm +0 -0
- package/wasm/bundler/smllm_wasm_bg.wasm.d.ts +5 -0
- package/wasm/web/smllm_wasm.d.ts +35 -5
- package/wasm/web/smllm_wasm.js +192 -15
- package/wasm/web/smllm_wasm_bg.wasm +0 -0
- package/wasm/web/smllm_wasm_bg.wasm.d.ts +5 -0
package/wasm/web/smllm_wasm.js
CHANGED
|
@@ -14,6 +14,37 @@ export class Engine {
|
|
|
14
14
|
const ptr = this.__destroy_into_raw();
|
|
15
15
|
wasm.__wbg_engine_free(ptr, 0);
|
|
16
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* The JSON Schema of a valid answer, as JSON (ENG-8).
|
|
19
|
+
* @param {string} key
|
|
20
|
+
* @returns {string}
|
|
21
|
+
*/
|
|
22
|
+
answerSchema(key) {
|
|
23
|
+
let deferred3_0;
|
|
24
|
+
let deferred3_1;
|
|
25
|
+
try {
|
|
26
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
27
|
+
const ptr0 = passStringToWasm0(key, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
28
|
+
const len0 = WASM_VECTOR_LEN;
|
|
29
|
+
wasm.engine_answerSchema(retptr, this.__wbg_ptr, ptr0, len0);
|
|
30
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
31
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
32
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
33
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
34
|
+
var ptr2 = r0;
|
|
35
|
+
var len2 = r1;
|
|
36
|
+
if (r3) {
|
|
37
|
+
ptr2 = 0; len2 = 0;
|
|
38
|
+
throw takeObject(r2);
|
|
39
|
+
}
|
|
40
|
+
deferred3_0 = ptr2;
|
|
41
|
+
deferred3_1 = len2;
|
|
42
|
+
return getStringFromWasm0(ptr2, len2);
|
|
43
|
+
} finally {
|
|
44
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
45
|
+
wasm.__wbindgen_export4(deferred3_0, deferred3_1, 1);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
17
48
|
/**
|
|
18
49
|
* Bind a session; returns the reply JSON (its `session` is the key).
|
|
19
50
|
* @param {string} harness
|
|
@@ -53,7 +84,7 @@ export class Engine {
|
|
|
53
84
|
}
|
|
54
85
|
/**
|
|
55
86
|
* A tool call: the agent's arguments as JSON, answered as the MCP
|
|
56
|
-
* server answers them (
|
|
87
|
+
* server answers them (WASM-1). A malformed call or an engine error is
|
|
57
88
|
* a reply with `ok: false` and `error: …`, never a throw: the agent
|
|
58
89
|
* sees its mistake as the tool's answer.
|
|
59
90
|
* @param {string} args
|
|
@@ -77,6 +108,42 @@ export class Engine {
|
|
|
77
108
|
wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
|
|
78
109
|
}
|
|
79
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* A model's answer checked (ENG-9), as JSON: `{"ok": true, "event",
|
|
113
|
+
* "params"}`, whose params are JSON values ready for `fire`, or
|
|
114
|
+
* `{"ok": false, "error"}`.
|
|
115
|
+
* @param {string} key
|
|
116
|
+
* @param {string} text
|
|
117
|
+
* @returns {string}
|
|
118
|
+
*/
|
|
119
|
+
checkAnswer(key, text) {
|
|
120
|
+
let deferred4_0;
|
|
121
|
+
let deferred4_1;
|
|
122
|
+
try {
|
|
123
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
124
|
+
const ptr0 = passStringToWasm0(key, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
125
|
+
const len0 = WASM_VECTOR_LEN;
|
|
126
|
+
const ptr1 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
127
|
+
const len1 = WASM_VECTOR_LEN;
|
|
128
|
+
wasm.engine_checkAnswer(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
129
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
130
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
131
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
132
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
133
|
+
var ptr3 = r0;
|
|
134
|
+
var len3 = r1;
|
|
135
|
+
if (r3) {
|
|
136
|
+
ptr3 = 0; len3 = 0;
|
|
137
|
+
throw takeObject(r2);
|
|
138
|
+
}
|
|
139
|
+
deferred4_0 = ptr3;
|
|
140
|
+
deferred4_1 = len3;
|
|
141
|
+
return getStringFromWasm0(ptr3, len3);
|
|
142
|
+
} finally {
|
|
143
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
144
|
+
wasm.__wbindgen_export4(deferred4_0, deferred4_1, 1);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
80
147
|
/**
|
|
81
148
|
* The events list.
|
|
82
149
|
* @param {string} key
|
|
@@ -129,7 +196,45 @@ export class Engine {
|
|
|
129
196
|
}
|
|
130
197
|
}
|
|
131
198
|
/**
|
|
132
|
-
* Fire an event
|
|
199
|
+
* Fire an event as the host, host-only events included (ENG-6).
|
|
200
|
+
* @param {string | null | undefined} key
|
|
201
|
+
* @param {string} event
|
|
202
|
+
* @param {string} params
|
|
203
|
+
* @returns {string}
|
|
204
|
+
*/
|
|
205
|
+
fireAsHost(key, event, params) {
|
|
206
|
+
let deferred5_0;
|
|
207
|
+
let deferred5_1;
|
|
208
|
+
try {
|
|
209
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
210
|
+
var ptr0 = isLikeNone(key) ? 0 : passStringToWasm0(key, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
211
|
+
var len0 = WASM_VECTOR_LEN;
|
|
212
|
+
const ptr1 = passStringToWasm0(event, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
213
|
+
const len1 = WASM_VECTOR_LEN;
|
|
214
|
+
const ptr2 = passStringToWasm0(params, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
215
|
+
const len2 = WASM_VECTOR_LEN;
|
|
216
|
+
wasm.engine_fireAsHost(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
217
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
218
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
219
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
220
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
221
|
+
var ptr4 = r0;
|
|
222
|
+
var len4 = r1;
|
|
223
|
+
if (r3) {
|
|
224
|
+
ptr4 = 0; len4 = 0;
|
|
225
|
+
throw takeObject(r2);
|
|
226
|
+
}
|
|
227
|
+
deferred5_0 = ptr4;
|
|
228
|
+
deferred5_1 = len4;
|
|
229
|
+
return getStringFromWasm0(ptr4, len4);
|
|
230
|
+
} finally {
|
|
231
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
232
|
+
wasm.__wbindgen_export4(deferred5_0, deferred5_1, 1);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Fire an event for the agent; `params` is a JSON object, of strings
|
|
237
|
+
* except for a JSON param's value.
|
|
133
238
|
* @param {string | null | undefined} key
|
|
134
239
|
* @param {string} event
|
|
135
240
|
* @param {string} params
|
|
@@ -165,6 +270,38 @@ export class Engine {
|
|
|
165
270
|
wasm.__wbindgen_export4(deferred5_0, deferred5_1, 1);
|
|
166
271
|
}
|
|
167
272
|
}
|
|
273
|
+
/**
|
|
274
|
+
* The state's offered events in two lists, the model's and the
|
|
275
|
+
* host's, with where the session is, as JSON (ENG-10).
|
|
276
|
+
* @param {string} key
|
|
277
|
+
* @returns {string}
|
|
278
|
+
*/
|
|
279
|
+
hostView(key) {
|
|
280
|
+
let deferred3_0;
|
|
281
|
+
let deferred3_1;
|
|
282
|
+
try {
|
|
283
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
284
|
+
const ptr0 = passStringToWasm0(key, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
285
|
+
const len0 = WASM_VECTOR_LEN;
|
|
286
|
+
wasm.engine_hostView(retptr, this.__wbg_ptr, ptr0, len0);
|
|
287
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
288
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
289
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
290
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
291
|
+
var ptr2 = r0;
|
|
292
|
+
var len2 = r1;
|
|
293
|
+
if (r3) {
|
|
294
|
+
ptr2 = 0; len2 = 0;
|
|
295
|
+
throw takeObject(r2);
|
|
296
|
+
}
|
|
297
|
+
deferred3_0 = ptr2;
|
|
298
|
+
deferred3_1 = len2;
|
|
299
|
+
return getStringFromWasm0(ptr2, len2);
|
|
300
|
+
} finally {
|
|
301
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
302
|
+
wasm.__wbindgen_export4(deferred3_0, deferred3_1, 1);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
168
305
|
/**
|
|
169
306
|
* Replace the store from [`Engine::export_state`] JSON.
|
|
170
307
|
* @param {string} state
|
|
@@ -228,7 +365,40 @@ export class Engine {
|
|
|
228
365
|
}
|
|
229
366
|
}
|
|
230
367
|
/**
|
|
231
|
-
*
|
|
368
|
+
* The state's text for a model without tools; `schemas` shows each
|
|
369
|
+
* JSON param's schema (ENG-7).
|
|
370
|
+
* @param {string} key
|
|
371
|
+
* @param {boolean} schemas
|
|
372
|
+
* @returns {string}
|
|
373
|
+
*/
|
|
374
|
+
stateText(key, schemas) {
|
|
375
|
+
let deferred3_0;
|
|
376
|
+
let deferred3_1;
|
|
377
|
+
try {
|
|
378
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
379
|
+
const ptr0 = passStringToWasm0(key, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
380
|
+
const len0 = WASM_VECTOR_LEN;
|
|
381
|
+
wasm.engine_stateText(retptr, this.__wbg_ptr, ptr0, len0, schemas);
|
|
382
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
383
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
384
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
385
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
386
|
+
var ptr2 = r0;
|
|
387
|
+
var len2 = r1;
|
|
388
|
+
if (r3) {
|
|
389
|
+
ptr2 = 0; len2 = 0;
|
|
390
|
+
throw takeObject(r2);
|
|
391
|
+
}
|
|
392
|
+
deferred3_0 = ptr2;
|
|
393
|
+
deferred3_1 = len2;
|
|
394
|
+
return getStringFromWasm0(ptr2, len2);
|
|
395
|
+
} finally {
|
|
396
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
397
|
+
wasm.__wbindgen_export4(deferred3_0, deferred3_1, 1);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* Where the session is, as the `smllm statusline --json` object (ENG-3).
|
|
232
402
|
* @param {string} key
|
|
233
403
|
* @returns {string}
|
|
234
404
|
*/
|
|
@@ -259,7 +429,7 @@ export class Engine {
|
|
|
259
429
|
}
|
|
260
430
|
}
|
|
261
431
|
/**
|
|
262
|
-
* The stop decision as JSON (
|
|
432
|
+
* The stop decision as JSON (AGT-8..6): `{"decision": "allow"}` = may
|
|
263
433
|
* stop; `{"decision": "block", "text"}` = hold the agent with the events
|
|
264
434
|
* list; `{"decision": "runaway", "text"}` = let it stop, showing the
|
|
265
435
|
* list to the user (the harness was already continuing because of a
|
|
@@ -296,7 +466,7 @@ export class Engine {
|
|
|
296
466
|
}
|
|
297
467
|
/**
|
|
298
468
|
* The agent-facing tool, as JSON `{name, description, inputSchema}`:
|
|
299
|
-
* the core's definition, as the MCP server offers it (
|
|
469
|
+
* the core's definition, as the MCP server offers it (WASM-1).
|
|
300
470
|
* @returns {string}
|
|
301
471
|
*/
|
|
302
472
|
tool() {
|
|
@@ -375,7 +545,7 @@ function __wbg_get_imports() {
|
|
|
375
545
|
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
376
546
|
return addHeapObject(ret);
|
|
377
547
|
},
|
|
378
|
-
|
|
548
|
+
__wbg_String_a5249499d8036ec9: function(arg0, arg1) {
|
|
379
549
|
const ret = String(getObject(arg1));
|
|
380
550
|
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
381
551
|
const len1 = WASM_VECTOR_LEN;
|
|
@@ -385,46 +555,53 @@ function __wbg_get_imports() {
|
|
|
385
555
|
__wbg___wbindgen_throw_41e9ee4f547fc59a: function(arg0, arg1) {
|
|
386
556
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
387
557
|
},
|
|
388
|
-
|
|
558
|
+
__wbg_audit_85f5bb21263e0644: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
|
|
559
|
+
getObject(arg0).audit(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
|
|
560
|
+
}, arguments); },
|
|
561
|
+
__wbg_check_e9ea28c77bd41729: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) {
|
|
389
562
|
const ret = getObject(arg0).check(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4), getStringFromWasm0(arg5, arg6), getStringFromWasm0(arg7, arg8));
|
|
390
563
|
return ret;
|
|
391
564
|
}, arguments); },
|
|
392
|
-
|
|
565
|
+
__wbg_history_ba99161437b60e0e: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6) {
|
|
393
566
|
getObject(arg0).history(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4), getStringFromWasm0(arg5, arg6));
|
|
394
567
|
}, arguments); },
|
|
395
|
-
|
|
568
|
+
__wbg_isMatch_57a619cdd9087ba8: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
|
|
396
569
|
const ret = getObject(arg0).isMatch(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
|
|
397
570
|
return ret;
|
|
398
571
|
}, arguments); },
|
|
399
|
-
|
|
572
|
+
__wbg_now_1a669daa685d184d: function() { return handleError(function (arg0) {
|
|
400
573
|
const ret = getObject(arg0).now();
|
|
401
574
|
return ret;
|
|
402
575
|
}, arguments); },
|
|
403
|
-
|
|
576
|
+
__wbg_put_8270908aa8f03c2a: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6) {
|
|
404
577
|
getObject(arg0).put(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4), getStringFromWasm0(arg5, arg6));
|
|
405
578
|
}, arguments); },
|
|
406
|
-
|
|
579
|
+
__wbg_random_a2849827a284f2d5: function() { return handleError(function (arg0) {
|
|
407
580
|
const ret = getObject(arg0).random();
|
|
408
581
|
return ret;
|
|
409
582
|
}, arguments); },
|
|
410
|
-
|
|
583
|
+
__wbg_read_e79d6ea23600ac6f: function() { return handleError(function (arg0, arg1, arg2, arg3) {
|
|
411
584
|
const ret = getObject(arg1).read(getStringFromWasm0(arg2, arg3));
|
|
412
585
|
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
413
586
|
var len1 = WASM_VECTOR_LEN;
|
|
414
587
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
415
588
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
416
589
|
}, arguments); },
|
|
417
|
-
|
|
590
|
+
__wbg_run_e1681363901db5c8: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) {
|
|
418
591
|
const ret = getObject(arg1).run(getStringFromWasm0(arg2, arg3), getStringFromWasm0(arg4, arg5), getStringFromWasm0(arg6, arg7), getStringFromWasm0(arg8, arg9));
|
|
419
592
|
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
420
593
|
const len1 = WASM_VECTOR_LEN;
|
|
421
594
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
422
595
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
423
596
|
}, arguments); },
|
|
424
|
-
|
|
597
|
+
__wbg_supports_5e904725127552cf: function() { return handleError(function (arg0, arg1, arg2) {
|
|
425
598
|
const ret = getObject(arg0).supports(getStringFromWasm0(arg1, arg2));
|
|
426
599
|
return ret;
|
|
427
600
|
}, arguments); },
|
|
601
|
+
__wbg_wantsAudit_27e6b386da9d3696: function() { return handleError(function (arg0) {
|
|
602
|
+
const ret = getObject(arg0).wantsAudit();
|
|
603
|
+
return ret;
|
|
604
|
+
}, arguments); },
|
|
428
605
|
__wbindgen_object_drop_ref: function(arg0) {
|
|
429
606
|
takeObject(arg0);
|
|
430
607
|
},
|
|
Binary file
|
|
@@ -2,14 +2,19 @@
|
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
4
|
export const __wbg_engine_free: (a: number, b: number) => void;
|
|
5
|
+
export const engine_answerSchema: (a: number, b: number, c: number, d: number) => void;
|
|
5
6
|
export const engine_bind: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
|
|
6
7
|
export const engine_callTool: (a: number, b: number, c: number, d: number) => void;
|
|
8
|
+
export const engine_checkAnswer: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
7
9
|
export const engine_events: (a: number, b: number, c: number, d: number) => void;
|
|
8
10
|
export const engine_exportState: (a: number, b: number) => void;
|
|
9
11
|
export const engine_fire: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
|
|
12
|
+
export const engine_fireAsHost: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
|
|
13
|
+
export const engine_hostView: (a: number, b: number, c: number, d: number) => void;
|
|
10
14
|
export const engine_importState: (a: number, b: number, c: number, d: number) => void;
|
|
11
15
|
export const engine_new: (a: number, b: number, c: number, d: number) => void;
|
|
12
16
|
export const engine_promptSubmitted: (a: number, b: number, c: number, d: number) => void;
|
|
17
|
+
export const engine_stateText: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
13
18
|
export const engine_status: (a: number, b: number, c: number, d: number) => void;
|
|
14
19
|
export const engine_stop: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
15
20
|
export const engine_tool: (a: number, b: number) => void;
|