dsh-rwkv-plugin 0.0.0-stage → 0.2.0

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.
Files changed (92) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +50 -2
  3. package/cordis.patch.yml +59 -0
  4. package/lib/client.js +3148 -0
  5. package/lib/client.js.map +7 -0
  6. package/lib/index.js +6294 -0
  7. package/lib/index.js.map +7 -0
  8. package/lib/line-edit.js +1423 -0
  9. package/lib/line-edit.js.map +7 -0
  10. package/lib/todo.js +610 -0
  11. package/lib/todo.js.map +7 -0
  12. package/package.json +72 -4
  13. package/scripts/build.mjs +77 -0
  14. package/scripts/headless.ts +279 -0
  15. package/scripts/link-dsh.sh +31 -0
  16. package/scripts/relay-e2e.mjs +157 -0
  17. package/scripts/smoke.ts +116 -0
  18. package/scripts/state.ts +39 -0
  19. package/scripts/tokenizer-parity.ts +107 -0
  20. package/scripts/trace-stats.ts +33 -0
  21. package/src/adapter.ts +388 -0
  22. package/src/backend/generator.ts +221 -0
  23. package/src/backend/irwkv.ts +117 -0
  24. package/src/backend/lightning.ts +228 -0
  25. package/src/backend/stream.ts +97 -0
  26. package/src/client/AdapterPicker.tsx +264 -0
  27. package/src/client/DeveloperPanel.tsx +403 -0
  28. package/src/client/FoldNode.tsx +82 -0
  29. package/src/client/ModelCard.tsx +230 -0
  30. package/src/client/RwkvSettings.tsx +265 -0
  31. package/src/client/Segment.tsx +15 -0
  32. package/src/client/StatePicker.tsx +248 -0
  33. package/src/client/TraceFrames.tsx +462 -0
  34. package/src/client/TraceView.tsx +77 -0
  35. package/src/client/WirePanel.tsx +566 -0
  36. package/src/client/fields.tsx +362 -0
  37. package/src/client/index.tsx +109 -0
  38. package/src/client/styles.ts +277 -0
  39. package/src/client/traces-api.ts +222 -0
  40. package/src/client/url.ts +20 -0
  41. package/src/core/agent.ts +586 -0
  42. package/src/core/defaults.ts +51 -0
  43. package/src/core/dsh-prompt.ts +32 -0
  44. package/src/core/edit-modes/index.ts +108 -0
  45. package/src/core/edit-modes/line-edit.ts +793 -0
  46. package/src/core/edit-modes/literal.ts +26 -0
  47. package/src/core/edit-modes/shared.ts +213 -0
  48. package/src/core/edit-modes/tolerant.ts +558 -0
  49. package/src/core/fold-pairs.ts +407 -0
  50. package/src/core/fold-window.ts +563 -0
  51. package/src/core/line-edit.ts +33 -0
  52. package/src/core/parse.ts +290 -0
  53. package/src/core/policy.ts +500 -0
  54. package/src/core/prompt.ts +220 -0
  55. package/src/core/relay.ts +400 -0
  56. package/src/core/step-gates.ts +371 -0
  57. package/src/core/time-zone.ts +32 -0
  58. package/src/core/todo-state.ts +227 -0
  59. package/src/core/tolerant-edit.ts +14 -0
  60. package/src/core/tool-mappings.ts +209 -0
  61. package/src/core/tool-repairs.ts +255 -0
  62. package/src/core/tools.ts +162 -0
  63. package/src/core/worklist.ts +606 -0
  64. package/src/dsh-host.ts +48 -0
  65. package/src/edit-modes/folded-read-guard.ts +32 -0
  66. package/src/edit-modes/index.ts +26 -0
  67. package/src/edit-modes/line-edit.ts +154 -0
  68. package/src/edit-modes/literal.ts +9 -0
  69. package/src/edit-modes/observations.ts +234 -0
  70. package/src/edit-modes/syntax-check.ts +226 -0
  71. package/src/edit-modes/tolerant.ts +232 -0
  72. package/src/folded-read-guard.ts +6 -0
  73. package/src/history.ts +163 -0
  74. package/src/index.ts +287 -0
  75. package/src/line-edit.ts +15 -0
  76. package/src/live-wire.ts +133 -0
  77. package/src/paths.ts +91 -0
  78. package/src/relay-store.ts +59 -0
  79. package/src/result-budget.ts +225 -0
  80. package/src/routes.ts +324 -0
  81. package/src/session-setup.ts +150 -0
  82. package/src/syntax-check.ts +2 -0
  83. package/src/todo.ts +328 -0
  84. package/src/tokenizer.ts +48 -0
  85. package/src/tolerant-edit.ts +2 -0
  86. package/src/trace-stats.ts +225 -0
  87. package/src/traces.ts +289 -0
  88. package/vendor/rwkv-tokenizer/NOTICE.md +26 -0
  89. package/vendor/rwkv-tokenizer/package.json +5 -0
  90. package/vendor/rwkv-tokenizer/rwkv_tokenizer.d.ts +11 -0
  91. package/vendor/rwkv-tokenizer/rwkv_tokenizer.js +280 -0
  92. package/vendor/rwkv-tokenizer/rwkv_tokenizer_bg.wasm +0 -0
@@ -0,0 +1,280 @@
1
+
2
+ let imports = {};
3
+ imports['__wbindgen_placeholder__'] = module.exports;
4
+ let wasm;
5
+ const { TextEncoder, TextDecoder } = require(`util`);
6
+
7
+ let WASM_VECTOR_LEN = 0;
8
+
9
+ let cachedUint8ArrayMemory0 = null;
10
+
11
+ function getUint8ArrayMemory0() {
12
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
13
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
14
+ }
15
+ return cachedUint8ArrayMemory0;
16
+ }
17
+
18
+ let cachedTextEncoder = new TextEncoder('utf-8');
19
+
20
+ const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
21
+ ? function (arg, view) {
22
+ return cachedTextEncoder.encodeInto(arg, view);
23
+ }
24
+ : function (arg, view) {
25
+ const buf = cachedTextEncoder.encode(arg);
26
+ view.set(buf);
27
+ return {
28
+ read: arg.length,
29
+ written: buf.length
30
+ };
31
+ });
32
+
33
+ function passStringToWasm0(arg, malloc, realloc) {
34
+
35
+ if (realloc === undefined) {
36
+ const buf = cachedTextEncoder.encode(arg);
37
+ const ptr = malloc(buf.length, 1) >>> 0;
38
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
39
+ WASM_VECTOR_LEN = buf.length;
40
+ return ptr;
41
+ }
42
+
43
+ let len = arg.length;
44
+ let ptr = malloc(len, 1) >>> 0;
45
+
46
+ const mem = getUint8ArrayMemory0();
47
+
48
+ let offset = 0;
49
+
50
+ for (; offset < len; offset++) {
51
+ const code = arg.charCodeAt(offset);
52
+ if (code > 0x7F) break;
53
+ mem[ptr + offset] = code;
54
+ }
55
+
56
+ if (offset !== len) {
57
+ if (offset !== 0) {
58
+ arg = arg.slice(offset);
59
+ }
60
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
61
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
62
+ const ret = encodeString(arg, view);
63
+
64
+ offset += ret.written;
65
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
66
+ }
67
+
68
+ WASM_VECTOR_LEN = offset;
69
+ return ptr;
70
+ }
71
+
72
+ function isLikeNone(x) {
73
+ return x === undefined || x === null;
74
+ }
75
+
76
+ let cachedDataViewMemory0 = null;
77
+
78
+ function getDataViewMemory0() {
79
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
80
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
81
+ }
82
+ return cachedDataViewMemory0;
83
+ }
84
+
85
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
86
+
87
+ cachedTextDecoder.decode();
88
+
89
+ function getStringFromWasm0(ptr, len) {
90
+ ptr = ptr >>> 0;
91
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
92
+ }
93
+
94
+ function addToExternrefTable0(obj) {
95
+ const idx = wasm.__externref_table_alloc();
96
+ wasm.__wbindgen_export_0.set(idx, obj);
97
+ return idx;
98
+ }
99
+
100
+ function passArrayJsValueToWasm0(array, malloc) {
101
+ const ptr = malloc(array.length * 4, 4) >>> 0;
102
+ for (let i = 0; i < array.length; i++) {
103
+ const add = addToExternrefTable0(array[i]);
104
+ getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
105
+ }
106
+ WASM_VECTOR_LEN = array.length;
107
+ return ptr;
108
+ }
109
+
110
+ let cachedUint16ArrayMemory0 = null;
111
+
112
+ function getUint16ArrayMemory0() {
113
+ if (cachedUint16ArrayMemory0 === null || cachedUint16ArrayMemory0.byteLength === 0) {
114
+ cachedUint16ArrayMemory0 = new Uint16Array(wasm.memory.buffer);
115
+ }
116
+ return cachedUint16ArrayMemory0;
117
+ }
118
+
119
+ function passArray16ToWasm0(arg, malloc) {
120
+ const ptr = malloc(arg.length * 2, 2) >>> 0;
121
+ getUint16ArrayMemory0().set(arg, ptr / 2);
122
+ WASM_VECTOR_LEN = arg.length;
123
+ return ptr;
124
+ }
125
+
126
+ function takeFromExternrefTable0(idx) {
127
+ const value = wasm.__wbindgen_export_0.get(idx);
128
+ wasm.__externref_table_dealloc(idx);
129
+ return value;
130
+ }
131
+
132
+ const WorldTokenizerFinalization = (typeof FinalizationRegistry === 'undefined')
133
+ ? { register: () => {}, unregister: () => {} }
134
+ : new FinalizationRegistry(ptr => wasm.__wbg_worldtokenizer_free(ptr >>> 0, 1));
135
+
136
+ class WorldTokenizer {
137
+
138
+ __destroy_into_raw() {
139
+ const ptr = this.__wbg_ptr;
140
+ this.__wbg_ptr = 0;
141
+ WorldTokenizerFinalization.unregister(this);
142
+ return ptr;
143
+ }
144
+
145
+ free() {
146
+ const ptr = this.__destroy_into_raw();
147
+ wasm.__wbg_worldtokenizer_free(ptr, 0);
148
+ }
149
+ constructor() {
150
+ const ret = wasm.worldtokenizer_new();
151
+ this.__wbg_ptr = ret >>> 0;
152
+ WorldTokenizerFinalization.register(this, this.__wbg_ptr, this);
153
+ return this;
154
+ }
155
+ /**
156
+ * @param {string} word
157
+ * @returns {Uint16Array}
158
+ */
159
+ encode(word) {
160
+ const ptr0 = passStringToWasm0(word, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
161
+ const len0 = WASM_VECTOR_LEN;
162
+ const ret = wasm.worldtokenizer_encode(this.__wbg_ptr, ptr0, len0);
163
+ return ret;
164
+ }
165
+ /**
166
+ * @param {string[]} word_list
167
+ * @returns {Array<any>}
168
+ */
169
+ encode_batch(word_list) {
170
+ const ptr0 = passArrayJsValueToWasm0(word_list, wasm.__wbindgen_malloc);
171
+ const len0 = WASM_VECTOR_LEN;
172
+ const ret = wasm.worldtokenizer_encode_batch(this.__wbg_ptr, ptr0, len0);
173
+ return ret;
174
+ }
175
+ /**
176
+ * @param {Uint16Array} vec
177
+ * @returns {string}
178
+ */
179
+ decode(vec) {
180
+ let deferred2_0;
181
+ let deferred2_1;
182
+ try {
183
+ const ptr0 = passArray16ToWasm0(vec, wasm.__wbindgen_malloc);
184
+ const len0 = WASM_VECTOR_LEN;
185
+ const ret = wasm.worldtokenizer_decode(this.__wbg_ptr, ptr0, len0);
186
+ deferred2_0 = ret[0];
187
+ deferred2_1 = ret[1];
188
+ return getStringFromWasm0(ret[0], ret[1]);
189
+ } finally {
190
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
191
+ }
192
+ }
193
+ /**
194
+ * @returns {number}
195
+ */
196
+ vocab_size() {
197
+ const ret = wasm.worldtokenizer_vocab_size(this.__wbg_ptr);
198
+ return ret >>> 0;
199
+ }
200
+ /**
201
+ * @returns {any}
202
+ */
203
+ get_vocab_as_json() {
204
+ const ret = wasm.worldtokenizer_get_vocab_as_json(this.__wbg_ptr);
205
+ if (ret[2]) {
206
+ throw takeFromExternrefTable0(ret[1]);
207
+ }
208
+ return takeFromExternrefTable0(ret[0]);
209
+ }
210
+ }
211
+ module.exports.WorldTokenizer = WorldTokenizer;
212
+
213
+ module.exports.__wbg_buffer_609cc3eee51ed158 = function(arg0) {
214
+ const ret = arg0.buffer;
215
+ return ret;
216
+ };
217
+
218
+ module.exports.__wbg_new_9fee97a409b32b68 = function(arg0) {
219
+ const ret = new Uint16Array(arg0);
220
+ return ret;
221
+ };
222
+
223
+ module.exports.__wbg_newwithbyteoffsetandlength_d4a86622320ea258 = function(arg0, arg1, arg2) {
224
+ const ret = new Uint16Array(arg0, arg1 >>> 0, arg2 >>> 0);
225
+ return ret;
226
+ };
227
+
228
+ module.exports.__wbg_newwithlength_c4c419ef0bc8a1f8 = function(arg0) {
229
+ const ret = new Array(arg0 >>> 0);
230
+ return ret;
231
+ };
232
+
233
+ module.exports.__wbg_set_37837023f3d740e8 = function(arg0, arg1, arg2) {
234
+ arg0[arg1 >>> 0] = arg2;
235
+ };
236
+
237
+ module.exports.__wbindgen_init_externref_table = function() {
238
+ const table = wasm.__wbindgen_export_0;
239
+ const offset = table.grow(4);
240
+ table.set(0, undefined);
241
+ table.set(offset + 0, undefined);
242
+ table.set(offset + 1, null);
243
+ table.set(offset + 2, true);
244
+ table.set(offset + 3, false);
245
+ ;
246
+ };
247
+
248
+ module.exports.__wbindgen_memory = function() {
249
+ const ret = wasm.memory;
250
+ return ret;
251
+ };
252
+
253
+ module.exports.__wbindgen_string_get = function(arg0, arg1) {
254
+ const obj = arg1;
255
+ const ret = typeof(obj) === 'string' ? obj : undefined;
256
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
257
+ var len1 = WASM_VECTOR_LEN;
258
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
259
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
260
+ };
261
+
262
+ module.exports.__wbindgen_string_new = function(arg0, arg1) {
263
+ const ret = getStringFromWasm0(arg0, arg1);
264
+ return ret;
265
+ };
266
+
267
+ module.exports.__wbindgen_throw = function(arg0, arg1) {
268
+ throw new Error(getStringFromWasm0(arg0, arg1));
269
+ };
270
+
271
+ const path = require('path').join(__dirname, 'rwkv_tokenizer_bg.wasm');
272
+ const bytes = require('fs').readFileSync(path);
273
+
274
+ const wasmModule = new WebAssembly.Module(bytes);
275
+ const wasmInstance = new WebAssembly.Instance(wasmModule, imports);
276
+ wasm = wasmInstance.exports;
277
+ module.exports.__wasm = wasm;
278
+
279
+ wasm.__wbindgen_start();
280
+