nanocodex 0.1.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.
- package/README.md +116 -0
- package/actions/events.d.mts +10 -0
- package/actions/events.mjs +91 -0
- package/actions/index.d.mts +12 -0
- package/actions/index.mjs +20 -0
- package/actions/session.d.mts +14 -0
- package/actions/session.mjs +9 -0
- package/actions/turn.d.mts +30 -0
- package/actions/turn.mjs +22 -0
- package/browser/Agent.d.mts +25 -0
- package/browser/Agent.mjs +54 -0
- package/browser/host.d.mts +20 -0
- package/browser/host.mjs +161 -0
- package/browser/index.d.mts +13 -0
- package/browser/index.mjs +2 -0
- package/index.d.mts +19 -0
- package/index.mjs +1 -0
- package/internal.mjs +303 -0
- package/node/Agent.d.mts +24 -0
- package/node/Agent.mjs +51 -0
- package/node/host.mjs +204 -0
- package/node/index.d.mts +13 -0
- package/node/index.mjs +2 -0
- package/package.json +61 -0
- package/pkg-node/nanocodex.d.ts +109 -0
- package/pkg-node/nanocodex.js +652 -0
- package/pkg-node/nanocodex_bg.wasm +0 -0
- package/pkg-node/nanocodex_bg.wasm.d.ts +27 -0
- package/pkg-node/package.json +1 -0
- package/pkg-web/nanocodex.d.ts +161 -0
- package/pkg-web/nanocodex.js +745 -0
- package/pkg-web/nanocodex_bg.wasm +0 -0
- package/pkg-web/nanocodex_bg.wasm.d.ts +27 -0
- package/pkg-web/package.json +1 -0
- package/runtime/code-runtime.mjs +191 -0
- package/scripts/check-package.mjs +38 -0
- package/types.d.mts +82 -0
|
@@ -0,0 +1,652 @@
|
|
|
1
|
+
/* @ts-self-types="./nanocodex.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Persistent WASM agent handle hosted by Node.js or a browser Worker.
|
|
5
|
+
*/
|
|
6
|
+
class Nanocodex {
|
|
7
|
+
static __wrap(ptr) {
|
|
8
|
+
const obj = Object.create(Nanocodex.prototype);
|
|
9
|
+
obj.__wbg_ptr = ptr;
|
|
10
|
+
NanocodexFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
11
|
+
return obj;
|
|
12
|
+
}
|
|
13
|
+
__destroy_into_raw() {
|
|
14
|
+
const ptr = this.__wbg_ptr;
|
|
15
|
+
this.__wbg_ptr = 0;
|
|
16
|
+
NanocodexFinalization.unregister(this);
|
|
17
|
+
return ptr;
|
|
18
|
+
}
|
|
19
|
+
free() {
|
|
20
|
+
const ptr = this.__destroy_into_raw();
|
|
21
|
+
wasm.__wbg_nanocodex_free(ptr, 0);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Fork the latest safe committed model boundary.
|
|
25
|
+
*
|
|
26
|
+
* # Errors
|
|
27
|
+
*
|
|
28
|
+
* Rejects before the first safe boundary or after the driver stops.
|
|
29
|
+
* @returns {Promise<Nanocodex>}
|
|
30
|
+
*/
|
|
31
|
+
fork() {
|
|
32
|
+
const ret = wasm.nanocodex_fork(this.__wbg_ptr);
|
|
33
|
+
return ret;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Fork from the exact checkpoint retained by a completed historical turn.
|
|
37
|
+
*
|
|
38
|
+
* # Errors
|
|
39
|
+
*
|
|
40
|
+
* Rejects if the turn is incomplete, belongs to another lineage, or the
|
|
41
|
+
* driver stops.
|
|
42
|
+
* @param {Turn} turn
|
|
43
|
+
* @returns {Promise<Nanocodex>}
|
|
44
|
+
*/
|
|
45
|
+
forkFrom(turn) {
|
|
46
|
+
_assertClass(turn, Turn);
|
|
47
|
+
const ret = wasm.nanocodex_forkFrom(this.__wbg_ptr, turn.__wbg_ptr);
|
|
48
|
+
return ret;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Build a persistent agent from a JSON configuration object.
|
|
52
|
+
*
|
|
53
|
+
* # Errors
|
|
54
|
+
*
|
|
55
|
+
* Throws when the JSON or required configuration is invalid.
|
|
56
|
+
* @param {string} config_json
|
|
57
|
+
*/
|
|
58
|
+
constructor(config_json) {
|
|
59
|
+
const ptr0 = passStringToWasm0(config_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
60
|
+
const len0 = WASM_VECTOR_LEN;
|
|
61
|
+
const ret = wasm.nanocodex_new(ptr0, len0);
|
|
62
|
+
if (ret[2]) {
|
|
63
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
64
|
+
}
|
|
65
|
+
this.__wbg_ptr = ret[0];
|
|
66
|
+
NanocodexFinalization.register(this, this.__wbg_ptr, this);
|
|
67
|
+
return this;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Accept a prompt immediately and return its independently awaitable turn.
|
|
71
|
+
*
|
|
72
|
+
* # Errors
|
|
73
|
+
*
|
|
74
|
+
* Throws when the prompt is empty or the agent driver has stopped.
|
|
75
|
+
* @param {string} instruction
|
|
76
|
+
* @returns {Turn}
|
|
77
|
+
*/
|
|
78
|
+
prompt(instruction) {
|
|
79
|
+
const ptr0 = passStringToWasm0(instruction, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
80
|
+
const len0 = WASM_VECTOR_LEN;
|
|
81
|
+
const ret = wasm.nanocodex_prompt(this.__wbg_ptr, ptr0, len0);
|
|
82
|
+
if (ret[2]) {
|
|
83
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
84
|
+
}
|
|
85
|
+
return Turn.__wrap(ret[0]);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Accept ordered browser-safe text, image, or audio input encoded as JSON.
|
|
89
|
+
*
|
|
90
|
+
* # Errors
|
|
91
|
+
*
|
|
92
|
+
* Throws for malformed or empty content, local filesystem inputs, or a
|
|
93
|
+
* stopped driver.
|
|
94
|
+
* @param {string} content_json
|
|
95
|
+
* @returns {Turn}
|
|
96
|
+
*/
|
|
97
|
+
promptContent(content_json) {
|
|
98
|
+
const ptr0 = passStringToWasm0(content_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
99
|
+
const len0 = WASM_VECTOR_LEN;
|
|
100
|
+
const ret = wasm.nanocodex_promptContent(this.__wbg_ptr, ptr0, len0);
|
|
101
|
+
if (ret[2]) {
|
|
102
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
103
|
+
}
|
|
104
|
+
return Turn.__wrap(ret[0]);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Stable session identifier used to route this agent's event stream.
|
|
108
|
+
* @returns {string}
|
|
109
|
+
*/
|
|
110
|
+
get sessionId() {
|
|
111
|
+
let deferred1_0;
|
|
112
|
+
let deferred1_1;
|
|
113
|
+
try {
|
|
114
|
+
const ret = wasm.nanocodex_sessionId(this.__wbg_ptr);
|
|
115
|
+
deferred1_0 = ret[0];
|
|
116
|
+
deferred1_1 = ret[1];
|
|
117
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
118
|
+
} finally {
|
|
119
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Start a clean sibling with the same configuration and tools.
|
|
124
|
+
*
|
|
125
|
+
* # Errors
|
|
126
|
+
*
|
|
127
|
+
* Rejects after the driver stops.
|
|
128
|
+
* @returns {Promise<Nanocodex>}
|
|
129
|
+
*/
|
|
130
|
+
spawn() {
|
|
131
|
+
const ret = wasm.nanocodex_spawn(this.__wbg_ptr);
|
|
132
|
+
return ret;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
if (Symbol.dispose) Nanocodex.prototype[Symbol.dispose] = Nanocodex.prototype.free;
|
|
136
|
+
exports.Nanocodex = Nanocodex;
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Completion and control handle for one accepted WASM turn.
|
|
140
|
+
*/
|
|
141
|
+
class Turn {
|
|
142
|
+
static __wrap(ptr) {
|
|
143
|
+
const obj = Object.create(Turn.prototype);
|
|
144
|
+
obj.__wbg_ptr = ptr;
|
|
145
|
+
TurnFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
146
|
+
return obj;
|
|
147
|
+
}
|
|
148
|
+
__destroy_into_raw() {
|
|
149
|
+
const ptr = this.__wbg_ptr;
|
|
150
|
+
this.__wbg_ptr = 0;
|
|
151
|
+
TurnFinalization.unregister(this);
|
|
152
|
+
return ptr;
|
|
153
|
+
}
|
|
154
|
+
free() {
|
|
155
|
+
const ptr = this.__destroy_into_raw();
|
|
156
|
+
wasm.__wbg_turn_free(ptr, 0);
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Cancel this exact active or queued turn.
|
|
160
|
+
*
|
|
161
|
+
* # Errors
|
|
162
|
+
*
|
|
163
|
+
* Rejects if the turn is already terminal or the driver stops.
|
|
164
|
+
* @returns {Promise<void>}
|
|
165
|
+
*/
|
|
166
|
+
cancel() {
|
|
167
|
+
const ret = wasm.turn_cancel(this.__wbg_ptr);
|
|
168
|
+
return ret;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Wait for the turn and return its final assistant message.
|
|
172
|
+
*
|
|
173
|
+
* # Errors
|
|
174
|
+
*
|
|
175
|
+
* Rejects when the model run fails, the driver stops, or two consumers
|
|
176
|
+
* await the same pending turn concurrently.
|
|
177
|
+
* @returns {Promise<string>}
|
|
178
|
+
*/
|
|
179
|
+
result() {
|
|
180
|
+
const ret = wasm.turn_result(this.__wbg_ptr);
|
|
181
|
+
return ret;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Inject input at this active turn's next safe model boundary.
|
|
185
|
+
*
|
|
186
|
+
* # Errors
|
|
187
|
+
*
|
|
188
|
+
* Rejects for empty input, a queued or terminal turn, a full steer queue,
|
|
189
|
+
* or a stopped driver.
|
|
190
|
+
* @param {string} instruction
|
|
191
|
+
* @returns {Promise<void>}
|
|
192
|
+
*/
|
|
193
|
+
steer(instruction) {
|
|
194
|
+
const ptr0 = passStringToWasm0(instruction, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
195
|
+
const len0 = WASM_VECTOR_LEN;
|
|
196
|
+
const ret = wasm.turn_steer(this.__wbg_ptr, ptr0, len0);
|
|
197
|
+
return ret;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Inject ordered browser-safe text, image, or audio input at this active
|
|
201
|
+
* turn's next safe model boundary.
|
|
202
|
+
*
|
|
203
|
+
* # Errors
|
|
204
|
+
*
|
|
205
|
+
* Rejects for malformed or empty content, local filesystem inputs, a
|
|
206
|
+
* queued or terminal turn, a full steer queue, or a stopped driver.
|
|
207
|
+
* @param {string} content_json
|
|
208
|
+
* @returns {Promise<void>}
|
|
209
|
+
*/
|
|
210
|
+
steerContent(content_json) {
|
|
211
|
+
const ptr0 = passStringToWasm0(content_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
212
|
+
const len0 = WASM_VECTOR_LEN;
|
|
213
|
+
const ret = wasm.turn_steerContent(this.__wbg_ptr, ptr0, len0);
|
|
214
|
+
return ret;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
if (Symbol.dispose) Turn.prototype[Symbol.dispose] = Turn.prototype.free;
|
|
218
|
+
exports.Turn = Turn;
|
|
219
|
+
function __wbg_get_imports() {
|
|
220
|
+
const import0 = {
|
|
221
|
+
__proto__: null,
|
|
222
|
+
__wbg___wbindgen_debug_string_c25d447a39f5578f: function(arg0, arg1) {
|
|
223
|
+
const ret = debugString(arg1);
|
|
224
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
225
|
+
const len1 = WASM_VECTOR_LEN;
|
|
226
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
227
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
228
|
+
},
|
|
229
|
+
__wbg___wbindgen_is_function_1ff95bcc5517c252: function(arg0) {
|
|
230
|
+
const ret = typeof(arg0) === 'function';
|
|
231
|
+
return ret;
|
|
232
|
+
},
|
|
233
|
+
__wbg___wbindgen_is_undefined_c05833b95a3cf397: function(arg0) {
|
|
234
|
+
const ret = arg0 === undefined;
|
|
235
|
+
return ret;
|
|
236
|
+
},
|
|
237
|
+
__wbg___wbindgen_string_get_b0ca35b86a603356: function(arg0, arg1) {
|
|
238
|
+
const obj = arg1;
|
|
239
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
240
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
241
|
+
var len1 = WASM_VECTOR_LEN;
|
|
242
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
243
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
244
|
+
},
|
|
245
|
+
__wbg___wbindgen_throw_344f42d3211c4765: function(arg0, arg1) {
|
|
246
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
247
|
+
},
|
|
248
|
+
__wbg__wbg_cb_unref_fffb441def202758: function(arg0) {
|
|
249
|
+
arg0._wbg_cb_unref();
|
|
250
|
+
},
|
|
251
|
+
__wbg_call_a6e5c5dce5018821: function() { return handleError(function (arg0, arg1, arg2) {
|
|
252
|
+
const ret = arg0.call(arg1, arg2);
|
|
253
|
+
return ret;
|
|
254
|
+
}, arguments); },
|
|
255
|
+
__wbg_close_b36455f162d504cf: function(arg0) {
|
|
256
|
+
globalThis.nanocodexHost.close(arg0 >>> 0);
|
|
257
|
+
},
|
|
258
|
+
__wbg_connect_82a82e999c6dad2f: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5) {
|
|
259
|
+
const ret = globalThis.nanocodexHost.connect(getStringFromWasm0(arg0, arg1), getStringFromWasm0(arg2, arg3), getStringFromWasm0(arg4, arg5));
|
|
260
|
+
return ret;
|
|
261
|
+
}, arguments); },
|
|
262
|
+
__wbg_emitEvent_fe69df479c60b4dc: function(arg0, arg1) {
|
|
263
|
+
globalThis.nanocodexHost.emitEvent(getStringFromWasm0(arg0, arg1));
|
|
264
|
+
},
|
|
265
|
+
__wbg_executeCode_1b0871b5adb65342: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5) {
|
|
266
|
+
const ret = globalThis.nanocodexHost.executeCode(getStringFromWasm0(arg0, arg1), getStringFromWasm0(arg2, arg3), getStringFromWasm0(arg4, arg5));
|
|
267
|
+
return ret;
|
|
268
|
+
}, arguments); },
|
|
269
|
+
__wbg_getDate_a1a40c1c5f40fe3b: function(arg0) {
|
|
270
|
+
const ret = arg0.getDate();
|
|
271
|
+
return ret;
|
|
272
|
+
},
|
|
273
|
+
__wbg_getFullYear_6af8b229792ae254: function(arg0) {
|
|
274
|
+
const ret = arg0.getFullYear();
|
|
275
|
+
return ret;
|
|
276
|
+
},
|
|
277
|
+
__wbg_getMonth_fffe29d654d5eb69: function(arg0) {
|
|
278
|
+
const ret = arg0.getMonth();
|
|
279
|
+
return ret;
|
|
280
|
+
},
|
|
281
|
+
__wbg_get_78f252d074a84d0b: function() { return handleError(function (arg0, arg1) {
|
|
282
|
+
const ret = Reflect.get(arg0, arg1);
|
|
283
|
+
return ret;
|
|
284
|
+
}, arguments); },
|
|
285
|
+
__wbg_nanocodex_new: function(arg0) {
|
|
286
|
+
const ret = Nanocodex.__wrap(arg0);
|
|
287
|
+
return ret;
|
|
288
|
+
},
|
|
289
|
+
__wbg_new_0_3da9e97f24fc69be: function() {
|
|
290
|
+
const ret = new Date();
|
|
291
|
+
return ret;
|
|
292
|
+
},
|
|
293
|
+
__wbg_new_32b398fb48b6d94a: function() {
|
|
294
|
+
const ret = new Array();
|
|
295
|
+
return ret;
|
|
296
|
+
},
|
|
297
|
+
__wbg_new_b667d279fd5aa943: function(arg0, arg1) {
|
|
298
|
+
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
299
|
+
return ret;
|
|
300
|
+
},
|
|
301
|
+
__wbg_new_cbb95886ce0eb0cb: function(arg0, arg1) {
|
|
302
|
+
const ret = new Intl.DateTimeFormat(arg0, arg1);
|
|
303
|
+
return ret;
|
|
304
|
+
},
|
|
305
|
+
__wbg_new_da52cf8fe3429cb2: function() {
|
|
306
|
+
const ret = new Object();
|
|
307
|
+
return ret;
|
|
308
|
+
},
|
|
309
|
+
__wbg_new_typed_1824d93f294193e5: function(arg0, arg1) {
|
|
310
|
+
try {
|
|
311
|
+
var state0 = {a: arg0, b: arg1};
|
|
312
|
+
var cb0 = (arg0, arg1) => {
|
|
313
|
+
const a = state0.a;
|
|
314
|
+
state0.a = 0;
|
|
315
|
+
try {
|
|
316
|
+
return wasm_bindgen__convert__closures_____invoke__h179cb8eb2e8755ae(a, state0.b, arg0, arg1);
|
|
317
|
+
} finally {
|
|
318
|
+
state0.a = a;
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
const ret = new Promise(cb0);
|
|
322
|
+
return ret;
|
|
323
|
+
} finally {
|
|
324
|
+
state0.a = 0;
|
|
325
|
+
}
|
|
326
|
+
},
|
|
327
|
+
__wbg_next_9da746b48109347a: function() { return handleError(function (arg0, arg1) {
|
|
328
|
+
const ret = globalThis.nanocodexHost.next(arg0 >>> 0, arg1 >>> 0);
|
|
329
|
+
return ret;
|
|
330
|
+
}, arguments); },
|
|
331
|
+
__wbg_now_86c0d4ba3fa605b8: function() {
|
|
332
|
+
const ret = Date.now();
|
|
333
|
+
return ret;
|
|
334
|
+
},
|
|
335
|
+
__wbg_now_e7c6795a7f81e10f: function(arg0) {
|
|
336
|
+
const ret = arg0.now();
|
|
337
|
+
return ret;
|
|
338
|
+
},
|
|
339
|
+
__wbg_performance_3fcf6e32a7e1ed0a: function(arg0) {
|
|
340
|
+
const ret = arg0.performance;
|
|
341
|
+
return ret;
|
|
342
|
+
},
|
|
343
|
+
__wbg_queueMicrotask_0ab5b2d2393e99b9: function(arg0) {
|
|
344
|
+
const ret = arg0.queueMicrotask;
|
|
345
|
+
return ret;
|
|
346
|
+
},
|
|
347
|
+
__wbg_queueMicrotask_6a09b7bc46549209: function(arg0) {
|
|
348
|
+
queueMicrotask(arg0);
|
|
349
|
+
},
|
|
350
|
+
__wbg_resolve_2191a4dfe481c25b: function(arg0) {
|
|
351
|
+
const ret = Promise.resolve(arg0);
|
|
352
|
+
return ret;
|
|
353
|
+
},
|
|
354
|
+
__wbg_resolvedOptions_ce0ede387898d6bd: function(arg0) {
|
|
355
|
+
const ret = arg0.resolvedOptions();
|
|
356
|
+
return ret;
|
|
357
|
+
},
|
|
358
|
+
__wbg_send_211e498fb0677de2: function() { return handleError(function (arg0, arg1, arg2) {
|
|
359
|
+
const ret = globalThis.nanocodexHost.send(arg0 >>> 0, getStringFromWasm0(arg1, arg2));
|
|
360
|
+
return ret;
|
|
361
|
+
}, arguments); },
|
|
362
|
+
__wbg_sleep_03cdb40ace612b9f: function(arg0) {
|
|
363
|
+
const ret = globalThis.nanocodexHost.sleep(arg0 >>> 0);
|
|
364
|
+
return ret;
|
|
365
|
+
},
|
|
366
|
+
__wbg_static_accessor_GLOBAL_4ef717fb391d88b7: function() {
|
|
367
|
+
const ret = typeof global === 'undefined' ? null : global;
|
|
368
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
369
|
+
},
|
|
370
|
+
__wbg_static_accessor_GLOBAL_THIS_8d1badc68b5a74f4: function() {
|
|
371
|
+
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
|
372
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
373
|
+
},
|
|
374
|
+
__wbg_static_accessor_SELF_146583524fe1469b: function() {
|
|
375
|
+
const ret = typeof self === 'undefined' ? null : self;
|
|
376
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
377
|
+
},
|
|
378
|
+
__wbg_static_accessor_WINDOW_f2829a2234d7819e: function() {
|
|
379
|
+
const ret = typeof window === 'undefined' ? null : window;
|
|
380
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
381
|
+
},
|
|
382
|
+
__wbg_then_16d107c451e9905d: function(arg0, arg1, arg2) {
|
|
383
|
+
const ret = arg0.then(arg1, arg2);
|
|
384
|
+
return ret;
|
|
385
|
+
},
|
|
386
|
+
__wbg_then_6ec10ae38b3e92f7: function(arg0, arg1) {
|
|
387
|
+
const ret = arg0.then(arg1);
|
|
388
|
+
return ret;
|
|
389
|
+
},
|
|
390
|
+
__wbg_toolDefinitions_976a998d8a17c04c: function(arg0, arg1, arg2) {
|
|
391
|
+
const ret = globalThis.nanocodexHost.toolDefinitions(getStringFromWasm0(arg1, arg2));
|
|
392
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
393
|
+
const len1 = WASM_VECTOR_LEN;
|
|
394
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
395
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
396
|
+
},
|
|
397
|
+
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
398
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 57, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
399
|
+
const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h02eb5eea4c10a535);
|
|
400
|
+
return ret;
|
|
401
|
+
},
|
|
402
|
+
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
403
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
404
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
405
|
+
return ret;
|
|
406
|
+
},
|
|
407
|
+
__wbindgen_init_externref_table: function() {
|
|
408
|
+
const table = wasm.__wbindgen_externrefs;
|
|
409
|
+
const offset = table.grow(4);
|
|
410
|
+
table.set(0, undefined);
|
|
411
|
+
table.set(offset + 0, undefined);
|
|
412
|
+
table.set(offset + 1, null);
|
|
413
|
+
table.set(offset + 2, true);
|
|
414
|
+
table.set(offset + 3, false);
|
|
415
|
+
},
|
|
416
|
+
};
|
|
417
|
+
return {
|
|
418
|
+
__proto__: null,
|
|
419
|
+
"./nanocodex_bg.js": import0,
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
function wasm_bindgen__convert__closures_____invoke__h02eb5eea4c10a535(arg0, arg1, arg2) {
|
|
424
|
+
const ret = wasm.wasm_bindgen__convert__closures_____invoke__h02eb5eea4c10a535(arg0, arg1, arg2);
|
|
425
|
+
if (ret[1]) {
|
|
426
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
function wasm_bindgen__convert__closures_____invoke__h179cb8eb2e8755ae(arg0, arg1, arg2, arg3) {
|
|
431
|
+
wasm.wasm_bindgen__convert__closures_____invoke__h179cb8eb2e8755ae(arg0, arg1, arg2, arg3);
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
const NanocodexFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
435
|
+
? { register: () => {}, unregister: () => {} }
|
|
436
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_nanocodex_free(ptr, 1));
|
|
437
|
+
const TurnFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
438
|
+
? { register: () => {}, unregister: () => {} }
|
|
439
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_turn_free(ptr, 1));
|
|
440
|
+
|
|
441
|
+
function addToExternrefTable0(obj) {
|
|
442
|
+
const idx = wasm.__externref_table_alloc();
|
|
443
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
444
|
+
return idx;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
function _assertClass(instance, klass) {
|
|
448
|
+
if (!(instance instanceof klass)) {
|
|
449
|
+
throw new Error(`expected instance of ${klass.name}`);
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
|
|
454
|
+
? { register: () => {}, unregister: () => {} }
|
|
455
|
+
: new FinalizationRegistry(state => wasm.__wbindgen_destroy_closure(state.a, state.b));
|
|
456
|
+
|
|
457
|
+
function debugString(val) {
|
|
458
|
+
// primitive types
|
|
459
|
+
const type = typeof val;
|
|
460
|
+
if (type == 'number' || type == 'boolean' || val == null) {
|
|
461
|
+
return `${val}`;
|
|
462
|
+
}
|
|
463
|
+
if (type == 'string') {
|
|
464
|
+
return `"${val}"`;
|
|
465
|
+
}
|
|
466
|
+
if (type == 'symbol') {
|
|
467
|
+
const description = val.description;
|
|
468
|
+
if (description == null) {
|
|
469
|
+
return 'Symbol';
|
|
470
|
+
} else {
|
|
471
|
+
return `Symbol(${description})`;
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
if (type == 'function') {
|
|
475
|
+
const name = val.name;
|
|
476
|
+
if (typeof name == 'string' && name.length > 0) {
|
|
477
|
+
return `Function(${name})`;
|
|
478
|
+
} else {
|
|
479
|
+
return 'Function';
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
// objects
|
|
483
|
+
if (Array.isArray(val)) {
|
|
484
|
+
const length = val.length;
|
|
485
|
+
let debug = '[';
|
|
486
|
+
if (length > 0) {
|
|
487
|
+
debug += debugString(val[0]);
|
|
488
|
+
}
|
|
489
|
+
for(let i = 1; i < length; i++) {
|
|
490
|
+
debug += ', ' + debugString(val[i]);
|
|
491
|
+
}
|
|
492
|
+
debug += ']';
|
|
493
|
+
return debug;
|
|
494
|
+
}
|
|
495
|
+
// Test for built-in
|
|
496
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
497
|
+
let className;
|
|
498
|
+
if (builtInMatches && builtInMatches.length > 1) {
|
|
499
|
+
className = builtInMatches[1];
|
|
500
|
+
} else {
|
|
501
|
+
// Failed to match the standard '[object ClassName]'
|
|
502
|
+
return toString.call(val);
|
|
503
|
+
}
|
|
504
|
+
if (className == 'Object') {
|
|
505
|
+
// we're a user defined class or Object
|
|
506
|
+
// JSON.stringify avoids problems with cycles, and is generally much
|
|
507
|
+
// easier than looping through ownProperties of `val`.
|
|
508
|
+
try {
|
|
509
|
+
return 'Object(' + JSON.stringify(val) + ')';
|
|
510
|
+
} catch (_) {
|
|
511
|
+
return 'Object';
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
// errors
|
|
515
|
+
if (val instanceof Error) {
|
|
516
|
+
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
517
|
+
}
|
|
518
|
+
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
519
|
+
return className;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
let cachedDataViewMemory0 = null;
|
|
523
|
+
function getDataViewMemory0() {
|
|
524
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
525
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
526
|
+
}
|
|
527
|
+
return cachedDataViewMemory0;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
function getStringFromWasm0(ptr, len) {
|
|
531
|
+
return decodeText(ptr >>> 0, len);
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
let cachedUint8ArrayMemory0 = null;
|
|
535
|
+
function getUint8ArrayMemory0() {
|
|
536
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
537
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
538
|
+
}
|
|
539
|
+
return cachedUint8ArrayMemory0;
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
function handleError(f, args) {
|
|
543
|
+
try {
|
|
544
|
+
return f.apply(this, args);
|
|
545
|
+
} catch (e) {
|
|
546
|
+
const idx = addToExternrefTable0(e);
|
|
547
|
+
wasm.__wbindgen_exn_store(idx);
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
function isLikeNone(x) {
|
|
552
|
+
return x === undefined || x === null;
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
function makeMutClosure(arg0, arg1, f) {
|
|
556
|
+
const state = { a: arg0, b: arg1, cnt: 1 };
|
|
557
|
+
const real = (...args) => {
|
|
558
|
+
|
|
559
|
+
// First up with a closure we increment the internal reference
|
|
560
|
+
// count. This ensures that the Rust closure environment won't
|
|
561
|
+
// be deallocated while we're invoking it.
|
|
562
|
+
state.cnt++;
|
|
563
|
+
const a = state.a;
|
|
564
|
+
state.a = 0;
|
|
565
|
+
try {
|
|
566
|
+
return f(a, state.b, ...args);
|
|
567
|
+
} finally {
|
|
568
|
+
state.a = a;
|
|
569
|
+
real._wbg_cb_unref();
|
|
570
|
+
}
|
|
571
|
+
};
|
|
572
|
+
real._wbg_cb_unref = () => {
|
|
573
|
+
if (--state.cnt === 0) {
|
|
574
|
+
wasm.__wbindgen_destroy_closure(state.a, state.b);
|
|
575
|
+
state.a = 0;
|
|
576
|
+
CLOSURE_DTORS.unregister(state);
|
|
577
|
+
}
|
|
578
|
+
};
|
|
579
|
+
CLOSURE_DTORS.register(real, state, state);
|
|
580
|
+
return real;
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
584
|
+
if (realloc === undefined) {
|
|
585
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
586
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
587
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
588
|
+
WASM_VECTOR_LEN = buf.length;
|
|
589
|
+
return ptr;
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
let len = arg.length;
|
|
593
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
594
|
+
|
|
595
|
+
const mem = getUint8ArrayMemory0();
|
|
596
|
+
|
|
597
|
+
let offset = 0;
|
|
598
|
+
|
|
599
|
+
for (; offset < len; offset++) {
|
|
600
|
+
const code = arg.charCodeAt(offset);
|
|
601
|
+
if (code > 0x7F) break;
|
|
602
|
+
mem[ptr + offset] = code;
|
|
603
|
+
}
|
|
604
|
+
if (offset !== len) {
|
|
605
|
+
if (offset !== 0) {
|
|
606
|
+
arg = arg.slice(offset);
|
|
607
|
+
}
|
|
608
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
609
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
610
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
611
|
+
|
|
612
|
+
offset += ret.written;
|
|
613
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
WASM_VECTOR_LEN = offset;
|
|
617
|
+
return ptr;
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
function takeFromExternrefTable0(idx) {
|
|
621
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
622
|
+
wasm.__externref_table_dealloc(idx);
|
|
623
|
+
return value;
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
627
|
+
cachedTextDecoder.decode();
|
|
628
|
+
function decodeText(ptr, len) {
|
|
629
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
const cachedTextEncoder = new TextEncoder();
|
|
633
|
+
|
|
634
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
635
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
636
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
637
|
+
view.set(buf);
|
|
638
|
+
return {
|
|
639
|
+
read: arg.length,
|
|
640
|
+
written: buf.length
|
|
641
|
+
};
|
|
642
|
+
};
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
let WASM_VECTOR_LEN = 0;
|
|
646
|
+
|
|
647
|
+
const wasmPath = `${__dirname}/nanocodex_bg.wasm`;
|
|
648
|
+
const wasmBytes = require('fs').readFileSync(wasmPath);
|
|
649
|
+
const wasmModule = new WebAssembly.Module(wasmBytes);
|
|
650
|
+
let wasmInstance = new WebAssembly.Instance(wasmModule, __wbg_get_imports());
|
|
651
|
+
let wasm = wasmInstance.exports;
|
|
652
|
+
wasm.__wbindgen_start();
|
|
Binary file
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const __wbg_nanocodex_free: (a: number, b: number) => void;
|
|
5
|
+
export const __wbg_turn_free: (a: number, b: number) => void;
|
|
6
|
+
export const nanocodex_fork: (a: number) => any;
|
|
7
|
+
export const nanocodex_forkFrom: (a: number, b: number) => any;
|
|
8
|
+
export const nanocodex_new: (a: number, b: number) => [number, number, number];
|
|
9
|
+
export const nanocodex_prompt: (a: number, b: number, c: number) => [number, number, number];
|
|
10
|
+
export const nanocodex_promptContent: (a: number, b: number, c: number) => [number, number, number];
|
|
11
|
+
export const nanocodex_sessionId: (a: number) => [number, number];
|
|
12
|
+
export const nanocodex_spawn: (a: number) => any;
|
|
13
|
+
export const turn_cancel: (a: number) => any;
|
|
14
|
+
export const turn_result: (a: number) => any;
|
|
15
|
+
export const turn_steer: (a: number, b: number, c: number) => any;
|
|
16
|
+
export const turn_steerContent: (a: number, b: number, c: number) => any;
|
|
17
|
+
export const wasm_bindgen__convert__closures_____invoke__h02eb5eea4c10a535: (a: number, b: number, c: any) => [number, number];
|
|
18
|
+
export const wasm_bindgen__convert__closures_____invoke__h179cb8eb2e8755ae: (a: number, b: number, c: any, d: any) => void;
|
|
19
|
+
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
20
|
+
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
21
|
+
export const __wbindgen_exn_store: (a: number) => void;
|
|
22
|
+
export const __externref_table_alloc: () => number;
|
|
23
|
+
export const __wbindgen_externrefs: WebAssembly.Table;
|
|
24
|
+
export const __wbindgen_destroy_closure: (a: number, b: number) => void;
|
|
25
|
+
export const __externref_table_dealloc: (a: number) => void;
|
|
26
|
+
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
27
|
+
export const __wbindgen_start: () => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|