@sid-ai/sid-sdk 0.1.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.
@@ -0,0 +1,174 @@
1
+
2
+ let imports = {};
3
+ imports['__wbindgen_placeholder__'] = module.exports;
4
+ let wasm;
5
+ const { TextDecoder, TextEncoder } = require(`util`);
6
+
7
+ let cachedUint8ArrayMemory0 = null;
8
+
9
+ function getUint8ArrayMemory0() {
10
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
11
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
12
+ }
13
+ return cachedUint8ArrayMemory0;
14
+ }
15
+
16
+ function getArrayU8FromWasm0(ptr, len) {
17
+ ptr = ptr >>> 0;
18
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
19
+ }
20
+
21
+ function addToExternrefTable0(obj) {
22
+ const idx = wasm.__externref_table_alloc();
23
+ wasm.__wbindgen_export_2.set(idx, obj);
24
+ return idx;
25
+ }
26
+
27
+ function handleError(f, args) {
28
+ try {
29
+ return f.apply(this, args);
30
+ } catch (e) {
31
+ const idx = addToExternrefTable0(e);
32
+ wasm.__wbindgen_exn_store(idx);
33
+ }
34
+ }
35
+
36
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
37
+
38
+ cachedTextDecoder.decode();
39
+
40
+ function getStringFromWasm0(ptr, len) {
41
+ ptr = ptr >>> 0;
42
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
43
+ }
44
+
45
+ let WASM_VECTOR_LEN = 0;
46
+
47
+ let cachedTextEncoder = new TextEncoder('utf-8');
48
+
49
+ const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
50
+ ? function (arg, view) {
51
+ return cachedTextEncoder.encodeInto(arg, view);
52
+ }
53
+ : function (arg, view) {
54
+ const buf = cachedTextEncoder.encode(arg);
55
+ view.set(buf);
56
+ return {
57
+ read: arg.length,
58
+ written: buf.length
59
+ };
60
+ });
61
+
62
+ function passStringToWasm0(arg, malloc, realloc) {
63
+
64
+ if (realloc === undefined) {
65
+ const buf = cachedTextEncoder.encode(arg);
66
+ const ptr = malloc(buf.length, 1) >>> 0;
67
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
68
+ WASM_VECTOR_LEN = buf.length;
69
+ return ptr;
70
+ }
71
+
72
+ let len = arg.length;
73
+ let ptr = malloc(len, 1) >>> 0;
74
+
75
+ const mem = getUint8ArrayMemory0();
76
+
77
+ let offset = 0;
78
+
79
+ for (; offset < len; offset++) {
80
+ const code = arg.charCodeAt(offset);
81
+ if (code > 0x7F) break;
82
+ mem[ptr + offset] = code;
83
+ }
84
+
85
+ if (offset !== len) {
86
+ if (offset !== 0) {
87
+ arg = arg.slice(offset);
88
+ }
89
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
90
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
91
+ const ret = encodeString(arg, view);
92
+
93
+ offset += ret.written;
94
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
95
+ }
96
+
97
+ WASM_VECTOR_LEN = offset;
98
+ return ptr;
99
+ }
100
+
101
+ function takeFromExternrefTable0(idx) {
102
+ const value = wasm.__wbindgen_export_2.get(idx);
103
+ wasm.__externref_table_dealloc(idx);
104
+ return value;
105
+ }
106
+
107
+ let cachedUint32ArrayMemory0 = null;
108
+
109
+ function getUint32ArrayMemory0() {
110
+ if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
111
+ cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
112
+ }
113
+ return cachedUint32ArrayMemory0;
114
+ }
115
+
116
+ function getArrayU32FromWasm0(ptr, len) {
117
+ ptr = ptr >>> 0;
118
+ return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
119
+ }
120
+ /**
121
+ * Select a source-token window and return Unicode code-point offsets.
122
+ * @param {string} query
123
+ * @param {string} content
124
+ * @param {number} window_size
125
+ * @param {number} stride
126
+ * @param {string} language
127
+ * @returns {Uint32Array}
128
+ */
129
+ module.exports.bm25SnippetWithStride = function(query, content, window_size, stride, language) {
130
+ const ptr0 = passStringToWasm0(query, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
131
+ const len0 = WASM_VECTOR_LEN;
132
+ const ptr1 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
133
+ const len1 = WASM_VECTOR_LEN;
134
+ const ptr2 = passStringToWasm0(language, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
135
+ const len2 = WASM_VECTOR_LEN;
136
+ const ret = wasm.bm25SnippetWithStride(ptr0, len0, ptr1, len1, window_size, stride, ptr2, len2);
137
+ if (ret[3]) {
138
+ throw takeFromExternrefTable0(ret[2]);
139
+ }
140
+ var v4 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
141
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
142
+ return v4;
143
+ };
144
+
145
+ module.exports.__wbg_getRandomValues_1c61fac11405ffdc = function() { return handleError(function (arg0, arg1) {
146
+ globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
147
+ }, arguments) };
148
+
149
+ module.exports.__wbindgen_init_externref_table = function() {
150
+ const table = wasm.__wbindgen_export_2;
151
+ const offset = table.grow(4);
152
+ table.set(0, undefined);
153
+ table.set(offset + 0, undefined);
154
+ table.set(offset + 1, null);
155
+ table.set(offset + 2, true);
156
+ table.set(offset + 3, false);
157
+ ;
158
+ };
159
+
160
+ module.exports.__wbindgen_string_new = function(arg0, arg1) {
161
+ const ret = getStringFromWasm0(arg0, arg1);
162
+ return ret;
163
+ };
164
+
165
+ const path = require('path').join(__dirname, 'sid_snippet_bg.wasm');
166
+ const bytes = require('fs').readFileSync(path);
167
+
168
+ const wasmModule = new WebAssembly.Module(bytes);
169
+ const wasmInstance = new WebAssembly.Instance(wasmModule, imports);
170
+ wasm = wasmInstance.exports;
171
+ module.exports.__wasm = wasm;
172
+
173
+ wasm.__wbindgen_start();
174
+
Binary file
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@sid-ai/sid-sdk",
3
+ "version": "0.1.0",
4
+ "description": "Stable document IDs, relevant snippets, and seen-text tracking for AI agents",
5
+ "type": "module",
6
+ "main": "./dist/cjs/index.js",
7
+ "module": "./dist/esm/index.js",
8
+ "types": "./dist/cjs/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/cjs/index.d.ts",
12
+ "import": "./dist/esm/index.js",
13
+ "require": "./dist/cjs/index.js"
14
+ },
15
+ "./package.json": "./package.json"
16
+ },
17
+ "files": [
18
+ "dist",
19
+ "README.md",
20
+ "LICENSE",
21
+ "THIRD_PARTY_NOTICES.md"
22
+ ],
23
+ "engines": {
24
+ "node": ">=22"
25
+ },
26
+ "license": "MIT",
27
+ "repository": {
28
+ "type": "git",
29
+ "url": "git+https://github.com/sidhq/sid-typescript.git"
30
+ },
31
+ "publishConfig": {
32
+ "access": "public",
33
+ "registry": "https://registry.npmjs.org/"
34
+ },
35
+ "scripts": {
36
+ "build": "node scripts/build.mjs",
37
+ "typecheck": "tsc --noEmit",
38
+ "test": "node --test tests/*.test.mjs",
39
+ "test:package": "node scripts/smoke-package.mjs",
40
+ "check:rust": "cargo fmt --check && cargo clippy --locked --all-targets -- -D warnings && cargo test --locked",
41
+ "check": "npm run typecheck && npm run check:rust && npm run build && npm test && npm run test:package"
42
+ },
43
+ "devDependencies": {
44
+ "@types/node": "^22.0.0",
45
+ "typescript": "~5.9.3"
46
+ },
47
+ "sidSourceCommit": "aa044ca3e285fe7afaeffb77410958c0dfef2afb"
48
+ }