@chanto/web 0.0.0-stage → 0.1.11
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/LICENSE +202 -0
- package/NOTICE +55 -0
- package/README.md +27 -2
- package/THIRD_PARTY_LICENSES.txt +9944 -0
- package/chanto_web.d.ts +75 -0
- package/chanto_web.js +637 -0
- package/chanto_web_bg.wasm +0 -0
- package/chanto_web_bg.wasm.d.ts +19 -0
- package/package.json +30 -4
package/chanto_web.js
ADDED
|
@@ -0,0 +1,637 @@
|
|
|
1
|
+
/* @ts-self-types="./chanto_web.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* One conversation with the agent, over one project.
|
|
5
|
+
*/
|
|
6
|
+
export class Session {
|
|
7
|
+
__destroy_into_raw() {
|
|
8
|
+
const ptr = this.__wbg_ptr;
|
|
9
|
+
this.__wbg_ptr = 0;
|
|
10
|
+
SessionFinalization.unregister(this);
|
|
11
|
+
return ptr;
|
|
12
|
+
}
|
|
13
|
+
free() {
|
|
14
|
+
const ptr = this.__destroy_into_raw();
|
|
15
|
+
wasm.__wbg_session_free(ptr, 0);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Every file in the project (`.gitignore` honoured), sorted.
|
|
19
|
+
* @returns {string[]}
|
|
20
|
+
*/
|
|
21
|
+
files() {
|
|
22
|
+
try {
|
|
23
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
24
|
+
wasm.session_files(retptr, this.__wbg_ptr);
|
|
25
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
26
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
27
|
+
var v1 = getArrayJsValueFromWasm0(r0, r1);
|
|
28
|
+
wasm.__wbindgen_export5(r0, r1 * 4, 4);
|
|
29
|
+
return v1;
|
|
30
|
+
} finally {
|
|
31
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The conversation so far, as the model sees it (JSON); empty while a
|
|
36
|
+
* turn runs.
|
|
37
|
+
* @returns {string}
|
|
38
|
+
*/
|
|
39
|
+
messages_json() {
|
|
40
|
+
let deferred1_0;
|
|
41
|
+
let deferred1_1;
|
|
42
|
+
try {
|
|
43
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
44
|
+
wasm.session_messages_json(retptr, this.__wbg_ptr);
|
|
45
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
46
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
47
|
+
deferred1_0 = r0;
|
|
48
|
+
deferred1_1 = r1;
|
|
49
|
+
return getStringFromWasm0(r0, r1);
|
|
50
|
+
} finally {
|
|
51
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
52
|
+
wasm.__wbindgen_export5(deferred1_0, deferred1_1, 1);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* @param {string} base_url
|
|
57
|
+
* @param {string} model
|
|
58
|
+
* @param {string | null | undefined} api_key
|
|
59
|
+
* @param {string} system_prompt
|
|
60
|
+
* @param {boolean} text_tools
|
|
61
|
+
* @param {string} cwd
|
|
62
|
+
*/
|
|
63
|
+
constructor(base_url, model, api_key, system_prompt, text_tools, cwd) {
|
|
64
|
+
const ptr0 = passStringToWasm0(base_url, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
65
|
+
const len0 = WASM_VECTOR_LEN;
|
|
66
|
+
const ptr1 = passStringToWasm0(model, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
67
|
+
const len1 = WASM_VECTOR_LEN;
|
|
68
|
+
var ptr2 = isLikeNone(api_key) ? 0 : passStringToWasm0(api_key, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
69
|
+
var len2 = WASM_VECTOR_LEN;
|
|
70
|
+
const ptr3 = passStringToWasm0(system_prompt, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
71
|
+
const len3 = WASM_VECTOR_LEN;
|
|
72
|
+
const ptr4 = passStringToWasm0(cwd, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
73
|
+
const len4 = WASM_VECTOR_LEN;
|
|
74
|
+
const ret = wasm.session_new(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, text_tools, ptr4, len4);
|
|
75
|
+
this.__wbg_ptr = ret;
|
|
76
|
+
SessionFinalization.register(this, this.__wbg_ptr, this);
|
|
77
|
+
return this;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* @param {string} path
|
|
81
|
+
* @returns {string | undefined}
|
|
82
|
+
*/
|
|
83
|
+
read_file(path) {
|
|
84
|
+
try {
|
|
85
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
86
|
+
const ptr0 = passStringToWasm0(path, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
87
|
+
const len0 = WASM_VECTOR_LEN;
|
|
88
|
+
wasm.session_read_file(retptr, this.__wbg_ptr, ptr0, len0);
|
|
89
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
90
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
91
|
+
let v2;
|
|
92
|
+
if (r0 !== 0) {
|
|
93
|
+
v2 = getStringFromWasm0(r0, r1);
|
|
94
|
+
wasm.__wbindgen_export5(r0, r1 * 1, 1);
|
|
95
|
+
}
|
|
96
|
+
return v2;
|
|
97
|
+
} finally {
|
|
98
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Answer `input`. `on_event` gets each event as a JSON string (see
|
|
103
|
+
* `chanto_core::agent::Event`); resolves to the final reply.
|
|
104
|
+
* @param {string} input
|
|
105
|
+
* @param {Function} transport
|
|
106
|
+
* @param {Function} on_event
|
|
107
|
+
* @returns {Promise<any>}
|
|
108
|
+
*/
|
|
109
|
+
run(input, transport, on_event) {
|
|
110
|
+
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
111
|
+
const len0 = WASM_VECTOR_LEN;
|
|
112
|
+
const ret = wasm.session_run(this.__wbg_ptr, ptr0, len0, addHeapObject(transport), addHeapObject(on_event));
|
|
113
|
+
return takeObject(ret);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Model requests one turn may make (default 50).
|
|
117
|
+
* @param {number} n
|
|
118
|
+
*/
|
|
119
|
+
set_max_steps(n) {
|
|
120
|
+
wasm.session_set_max_steps(this.__wbg_ptr, n);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* @param {string} path
|
|
124
|
+
* @param {string} text
|
|
125
|
+
*/
|
|
126
|
+
write_file(path, text) {
|
|
127
|
+
const ptr0 = passStringToWasm0(path, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
128
|
+
const len0 = WASM_VECTOR_LEN;
|
|
129
|
+
const ptr1 = passStringToWasm0(text, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
130
|
+
const len1 = WASM_VECTOR_LEN;
|
|
131
|
+
wasm.session_write_file(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
if (Symbol.dispose) Session.prototype[Symbol.dispose] = Session.prototype.free;
|
|
135
|
+
function __wbg_get_imports() {
|
|
136
|
+
const import0 = {
|
|
137
|
+
__proto__: null,
|
|
138
|
+
__wbg___wbindgen_debug_string_4687d8d8c2017d52: function(arg0, arg1) {
|
|
139
|
+
const ret = debugString(getObject(arg1));
|
|
140
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
141
|
+
const len1 = WASM_VECTOR_LEN;
|
|
142
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
143
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
144
|
+
},
|
|
145
|
+
__wbg___wbindgen_is_falsy_16bd49b68658263e: function(arg0) {
|
|
146
|
+
const ret = !getObject(arg0);
|
|
147
|
+
return ret;
|
|
148
|
+
},
|
|
149
|
+
__wbg___wbindgen_is_function_1f9d30630b8b1d3d: function(arg0) {
|
|
150
|
+
const ret = typeof(getObject(arg0)) === 'function';
|
|
151
|
+
return ret;
|
|
152
|
+
},
|
|
153
|
+
__wbg___wbindgen_is_undefined_8865fb403f8fe9d8: function(arg0) {
|
|
154
|
+
const ret = getObject(arg0) === undefined;
|
|
155
|
+
return ret;
|
|
156
|
+
},
|
|
157
|
+
__wbg___wbindgen_string_get_0380ccaa2f57f0d9: function(arg0, arg1) {
|
|
158
|
+
const obj = getObject(arg1);
|
|
159
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
160
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
161
|
+
var len1 = WASM_VECTOR_LEN;
|
|
162
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
163
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
164
|
+
},
|
|
165
|
+
__wbg___wbindgen_throw_41e9ee4f547fc59a: function(arg0, arg1) {
|
|
166
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
167
|
+
},
|
|
168
|
+
__wbg__wbg_cb_unref_dcc1a90847f04c41: function(arg0) {
|
|
169
|
+
getObject(arg0)._wbg_cb_unref();
|
|
170
|
+
},
|
|
171
|
+
__wbg_call_187d372bd5fdd4aa: function() { return handleError(function (arg0, arg1, arg2) {
|
|
172
|
+
const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
|
|
173
|
+
return addHeapObject(ret);
|
|
174
|
+
}, arguments); },
|
|
175
|
+
__wbg_call_6137034ef55c9d0f: function() { return handleError(function (arg0, arg1) {
|
|
176
|
+
const ret = getObject(arg0).call(getObject(arg1));
|
|
177
|
+
return addHeapObject(ret);
|
|
178
|
+
}, arguments); },
|
|
179
|
+
__wbg_call_939a2607c4484b0b: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
|
|
180
|
+
const ret = getObject(arg0).call(getObject(arg1), getObject(arg2), getObject(arg3), getObject(arg4));
|
|
181
|
+
return addHeapObject(ret);
|
|
182
|
+
}, arguments); },
|
|
183
|
+
__wbg_getRandomValues_869eb80731672410: function() { return handleError(function (arg0, arg1) {
|
|
184
|
+
globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
|
|
185
|
+
}, arguments); },
|
|
186
|
+
__wbg_get_31af05bd4842a84f: function() { return handleError(function (arg0, arg1) {
|
|
187
|
+
const ret = Reflect.get(getObject(arg0), getObject(arg1));
|
|
188
|
+
return addHeapObject(ret);
|
|
189
|
+
}, arguments); },
|
|
190
|
+
__wbg_length_7f3c00c40364105e: function(arg0) {
|
|
191
|
+
const ret = getObject(arg0).length;
|
|
192
|
+
return ret;
|
|
193
|
+
},
|
|
194
|
+
__wbg_new_1dbf7428bba60a42: function(arg0) {
|
|
195
|
+
const ret = new Uint8Array(getObject(arg0));
|
|
196
|
+
return addHeapObject(ret);
|
|
197
|
+
},
|
|
198
|
+
__wbg_new_from_slice_9a868026ffa4208a: function(arg0, arg1) {
|
|
199
|
+
const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
|
|
200
|
+
return addHeapObject(ret);
|
|
201
|
+
},
|
|
202
|
+
__wbg_new_typed_b01cb72a8af741a3: function(arg0, arg1) {
|
|
203
|
+
try {
|
|
204
|
+
var state0 = {a: arg0, b: arg1};
|
|
205
|
+
var cb0 = (arg0, arg1) => {
|
|
206
|
+
const a = state0.a;
|
|
207
|
+
state0.a = 0;
|
|
208
|
+
try {
|
|
209
|
+
return __wasm_bindgen_func_elem_267(a, state0.b, arg0, arg1);
|
|
210
|
+
} finally {
|
|
211
|
+
state0.a = a;
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
const ret = new Promise(cb0);
|
|
215
|
+
return addHeapObject(ret);
|
|
216
|
+
} finally {
|
|
217
|
+
state0.a = 0;
|
|
218
|
+
}
|
|
219
|
+
},
|
|
220
|
+
__wbg_prototypesetcall_bc27214492979395: function(arg0, arg1, arg2) {
|
|
221
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
|
|
222
|
+
},
|
|
223
|
+
__wbg_queueMicrotask_9833f9a49df95a49: function(arg0) {
|
|
224
|
+
const ret = getObject(arg0).queueMicrotask;
|
|
225
|
+
return addHeapObject(ret);
|
|
226
|
+
},
|
|
227
|
+
__wbg_queueMicrotask_a72f977e97f23c5f: function(arg0) {
|
|
228
|
+
queueMicrotask(getObject(arg0));
|
|
229
|
+
},
|
|
230
|
+
__wbg_resolve_0076e10020304ede: function(arg0) {
|
|
231
|
+
const ret = Promise.resolve(getObject(arg0));
|
|
232
|
+
return addHeapObject(ret);
|
|
233
|
+
},
|
|
234
|
+
__wbg_static_accessor_GLOBAL_266715b9d96ba635: function() {
|
|
235
|
+
const ret = typeof global === 'undefined' ? null : global;
|
|
236
|
+
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
|
237
|
+
},
|
|
238
|
+
__wbg_static_accessor_GLOBAL_THIS_10fb7dc1ae063179: function() {
|
|
239
|
+
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
|
240
|
+
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
|
241
|
+
},
|
|
242
|
+
__wbg_static_accessor_SELF_0b583911f537483a: function() {
|
|
243
|
+
const ret = typeof self === 'undefined' ? null : self;
|
|
244
|
+
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
|
245
|
+
},
|
|
246
|
+
__wbg_static_accessor_WINDOW_d7f903d1508cbdc4: function() {
|
|
247
|
+
const ret = typeof window === 'undefined' ? null : window;
|
|
248
|
+
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
|
249
|
+
},
|
|
250
|
+
__wbg_then_c949d5a25a4e78f8: function(arg0, arg1, arg2) {
|
|
251
|
+
const ret = getObject(arg0).then(getObject(arg1), getObject(arg2));
|
|
252
|
+
return addHeapObject(ret);
|
|
253
|
+
},
|
|
254
|
+
__wbg_then_e71170d78fcf8954: function(arg0, arg1) {
|
|
255
|
+
const ret = getObject(arg0).then(getObject(arg1));
|
|
256
|
+
return addHeapObject(ret);
|
|
257
|
+
},
|
|
258
|
+
__wbindgen_generic_0000000000000001: function(arg0, arg1) {
|
|
259
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 72, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
260
|
+
const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_265);
|
|
261
|
+
return addHeapObject(ret);
|
|
262
|
+
},
|
|
263
|
+
__wbindgen_generic_0000000000000002: function(arg0, arg1) {
|
|
264
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
265
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
266
|
+
return addHeapObject(ret);
|
|
267
|
+
},
|
|
268
|
+
__wbindgen_object_clone_ref: function(arg0) {
|
|
269
|
+
const ret = getObject(arg0);
|
|
270
|
+
return addHeapObject(ret);
|
|
271
|
+
},
|
|
272
|
+
__wbindgen_object_drop_ref: function(arg0) {
|
|
273
|
+
takeObject(arg0);
|
|
274
|
+
},
|
|
275
|
+
};
|
|
276
|
+
return {
|
|
277
|
+
__proto__: null,
|
|
278
|
+
"./chanto_web_bg.js": import0,
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
function __wasm_bindgen_func_elem_267(arg0, arg1, arg2, arg3) {
|
|
283
|
+
wasm.__wasm_bindgen_func_elem_267(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
function __wasm_bindgen_func_elem_265(arg0, arg1, arg2) {
|
|
287
|
+
try {
|
|
288
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
289
|
+
wasm.__wasm_bindgen_func_elem_265(retptr, arg0, arg1, addHeapObject(arg2));
|
|
290
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
291
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
292
|
+
if (r1) {
|
|
293
|
+
throw takeObject(r0);
|
|
294
|
+
}
|
|
295
|
+
} finally {
|
|
296
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
const SessionFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
301
|
+
? { register: () => {}, unregister: () => {} }
|
|
302
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_session_free(ptr, 1));
|
|
303
|
+
|
|
304
|
+
function addHeapObject(obj) {
|
|
305
|
+
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
306
|
+
const idx = heap_next;
|
|
307
|
+
heap_next = heap[idx];
|
|
308
|
+
|
|
309
|
+
heap[idx] = obj;
|
|
310
|
+
return idx;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
|
|
314
|
+
? { register: () => {}, unregister: () => {} }
|
|
315
|
+
: new FinalizationRegistry(state => wasm.__wbindgen_export4(state.a, state.b));
|
|
316
|
+
|
|
317
|
+
function debugString(val) {
|
|
318
|
+
// primitive types
|
|
319
|
+
const type = typeof val;
|
|
320
|
+
if (type == 'number' || type == 'boolean' || val == null) {
|
|
321
|
+
return `${val}`;
|
|
322
|
+
}
|
|
323
|
+
if (type == 'string') {
|
|
324
|
+
return `"${val}"`;
|
|
325
|
+
}
|
|
326
|
+
if (type == 'symbol') {
|
|
327
|
+
const description = val.description;
|
|
328
|
+
if (description == null) {
|
|
329
|
+
return 'Symbol';
|
|
330
|
+
} else {
|
|
331
|
+
return `Symbol(${description})`;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
if (type == 'function') {
|
|
335
|
+
const name = val.name;
|
|
336
|
+
if (typeof name == 'string' && name.length > 0) {
|
|
337
|
+
return `Function(${name})`;
|
|
338
|
+
} else {
|
|
339
|
+
return 'Function';
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
// objects
|
|
343
|
+
if (Array.isArray(val)) {
|
|
344
|
+
const length = val.length;
|
|
345
|
+
let debug = '[';
|
|
346
|
+
if (length > 0) {
|
|
347
|
+
debug += debugString(val[0]);
|
|
348
|
+
}
|
|
349
|
+
for(let i = 1; i < length; i++) {
|
|
350
|
+
debug += ', ' + debugString(val[i]);
|
|
351
|
+
}
|
|
352
|
+
debug += ']';
|
|
353
|
+
return debug;
|
|
354
|
+
}
|
|
355
|
+
// Test for built-in
|
|
356
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
357
|
+
let className;
|
|
358
|
+
if (builtInMatches && builtInMatches.length > 1) {
|
|
359
|
+
className = builtInMatches[1];
|
|
360
|
+
} else {
|
|
361
|
+
// Failed to match the standard '[object ClassName]'
|
|
362
|
+
return toString.call(val);
|
|
363
|
+
}
|
|
364
|
+
if (className == 'Object') {
|
|
365
|
+
// we're a user defined class or Object
|
|
366
|
+
// JSON.stringify avoids problems with cycles, and is generally much
|
|
367
|
+
// easier than looping through ownProperties of `val`.
|
|
368
|
+
try {
|
|
369
|
+
return 'Object(' + JSON.stringify(val) + ')';
|
|
370
|
+
} catch (_) {
|
|
371
|
+
return 'Object';
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
// errors
|
|
375
|
+
if (val instanceof Error) {
|
|
376
|
+
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
377
|
+
}
|
|
378
|
+
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
379
|
+
return className;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
function dropObject(idx) {
|
|
383
|
+
if (idx < 1028) return;
|
|
384
|
+
heap[idx] = heap_next;
|
|
385
|
+
heap_next = idx;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
function getArrayJsValueFromWasm0(ptr, len) {
|
|
389
|
+
ptr = ptr >>> 0;
|
|
390
|
+
const mem = getDataViewMemory0();
|
|
391
|
+
const result = [];
|
|
392
|
+
for (let i = ptr; i < ptr + 4 * len; i += 4) {
|
|
393
|
+
result.push(takeObject(mem.getUint32(i, true)));
|
|
394
|
+
}
|
|
395
|
+
return result;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
399
|
+
ptr = ptr >>> 0;
|
|
400
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
let cachedDataViewMemory0 = null;
|
|
404
|
+
function getDataViewMemory0() {
|
|
405
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
406
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
407
|
+
}
|
|
408
|
+
return cachedDataViewMemory0;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
function getStringFromWasm0(ptr, len) {
|
|
412
|
+
return decodeText(ptr >>> 0, len);
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
let cachedUint8ArrayMemory0 = null;
|
|
416
|
+
function getUint8ArrayMemory0() {
|
|
417
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
418
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
419
|
+
}
|
|
420
|
+
return cachedUint8ArrayMemory0;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
function getObject(idx) { return heap[idx]; }
|
|
424
|
+
|
|
425
|
+
function handleError(f, args) {
|
|
426
|
+
try {
|
|
427
|
+
return f.apply(this, args);
|
|
428
|
+
} catch (e) {
|
|
429
|
+
wasm.__wbindgen_export3(addHeapObject(e));
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
let heap = new Array(1024).fill(undefined);
|
|
434
|
+
heap.push(undefined, null, true, false);
|
|
435
|
+
|
|
436
|
+
let heap_next = heap.length;
|
|
437
|
+
|
|
438
|
+
function isLikeNone(x) {
|
|
439
|
+
return x === undefined || x === null;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
function makeMutClosure(arg0, arg1, f) {
|
|
443
|
+
const state = { a: arg0, b: arg1, cnt: 1 };
|
|
444
|
+
const real = (...args) => {
|
|
445
|
+
|
|
446
|
+
// First up with a closure we increment the internal reference
|
|
447
|
+
// count. This ensures that the Rust closure environment won't
|
|
448
|
+
// be deallocated while we're invoking it.
|
|
449
|
+
state.cnt++;
|
|
450
|
+
const a = state.a;
|
|
451
|
+
state.a = 0;
|
|
452
|
+
try {
|
|
453
|
+
return f(a, state.b, ...args);
|
|
454
|
+
} finally {
|
|
455
|
+
state.a = a;
|
|
456
|
+
real._wbg_cb_unref();
|
|
457
|
+
}
|
|
458
|
+
};
|
|
459
|
+
real._wbg_cb_unref = () => {
|
|
460
|
+
if (--state.cnt === 0) {
|
|
461
|
+
wasm.__wbindgen_export4(state.a, state.b);
|
|
462
|
+
state.a = 0;
|
|
463
|
+
CLOSURE_DTORS.unregister(state);
|
|
464
|
+
}
|
|
465
|
+
};
|
|
466
|
+
CLOSURE_DTORS.register(real, state, state);
|
|
467
|
+
return real;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
471
|
+
if (realloc === undefined) {
|
|
472
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
473
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
474
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
475
|
+
WASM_VECTOR_LEN = buf.length;
|
|
476
|
+
return ptr;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
let len = arg.length;
|
|
480
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
481
|
+
|
|
482
|
+
const mem = getUint8ArrayMemory0();
|
|
483
|
+
|
|
484
|
+
let offset = 0;
|
|
485
|
+
|
|
486
|
+
for (; offset < len; offset++) {
|
|
487
|
+
const code = arg.charCodeAt(offset);
|
|
488
|
+
if (code > 0x7F) break;
|
|
489
|
+
mem[ptr + offset] = code;
|
|
490
|
+
}
|
|
491
|
+
if (offset !== len) {
|
|
492
|
+
if (offset !== 0) {
|
|
493
|
+
arg = arg.slice(offset);
|
|
494
|
+
}
|
|
495
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
496
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
497
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
498
|
+
|
|
499
|
+
offset += ret.written;
|
|
500
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
WASM_VECTOR_LEN = offset;
|
|
504
|
+
return ptr;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
function takeObject(idx) {
|
|
508
|
+
const ret = getObject(idx);
|
|
509
|
+
dropObject(idx);
|
|
510
|
+
return ret;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
514
|
+
cachedTextDecoder.decode();
|
|
515
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
516
|
+
let numBytesDecoded = 0;
|
|
517
|
+
function decodeText(ptr, len) {
|
|
518
|
+
numBytesDecoded += len;
|
|
519
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
520
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
521
|
+
cachedTextDecoder.decode();
|
|
522
|
+
numBytesDecoded = len;
|
|
523
|
+
}
|
|
524
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
const cachedTextEncoder = new TextEncoder();
|
|
528
|
+
|
|
529
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
530
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
531
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
532
|
+
view.set(buf);
|
|
533
|
+
return {
|
|
534
|
+
read: arg.length,
|
|
535
|
+
written: buf.length
|
|
536
|
+
};
|
|
537
|
+
};
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
let WASM_VECTOR_LEN = 0;
|
|
541
|
+
|
|
542
|
+
let wasmModule, wasmInstance, wasm;
|
|
543
|
+
function __wbg_finalize_init(instance, module) {
|
|
544
|
+
wasmInstance = instance;
|
|
545
|
+
wasm = instance.exports;
|
|
546
|
+
wasmModule = module;
|
|
547
|
+
cachedDataViewMemory0 = null;
|
|
548
|
+
cachedUint8ArrayMemory0 = null;
|
|
549
|
+
return wasm;
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
async function __wbg_load(module, imports) {
|
|
553
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
554
|
+
if (!module.ok) {
|
|
555
|
+
throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
559
|
+
try {
|
|
560
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
561
|
+
} catch (e) {
|
|
562
|
+
const validResponse = expectedResponseType(module.type);
|
|
563
|
+
|
|
564
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
565
|
+
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);
|
|
566
|
+
|
|
567
|
+
} else { throw e; }
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
const bytes = await module.arrayBuffer();
|
|
572
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
573
|
+
} else {
|
|
574
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
575
|
+
|
|
576
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
577
|
+
return { instance, module };
|
|
578
|
+
} else {
|
|
579
|
+
return instance;
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
function expectedResponseType(type) {
|
|
584
|
+
switch (type) {
|
|
585
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
586
|
+
}
|
|
587
|
+
return false;
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
function initSync(module) {
|
|
592
|
+
if (wasm !== undefined) return wasm;
|
|
593
|
+
|
|
594
|
+
|
|
595
|
+
if (module !== undefined) {
|
|
596
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
597
|
+
({module} = module)
|
|
598
|
+
} else {
|
|
599
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
const imports = __wbg_get_imports();
|
|
604
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
605
|
+
module = new WebAssembly.Module(module);
|
|
606
|
+
}
|
|
607
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
608
|
+
return __wbg_finalize_init(instance, module);
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
async function __wbg_init(module_or_path) {
|
|
612
|
+
if (wasm !== undefined) return wasm;
|
|
613
|
+
|
|
614
|
+
|
|
615
|
+
if (module_or_path !== undefined) {
|
|
616
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
617
|
+
({module_or_path} = module_or_path)
|
|
618
|
+
} else {
|
|
619
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
if (module_or_path === undefined) {
|
|
624
|
+
module_or_path = new URL('chanto_web_bg.wasm', import.meta.url);
|
|
625
|
+
}
|
|
626
|
+
const imports = __wbg_get_imports();
|
|
627
|
+
|
|
628
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
629
|
+
module_or_path = fetch(module_or_path);
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
633
|
+
|
|
634
|
+
return __wbg_finalize_init(instance, module);
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
export { initSync, __wbg_init as default };
|
|
Binary file
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const __wbg_session_free: (a: number, b: number) => void;
|
|
5
|
+
export const session_files: (a: number, b: number) => void;
|
|
6
|
+
export const session_messages_json: (a: number, b: number) => void;
|
|
7
|
+
export const session_new: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number) => number;
|
|
8
|
+
export const session_read_file: (a: number, b: number, c: number, d: number) => void;
|
|
9
|
+
export const session_run: (a: number, b: number, c: number, d: number, e: number) => number;
|
|
10
|
+
export const session_set_max_steps: (a: number, b: number) => void;
|
|
11
|
+
export const session_write_file: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
12
|
+
export const __wasm_bindgen_func_elem_265: (a: number, b: number, c: number, d: number) => void;
|
|
13
|
+
export const __wasm_bindgen_func_elem_267: (a: number, b: number, c: number, d: number) => void;
|
|
14
|
+
export const __wbindgen_export: (a: number, b: number) => number;
|
|
15
|
+
export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
16
|
+
export const __wbindgen_export3: (a: number) => void;
|
|
17
|
+
export const __wbindgen_export4: (a: number, b: number) => void;
|
|
18
|
+
export const __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
19
|
+
export const __wbindgen_export5: (a: number, b: number, c: number) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chanto/web",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.11",
|
|
4
|
+
"description": "Chanto's agent in the browser: its agent loop and file tools as WebAssembly",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"homepage": "https://chanto.sh",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/chanto-sh/chanto.git",
|
|
10
|
+
"directory": "web"
|
|
11
|
+
},
|
|
12
|
+
"type": "module",
|
|
13
|
+
"main": "chanto_web.js",
|
|
14
|
+
"module": "chanto_web.js",
|
|
15
|
+
"types": "chanto_web.d.ts",
|
|
16
|
+
"files": [
|
|
17
|
+
"chanto_web.js",
|
|
18
|
+
"chanto_web.d.ts",
|
|
19
|
+
"chanto_web_bg.wasm",
|
|
20
|
+
"chanto_web_bg.wasm.d.ts",
|
|
21
|
+
"LICENSE",
|
|
22
|
+
"NOTICE",
|
|
23
|
+
"THIRD_PARTY_LICENSES.txt",
|
|
24
|
+
"README.md"
|
|
25
|
+
],
|
|
26
|
+
"sideEffects": false,
|
|
27
|
+
"keywords": [
|
|
28
|
+
"chanto",
|
|
29
|
+
"coding-agent",
|
|
30
|
+
"webassembly"
|
|
31
|
+
]
|
|
32
|
+
}
|