searchsocket 0.3.3 → 0.5.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.
package/dist/index.d.cts CHANGED
@@ -1,6 +1,7 @@
1
- import { R as ResolvedSearchSocketConfig, b as SearchSocketConfig, c as Scope, E as EmbeddingsProvider, d as Reranker, e as RerankCandidate, V as VectorStore, I as IndexOptions, f as IndexStats, S as SearchRequest, a as SearchResponse } from './types-BrG6XTUU.cjs';
2
- export { C as Chunk, Q as QueryOpts, g as VectorHit, h as VectorRecord } from './types-BrG6XTUU.cjs';
3
- export { searchsocketHandle, searchsocketVitePlugin } from './sveltekit.cjs';
1
+ import { R as ResolvedSearchSocketConfig, c as SearchSocketConfig, d as Scope, V as VectorHit, P as PageHit, e as ScopeInfo, f as PageRecord, I as IndexOptions, g as IndexStats, S as SearchRequest, a as SearchResponse } from './types-Dk43uz25.cjs';
2
+ export { C as Chunk } from './types-Dk43uz25.cjs';
3
+ import { Search } from '@upstash/search';
4
+ export { s as searchsocketHandle, b as searchsocketVitePlugin } from './plugin-B_npJSux.cjs';
4
5
  export { createSearchClient } from './client.cjs';
5
6
 
6
7
  interface LoadConfigOptions {
@@ -28,26 +29,71 @@ declare function isServerless(): boolean;
28
29
 
29
30
  declare function resolveScope(config: ResolvedSearchSocketConfig, override?: string): Scope;
30
31
 
31
- declare function createEmbeddingsProvider(config: ResolvedSearchSocketConfig): EmbeddingsProvider;
32
-
33
- interface JinaRerankerOptions {
34
- apiKey: string;
35
- model: string;
36
- maxRetries?: number;
32
+ /** Content fields stored in Upstash Search (indexed and searchable) */
33
+ interface ChunkContent {
34
+ title: string;
35
+ sectionTitle: string;
36
+ text: string;
37
+ url: string;
38
+ tags: string;
39
+ headingPath: string;
40
+ [key: string]: unknown;
41
+ }
42
+ /** Metadata fields stored in Upstash Search (returned but not searchable) */
43
+ interface ChunkMetadata {
44
+ projectId: string;
45
+ scopeName: string;
46
+ path: string;
47
+ snippet: string;
48
+ ordinal: number;
49
+ contentHash: string;
50
+ depth: number;
51
+ incomingLinks: number;
52
+ routeFile: string;
53
+ description: string;
54
+ keywords: string;
55
+ [key: string]: unknown;
37
56
  }
38
- declare class JinaReranker implements Reranker {
39
- private readonly apiKey;
40
- private readonly model;
41
- private readonly maxRetries;
42
- constructor(options: JinaRerankerOptions);
43
- rerank(query: string, candidates: RerankCandidate[], topN?: number): Promise<Array<{
57
+ interface UpstashSearchStoreOptions {
58
+ client: Search;
59
+ }
60
+ declare class UpstashSearchStore {
61
+ private readonly client;
62
+ constructor(opts: UpstashSearchStoreOptions);
63
+ private chunkIndex;
64
+ private pageIndex;
65
+ upsertChunks(chunks: Array<{
44
66
  id: string;
45
- score: number;
46
- }>>;
67
+ content: ChunkContent;
68
+ metadata: ChunkMetadata;
69
+ }>, scope: Scope): Promise<void>;
70
+ search(query: string, opts: {
71
+ limit: number;
72
+ semanticWeight?: number;
73
+ inputEnrichment?: boolean;
74
+ reranking?: boolean;
75
+ filter?: string;
76
+ }, scope: Scope): Promise<VectorHit[]>;
77
+ searchPages(query: string, opts: {
78
+ limit: number;
79
+ semanticWeight?: number;
80
+ inputEnrichment?: boolean;
81
+ filter?: string;
82
+ }, scope: Scope): Promise<PageHit[]>;
83
+ deleteByIds(ids: string[], scope: Scope): Promise<void>;
84
+ deleteScope(scope: Scope): Promise<void>;
85
+ listScopes(projectId: string): Promise<ScopeInfo[]>;
86
+ getContentHashes(scope: Scope): Promise<Map<string, string>>;
87
+ upsertPages(pages: PageRecord[], scope: Scope): Promise<void>;
88
+ getPage(url: string, scope: Scope): Promise<PageRecord | null>;
89
+ deletePages(scope: Scope): Promise<void>;
90
+ health(): Promise<{
91
+ ok: boolean;
92
+ details?: string;
93
+ }>;
94
+ dropAllIndexes(projectId: string): Promise<void>;
47
95
  }
48
96
 
49
- declare function createReranker(config: ResolvedSearchSocketConfig): Reranker | null;
50
-
51
97
  interface LoggerOptions {
52
98
  json?: boolean;
53
99
  verbose?: boolean;
@@ -74,15 +120,13 @@ interface IndexPipelineOptions {
74
120
  cwd?: string;
75
121
  configPath?: string;
76
122
  config?: ResolvedSearchSocketConfig;
77
- embeddingsProvider?: EmbeddingsProvider;
78
- vectorStore?: VectorStore;
123
+ store?: UpstashSearchStore;
79
124
  logger?: Logger;
80
125
  }
81
126
  declare class IndexPipeline {
82
127
  private readonly cwd;
83
128
  private readonly config;
84
- private readonly embeddings;
85
- private readonly vectorStore;
129
+ private readonly store;
86
130
  private readonly logger;
87
131
  private constructor();
88
132
  static create(options?: IndexPipelineOptions): Promise<IndexPipeline>;
@@ -94,20 +138,18 @@ interface SearchEngineOptions {
94
138
  cwd?: string;
95
139
  configPath?: string;
96
140
  config?: ResolvedSearchSocketConfig;
97
- embeddingsProvider?: EmbeddingsProvider;
98
- vectorStore?: VectorStore;
99
- reranker?: Reranker | null;
141
+ store?: UpstashSearchStore;
100
142
  }
101
143
  declare class SearchEngine {
102
144
  private readonly cwd;
103
145
  private readonly config;
104
- private readonly embeddings;
105
- private readonly vectorStore;
106
- private readonly reranker;
146
+ private readonly store;
107
147
  private constructor();
108
148
  static create(options?: SearchEngineOptions): Promise<SearchEngine>;
109
149
  getConfig(): ResolvedSearchSocketConfig;
110
150
  search(request: SearchRequest): Promise<SearchResponse>;
151
+ private ensureSnippet;
152
+ private buildResults;
111
153
  getPage(pathOrUrl: string, scope?: string): Promise<{
112
154
  url: string;
113
155
  frontmatter: Record<string, unknown>;
@@ -118,11 +160,9 @@ declare class SearchEngine {
118
160
  details?: string;
119
161
  }>;
120
162
  private resolveInputPath;
121
- private assertModelCompatibility;
122
- private rerankHits;
123
163
  }
124
164
 
125
- declare function createVectorStore(config: ResolvedSearchSocketConfig, cwd: string): Promise<VectorStore>;
165
+ declare function createUpstashStore(config: ResolvedSearchSocketConfig): Promise<UpstashSearchStore>;
126
166
 
127
167
  interface McpServerOptions {
128
168
  cwd?: string;
@@ -133,4 +173,4 @@ interface McpServerOptions {
133
173
  }
134
174
  declare function runMcpServer(options?: McpServerOptions): Promise<void>;
135
175
 
136
- export { EmbeddingsProvider, IndexOptions, IndexPipeline, IndexStats, JinaReranker, RerankCandidate, Reranker, ResolvedSearchSocketConfig, Scope, SearchEngine, SearchRequest, SearchResponse, SearchSocketConfig, VectorStore, createEmbeddingsProvider, createReranker, createVectorStore, isServerless, loadConfig, mergeConfig, mergeConfigServerless, resolveScope, runMcpServer };
176
+ export { IndexOptions, IndexPipeline, IndexStats, ResolvedSearchSocketConfig, Scope, SearchEngine, SearchRequest, SearchResponse, SearchSocketConfig, UpstashSearchStore, VectorHit, createUpstashStore, isServerless, loadConfig, mergeConfig, mergeConfigServerless, resolveScope, runMcpServer };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
- import { R as ResolvedSearchSocketConfig, b as SearchSocketConfig, c as Scope, E as EmbeddingsProvider, d as Reranker, e as RerankCandidate, V as VectorStore, I as IndexOptions, f as IndexStats, S as SearchRequest, a as SearchResponse } from './types-BrG6XTUU.js';
2
- export { C as Chunk, Q as QueryOpts, g as VectorHit, h as VectorRecord } from './types-BrG6XTUU.js';
3
- export { searchsocketHandle, searchsocketVitePlugin } from './sveltekit.js';
1
+ import { R as ResolvedSearchSocketConfig, c as SearchSocketConfig, d as Scope, V as VectorHit, P as PageHit, e as ScopeInfo, f as PageRecord, I as IndexOptions, g as IndexStats, S as SearchRequest, a as SearchResponse } from './types-Dk43uz25.js';
2
+ export { C as Chunk } from './types-Dk43uz25.js';
3
+ import { Search } from '@upstash/search';
4
+ export { s as searchsocketHandle, b as searchsocketVitePlugin } from './plugin-M-aW0ev6.js';
4
5
  export { createSearchClient } from './client.js';
5
6
 
6
7
  interface LoadConfigOptions {
@@ -28,26 +29,71 @@ declare function isServerless(): boolean;
28
29
 
29
30
  declare function resolveScope(config: ResolvedSearchSocketConfig, override?: string): Scope;
30
31
 
31
- declare function createEmbeddingsProvider(config: ResolvedSearchSocketConfig): EmbeddingsProvider;
32
-
33
- interface JinaRerankerOptions {
34
- apiKey: string;
35
- model: string;
36
- maxRetries?: number;
32
+ /** Content fields stored in Upstash Search (indexed and searchable) */
33
+ interface ChunkContent {
34
+ title: string;
35
+ sectionTitle: string;
36
+ text: string;
37
+ url: string;
38
+ tags: string;
39
+ headingPath: string;
40
+ [key: string]: unknown;
41
+ }
42
+ /** Metadata fields stored in Upstash Search (returned but not searchable) */
43
+ interface ChunkMetadata {
44
+ projectId: string;
45
+ scopeName: string;
46
+ path: string;
47
+ snippet: string;
48
+ ordinal: number;
49
+ contentHash: string;
50
+ depth: number;
51
+ incomingLinks: number;
52
+ routeFile: string;
53
+ description: string;
54
+ keywords: string;
55
+ [key: string]: unknown;
37
56
  }
38
- declare class JinaReranker implements Reranker {
39
- private readonly apiKey;
40
- private readonly model;
41
- private readonly maxRetries;
42
- constructor(options: JinaRerankerOptions);
43
- rerank(query: string, candidates: RerankCandidate[], topN?: number): Promise<Array<{
57
+ interface UpstashSearchStoreOptions {
58
+ client: Search;
59
+ }
60
+ declare class UpstashSearchStore {
61
+ private readonly client;
62
+ constructor(opts: UpstashSearchStoreOptions);
63
+ private chunkIndex;
64
+ private pageIndex;
65
+ upsertChunks(chunks: Array<{
44
66
  id: string;
45
- score: number;
46
- }>>;
67
+ content: ChunkContent;
68
+ metadata: ChunkMetadata;
69
+ }>, scope: Scope): Promise<void>;
70
+ search(query: string, opts: {
71
+ limit: number;
72
+ semanticWeight?: number;
73
+ inputEnrichment?: boolean;
74
+ reranking?: boolean;
75
+ filter?: string;
76
+ }, scope: Scope): Promise<VectorHit[]>;
77
+ searchPages(query: string, opts: {
78
+ limit: number;
79
+ semanticWeight?: number;
80
+ inputEnrichment?: boolean;
81
+ filter?: string;
82
+ }, scope: Scope): Promise<PageHit[]>;
83
+ deleteByIds(ids: string[], scope: Scope): Promise<void>;
84
+ deleteScope(scope: Scope): Promise<void>;
85
+ listScopes(projectId: string): Promise<ScopeInfo[]>;
86
+ getContentHashes(scope: Scope): Promise<Map<string, string>>;
87
+ upsertPages(pages: PageRecord[], scope: Scope): Promise<void>;
88
+ getPage(url: string, scope: Scope): Promise<PageRecord | null>;
89
+ deletePages(scope: Scope): Promise<void>;
90
+ health(): Promise<{
91
+ ok: boolean;
92
+ details?: string;
93
+ }>;
94
+ dropAllIndexes(projectId: string): Promise<void>;
47
95
  }
48
96
 
49
- declare function createReranker(config: ResolvedSearchSocketConfig): Reranker | null;
50
-
51
97
  interface LoggerOptions {
52
98
  json?: boolean;
53
99
  verbose?: boolean;
@@ -74,15 +120,13 @@ interface IndexPipelineOptions {
74
120
  cwd?: string;
75
121
  configPath?: string;
76
122
  config?: ResolvedSearchSocketConfig;
77
- embeddingsProvider?: EmbeddingsProvider;
78
- vectorStore?: VectorStore;
123
+ store?: UpstashSearchStore;
79
124
  logger?: Logger;
80
125
  }
81
126
  declare class IndexPipeline {
82
127
  private readonly cwd;
83
128
  private readonly config;
84
- private readonly embeddings;
85
- private readonly vectorStore;
129
+ private readonly store;
86
130
  private readonly logger;
87
131
  private constructor();
88
132
  static create(options?: IndexPipelineOptions): Promise<IndexPipeline>;
@@ -94,20 +138,18 @@ interface SearchEngineOptions {
94
138
  cwd?: string;
95
139
  configPath?: string;
96
140
  config?: ResolvedSearchSocketConfig;
97
- embeddingsProvider?: EmbeddingsProvider;
98
- vectorStore?: VectorStore;
99
- reranker?: Reranker | null;
141
+ store?: UpstashSearchStore;
100
142
  }
101
143
  declare class SearchEngine {
102
144
  private readonly cwd;
103
145
  private readonly config;
104
- private readonly embeddings;
105
- private readonly vectorStore;
106
- private readonly reranker;
146
+ private readonly store;
107
147
  private constructor();
108
148
  static create(options?: SearchEngineOptions): Promise<SearchEngine>;
109
149
  getConfig(): ResolvedSearchSocketConfig;
110
150
  search(request: SearchRequest): Promise<SearchResponse>;
151
+ private ensureSnippet;
152
+ private buildResults;
111
153
  getPage(pathOrUrl: string, scope?: string): Promise<{
112
154
  url: string;
113
155
  frontmatter: Record<string, unknown>;
@@ -118,11 +160,9 @@ declare class SearchEngine {
118
160
  details?: string;
119
161
  }>;
120
162
  private resolveInputPath;
121
- private assertModelCompatibility;
122
- private rerankHits;
123
163
  }
124
164
 
125
- declare function createVectorStore(config: ResolvedSearchSocketConfig, cwd: string): Promise<VectorStore>;
165
+ declare function createUpstashStore(config: ResolvedSearchSocketConfig): Promise<UpstashSearchStore>;
126
166
 
127
167
  interface McpServerOptions {
128
168
  cwd?: string;
@@ -133,4 +173,4 @@ interface McpServerOptions {
133
173
  }
134
174
  declare function runMcpServer(options?: McpServerOptions): Promise<void>;
135
175
 
136
- export { EmbeddingsProvider, IndexOptions, IndexPipeline, IndexStats, JinaReranker, RerankCandidate, Reranker, ResolvedSearchSocketConfig, Scope, SearchEngine, SearchRequest, SearchResponse, SearchSocketConfig, VectorStore, createEmbeddingsProvider, createReranker, createVectorStore, isServerless, loadConfig, mergeConfig, mergeConfigServerless, resolveScope, runMcpServer };
176
+ export { IndexOptions, IndexPipeline, IndexStats, ResolvedSearchSocketConfig, Scope, SearchEngine, SearchRequest, SearchResponse, SearchSocketConfig, UpstashSearchStore, VectorHit, createUpstashStore, isServerless, loadConfig, mergeConfig, mergeConfigServerless, resolveScope, runMcpServer };