@o-lang/semantic-doc-search 1.0.28 → 1.0.30

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@o-lang/semantic-doc-search",
3
- "version": "1.0.28",
3
+ "version": "1.0.30",
4
4
  "description": "O-lang Semantic Document Search Resolver with hybrid search, embeddings, rerank, and streaming.",
5
5
  "main": "src/index.js",
6
6
  "type": "commonjs",
@@ -1,101 +1,40 @@
1
- /**
2
- * Pinecone Vector Store Adapter
3
- *
4
- * Requirements:
5
- * npm install @pinecone-database/pinecone
6
- *
7
- * Env:
8
- * PINECONE_API_KEY
9
- * PINECONE_INDEX=olang-docs
10
- */
1
+ let Pinecone;
11
2
 
12
- const { Pinecone } = require("@pinecone-database/pinecone");
13
- const VectorAdapter = require("./VectorAdapter");
14
- const vectorCapabilities = require("./vectorCapabilities");
15
-
16
- class PineconeAdapter extends VectorAdapter {
3
+ class PineconeAdapter {
17
4
  constructor(config = {}) {
18
- super({
19
- ...config,
20
- backend: "pinecone",
21
- capabilities: vectorCapabilities.pinecone.capabilities,
22
- supportsHybrid: true,
23
- requiresIdempotentInsert: true
24
- });
25
-
26
- this.dimension = config.dimension || 1536;
27
- this.indexName = config.PINECONE_INDEX || process.env.PINECONE_INDEX || "olang-docs";
5
+ if (!Pinecone) {
6
+ try {
7
+ Pinecone = require("@pinecone-database/pinecone");
8
+ } catch (err) {
9
+ throw new Error(
10
+ "Pinecone adapter requires '@pinecone-database/pinecone'. Please install it via npm."
11
+ );
12
+ }
13
+ }
28
14
 
29
- const apiKey = config.PINECONE_API_KEY || process.env.PINECONE_API_KEY;
30
- if (!apiKey) throw new Error("Missing PINECONE_API_KEY");
15
+ this.apiKey = process.env.PINECONE_API_KEY;
16
+ if (!this.apiKey) throw new Error("Missing PINECONE_API_KEY");
31
17
 
32
- this.client = new Pinecone({ apiKey });
33
- this.index = this.client.index(this.indexName);
18
+ const indexName = process.env.PINECONE_INDEX || "olang-docs";
19
+ this.client = new Pinecone({ apiKey: this.apiKey });
20
+ this.indexName = indexName;
34
21
  }
35
22
 
36
- /* ---------------- INGEST ---------------- */
37
-
38
- async upsert({ id, vector, content, source, metadata = {} }) {
39
- this.ensureCapability("vector.insert");
40
- this.validateVector(vector);
41
-
42
- await this.index.upsert([
43
- {
44
- id: id.toString(),
45
- values: vector,
46
- metadata: {
47
- content,
48
- source,
49
- ...metadata
50
- }
51
- }
52
- ]);
23
+ static capabilities() {
24
+ return { persistent: true, offline: false, distance: "cosine", maxDimension: 1536, capabilities: ["vector.insert", "vector.search"] };
53
25
  }
54
26
 
55
- /* ---------------- SEARCH ---------------- */
56
-
57
- async query(vector, { topK = 5, minScore = 0 } = {}) {
58
- this.ensureCapability("vector.search");
59
- this.validateVector(vector);
60
-
61
- const res = await this.index.query({
62
- vector,
63
- topK,
64
- includeMetadata: true
65
- });
66
-
67
- return res.matches
68
- .filter(m => m.score >= minScore)
69
- .map(m => ({
70
- id: m.id,
71
- score: m.score,
72
- content: m.metadata?.content,
73
- source: m.metadata?.source,
74
- metadata: m.metadata
75
- }));
27
+ async init() {
28
+ // ... your init logic here
76
29
  }
77
30
 
78
- /* ---------------- HEALTH ---------------- */
79
-
80
- async health() {
81
- try {
82
- await this.client.listIndexes();
83
- return {
84
- backend: this.backend,
85
- status: "ok",
86
- offline: false,
87
- hybrid: true
88
- };
89
- } catch (err) {
90
- return {
91
- backend: this.backend,
92
- status: "error",
93
- error: err.message
94
- };
95
- }
31
+ async upsert(id, vector, metadata) {
32
+ // ...
96
33
  }
97
34
 
98
- async close() {}
35
+ async search(queryVector, limit = 5) {
36
+ // ...
37
+ }
99
38
  }
100
39
 
101
40
  module.exports = PineconeAdapter;
@@ -6,6 +6,7 @@
6
6
  * - No silent failures
7
7
  * - No zero vectors
8
8
  * - Deterministic behavior
9
+ * - DEFENSIVE against method detaching
9
10
  */
10
11
 
11
12
  class LocalEmbedding {
@@ -13,6 +14,12 @@ class LocalEmbedding {
13
14
  this.dim = 384;
14
15
  this.model = null;
15
16
  this.loading = null;
17
+
18
+ // 🔒 CRITICAL: bind methods to prevent resolver breakage
19
+ this.loadModel = this.loadModel.bind(this);
20
+ this.embed = this.embed.bind(this);
21
+ this.embedBatch = this.embedBatch.bind(this);
22
+ this.getDimension = this.getDimension.bind(this);
16
23
  }
17
24
 
18
25
  /* ---------------- INTERNAL ---------------- */