llmtxt 2026.4.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 (103) hide show
  1. package/CHANGELOG.md +66 -0
  2. package/LICENSE +21 -0
  3. package/README.md +64 -0
  4. package/dist/cache.d.ts +155 -0
  5. package/dist/cache.d.ts.map +1 -0
  6. package/dist/cache.js +193 -0
  7. package/dist/cache.js.map +1 -0
  8. package/dist/client.d.ts +80 -0
  9. package/dist/client.d.ts.map +1 -0
  10. package/dist/client.js +143 -0
  11. package/dist/client.js.map +1 -0
  12. package/dist/compression.d.ts +9 -0
  13. package/dist/compression.d.ts.map +1 -0
  14. package/dist/compression.js +8 -0
  15. package/dist/compression.js.map +1 -0
  16. package/dist/disclosure.d.ts +215 -0
  17. package/dist/disclosure.d.ts.map +1 -0
  18. package/dist/disclosure.js +532 -0
  19. package/dist/disclosure.js.map +1 -0
  20. package/dist/graph.d.ts +76 -0
  21. package/dist/graph.d.ts.map +1 -0
  22. package/dist/graph.js +137 -0
  23. package/dist/graph.js.map +1 -0
  24. package/dist/index.d.ts +38 -0
  25. package/dist/index.d.ts.map +1 -0
  26. package/dist/index.js +31 -0
  27. package/dist/index.js.map +1 -0
  28. package/dist/patch.d.ts +8 -0
  29. package/dist/patch.d.ts.map +1 -0
  30. package/dist/patch.js +8 -0
  31. package/dist/patch.js.map +1 -0
  32. package/dist/schemas.d.ts +290 -0
  33. package/dist/schemas.d.ts.map +1 -0
  34. package/dist/schemas.js +154 -0
  35. package/dist/schemas.js.map +1 -0
  36. package/dist/sdk/attribution.d.ts +59 -0
  37. package/dist/sdk/attribution.d.ts.map +1 -0
  38. package/dist/sdk/attribution.js +99 -0
  39. package/dist/sdk/attribution.js.map +1 -0
  40. package/dist/sdk/consensus.d.ts +73 -0
  41. package/dist/sdk/consensus.d.ts.map +1 -0
  42. package/dist/sdk/consensus.js +110 -0
  43. package/dist/sdk/consensus.js.map +1 -0
  44. package/dist/sdk/document.d.ts +92 -0
  45. package/dist/sdk/document.d.ts.map +1 -0
  46. package/dist/sdk/document.js +182 -0
  47. package/dist/sdk/document.js.map +1 -0
  48. package/dist/sdk/index.d.ts +22 -0
  49. package/dist/sdk/index.d.ts.map +1 -0
  50. package/dist/sdk/index.js +15 -0
  51. package/dist/sdk/index.js.map +1 -0
  52. package/dist/sdk/lifecycle.d.ts +66 -0
  53. package/dist/sdk/lifecycle.d.ts.map +1 -0
  54. package/dist/sdk/lifecycle.js +80 -0
  55. package/dist/sdk/lifecycle.js.map +1 -0
  56. package/dist/sdk/retrieval.d.ts +64 -0
  57. package/dist/sdk/retrieval.d.ts.map +1 -0
  58. package/dist/sdk/retrieval.js +102 -0
  59. package/dist/sdk/retrieval.js.map +1 -0
  60. package/dist/sdk/storage-adapter.d.ts +53 -0
  61. package/dist/sdk/storage-adapter.d.ts.map +1 -0
  62. package/dist/sdk/storage-adapter.js +2 -0
  63. package/dist/sdk/storage-adapter.js.map +1 -0
  64. package/dist/sdk/storage.d.ts +86 -0
  65. package/dist/sdk/storage.d.ts.map +1 -0
  66. package/dist/sdk/storage.js +69 -0
  67. package/dist/sdk/storage.js.map +1 -0
  68. package/dist/sdk/versions.d.ts +107 -0
  69. package/dist/sdk/versions.d.ts.map +1 -0
  70. package/dist/sdk/versions.js +129 -0
  71. package/dist/sdk/versions.js.map +1 -0
  72. package/dist/signed-url.d.ts +90 -0
  73. package/dist/signed-url.d.ts.map +1 -0
  74. package/dist/signed-url.js +159 -0
  75. package/dist/signed-url.js.map +1 -0
  76. package/dist/similarity.d.ts +57 -0
  77. package/dist/similarity.d.ts.map +1 -0
  78. package/dist/similarity.js +134 -0
  79. package/dist/similarity.js.map +1 -0
  80. package/dist/snapshot.d.ts +54 -0
  81. package/dist/snapshot.d.ts.map +1 -0
  82. package/dist/snapshot.js +94 -0
  83. package/dist/snapshot.js.map +1 -0
  84. package/dist/types.d.ts +92 -0
  85. package/dist/types.d.ts.map +1 -0
  86. package/dist/types.js +8 -0
  87. package/dist/types.js.map +1 -0
  88. package/dist/validation.d.ts +146 -0
  89. package/dist/validation.d.ts.map +1 -0
  90. package/dist/validation.js +285 -0
  91. package/dist/validation.js.map +1 -0
  92. package/dist/wasm.d.ts +28 -0
  93. package/dist/wasm.d.ts.map +1 -0
  94. package/dist/wasm.js +92 -0
  95. package/dist/wasm.js.map +1 -0
  96. package/package.json +98 -0
  97. package/wasm/LICENSE +21 -0
  98. package/wasm/README.md +63 -0
  99. package/wasm/llmtxt_core.d.ts +176 -0
  100. package/wasm/llmtxt_core.js +719 -0
  101. package/wasm/llmtxt_core_bg.wasm +0 -0
  102. package/wasm/llmtxt_core_bg.wasm.d.ts +37 -0
  103. package/wasm/package.json +25 -0
@@ -0,0 +1,719 @@
1
+ /* @ts-self-types="./llmtxt_core.d.ts" */
2
+
3
+ /**
4
+ * Result of computing a line-based diff between two texts.
5
+ */
6
+ class DiffResult {
7
+ static __wrap(ptr) {
8
+ ptr = ptr >>> 0;
9
+ const obj = Object.create(DiffResult.prototype);
10
+ obj.__wbg_ptr = ptr;
11
+ DiffResultFinalization.register(obj, obj.__wbg_ptr, obj);
12
+ return obj;
13
+ }
14
+ __destroy_into_raw() {
15
+ const ptr = this.__wbg_ptr;
16
+ this.__wbg_ptr = 0;
17
+ DiffResultFinalization.unregister(this);
18
+ return ptr;
19
+ }
20
+ free() {
21
+ const ptr = this.__destroy_into_raw();
22
+ wasm.__wbg_diffresult_free(ptr, 0);
23
+ }
24
+ /**
25
+ * Number of lines added in the new text.
26
+ * @returns {number}
27
+ */
28
+ get added_lines() {
29
+ const ret = wasm.diffresult_added_lines(this.__wbg_ptr);
30
+ return ret >>> 0;
31
+ }
32
+ /**
33
+ * Estimated tokens added.
34
+ * @returns {number}
35
+ */
36
+ get added_tokens() {
37
+ const ret = wasm.diffresult_added_tokens(this.__wbg_ptr);
38
+ return ret >>> 0;
39
+ }
40
+ /**
41
+ * Number of lines removed from the old text.
42
+ * @returns {number}
43
+ */
44
+ get removed_lines() {
45
+ const ret = wasm.diffresult_removed_lines(this.__wbg_ptr);
46
+ return ret >>> 0;
47
+ }
48
+ /**
49
+ * Estimated tokens removed.
50
+ * @returns {number}
51
+ */
52
+ get removed_tokens() {
53
+ const ret = wasm.diffresult_removed_tokens(this.__wbg_ptr);
54
+ return ret >>> 0;
55
+ }
56
+ }
57
+ if (Symbol.dispose) DiffResult.prototype[Symbol.dispose] = DiffResult.prototype.free;
58
+ exports.DiffResult = DiffResult;
59
+
60
+ /**
61
+ * Apply a unified diff patch to an original string.
62
+ * Returns the updated string on success, or an error if the patch is invalid
63
+ * or fails to apply cleanly.
64
+ * @param {string} original
65
+ * @param {string} patch_text
66
+ * @returns {string}
67
+ */
68
+ function apply_patch(original, patch_text) {
69
+ let deferred4_0;
70
+ let deferred4_1;
71
+ try {
72
+ const ptr0 = passStringToWasm0(original, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
73
+ const len0 = WASM_VECTOR_LEN;
74
+ const ptr1 = passStringToWasm0(patch_text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
75
+ const len1 = WASM_VECTOR_LEN;
76
+ const ret = wasm.apply_patch(ptr0, len0, ptr1, len1);
77
+ var ptr3 = ret[0];
78
+ var len3 = ret[1];
79
+ if (ret[3]) {
80
+ ptr3 = 0; len3 = 0;
81
+ throw takeFromExternrefTable0(ret[2]);
82
+ }
83
+ deferred4_0 = ptr3;
84
+ deferred4_1 = len3;
85
+ return getStringFromWasm0(ptr3, len3);
86
+ } finally {
87
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
88
+ }
89
+ }
90
+ exports.apply_patch = apply_patch;
91
+
92
+ /**
93
+ * Calculate the compression ratio (original / compressed), rounded to 2 decimals.
94
+ * Returns 1.0 when `compressed_size` is 0.
95
+ * @param {number} original_size
96
+ * @param {number} compressed_size
97
+ * @returns {number}
98
+ */
99
+ function calculate_compression_ratio(original_size, compressed_size) {
100
+ const ret = wasm.calculate_compression_ratio(original_size, compressed_size);
101
+ return ret;
102
+ }
103
+ exports.calculate_compression_ratio = calculate_compression_ratio;
104
+
105
+ /**
106
+ * Estimate token count using the ~4 chars/token heuristic.
107
+ * @param {string} text
108
+ * @returns {number}
109
+ */
110
+ function calculate_tokens(text) {
111
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
112
+ const len0 = WASM_VECTOR_LEN;
113
+ const ret = wasm.calculate_tokens(ptr0, len0);
114
+ return ret >>> 0;
115
+ }
116
+ exports.calculate_tokens = calculate_tokens;
117
+
118
+ /**
119
+ * Compress a UTF-8 string using zlib-wrapped deflate (RFC 1950).
120
+ *
121
+ * Matches Node.js `zlib.deflate` output for backward compatibility
122
+ * with existing stored data.
123
+ *
124
+ * # Errors
125
+ * Returns an error string if compression fails.
126
+ * @param {string} data
127
+ * @returns {Uint8Array}
128
+ */
129
+ function compress(data) {
130
+ const ptr0 = passStringToWasm0(data, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
131
+ const len0 = WASM_VECTOR_LEN;
132
+ const ret = wasm.compress(ptr0, len0);
133
+ if (ret[3]) {
134
+ throw takeFromExternrefTable0(ret[2]);
135
+ }
136
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
137
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
138
+ return v2;
139
+ }
140
+ exports.compress = compress;
141
+
142
+ /**
143
+ * Compute a line-based diff between two texts.
144
+ *
145
+ * Uses a hash-based LCS (Longest Common Subsequence) approach for
146
+ * O(n*m) comparison where n and m are line counts. Returns counts
147
+ * of added/removed lines and estimated token impact.
148
+ * @param {string} old_text
149
+ * @param {string} new_text
150
+ * @returns {DiffResult}
151
+ */
152
+ function compute_diff(old_text, new_text) {
153
+ const ptr0 = passStringToWasm0(old_text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
154
+ const len0 = WASM_VECTOR_LEN;
155
+ const ptr1 = passStringToWasm0(new_text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
156
+ const len1 = WASM_VECTOR_LEN;
157
+ const ret = wasm.compute_diff(ptr0, len0, ptr1, len1);
158
+ return DiffResult.__wrap(ret);
159
+ }
160
+ exports.compute_diff = compute_diff;
161
+
162
+ /**
163
+ * Compute the HMAC-SHA256 signature for org-scoped signed URL parameters.
164
+ * Includes `org_id` in the HMAC payload for organization-level access control.
165
+ * Returns the first 32 hex characters (128 bits) by default.
166
+ * @param {string} slug
167
+ * @param {string} agent_id
168
+ * @param {string} conversation_id
169
+ * @param {string} org_id
170
+ * @param {number} expires_at
171
+ * @param {string} secret
172
+ * @returns {string}
173
+ */
174
+ function compute_org_signature(slug, agent_id, conversation_id, org_id, expires_at, secret) {
175
+ let deferred6_0;
176
+ let deferred6_1;
177
+ try {
178
+ const ptr0 = passStringToWasm0(slug, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
179
+ const len0 = WASM_VECTOR_LEN;
180
+ const ptr1 = passStringToWasm0(agent_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
181
+ const len1 = WASM_VECTOR_LEN;
182
+ const ptr2 = passStringToWasm0(conversation_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
183
+ const len2 = WASM_VECTOR_LEN;
184
+ const ptr3 = passStringToWasm0(org_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
185
+ const len3 = WASM_VECTOR_LEN;
186
+ const ptr4 = passStringToWasm0(secret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
187
+ const len4 = WASM_VECTOR_LEN;
188
+ const ret = wasm.compute_org_signature(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, expires_at, ptr4, len4);
189
+ deferred6_0 = ret[0];
190
+ deferred6_1 = ret[1];
191
+ return getStringFromWasm0(ret[0], ret[1]);
192
+ } finally {
193
+ wasm.__wbindgen_free(deferred6_0, deferred6_1, 1);
194
+ }
195
+ }
196
+ exports.compute_org_signature = compute_org_signature;
197
+
198
+ /**
199
+ * Compute org-scoped HMAC-SHA256 signature with configurable output length.
200
+ * @param {string} slug
201
+ * @param {string} agent_id
202
+ * @param {string} conversation_id
203
+ * @param {string} org_id
204
+ * @param {number} expires_at
205
+ * @param {string} secret
206
+ * @param {number} sig_length
207
+ * @returns {string}
208
+ */
209
+ function compute_org_signature_with_length(slug, agent_id, conversation_id, org_id, expires_at, secret, sig_length) {
210
+ let deferred6_0;
211
+ let deferred6_1;
212
+ try {
213
+ const ptr0 = passStringToWasm0(slug, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
214
+ const len0 = WASM_VECTOR_LEN;
215
+ const ptr1 = passStringToWasm0(agent_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
216
+ const len1 = WASM_VECTOR_LEN;
217
+ const ptr2 = passStringToWasm0(conversation_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
218
+ const len2 = WASM_VECTOR_LEN;
219
+ const ptr3 = passStringToWasm0(org_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
220
+ const len3 = WASM_VECTOR_LEN;
221
+ const ptr4 = passStringToWasm0(secret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
222
+ const len4 = WASM_VECTOR_LEN;
223
+ const ret = wasm.compute_org_signature_with_length(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, expires_at, ptr4, len4, sig_length);
224
+ deferred6_0 = ret[0];
225
+ deferred6_1 = ret[1];
226
+ return getStringFromWasm0(ret[0], ret[1]);
227
+ } finally {
228
+ wasm.__wbindgen_free(deferred6_0, deferred6_1, 1);
229
+ }
230
+ }
231
+ exports.compute_org_signature_with_length = compute_org_signature_with_length;
232
+
233
+ /**
234
+ * Compute the HMAC-SHA256 signature for signed URL parameters.
235
+ * Returns the first 16 hex characters of the digest (64 bits).
236
+ * For longer signatures, use [`compute_signature_with_length`].
237
+ * @param {string} slug
238
+ * @param {string} agent_id
239
+ * @param {string} conversation_id
240
+ * @param {number} expires_at
241
+ * @param {string} secret
242
+ * @returns {string}
243
+ */
244
+ function compute_signature(slug, agent_id, conversation_id, expires_at, secret) {
245
+ let deferred5_0;
246
+ let deferred5_1;
247
+ try {
248
+ const ptr0 = passStringToWasm0(slug, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
249
+ const len0 = WASM_VECTOR_LEN;
250
+ const ptr1 = passStringToWasm0(agent_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
251
+ const len1 = WASM_VECTOR_LEN;
252
+ const ptr2 = passStringToWasm0(conversation_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
253
+ const len2 = WASM_VECTOR_LEN;
254
+ const ptr3 = passStringToWasm0(secret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
255
+ const len3 = WASM_VECTOR_LEN;
256
+ const ret = wasm.compute_signature(ptr0, len0, ptr1, len1, ptr2, len2, expires_at, ptr3, len3);
257
+ deferred5_0 = ret[0];
258
+ deferred5_1 = ret[1];
259
+ return getStringFromWasm0(ret[0], ret[1]);
260
+ } finally {
261
+ wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
262
+ }
263
+ }
264
+ exports.compute_signature = compute_signature;
265
+
266
+ /**
267
+ * Compute the HMAC-SHA256 signature with configurable output length.
268
+ *
269
+ * `sig_length` controls how many hex characters to return (max 64).
270
+ * Use 16 for short-lived URLs (backward compat), 32 for long-lived URLs (128 bits).
271
+ * @param {string} slug
272
+ * @param {string} agent_id
273
+ * @param {string} conversation_id
274
+ * @param {number} expires_at
275
+ * @param {string} secret
276
+ * @param {number} sig_length
277
+ * @returns {string}
278
+ */
279
+ function compute_signature_with_length(slug, agent_id, conversation_id, expires_at, secret, sig_length) {
280
+ let deferred5_0;
281
+ let deferred5_1;
282
+ try {
283
+ const ptr0 = passStringToWasm0(slug, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
284
+ const len0 = WASM_VECTOR_LEN;
285
+ const ptr1 = passStringToWasm0(agent_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
286
+ const len1 = WASM_VECTOR_LEN;
287
+ const ptr2 = passStringToWasm0(conversation_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
288
+ const len2 = WASM_VECTOR_LEN;
289
+ const ptr3 = passStringToWasm0(secret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
290
+ const len3 = WASM_VECTOR_LEN;
291
+ const ret = wasm.compute_signature_with_length(ptr0, len0, ptr1, len1, ptr2, len2, expires_at, ptr3, len3, sig_length);
292
+ deferred5_0 = ret[0];
293
+ deferred5_1 = ret[1];
294
+ return getStringFromWasm0(ret[0], ret[1]);
295
+ } finally {
296
+ wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
297
+ }
298
+ }
299
+ exports.compute_signature_with_length = compute_signature_with_length;
300
+
301
+ /**
302
+ * Create a unified diff patch representing the difference between `original`
303
+ * and `modified`.
304
+ * @param {string} original
305
+ * @param {string} modified
306
+ * @returns {string}
307
+ */
308
+ function create_patch(original, modified) {
309
+ let deferred3_0;
310
+ let deferred3_1;
311
+ try {
312
+ const ptr0 = passStringToWasm0(original, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
313
+ const len0 = WASM_VECTOR_LEN;
314
+ const ptr1 = passStringToWasm0(modified, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
315
+ const len1 = WASM_VECTOR_LEN;
316
+ const ret = wasm.create_patch(ptr0, len0, ptr1, len1);
317
+ deferred3_0 = ret[0];
318
+ deferred3_1 = ret[1];
319
+ return getStringFromWasm0(ret[0], ret[1]);
320
+ } finally {
321
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
322
+ }
323
+ }
324
+ exports.create_patch = create_patch;
325
+
326
+ /**
327
+ * Decode a base62-encoded string back into an integer.
328
+ * @param {string} s
329
+ * @returns {bigint}
330
+ */
331
+ function decode_base62(s) {
332
+ const ptr0 = passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
333
+ const len0 = WASM_VECTOR_LEN;
334
+ const ret = wasm.decode_base62(ptr0, len0);
335
+ return BigInt.asUintN(64, ret);
336
+ }
337
+ exports.decode_base62 = decode_base62;
338
+
339
+ /**
340
+ * Decompress zlib-wrapped deflate bytes back to a UTF-8 string.
341
+ *
342
+ * Matches Node.js `zlib.inflate` for backward compatibility.
343
+ *
344
+ * # Errors
345
+ * Returns an error string if decompression or UTF-8 conversion fails.
346
+ * @param {Uint8Array} data
347
+ * @returns {string}
348
+ */
349
+ function decompress(data) {
350
+ let deferred3_0;
351
+ let deferred3_1;
352
+ try {
353
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
354
+ const len0 = WASM_VECTOR_LEN;
355
+ const ret = wasm.decompress(ptr0, len0);
356
+ var ptr2 = ret[0];
357
+ var len2 = ret[1];
358
+ if (ret[3]) {
359
+ ptr2 = 0; len2 = 0;
360
+ throw takeFromExternrefTable0(ret[2]);
361
+ }
362
+ deferred3_0 = ptr2;
363
+ deferred3_1 = len2;
364
+ return getStringFromWasm0(ptr2, len2);
365
+ } finally {
366
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
367
+ }
368
+ }
369
+ exports.decompress = decompress;
370
+
371
+ /**
372
+ * Derive a per-agent signing key from their API key.
373
+ * Uses `HMAC-SHA256(api_key, "llmtxt-signing")`.
374
+ * @param {string} api_key
375
+ * @returns {string}
376
+ */
377
+ function derive_signing_key(api_key) {
378
+ let deferred2_0;
379
+ let deferred2_1;
380
+ try {
381
+ const ptr0 = passStringToWasm0(api_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
382
+ const len0 = WASM_VECTOR_LEN;
383
+ const ret = wasm.derive_signing_key(ptr0, len0);
384
+ deferred2_0 = ret[0];
385
+ deferred2_1 = ret[1];
386
+ return getStringFromWasm0(ret[0], ret[1]);
387
+ } finally {
388
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
389
+ }
390
+ }
391
+ exports.derive_signing_key = derive_signing_key;
392
+
393
+ /**
394
+ * Encode a non-negative integer into a base62 string.
395
+ *
396
+ * Uses the alphabet `0-9A-Za-z`. Zero encodes to `"0"`.
397
+ * @param {bigint} num
398
+ * @returns {string}
399
+ */
400
+ function encode_base62(num) {
401
+ let deferred1_0;
402
+ let deferred1_1;
403
+ try {
404
+ const ret = wasm.encode_base62(num);
405
+ deferred1_0 = ret[0];
406
+ deferred1_1 = ret[1];
407
+ return getStringFromWasm0(ret[0], ret[1]);
408
+ } finally {
409
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
410
+ }
411
+ }
412
+ exports.encode_base62 = encode_base62;
413
+
414
+ /**
415
+ * Generate an 8-character base62 ID from a UUID v4.
416
+ * @returns {string}
417
+ */
418
+ function generate_id() {
419
+ let deferred1_0;
420
+ let deferred1_1;
421
+ try {
422
+ const ret = wasm.generate_id();
423
+ deferred1_0 = ret[0];
424
+ deferred1_1 = ret[1];
425
+ return getStringFromWasm0(ret[0], ret[1]);
426
+ } finally {
427
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
428
+ }
429
+ }
430
+ exports.generate_id = generate_id;
431
+
432
+ /**
433
+ * Compute the SHA-256 hash of a UTF-8 string, returned as lowercase hex.
434
+ * @param {string} data
435
+ * @returns {string}
436
+ */
437
+ function hash_content(data) {
438
+ let deferred2_0;
439
+ let deferred2_1;
440
+ try {
441
+ const ptr0 = passStringToWasm0(data, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
442
+ const len0 = WASM_VECTOR_LEN;
443
+ const ret = wasm.hash_content(ptr0, len0);
444
+ deferred2_0 = ret[0];
445
+ deferred2_1 = ret[1];
446
+ return getStringFromWasm0(ret[0], ret[1]);
447
+ } finally {
448
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
449
+ }
450
+ }
451
+ exports.hash_content = hash_content;
452
+
453
+ /**
454
+ * Check whether a timestamp (milliseconds) has expired.
455
+ * Returns false for 0 (no expiration).
456
+ *
457
+ * Uses `js_sys::Date::now()` in WASM, `std::time::SystemTime` natively.
458
+ * @param {number} expires_at_ms
459
+ * @returns {boolean}
460
+ */
461
+ function is_expired(expires_at_ms) {
462
+ const ret = wasm.is_expired(expires_at_ms);
463
+ return ret !== 0;
464
+ }
465
+ exports.is_expired = is_expired;
466
+
467
+ /**
468
+ * Apply a sequence of patches to base content, returning the content at the
469
+ * target version. This avoids N WASM boundary crossings by performing all
470
+ * patch applications in a single Rust call.
471
+ *
472
+ * `patches_json` is a JSON array of patch strings: `["patch1", "patch2", ...]`.
473
+ * `target` is the 1-based version to reconstruct (0 returns `base` unchanged).
474
+ * If `target` exceeds the number of patches, all patches are applied.
475
+ * @param {string} base
476
+ * @param {string} patches_json
477
+ * @param {number} target
478
+ * @returns {string}
479
+ */
480
+ function reconstruct_version(base, patches_json, target) {
481
+ let deferred4_0;
482
+ let deferred4_1;
483
+ try {
484
+ const ptr0 = passStringToWasm0(base, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
485
+ const len0 = WASM_VECTOR_LEN;
486
+ const ptr1 = passStringToWasm0(patches_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
487
+ const len1 = WASM_VECTOR_LEN;
488
+ const ret = wasm.reconstruct_version(ptr0, len0, ptr1, len1, target);
489
+ var ptr3 = ret[0];
490
+ var len3 = ret[1];
491
+ if (ret[3]) {
492
+ ptr3 = 0; len3 = 0;
493
+ throw takeFromExternrefTable0(ret[2]);
494
+ }
495
+ deferred4_0 = ptr3;
496
+ deferred4_1 = len3;
497
+ return getStringFromWasm0(ptr3, len3);
498
+ } finally {
499
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
500
+ }
501
+ }
502
+ exports.reconstruct_version = reconstruct_version;
503
+
504
+ /**
505
+ * Apply all patches sequentially to base content, then produce a single
506
+ * unified diff from the original base to the final state.
507
+ *
508
+ * `patches_json` is a JSON array of patch strings: `["patch1", "patch2", ...]`.
509
+ * @param {string} base
510
+ * @param {string} patches_json
511
+ * @returns {string}
512
+ */
513
+ function squash_patches(base, patches_json) {
514
+ let deferred4_0;
515
+ let deferred4_1;
516
+ try {
517
+ const ptr0 = passStringToWasm0(base, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
518
+ const len0 = WASM_VECTOR_LEN;
519
+ const ptr1 = passStringToWasm0(patches_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
520
+ const len1 = WASM_VECTOR_LEN;
521
+ const ret = wasm.squash_patches(ptr0, len0, ptr1, len1);
522
+ var ptr3 = ret[0];
523
+ var len3 = ret[1];
524
+ if (ret[3]) {
525
+ ptr3 = 0; len3 = 0;
526
+ throw takeFromExternrefTable0(ret[2]);
527
+ }
528
+ deferred4_0 = ptr3;
529
+ deferred4_1 = len3;
530
+ return getStringFromWasm0(ptr3, len3);
531
+ } finally {
532
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
533
+ }
534
+ }
535
+ exports.squash_patches = squash_patches;
536
+
537
+ /**
538
+ * Compute character-level n-gram Jaccard similarity between two texts.
539
+ * Returns 0.0 (no overlap) to 1.0 (identical). Default n=3.
540
+ *
541
+ * Suitable for finding similar messages without vector embeddings.
542
+ * @param {string} a
543
+ * @param {string} b
544
+ * @returns {number}
545
+ */
546
+ function text_similarity(a, b) {
547
+ const ptr0 = passStringToWasm0(a, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
548
+ const len0 = WASM_VECTOR_LEN;
549
+ const ptr1 = passStringToWasm0(b, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
550
+ const len1 = WASM_VECTOR_LEN;
551
+ const ret = wasm.text_similarity(ptr0, len0, ptr1, len1);
552
+ return ret;
553
+ }
554
+ exports.text_similarity = text_similarity;
555
+
556
+ /**
557
+ * Compute n-gram Jaccard similarity with configurable gram size.
558
+ * @param {string} a
559
+ * @param {string} b
560
+ * @param {number} n
561
+ * @returns {number}
562
+ */
563
+ function text_similarity_ngram(a, b, n) {
564
+ const ptr0 = passStringToWasm0(a, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
565
+ const len0 = WASM_VECTOR_LEN;
566
+ const ptr1 = passStringToWasm0(b, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
567
+ const len1 = WASM_VECTOR_LEN;
568
+ const ret = wasm.text_similarity_ngram(ptr0, len0, ptr1, len1, n);
569
+ return ret;
570
+ }
571
+ exports.text_similarity_ngram = text_similarity_ngram;
572
+
573
+ function __wbg_get_imports() {
574
+ const import0 = {
575
+ __proto__: null,
576
+ __wbg___wbindgen_throw_6ddd609b62940d55: function(arg0, arg1) {
577
+ throw new Error(getStringFromWasm0(arg0, arg1));
578
+ },
579
+ __wbg_getRandomValues_a1cf2e70b003a59d: function() { return handleError(function (arg0, arg1) {
580
+ globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
581
+ }, arguments); },
582
+ __wbg_now_16f0c993d5dd6c27: function() {
583
+ const ret = Date.now();
584
+ return ret;
585
+ },
586
+ __wbindgen_cast_0000000000000001: function(arg0, arg1) {
587
+ // Cast intrinsic for `Ref(String) -> Externref`.
588
+ const ret = getStringFromWasm0(arg0, arg1);
589
+ return ret;
590
+ },
591
+ __wbindgen_init_externref_table: function() {
592
+ const table = wasm.__wbindgen_externrefs;
593
+ const offset = table.grow(4);
594
+ table.set(0, undefined);
595
+ table.set(offset + 0, undefined);
596
+ table.set(offset + 1, null);
597
+ table.set(offset + 2, true);
598
+ table.set(offset + 3, false);
599
+ },
600
+ };
601
+ return {
602
+ __proto__: null,
603
+ "./llmtxt_core_bg.js": import0,
604
+ };
605
+ }
606
+
607
+ const DiffResultFinalization = (typeof FinalizationRegistry === 'undefined')
608
+ ? { register: () => {}, unregister: () => {} }
609
+ : new FinalizationRegistry(ptr => wasm.__wbg_diffresult_free(ptr >>> 0, 1));
610
+
611
+ function addToExternrefTable0(obj) {
612
+ const idx = wasm.__externref_table_alloc();
613
+ wasm.__wbindgen_externrefs.set(idx, obj);
614
+ return idx;
615
+ }
616
+
617
+ function getArrayU8FromWasm0(ptr, len) {
618
+ ptr = ptr >>> 0;
619
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
620
+ }
621
+
622
+ function getStringFromWasm0(ptr, len) {
623
+ ptr = ptr >>> 0;
624
+ return decodeText(ptr, len);
625
+ }
626
+
627
+ let cachedUint8ArrayMemory0 = null;
628
+ function getUint8ArrayMemory0() {
629
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
630
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
631
+ }
632
+ return cachedUint8ArrayMemory0;
633
+ }
634
+
635
+ function handleError(f, args) {
636
+ try {
637
+ return f.apply(this, args);
638
+ } catch (e) {
639
+ const idx = addToExternrefTable0(e);
640
+ wasm.__wbindgen_exn_store(idx);
641
+ }
642
+ }
643
+
644
+ function passArray8ToWasm0(arg, malloc) {
645
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
646
+ getUint8ArrayMemory0().set(arg, ptr / 1);
647
+ WASM_VECTOR_LEN = arg.length;
648
+ return ptr;
649
+ }
650
+
651
+ function passStringToWasm0(arg, malloc, realloc) {
652
+ if (realloc === undefined) {
653
+ const buf = cachedTextEncoder.encode(arg);
654
+ const ptr = malloc(buf.length, 1) >>> 0;
655
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
656
+ WASM_VECTOR_LEN = buf.length;
657
+ return ptr;
658
+ }
659
+
660
+ let len = arg.length;
661
+ let ptr = malloc(len, 1) >>> 0;
662
+
663
+ const mem = getUint8ArrayMemory0();
664
+
665
+ let offset = 0;
666
+
667
+ for (; offset < len; offset++) {
668
+ const code = arg.charCodeAt(offset);
669
+ if (code > 0x7F) break;
670
+ mem[ptr + offset] = code;
671
+ }
672
+ if (offset !== len) {
673
+ if (offset !== 0) {
674
+ arg = arg.slice(offset);
675
+ }
676
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
677
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
678
+ const ret = cachedTextEncoder.encodeInto(arg, view);
679
+
680
+ offset += ret.written;
681
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
682
+ }
683
+
684
+ WASM_VECTOR_LEN = offset;
685
+ return ptr;
686
+ }
687
+
688
+ function takeFromExternrefTable0(idx) {
689
+ const value = wasm.__wbindgen_externrefs.get(idx);
690
+ wasm.__externref_table_dealloc(idx);
691
+ return value;
692
+ }
693
+
694
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
695
+ cachedTextDecoder.decode();
696
+ function decodeText(ptr, len) {
697
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
698
+ }
699
+
700
+ const cachedTextEncoder = new TextEncoder();
701
+
702
+ if (!('encodeInto' in cachedTextEncoder)) {
703
+ cachedTextEncoder.encodeInto = function (arg, view) {
704
+ const buf = cachedTextEncoder.encode(arg);
705
+ view.set(buf);
706
+ return {
707
+ read: arg.length,
708
+ written: buf.length
709
+ };
710
+ };
711
+ }
712
+
713
+ let WASM_VECTOR_LEN = 0;
714
+
715
+ const wasmPath = `${__dirname}/llmtxt_core_bg.wasm`;
716
+ const wasmBytes = require('fs').readFileSync(wasmPath);
717
+ const wasmModule = new WebAssembly.Module(wasmBytes);
718
+ let wasm = new WebAssembly.Instance(wasmModule, __wbg_get_imports()).exports;
719
+ wasm.__wbindgen_start();