@codemem/core 0.47.3 → 0.47.4

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.
@@ -8,7 +8,7 @@ if (import.meta.url.endsWith(".ts")) {
8
8
  return t.parentURL?.startsWith(i) && e.startsWith(".") && e.endsWith(".js") ? n(`${e.slice(0, -3)}.ts`, t) : n(e, t);
9
9
  } });
10
10
  }
11
- await import("./semantic-worker-job-2fm4JmaO.js");
11
+ await import("./semantic-worker-job-D1qI9vRV.js");
12
12
  //#endregion
13
13
 
14
14
  //# sourceMappingURL=semantic-worker-entry.js.map
@@ -1,4 +1,4 @@
1
- import { Vn as e, n as t } from "./semantic-worker-ranking-D9bhmrS_.js";
1
+ import { Vn as e, n as t } from "./semantic-worker-ranking-DEOx8Xbb.js";
2
2
  import { statSync as n } from "node:fs";
3
3
  import { load as r } from "sqlite-vec";
4
4
  import { parentPort as i, workerData as a } from "node:worker_threads";
@@ -46,4 +46,4 @@ o.on("message", (e) => {
46
46
  }), o.postMessage({ type: "ready" });
47
47
  //#endregion
48
48
 
49
- //# sourceMappingURL=semantic-worker-job-2fm4JmaO.js.map
49
+ //# sourceMappingURL=semantic-worker-job-D1qI9vRV.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"semantic-worker-job-2fm4JmaO.js","names":[],"sources":["../src/semantic/semantic-worker-job.ts"],"sourcesContent":["import { statSync } from \"node:fs\";\nimport { parentPort, workerData } from \"node:worker_threads\";\nimport { load } from \"sqlite-vec\";\nimport { connectReadOnly } from \"../db.js\";\nimport type { RankInput, WorkerRequest } from \"./semantic-worker-protocol.js\";\nimport { rankWorkerInput } from \"./semantic-worker-ranking.js\";\n\nif (!parentPort) throw new Error(\"semantic_worker_parent_required\");\nconst port = parentPort;\nconst { dbPath, fileIdentity } = workerData as { dbPath: string; fileIdentity: string };\nconst stat = statSync(dbPath);\nif (`${stat.dev}:${stat.ino}` !== fileIdentity) throw new Error(\"semantic_worker_file_changed\");\nconst db = connectReadOnly(dbPath);\ntry {\n\tload(db);\n\tdb.pragma(\"query_only = ON\");\n\tdb.prepare(\"SELECT vec_version()\").get();\n} catch (error) {\n\tdb.close();\n\tthrow error;\n}\n\nfunction validateInput(input: RankInput): void {\n\tif (\n\t\ttypeof input.generationId !== \"string\" ||\n\t\t!input.generationId.trim() ||\n\t\tinput.generationId.length > 256 ||\n\t\t!(input.embedding instanceof Float32Array) ||\n\t\tinput.embedding.length !== 384 ||\n\t\t!input.embedding.every(Number.isFinite) ||\n\t\t!input.proof.actorId.trim() ||\n\t\t!input.proof.deviceId.trim() ||\n\t\t!input.embeddingIdentity ||\n\t\tinput.embeddingIdentity.length > 2048 ||\n\t\t!Number.isFinite(input.limit) ||\n\t\tJSON.stringify(input.filters).length > 32_768\n\t)\n\t\tthrow new Error(\"invalid_semantic_worker_input\");\n}\n\nport.on(\"message\", (request: WorkerRequest) => {\n\tif (request?.type === \"close\") {\n\t\tdb.close();\n\t\tport.close();\n\t\treturn;\n\t}\n\tif (\n\t\trequest?.type !== \"rank\" ||\n\t\t!Number.isSafeInteger(request.id) ||\n\t\t!Number.isFinite(request.deadlineAt)\n\t) {\n\t\tthrow new Error(\"invalid_semantic_worker_message\");\n\t}\n\ttry {\n\t\tvalidateInput(request.input);\n\t\tif (Date.now() >= request.deadlineAt) {\n\t\t\tport.postMessage({ type: \"error\", id: request.id, code: \"expired\" });\n\t\t\treturn;\n\t\t}\n\t\tconst output = rankWorkerInput(db, request.input);\n\t\tport.postMessage({ type: \"result\", id: request.id, output });\n\t} catch {\n\t\tport.postMessage({ type: \"error\", id: request.id, code: \"ranking_failed\" });\n\t}\n});\nport.postMessage({ type: \"ready\" });\n"],"mappings":";;;;;AAOA,IAAI,CAAC,GAAY,MAAU,MAAM,iCAAiC;AAClE,IAAM,IAAO,GACP,EAAE,WAAQ,oBAAiB,GAC3B,IAAO,EAAS,CAAM;AAC5B,IAAI,GAAG,EAAK,IAAI,GAAG,EAAK,UAAU,GAAc,MAAU,M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AI,MAAM;EAAiB,CAAC;CAC3E;AACD,CAAC,GACD,EAAK,YAAY,EAAE,MAAM,QAAQ,CAAC"}
1
+ {"version":3,"file":"semantic-worker-job-D1qI9vRV.js","names":[],"sources":["../src/semantic/semantic-worker-job.ts"],"sourcesContent":["import { statSync } from \"node:fs\";\nimport { parentPort, workerData } from \"node:worker_threads\";\nimport { load } from \"sqlite-vec\";\nimport { connectReadOnly } from \"../db.js\";\nimport type { RankInput, WorkerRequest } from \"./semantic-worker-protocol.js\";\nimport { rankWorkerInput } from \"./semantic-worker-ranking.js\";\n\nif (!parentPort) throw new Error(\"semantic_worker_parent_required\");\nconst port = parentPort;\nconst { dbPath, fileIdentity } = workerData as { dbPath: string; fileIdentity: string };\nconst stat = statSync(dbPath);\nif (`${stat.dev}:${stat.ino}` !== fileIdentity) throw new Error(\"semantic_worker_file_changed\");\nconst db = connectReadOnly(dbPath);\ntry {\n\tload(db);\n\tdb.pragma(\"query_only = ON\");\n\tdb.prepare(\"SELECT vec_version()\").get();\n} catch (error) {\n\tdb.close();\n\tthrow error;\n}\n\nfunction validateInput(input: RankInput): void {\n\tif (\n\t\ttypeof input.generationId !== \"string\" ||\n\t\t!input.generationId.trim() ||\n\t\tinput.generationId.length > 256 ||\n\t\t!(input.embedding instanceof Float32Array) ||\n\t\tinput.embedding.length !== 384 ||\n\t\t!input.embedding.every(Number.isFinite) ||\n\t\t!input.proof.actorId.trim() ||\n\t\t!input.proof.deviceId.trim() ||\n\t\t!input.embeddingIdentity ||\n\t\tinput.embeddingIdentity.length > 2048 ||\n\t\t!Number.isFinite(input.limit) ||\n\t\tJSON.stringify(input.filters).length > 32_768\n\t)\n\t\tthrow new Error(\"invalid_semantic_worker_input\");\n}\n\nport.on(\"message\", (request: WorkerRequest) => {\n\tif (request?.type === \"close\") {\n\t\tdb.close();\n\t\tport.close();\n\t\treturn;\n\t}\n\tif (\n\t\trequest?.type !== \"rank\" ||\n\t\t!Number.isSafeInteger(request.id) ||\n\t\t!Number.isFinite(request.deadlineAt)\n\t) {\n\t\tthrow new Error(\"invalid_semantic_worker_message\");\n\t}\n\ttry {\n\t\tvalidateInput(request.input);\n\t\tif (Date.now() >= request.deadlineAt) {\n\t\t\tport.postMessage({ type: \"error\", id: request.id, code: \"expired\" });\n\t\t\treturn;\n\t\t}\n\t\tconst output = rankWorkerInput(db, request.input);\n\t\tport.postMessage({ type: \"result\", id: request.id, output });\n\t} catch {\n\t\tport.postMessage({ type: \"error\", id: request.id, code: \"ranking_failed\" });\n\t}\n});\nport.postMessage({ type: \"ready\" });\n"],"mappings":";;;;;AAOA,IAAI,CAAC,GAAY,MAAU,MAAM,iCAAiC;AAClE,IAAM,IAAO,GACP,EAAE,WAAQ,oBAAiB,GAC3B,IAAO,EAAS,CAAM;AAC5B,IAAI,GAAG,EAAK,IAAI,GAAG,EAAK,UAAU,GAAc,MAAU,MAAM,8BAA8B;AAC9F,IAAM,IAAK,EAAgB,CAAM;AACjC,IAAI;CAGH,AAFA,EAAK,CAAE,GACP,EAAG,OAAO,iBAAiB,GAC3B,EAAG,QAAQ,sBAAsB,CAAC,CAAC,IAAI;AACxC,SAAS,GAAO;CAEf,MADA,EAAG,MAAM,GACH;AACP;AAEA,SAAS,EAAc,GAAwB;CAC9C,IACC,OAAO,EAAM,gBAAiB,YAC9B,CAAC,EAAM,aAAa,KAAK,KACzB,EAAM,aAAa,SAAS,OAC5B,EAAE,EAAM,qBAAqB,iBAC7B,EAAM,UAAU,WAAW,OAC3B,CAAC,EAAM,UAAU,MAAM,OAAO,QAAQ,KACtC,CAAC,EAAM,MAAM,QAAQ,KAAK,KAC1B,CAAC,EAAM,MAAM,SAAS,KAAK,KAC3B,CAAC,EAAM,qBACP,EAAM,kBAAkB,SAAS,QACjC,CAAC,OAAO,SAAS,EAAM,KAAK,KAC5B,KAAK,UAAU,EAAM,OAAO,CAAC,CAAC,SAAS,OAEvC,MAAU,MAAM,+BAA+B;AACjD;AAEA,EAAK,GAAG,YAAY,MAA2B;CAC9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