entroly-wasm 1.0.3 → 1.0.5
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/index.js +42 -7
- package/package.json +1 -1
- package/pkg/entroly_wasm.d.ts +4 -0
- package/pkg/entroly_wasm.js +46 -0
- package/pkg/entroly_wasm_bg.wasm +0 -0
package/index.js
CHANGED
|
@@ -11,19 +11,38 @@
|
|
|
11
11
|
// npx entroly-wasm serve
|
|
12
12
|
|
|
13
13
|
let WasmEntrolyEngine;
|
|
14
|
+
let classifyQueryTransitionRust;
|
|
15
|
+
let rewardWeightedOptimizeRust;
|
|
16
|
+
function bindWasmExports(mod) {
|
|
17
|
+
({
|
|
18
|
+
WasmEntrolyEngine,
|
|
19
|
+
classify_query_transition: classifyQueryTransitionRust,
|
|
20
|
+
reward_weighted_optimize: rewardWeightedOptimizeRust,
|
|
21
|
+
} = mod);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function buildAndBindWasm() {
|
|
25
|
+
const { execFileSync } = require('child_process');
|
|
26
|
+
execFileSync('wasm-pack', ['build', '--target', 'nodejs', '--out-dir', 'pkg'], {
|
|
27
|
+
cwd: __dirname,
|
|
28
|
+
stdio: 'inherit',
|
|
29
|
+
});
|
|
30
|
+
const pkgPath = require.resolve('./pkg/entroly_wasm');
|
|
31
|
+
delete require.cache[pkgPath];
|
|
32
|
+
bindWasmExports(require('./pkg/entroly_wasm'));
|
|
33
|
+
}
|
|
34
|
+
|
|
14
35
|
try {
|
|
15
|
-
(
|
|
36
|
+
bindWasmExports(require('./pkg/entroly_wasm'));
|
|
37
|
+
if (!classifyQueryTransitionRust || !rewardWeightedOptimizeRust) {
|
|
38
|
+
buildAndBindWasm();
|
|
39
|
+
}
|
|
16
40
|
} catch (err) {
|
|
17
41
|
if (err && err.code === 'MODULE_NOT_FOUND') {
|
|
18
42
|
// Source checkouts do not commit wasm-pack output. Build it lazily so
|
|
19
43
|
// `node -e "require('./entroly-wasm')"` and local smoke tests exercise the
|
|
20
44
|
// same module shape that the published npm tarball contains.
|
|
21
|
-
|
|
22
|
-
execFileSync('wasm-pack', ['build', '--target', 'nodejs', '--out-dir', 'pkg'], {
|
|
23
|
-
cwd: __dirname,
|
|
24
|
-
stdio: 'inherit',
|
|
25
|
-
});
|
|
26
|
-
({ WasmEntrolyEngine } = require('./pkg/entroly_wasm'));
|
|
45
|
+
buildAndBindWasm();
|
|
27
46
|
} else {
|
|
28
47
|
throw err;
|
|
29
48
|
}
|
|
@@ -38,10 +57,26 @@ const { exportPromoted: exportAgentSkills } = require('./js/agentskills_export')
|
|
|
38
57
|
const { TelegramGateway, DiscordGateway, SlackGateway } = require('./js/gateways');
|
|
39
58
|
const { VaultObserver } = require('./js/vault_observer');
|
|
40
59
|
|
|
60
|
+
function classifyQueryTransition(...args) {
|
|
61
|
+
if (!classifyQueryTransitionRust) {
|
|
62
|
+
throw new Error('Rust classify_query_transition is unavailable; rebuild entroly-wasm');
|
|
63
|
+
}
|
|
64
|
+
return classifyQueryTransitionRust(...args);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function rewardWeightedOptimize(...args) {
|
|
68
|
+
if (!rewardWeightedOptimizeRust) {
|
|
69
|
+
throw new Error('Rust reward_weighted_optimize is unavailable; rebuild entroly-wasm');
|
|
70
|
+
}
|
|
71
|
+
return rewardWeightedOptimizeRust(...args);
|
|
72
|
+
}
|
|
73
|
+
|
|
41
74
|
module.exports = {
|
|
42
75
|
// Core engine (wasm)
|
|
43
76
|
EntrolyEngine: WasmEntrolyEngine,
|
|
44
77
|
WasmEntrolyEngine,
|
|
78
|
+
classifyQueryTransition,
|
|
79
|
+
rewardWeightedOptimize,
|
|
45
80
|
|
|
46
81
|
// Configuration
|
|
47
82
|
EntrolyConfig,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "entroly-wasm",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "Information-theoretic context optimization for AI coding agents. Zero-friction, pure WebAssembly - no Python dependency.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "pkg/entroly_wasm.d.ts",
|
package/pkg/entroly_wasm.d.ts
CHANGED
|
@@ -200,3 +200,7 @@ export class WasmEntrolyEngine {
|
|
|
200
200
|
*/
|
|
201
201
|
stats(): any;
|
|
202
202
|
}
|
|
203
|
+
|
|
204
|
+
export function classify_query_transition(prev_hash: bigint, current_query: string, elapsed_s: number, time_window_s: number, rephrase_threshold: number, topic_change_threshold: number): any;
|
|
205
|
+
|
|
206
|
+
export function reward_weighted_optimize(episodes_json: string, current_weights_json: string): any;
|
package/pkg/entroly_wasm.js
CHANGED
|
@@ -436,6 +436,41 @@ class WasmEntrolyEngine {
|
|
|
436
436
|
if (Symbol.dispose) WasmEntrolyEngine.prototype[Symbol.dispose] = WasmEntrolyEngine.prototype.free;
|
|
437
437
|
exports.WasmEntrolyEngine = WasmEntrolyEngine;
|
|
438
438
|
|
|
439
|
+
/**
|
|
440
|
+
* @param {bigint} prev_hash
|
|
441
|
+
* @param {string} current_query
|
|
442
|
+
* @param {number} elapsed_s
|
|
443
|
+
* @param {number} time_window_s
|
|
444
|
+
* @param {number} rephrase_threshold
|
|
445
|
+
* @param {number} topic_change_threshold
|
|
446
|
+
* @returns {any}
|
|
447
|
+
*/
|
|
448
|
+
function classify_query_transition(prev_hash, current_query, elapsed_s, time_window_s, rephrase_threshold, topic_change_threshold) {
|
|
449
|
+
const ptr0 = passStringToWasm0(current_query, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
450
|
+
const len0 = WASM_VECTOR_LEN;
|
|
451
|
+
const ret = wasm.classify_query_transition(prev_hash, ptr0, len0, elapsed_s, time_window_s, rephrase_threshold, topic_change_threshold);
|
|
452
|
+
return ret;
|
|
453
|
+
}
|
|
454
|
+
exports.classify_query_transition = classify_query_transition;
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* @param {string} episodes_json
|
|
458
|
+
* @param {string} current_weights_json
|
|
459
|
+
* @returns {any}
|
|
460
|
+
*/
|
|
461
|
+
function reward_weighted_optimize(episodes_json, current_weights_json) {
|
|
462
|
+
const ptr0 = passStringToWasm0(episodes_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
463
|
+
const len0 = WASM_VECTOR_LEN;
|
|
464
|
+
const ptr1 = passStringToWasm0(current_weights_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
465
|
+
const len1 = WASM_VECTOR_LEN;
|
|
466
|
+
const ret = wasm.reward_weighted_optimize(ptr0, len0, ptr1, len1);
|
|
467
|
+
if (ret[2]) {
|
|
468
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
469
|
+
}
|
|
470
|
+
return takeFromExternrefTable0(ret[0]);
|
|
471
|
+
}
|
|
472
|
+
exports.reward_weighted_optimize = reward_weighted_optimize;
|
|
473
|
+
|
|
439
474
|
function __wbg_get_imports() {
|
|
440
475
|
const import0 = {
|
|
441
476
|
__proto__: null,
|
|
@@ -446,6 +481,11 @@ function __wbg_get_imports() {
|
|
|
446
481
|
const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
|
|
447
482
|
return ret;
|
|
448
483
|
}, arguments); },
|
|
484
|
+
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
485
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
486
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
487
|
+
return ret;
|
|
488
|
+
},
|
|
449
489
|
__wbindgen_init_externref_table: function() {
|
|
450
490
|
const table = wasm.__wbindgen_externrefs;
|
|
451
491
|
const offset = table.grow(4);
|
|
@@ -531,6 +571,12 @@ function passStringToWasm0(arg, malloc, realloc) {
|
|
|
531
571
|
return ptr;
|
|
532
572
|
}
|
|
533
573
|
|
|
574
|
+
function takeFromExternrefTable0(idx) {
|
|
575
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
576
|
+
wasm.__externref_table_dealloc(idx);
|
|
577
|
+
return value;
|
|
578
|
+
}
|
|
579
|
+
|
|
534
580
|
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
535
581
|
cachedTextDecoder.decode();
|
|
536
582
|
function decodeText(ptr, len) {
|
package/pkg/entroly_wasm_bg.wasm
CHANGED
|
Binary file
|