@six5536/smllm-wasm 0.0.0 → 0.4.1

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.
@@ -0,0 +1,663 @@
1
+ /* @ts-self-types="./smllm_wasm.d.ts" */
2
+
3
+ /**
4
+ * An smllm engine with an in-memory store.
5
+ */
6
+ export class Engine {
7
+ __destroy_into_raw() {
8
+ const ptr = this.__wbg_ptr;
9
+ this.__wbg_ptr = 0;
10
+ EngineFinalization.unregister(this);
11
+ return ptr;
12
+ }
13
+ free() {
14
+ const ptr = this.__destroy_into_raw();
15
+ wasm.__wbg_engine_free(ptr, 0);
16
+ }
17
+ /**
18
+ * Bind a session; returns the reply JSON (its `session` is the key).
19
+ * @param {string} harness
20
+ * @param {string | null | undefined} host_session
21
+ * @param {string} cwd
22
+ * @returns {string}
23
+ */
24
+ bind(harness, host_session, cwd) {
25
+ let deferred5_0;
26
+ let deferred5_1;
27
+ try {
28
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
29
+ const ptr0 = passStringToWasm0(harness, wasm.__wbindgen_export, wasm.__wbindgen_export2);
30
+ const len0 = WASM_VECTOR_LEN;
31
+ var ptr1 = isLikeNone(host_session) ? 0 : passStringToWasm0(host_session, wasm.__wbindgen_export, wasm.__wbindgen_export2);
32
+ var len1 = WASM_VECTOR_LEN;
33
+ const ptr2 = passStringToWasm0(cwd, wasm.__wbindgen_export, wasm.__wbindgen_export2);
34
+ const len2 = WASM_VECTOR_LEN;
35
+ wasm.engine_bind(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
36
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
37
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
38
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
39
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
40
+ var ptr4 = r0;
41
+ var len4 = r1;
42
+ if (r3) {
43
+ ptr4 = 0; len4 = 0;
44
+ throw takeObject(r2);
45
+ }
46
+ deferred5_0 = ptr4;
47
+ deferred5_1 = len4;
48
+ return getStringFromWasm0(ptr4, len4);
49
+ } finally {
50
+ wasm.__wbindgen_add_to_stack_pointer(16);
51
+ wasm.__wbindgen_export4(deferred5_0, deferred5_1, 1);
52
+ }
53
+ }
54
+ /**
55
+ * A tool call: the agent's arguments as JSON, answered as the MCP
56
+ * server answers them (HOST-13). A malformed call or an engine error is
57
+ * a reply with `ok: false` and `error: …`, never a throw: the agent
58
+ * sees its mistake as the tool's answer.
59
+ * @param {string} args
60
+ * @returns {string}
61
+ */
62
+ callTool(args) {
63
+ let deferred2_0;
64
+ let deferred2_1;
65
+ try {
66
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
67
+ const ptr0 = passStringToWasm0(args, wasm.__wbindgen_export, wasm.__wbindgen_export2);
68
+ const len0 = WASM_VECTOR_LEN;
69
+ wasm.engine_callTool(retptr, this.__wbg_ptr, ptr0, len0);
70
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
71
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
72
+ deferred2_0 = r0;
73
+ deferred2_1 = r1;
74
+ return getStringFromWasm0(r0, r1);
75
+ } finally {
76
+ wasm.__wbindgen_add_to_stack_pointer(16);
77
+ wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
78
+ }
79
+ }
80
+ /**
81
+ * The events list.
82
+ * @param {string} key
83
+ * @returns {string}
84
+ */
85
+ events(key) {
86
+ let deferred3_0;
87
+ let deferred3_1;
88
+ try {
89
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
90
+ const ptr0 = passStringToWasm0(key, wasm.__wbindgen_export, wasm.__wbindgen_export2);
91
+ const len0 = WASM_VECTOR_LEN;
92
+ wasm.engine_events(retptr, this.__wbg_ptr, ptr0, len0);
93
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
94
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
95
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
96
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
97
+ var ptr2 = r0;
98
+ var len2 = r1;
99
+ if (r3) {
100
+ ptr2 = 0; len2 = 0;
101
+ throw takeObject(r2);
102
+ }
103
+ deferred3_0 = ptr2;
104
+ deferred3_1 = len2;
105
+ return getStringFromWasm0(ptr2, len2);
106
+ } finally {
107
+ wasm.__wbindgen_add_to_stack_pointer(16);
108
+ wasm.__wbindgen_export4(deferred3_0, deferred3_1, 1);
109
+ }
110
+ }
111
+ /**
112
+ * Sessions, bindings and instances as JSON (history went to the host).
113
+ * @returns {string}
114
+ */
115
+ exportState() {
116
+ let deferred1_0;
117
+ let deferred1_1;
118
+ try {
119
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
120
+ wasm.engine_exportState(retptr, this.__wbg_ptr);
121
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
122
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
123
+ deferred1_0 = r0;
124
+ deferred1_1 = r1;
125
+ return getStringFromWasm0(r0, r1);
126
+ } finally {
127
+ wasm.__wbindgen_add_to_stack_pointer(16);
128
+ wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
129
+ }
130
+ }
131
+ /**
132
+ * Fire an event; `params` is a JSON object of strings.
133
+ * @param {string | null | undefined} key
134
+ * @param {string} event
135
+ * @param {string} params
136
+ * @returns {string}
137
+ */
138
+ fire(key, event, params) {
139
+ let deferred5_0;
140
+ let deferred5_1;
141
+ try {
142
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
143
+ var ptr0 = isLikeNone(key) ? 0 : passStringToWasm0(key, wasm.__wbindgen_export, wasm.__wbindgen_export2);
144
+ var len0 = WASM_VECTOR_LEN;
145
+ const ptr1 = passStringToWasm0(event, wasm.__wbindgen_export, wasm.__wbindgen_export2);
146
+ const len1 = WASM_VECTOR_LEN;
147
+ const ptr2 = passStringToWasm0(params, wasm.__wbindgen_export, wasm.__wbindgen_export2);
148
+ const len2 = WASM_VECTOR_LEN;
149
+ wasm.engine_fire(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
150
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
151
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
152
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
153
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
154
+ var ptr4 = r0;
155
+ var len4 = r1;
156
+ if (r3) {
157
+ ptr4 = 0; len4 = 0;
158
+ throw takeObject(r2);
159
+ }
160
+ deferred5_0 = ptr4;
161
+ deferred5_1 = len4;
162
+ return getStringFromWasm0(ptr4, len4);
163
+ } finally {
164
+ wasm.__wbindgen_add_to_stack_pointer(16);
165
+ wasm.__wbindgen_export4(deferred5_0, deferred5_1, 1);
166
+ }
167
+ }
168
+ /**
169
+ * Replace the store from [`Engine::export_state`] JSON.
170
+ * @param {string} state
171
+ */
172
+ importState(state) {
173
+ try {
174
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
175
+ const ptr0 = passStringToWasm0(state, wasm.__wbindgen_export, wasm.__wbindgen_export2);
176
+ const len0 = WASM_VECTOR_LEN;
177
+ wasm.engine_importState(retptr, this.__wbg_ptr, ptr0, len0);
178
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
179
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
180
+ if (r1) {
181
+ throw takeObject(r0);
182
+ }
183
+ } finally {
184
+ wasm.__wbindgen_add_to_stack_pointer(16);
185
+ }
186
+ }
187
+ /**
188
+ * Load compiled machines (`smllm compile` output).
189
+ * @param {string} compiled
190
+ * @param {any} host
191
+ */
192
+ constructor(compiled, host) {
193
+ try {
194
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
195
+ const ptr0 = passStringToWasm0(compiled, wasm.__wbindgen_export, wasm.__wbindgen_export2);
196
+ const len0 = WASM_VECTOR_LEN;
197
+ wasm.engine_new(retptr, ptr0, len0, addHeapObject(host));
198
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
199
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
200
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
201
+ if (r2) {
202
+ throw takeObject(r1);
203
+ }
204
+ this.__wbg_ptr = r0;
205
+ EngineFinalization.register(this, this.__wbg_ptr, this);
206
+ return this;
207
+ } finally {
208
+ wasm.__wbindgen_add_to_stack_pointer(16);
209
+ }
210
+ }
211
+ /**
212
+ * A user prompt arrived.
213
+ * @param {string} key
214
+ */
215
+ promptSubmitted(key) {
216
+ try {
217
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
218
+ const ptr0 = passStringToWasm0(key, wasm.__wbindgen_export, wasm.__wbindgen_export2);
219
+ const len0 = WASM_VECTOR_LEN;
220
+ wasm.engine_promptSubmitted(retptr, this.__wbg_ptr, ptr0, len0);
221
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
222
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
223
+ if (r1) {
224
+ throw takeObject(r0);
225
+ }
226
+ } finally {
227
+ wasm.__wbindgen_add_to_stack_pointer(16);
228
+ }
229
+ }
230
+ /**
231
+ * Where the session is, as the `smllm statusline --json` object (STL-8).
232
+ * @param {string} key
233
+ * @returns {string}
234
+ */
235
+ status(key) {
236
+ let deferred3_0;
237
+ let deferred3_1;
238
+ try {
239
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
240
+ const ptr0 = passStringToWasm0(key, wasm.__wbindgen_export, wasm.__wbindgen_export2);
241
+ const len0 = WASM_VECTOR_LEN;
242
+ wasm.engine_status(retptr, this.__wbg_ptr, ptr0, len0);
243
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
244
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
245
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
246
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
247
+ var ptr2 = r0;
248
+ var len2 = r1;
249
+ if (r3) {
250
+ ptr2 = 0; len2 = 0;
251
+ throw takeObject(r2);
252
+ }
253
+ deferred3_0 = ptr2;
254
+ deferred3_1 = len2;
255
+ return getStringFromWasm0(ptr2, len2);
256
+ } finally {
257
+ wasm.__wbindgen_add_to_stack_pointer(16);
258
+ wasm.__wbindgen_export4(deferred3_0, deferred3_1, 1);
259
+ }
260
+ }
261
+ /**
262
+ * The stop decision as JSON (TURN-4..6): `{"decision": "allow"}` = may
263
+ * stop; `{"decision": "block", "text"}` = hold the agent with the events
264
+ * list; `{"decision": "runaway", "text"}` = let it stop, showing the
265
+ * list to the user (the harness was already continuing because of a
266
+ * block, and no event was fired since).
267
+ * @param {string} key
268
+ * @param {boolean} stop_hook_active
269
+ * @returns {string}
270
+ */
271
+ stop(key, stop_hook_active) {
272
+ let deferred3_0;
273
+ let deferred3_1;
274
+ try {
275
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
276
+ const ptr0 = passStringToWasm0(key, wasm.__wbindgen_export, wasm.__wbindgen_export2);
277
+ const len0 = WASM_VECTOR_LEN;
278
+ wasm.engine_stop(retptr, this.__wbg_ptr, ptr0, len0, stop_hook_active);
279
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
280
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
281
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
282
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
283
+ var ptr2 = r0;
284
+ var len2 = r1;
285
+ if (r3) {
286
+ ptr2 = 0; len2 = 0;
287
+ throw takeObject(r2);
288
+ }
289
+ deferred3_0 = ptr2;
290
+ deferred3_1 = len2;
291
+ return getStringFromWasm0(ptr2, len2);
292
+ } finally {
293
+ wasm.__wbindgen_add_to_stack_pointer(16);
294
+ wasm.__wbindgen_export4(deferred3_0, deferred3_1, 1);
295
+ }
296
+ }
297
+ /**
298
+ * The agent-facing tool, as JSON `{name, description, inputSchema}`:
299
+ * the core's definition, as the MCP server offers it (HOST-13).
300
+ * @returns {string}
301
+ */
302
+ tool() {
303
+ let deferred1_0;
304
+ let deferred1_1;
305
+ try {
306
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
307
+ wasm.engine_tool(retptr, this.__wbg_ptr);
308
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
309
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
310
+ deferred1_0 = r0;
311
+ deferred1_1 = r1;
312
+ return getStringFromWasm0(r0, r1);
313
+ } finally {
314
+ wasm.__wbindgen_add_to_stack_pointer(16);
315
+ wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
316
+ }
317
+ }
318
+ /**
319
+ * Guard and action kinds this host cannot run, as a JSON array.
320
+ * @returns {string}
321
+ */
322
+ unsupported() {
323
+ let deferred1_0;
324
+ let deferred1_1;
325
+ try {
326
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
327
+ wasm.engine_unsupported(retptr, this.__wbg_ptr);
328
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
329
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
330
+ deferred1_0 = r0;
331
+ deferred1_1 = r1;
332
+ return getStringFromWasm0(r0, r1);
333
+ } finally {
334
+ wasm.__wbindgen_add_to_stack_pointer(16);
335
+ wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
336
+ }
337
+ }
338
+ /**
339
+ * Read-only view.
340
+ * @param {string} key
341
+ * @returns {string}
342
+ */
343
+ view(key) {
344
+ let deferred3_0;
345
+ let deferred3_1;
346
+ try {
347
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
348
+ const ptr0 = passStringToWasm0(key, wasm.__wbindgen_export, wasm.__wbindgen_export2);
349
+ const len0 = WASM_VECTOR_LEN;
350
+ wasm.engine_view(retptr, this.__wbg_ptr, ptr0, len0);
351
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
352
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
353
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
354
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
355
+ var ptr2 = r0;
356
+ var len2 = r1;
357
+ if (r3) {
358
+ ptr2 = 0; len2 = 0;
359
+ throw takeObject(r2);
360
+ }
361
+ deferred3_0 = ptr2;
362
+ deferred3_1 = len2;
363
+ return getStringFromWasm0(ptr2, len2);
364
+ } finally {
365
+ wasm.__wbindgen_add_to_stack_pointer(16);
366
+ wasm.__wbindgen_export4(deferred3_0, deferred3_1, 1);
367
+ }
368
+ }
369
+ }
370
+ if (Symbol.dispose) Engine.prototype[Symbol.dispose] = Engine.prototype.free;
371
+ function __wbg_get_imports() {
372
+ const import0 = {
373
+ __proto__: null,
374
+ __wbg_Error_30c8987f7c2ed4e2: function(arg0, arg1) {
375
+ const ret = Error(getStringFromWasm0(arg0, arg1));
376
+ return addHeapObject(ret);
377
+ },
378
+ __wbg_String_21dd8e4cadac6119: function(arg0, arg1) {
379
+ const ret = String(getObject(arg1));
380
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
381
+ const len1 = WASM_VECTOR_LEN;
382
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
383
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
384
+ },
385
+ __wbg___wbindgen_throw_41e9ee4f547fc59a: function(arg0, arg1) {
386
+ throw new Error(getStringFromWasm0(arg0, arg1));
387
+ },
388
+ __wbg_check_5d89c03ece031583: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) {
389
+ const ret = getObject(arg0).check(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4), getStringFromWasm0(arg5, arg6), getStringFromWasm0(arg7, arg8));
390
+ return ret;
391
+ }, arguments); },
392
+ __wbg_history_42d22e18a421fc7d: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6) {
393
+ getObject(arg0).history(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4), getStringFromWasm0(arg5, arg6));
394
+ }, arguments); },
395
+ __wbg_isMatch_5d8e08e35003826a: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
396
+ const ret = getObject(arg0).isMatch(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
397
+ return ret;
398
+ }, arguments); },
399
+ __wbg_now_ed16405009815575: function() { return handleError(function (arg0) {
400
+ const ret = getObject(arg0).now();
401
+ return ret;
402
+ }, arguments); },
403
+ __wbg_put_28f8c3f506bccce6: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6) {
404
+ getObject(arg0).put(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4), getStringFromWasm0(arg5, arg6));
405
+ }, arguments); },
406
+ __wbg_random_e53c67f802ca9858: function() { return handleError(function (arg0) {
407
+ const ret = getObject(arg0).random();
408
+ return ret;
409
+ }, arguments); },
410
+ __wbg_read_374ef6082863ec13: function() { return handleError(function (arg0, arg1, arg2, arg3) {
411
+ const ret = getObject(arg1).read(getStringFromWasm0(arg2, arg3));
412
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
413
+ var len1 = WASM_VECTOR_LEN;
414
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
415
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
416
+ }, arguments); },
417
+ __wbg_run_14928847c1b306ed: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) {
418
+ const ret = getObject(arg1).run(getStringFromWasm0(arg2, arg3), getStringFromWasm0(arg4, arg5), getStringFromWasm0(arg6, arg7), getStringFromWasm0(arg8, arg9));
419
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
420
+ const len1 = WASM_VECTOR_LEN;
421
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
422
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
423
+ }, arguments); },
424
+ __wbg_supports_3c4bd0fa0766d31a: function() { return handleError(function (arg0, arg1, arg2) {
425
+ const ret = getObject(arg0).supports(getStringFromWasm0(arg1, arg2));
426
+ return ret;
427
+ }, arguments); },
428
+ __wbindgen_object_drop_ref: function(arg0) {
429
+ takeObject(arg0);
430
+ },
431
+ };
432
+ return {
433
+ __proto__: null,
434
+ "./smllm_wasm_bg.js": import0,
435
+ };
436
+ }
437
+
438
+ const EngineFinalization = (typeof FinalizationRegistry === 'undefined')
439
+ ? { register: () => {}, unregister: () => {} }
440
+ : new FinalizationRegistry(ptr => wasm.__wbg_engine_free(ptr, 1));
441
+
442
+ function addHeapObject(obj) {
443
+ if (heap_next === heap.length) heap.push(heap.length + 1);
444
+ const idx = heap_next;
445
+ heap_next = heap[idx];
446
+
447
+ heap[idx] = obj;
448
+ return idx;
449
+ }
450
+
451
+ function dropObject(idx) {
452
+ if (idx < 1028) return;
453
+ heap[idx] = heap_next;
454
+ heap_next = idx;
455
+ }
456
+
457
+ let cachedDataViewMemory0 = null;
458
+ function getDataViewMemory0() {
459
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
460
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
461
+ }
462
+ return cachedDataViewMemory0;
463
+ }
464
+
465
+ function getStringFromWasm0(ptr, len) {
466
+ return decodeText(ptr >>> 0, len);
467
+ }
468
+
469
+ let cachedUint8ArrayMemory0 = null;
470
+ function getUint8ArrayMemory0() {
471
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
472
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
473
+ }
474
+ return cachedUint8ArrayMemory0;
475
+ }
476
+
477
+ function getObject(idx) { return heap[idx]; }
478
+
479
+ function handleError(f, args) {
480
+ try {
481
+ return f.apply(this, args);
482
+ } catch (e) {
483
+ wasm.__wbindgen_export3(addHeapObject(e));
484
+ }
485
+ }
486
+
487
+ let heap = new Array(1024).fill(undefined);
488
+ heap.push(undefined, null, true, false);
489
+
490
+ let heap_next = heap.length;
491
+
492
+ function isLikeNone(x) {
493
+ return x === undefined || x === null;
494
+ }
495
+
496
+ function passStringToWasm0(arg, malloc, realloc) {
497
+ if (realloc === undefined) {
498
+ const buf = cachedTextEncoder.encode(arg);
499
+ const ptr = malloc(buf.length, 1) >>> 0;
500
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
501
+ WASM_VECTOR_LEN = buf.length;
502
+ return ptr;
503
+ }
504
+
505
+ let len = arg.length;
506
+ let ptr = malloc(len, 1) >>> 0;
507
+
508
+ const mem = getUint8ArrayMemory0();
509
+
510
+ let offset = 0;
511
+
512
+ for (; offset < len; offset++) {
513
+ const code = arg.charCodeAt(offset);
514
+ if (code > 0x7F) break;
515
+ mem[ptr + offset] = code;
516
+ }
517
+ if (offset !== len) {
518
+ if (offset !== 0) {
519
+ arg = arg.slice(offset);
520
+ }
521
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
522
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
523
+ const ret = cachedTextEncoder.encodeInto(arg, view);
524
+
525
+ offset += ret.written;
526
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
527
+ }
528
+
529
+ WASM_VECTOR_LEN = offset;
530
+ return ptr;
531
+ }
532
+
533
+ function takeObject(idx) {
534
+ const ret = getObject(idx);
535
+ dropObject(idx);
536
+ return ret;
537
+ }
538
+
539
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
540
+ cachedTextDecoder.decode();
541
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
542
+ let numBytesDecoded = 0;
543
+ function decodeText(ptr, len) {
544
+ numBytesDecoded += len;
545
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
546
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
547
+ cachedTextDecoder.decode();
548
+ numBytesDecoded = len;
549
+ }
550
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
551
+ }
552
+
553
+ const cachedTextEncoder = new TextEncoder();
554
+
555
+ if (!('encodeInto' in cachedTextEncoder)) {
556
+ cachedTextEncoder.encodeInto = function (arg, view) {
557
+ const buf = cachedTextEncoder.encode(arg);
558
+ view.set(buf);
559
+ return {
560
+ read: arg.length,
561
+ written: buf.length
562
+ };
563
+ };
564
+ }
565
+
566
+ let WASM_VECTOR_LEN = 0;
567
+
568
+ let wasmModule, wasmInstance, wasm;
569
+ function __wbg_finalize_init(instance, module) {
570
+ wasmInstance = instance;
571
+ wasm = instance.exports;
572
+ wasmModule = module;
573
+ cachedDataViewMemory0 = null;
574
+ cachedUint8ArrayMemory0 = null;
575
+ return wasm;
576
+ }
577
+
578
+ async function __wbg_load(module, imports) {
579
+ if (typeof Response === 'function' && module instanceof Response) {
580
+ if (!module.ok) {
581
+ throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
582
+ }
583
+
584
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
585
+ try {
586
+ return await WebAssembly.instantiateStreaming(module, imports);
587
+ } catch (e) {
588
+ const validResponse = expectedResponseType(module.type);
589
+
590
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
591
+ console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
592
+
593
+ } else { throw e; }
594
+ }
595
+ }
596
+
597
+ const bytes = await module.arrayBuffer();
598
+ return await WebAssembly.instantiate(bytes, imports);
599
+ } else {
600
+ const instance = await WebAssembly.instantiate(module, imports);
601
+
602
+ if (instance instanceof WebAssembly.Instance) {
603
+ return { instance, module };
604
+ } else {
605
+ return instance;
606
+ }
607
+ }
608
+
609
+ function expectedResponseType(type) {
610
+ switch (type) {
611
+ case 'basic': case 'cors': case 'default': return true;
612
+ }
613
+ return false;
614
+ }
615
+ }
616
+
617
+ function initSync(module) {
618
+ if (wasm !== undefined) return wasm;
619
+
620
+
621
+ if (module !== undefined) {
622
+ if (Object.getPrototypeOf(module) === Object.prototype) {
623
+ ({module} = module)
624
+ } else {
625
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
626
+ }
627
+ }
628
+
629
+ const imports = __wbg_get_imports();
630
+ if (!(module instanceof WebAssembly.Module)) {
631
+ module = new WebAssembly.Module(module);
632
+ }
633
+ const instance = new WebAssembly.Instance(module, imports);
634
+ return __wbg_finalize_init(instance, module);
635
+ }
636
+
637
+ async function __wbg_init(module_or_path) {
638
+ if (wasm !== undefined) return wasm;
639
+
640
+
641
+ if (module_or_path !== undefined) {
642
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
643
+ ({module_or_path} = module_or_path)
644
+ } else {
645
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
646
+ }
647
+ }
648
+
649
+ if (module_or_path === undefined) {
650
+ module_or_path = new URL('smllm_wasm_bg.wasm', import.meta.url);
651
+ }
652
+ const imports = __wbg_get_imports();
653
+
654
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
655
+ module_or_path = fetch(module_or_path);
656
+ }
657
+
658
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
659
+
660
+ return __wbg_finalize_init(instance, module);
661
+ }
662
+
663
+ export { initSync, __wbg_init as default };
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;