entroly-wasm 1.0.4 → 1.0.6

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 CHANGED
@@ -11,19 +11,47 @@
11
11
  // npx entroly-wasm serve
12
12
 
13
13
  let WasmEntrolyEngine;
14
+ let classifyQueryTransitionRust;
15
+ let rewardWeightedOptimizeRust;
16
+ let optimizeTaskProfilesRust;
17
+ let classifyLearningQueryRust;
18
+ function bindWasmExports(mod) {
19
+ ({
20
+ WasmEntrolyEngine,
21
+ classify_query_transition: classifyQueryTransitionRust,
22
+ reward_weighted_optimize: rewardWeightedOptimizeRust,
23
+ optimize_task_profiles: optimizeTaskProfilesRust,
24
+ classify_learning_query: classifyLearningQueryRust,
25
+ } = mod);
26
+ }
27
+
28
+ function buildAndBindWasm() {
29
+ const { execFileSync } = require('child_process');
30
+ execFileSync('wasm-pack', ['build', '--target', 'nodejs', '--out-dir', 'pkg'], {
31
+ cwd: __dirname,
32
+ stdio: 'inherit',
33
+ });
34
+ const pkgPath = require.resolve('./pkg/entroly_wasm');
35
+ delete require.cache[pkgPath];
36
+ bindWasmExports(require('./pkg/entroly_wasm'));
37
+ }
38
+
14
39
  try {
15
- ({ WasmEntrolyEngine } = require('./pkg/entroly_wasm'));
40
+ bindWasmExports(require('./pkg/entroly_wasm'));
41
+ if (
42
+ !classifyQueryTransitionRust ||
43
+ !rewardWeightedOptimizeRust ||
44
+ !optimizeTaskProfilesRust ||
45
+ !classifyLearningQueryRust
46
+ ) {
47
+ buildAndBindWasm();
48
+ }
16
49
  } catch (err) {
17
50
  if (err && err.code === 'MODULE_NOT_FOUND') {
18
51
  // Source checkouts do not commit wasm-pack output. Build it lazily so
19
52
  // `node -e "require('./entroly-wasm')"` and local smoke tests exercise the
20
53
  // same module shape that the published npm tarball contains.
21
- const { execFileSync } = require('child_process');
22
- execFileSync('wasm-pack', ['build', '--target', 'nodejs', '--out-dir', 'pkg'], {
23
- cwd: __dirname,
24
- stdio: 'inherit',
25
- });
26
- ({ WasmEntrolyEngine } = require('./pkg/entroly_wasm'));
54
+ buildAndBindWasm();
27
55
  } else {
28
56
  throw err;
29
57
  }
@@ -38,10 +66,42 @@ const { exportPromoted: exportAgentSkills } = require('./js/agentskills_export')
38
66
  const { TelegramGateway, DiscordGateway, SlackGateway } = require('./js/gateways');
39
67
  const { VaultObserver } = require('./js/vault_observer');
40
68
 
69
+ function classifyQueryTransition(...args) {
70
+ if (!classifyQueryTransitionRust) {
71
+ throw new Error('Rust classify_query_transition is unavailable; rebuild entroly-wasm');
72
+ }
73
+ return classifyQueryTransitionRust(...args);
74
+ }
75
+
76
+ function rewardWeightedOptimize(...args) {
77
+ if (!rewardWeightedOptimizeRust) {
78
+ throw new Error('Rust reward_weighted_optimize is unavailable; rebuild entroly-wasm');
79
+ }
80
+ return rewardWeightedOptimizeRust(...args);
81
+ }
82
+
83
+ function optimizeTaskProfiles(...args) {
84
+ if (!optimizeTaskProfilesRust) {
85
+ throw new Error('Rust optimize_task_profiles is unavailable; rebuild entroly-wasm');
86
+ }
87
+ return optimizeTaskProfilesRust(...args);
88
+ }
89
+
90
+ function classifyLearningQuery(...args) {
91
+ if (!classifyLearningQueryRust) {
92
+ throw new Error('Rust classify_learning_query is unavailable; rebuild entroly-wasm');
93
+ }
94
+ return classifyLearningQueryRust(...args);
95
+ }
96
+
41
97
  module.exports = {
42
98
  // Core engine (wasm)
43
99
  EntrolyEngine: WasmEntrolyEngine,
44
100
  WasmEntrolyEngine,
101
+ classifyQueryTransition,
102
+ rewardWeightedOptimize,
103
+ optimizeTaskProfiles,
104
+ classifyLearningQuery,
45
105
 
46
106
  // Configuration
47
107
  EntrolyConfig,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "entroly-wasm",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
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",
@@ -200,3 +200,11 @@ export class WasmEntrolyEngine {
200
200
  */
201
201
  stats(): any;
202
202
  }
203
+
204
+ export function classify_learning_query(query: string): string;
205
+
206
+ 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;
207
+
208
+ export function optimize_task_profiles(episodes_json: string): any;
209
+
210
+ export function reward_weighted_optimize(episodes_json: string, current_weights_json: string): any;
@@ -436,6 +436,76 @@ class WasmEntrolyEngine {
436
436
  if (Symbol.dispose) WasmEntrolyEngine.prototype[Symbol.dispose] = WasmEntrolyEngine.prototype.free;
437
437
  exports.WasmEntrolyEngine = WasmEntrolyEngine;
438
438
 
439
+ /**
440
+ * @param {string} query
441
+ * @returns {string}
442
+ */
443
+ function classify_learning_query(query) {
444
+ let deferred2_0;
445
+ let deferred2_1;
446
+ try {
447
+ const ptr0 = passStringToWasm0(query, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
448
+ const len0 = WASM_VECTOR_LEN;
449
+ const ret = wasm.classify_learning_query(ptr0, len0);
450
+ deferred2_0 = ret[0];
451
+ deferred2_1 = ret[1];
452
+ return getStringFromWasm0(ret[0], ret[1]);
453
+ } finally {
454
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
455
+ }
456
+ }
457
+ exports.classify_learning_query = classify_learning_query;
458
+
459
+ /**
460
+ * @param {bigint} prev_hash
461
+ * @param {string} current_query
462
+ * @param {number} elapsed_s
463
+ * @param {number} time_window_s
464
+ * @param {number} rephrase_threshold
465
+ * @param {number} topic_change_threshold
466
+ * @returns {any}
467
+ */
468
+ function classify_query_transition(prev_hash, current_query, elapsed_s, time_window_s, rephrase_threshold, topic_change_threshold) {
469
+ const ptr0 = passStringToWasm0(current_query, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
470
+ const len0 = WASM_VECTOR_LEN;
471
+ const ret = wasm.classify_query_transition(prev_hash, ptr0, len0, elapsed_s, time_window_s, rephrase_threshold, topic_change_threshold);
472
+ return ret;
473
+ }
474
+ exports.classify_query_transition = classify_query_transition;
475
+
476
+ /**
477
+ * @param {string} episodes_json
478
+ * @returns {any}
479
+ */
480
+ function optimize_task_profiles(episodes_json) {
481
+ const ptr0 = passStringToWasm0(episodes_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
482
+ const len0 = WASM_VECTOR_LEN;
483
+ const ret = wasm.optimize_task_profiles(ptr0, len0);
484
+ if (ret[2]) {
485
+ throw takeFromExternrefTable0(ret[1]);
486
+ }
487
+ return takeFromExternrefTable0(ret[0]);
488
+ }
489
+ exports.optimize_task_profiles = optimize_task_profiles;
490
+
491
+ /**
492
+ * @param {string} episodes_json
493
+ * @param {string} current_weights_json
494
+ * @returns {any}
495
+ */
496
+ function reward_weighted_optimize(episodes_json, current_weights_json) {
497
+ const ptr0 = passStringToWasm0(episodes_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
498
+ const len0 = WASM_VECTOR_LEN;
499
+ const ptr1 = passStringToWasm0(current_weights_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
500
+ const len1 = WASM_VECTOR_LEN;
501
+ const ret = wasm.reward_weighted_optimize(ptr0, len0, ptr1, len1);
502
+ if (ret[2]) {
503
+ throw takeFromExternrefTable0(ret[1]);
504
+ }
505
+ return takeFromExternrefTable0(ret[0]);
506
+ }
507
+ exports.reward_weighted_optimize = reward_weighted_optimize;
508
+
439
509
  function __wbg_get_imports() {
440
510
  const import0 = {
441
511
  __proto__: null,
@@ -446,6 +516,11 @@ function __wbg_get_imports() {
446
516
  const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
447
517
  return ret;
448
518
  }, arguments); },
519
+ __wbindgen_cast_0000000000000001: function(arg0, arg1) {
520
+ // Cast intrinsic for `Ref(String) -> Externref`.
521
+ const ret = getStringFromWasm0(arg0, arg1);
522
+ return ret;
523
+ },
449
524
  __wbindgen_init_externref_table: function() {
450
525
  const table = wasm.__wbindgen_externrefs;
451
526
  const offset = table.grow(4);
@@ -531,6 +606,12 @@ function passStringToWasm0(arg, malloc, realloc) {
531
606
  return ptr;
532
607
  }
533
608
 
609
+ function takeFromExternrefTable0(idx) {
610
+ const value = wasm.__wbindgen_externrefs.get(idx);
611
+ wasm.__externref_table_dealloc(idx);
612
+ return value;
613
+ }
614
+
534
615
  let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
535
616
  cachedTextDecoder.decode();
536
617
  function decodeText(ptr, len) {
Binary file