searchsocket 0.4.0 → 0.6.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,7 +1,8 @@
1
- import { R as ResolvedSearchSocketConfig, d as SearchSocketConfig, e as Scope, E as EmbeddingsProvider, f as Reranker, g as RerankCandidate, V as VectorStore, I as IndexOptions, h as IndexStats, b as SearchRequest, S as SearchResponse, c as StreamSearchEvent } from './types-z2dw3H6E.cjs';
2
- export { C as Chunk, M as MergeSearchOptions, a as MergeSearchResult, Q as QueryOpts, i as StreamEvent, j as StreamSearchErrorEvent, k as VectorHit, l as VectorRecord } from './types-z2dw3H6E.cjs';
3
- export { searchsocketHandle, searchsocketVitePlugin } from './sveltekit.cjs';
4
- export { createSearchClient, mergeSearchResults } from './client.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 IndexingHooks, g as IndexOptions, h as IndexStats, S as SearchRequest, a as SearchResponse, i as SiteStructureResult, j as RelatedPagesResult } from './types-029hl6P2.cjs';
2
+ export { A as Awaitable, C as Chunk, k as CustomRecord } from './types-029hl6P2.cjs';
3
+ import { Index } from '@upstash/vector';
4
+ export { s as searchsocketHandle, b as searchsocketVitePlugin } from './plugin-DoBW1gkK.cjs';
5
+ export { createSearchClient } from './client.cjs';
5
6
 
6
7
  interface LoadConfigOptions {
7
8
  cwd?: string;
@@ -28,26 +29,104 @@ 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
+ /** Flat metadata stored alongside each page vector in Upstash Vector */
33
+ interface PageVectorMetadata {
34
+ projectId: string;
35
+ scopeName: string;
36
+ type: string;
37
+ title: string;
38
+ url: string;
39
+ description: string;
40
+ keywords: string[];
41
+ summary: string;
42
+ tags: string[];
43
+ markdown: string;
44
+ routeFile: string;
45
+ routeResolution: string;
46
+ incomingLinks: number;
47
+ outgoingLinks: number;
48
+ outgoingLinkUrls?: string[];
49
+ depth: number;
50
+ indexedAt: string;
51
+ contentHash: string;
52
+ publishedAt?: number | null;
53
+ [key: string]: unknown;
54
+ }
55
+ interface UpstashSearchStoreOptions {
56
+ index: Index;
57
+ pagesNamespace: string;
58
+ chunksNamespace: string;
37
59
  }
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<{
60
+ declare class UpstashSearchStore {
61
+ private readonly index;
62
+ private readonly pagesNs;
63
+ private readonly chunksNs;
64
+ constructor(opts: UpstashSearchStoreOptions);
65
+ upsertChunks(chunks: Array<{
66
+ id: string;
67
+ data: string;
68
+ metadata: Record<string, unknown>;
69
+ }>, scope: Scope): Promise<void>;
70
+ search(data: string, opts: {
71
+ limit: number;
72
+ filter?: string;
73
+ }, scope: Scope): Promise<VectorHit[]>;
74
+ searchChunksByUrl(data: string, url: string, opts: {
75
+ limit: number;
76
+ filter?: string;
77
+ }, scope: Scope): Promise<VectorHit[]>;
78
+ searchPagesByText(data: string, opts: {
79
+ limit: number;
80
+ filter?: string;
81
+ }, scope: Scope): Promise<PageHit[]>;
82
+ searchPagesByVector(vector: number[], opts: {
83
+ limit: number;
84
+ filter?: string;
85
+ }, scope: Scope): Promise<PageHit[]>;
86
+ private queryPages;
87
+ deleteByIds(ids: string[], _scope: Scope): Promise<void>;
88
+ deleteScope(scope: Scope): Promise<void>;
89
+ listScopes(projectId: string): Promise<ScopeInfo[]>;
90
+ getContentHashes(scope: Scope): Promise<Map<string, string>>;
91
+ listPages(scope: Scope, opts?: {
92
+ cursor?: string;
93
+ limit?: number;
94
+ pathPrefix?: string;
95
+ }): Promise<{
96
+ pages: Array<{
97
+ url: string;
98
+ title: string;
99
+ description: string;
100
+ routeFile: string;
101
+ }>;
102
+ nextCursor?: string;
103
+ }>;
104
+ getPageHashes(scope: Scope): Promise<Map<string, string>>;
105
+ deletePagesByIds(ids: string[], _scope: Scope): Promise<void>;
106
+ upsertPages(pages: Array<{
44
107
  id: string;
45
- score: number;
108
+ data: string;
109
+ metadata: Record<string, unknown>;
110
+ }>, scope: Scope): Promise<void>;
111
+ getPage(url: string, scope: Scope): Promise<PageRecord | null>;
112
+ fetchPageWithVector(url: string, scope: Scope): Promise<{
113
+ metadata: PageVectorMetadata;
114
+ vector: number[];
115
+ } | null>;
116
+ fetchPagesBatch(urls: string[], scope: Scope): Promise<Array<{
117
+ url: string;
118
+ title: string;
119
+ routeFile: string;
120
+ outgoingLinkUrls: string[];
46
121
  }>>;
122
+ deletePages(scope: Scope): Promise<void>;
123
+ health(): Promise<{
124
+ ok: boolean;
125
+ details?: string;
126
+ }>;
127
+ dropAllIndexes(projectId: string): Promise<void>;
47
128
  }
48
129
 
49
- declare function createReranker(config: ResolvedSearchSocketConfig): Reranker | null;
50
-
51
130
  interface LoggerOptions {
52
131
  json?: boolean;
53
132
  verbose?: boolean;
@@ -74,16 +153,16 @@ interface IndexPipelineOptions {
74
153
  cwd?: string;
75
154
  configPath?: string;
76
155
  config?: ResolvedSearchSocketConfig;
77
- embeddingsProvider?: EmbeddingsProvider;
78
- vectorStore?: VectorStore;
156
+ store?: UpstashSearchStore;
79
157
  logger?: Logger;
158
+ hooks?: IndexingHooks;
80
159
  }
81
160
  declare class IndexPipeline {
82
161
  private readonly cwd;
83
162
  private readonly config;
84
- private readonly embeddings;
85
- private readonly vectorStore;
163
+ private readonly store;
86
164
  private readonly logger;
165
+ private readonly hooks;
87
166
  private constructor();
88
167
  static create(options?: IndexPipelineOptions): Promise<IndexPipeline>;
89
168
  getConfig(): ResolvedSearchSocketConfig;
@@ -94,37 +173,55 @@ interface SearchEngineOptions {
94
173
  cwd?: string;
95
174
  configPath?: string;
96
175
  config?: ResolvedSearchSocketConfig;
97
- embeddingsProvider?: EmbeddingsProvider;
98
- vectorStore?: VectorStore;
99
- reranker?: Reranker | null;
176
+ store?: UpstashSearchStore;
100
177
  }
101
178
  declare class SearchEngine {
102
179
  private readonly cwd;
103
180
  private readonly config;
104
- private readonly embeddings;
105
- private readonly vectorStore;
106
- private readonly reranker;
181
+ private readonly store;
107
182
  private constructor();
108
183
  static create(options?: SearchEngineOptions): Promise<SearchEngine>;
109
184
  getConfig(): ResolvedSearchSocketConfig;
110
185
  search(request: SearchRequest): Promise<SearchResponse>;
111
- searchStreaming(request: SearchRequest): AsyncGenerator<StreamSearchEvent>;
186
+ private buildPageFirstResults;
187
+ private ensureSnippet;
112
188
  private buildResults;
113
189
  getPage(pathOrUrl: string, scope?: string): Promise<{
114
190
  url: string;
115
191
  frontmatter: Record<string, unknown>;
116
192
  markdown: string;
117
193
  }>;
194
+ listPages(opts?: {
195
+ pathPrefix?: string;
196
+ cursor?: string;
197
+ limit?: number;
198
+ scope?: string;
199
+ }): Promise<{
200
+ pages: Array<{
201
+ url: string;
202
+ title: string;
203
+ description: string;
204
+ routeFile: string;
205
+ }>;
206
+ nextCursor?: string;
207
+ }>;
208
+ getSiteStructure(opts?: {
209
+ pathPrefix?: string;
210
+ scope?: string;
211
+ maxPages?: number;
212
+ }): Promise<SiteStructureResult>;
213
+ getRelatedPages(pathOrUrl: string, opts?: {
214
+ topK?: number;
215
+ scope?: string;
216
+ }): Promise<RelatedPagesResult>;
118
217
  health(): Promise<{
119
218
  ok: boolean;
120
219
  details?: string;
121
220
  }>;
122
221
  private resolveInputPath;
123
- private assertModelCompatibility;
124
- private rerankHits;
125
222
  }
126
223
 
127
- declare function createVectorStore(config: ResolvedSearchSocketConfig, cwd: string): Promise<VectorStore>;
224
+ declare function createUpstashStore(config: ResolvedSearchSocketConfig): Promise<UpstashSearchStore>;
128
225
 
129
226
  interface McpServerOptions {
130
227
  cwd?: string;
@@ -132,7 +229,9 @@ interface McpServerOptions {
132
229
  transport?: "stdio" | "http";
133
230
  httpPort?: number;
134
231
  httpPath?: string;
232
+ access?: "public" | "private";
233
+ apiKey?: string;
135
234
  }
136
235
  declare function runMcpServer(options?: McpServerOptions): Promise<void>;
137
236
 
138
- export { EmbeddingsProvider, IndexOptions, IndexPipeline, IndexStats, JinaReranker, RerankCandidate, Reranker, ResolvedSearchSocketConfig, Scope, SearchEngine, SearchRequest, SearchResponse, SearchSocketConfig, StreamSearchEvent, VectorStore, createEmbeddingsProvider, createReranker, createVectorStore, isServerless, loadConfig, mergeConfig, mergeConfigServerless, resolveScope, runMcpServer };
237
+ export { IndexOptions, IndexPipeline, IndexStats, IndexingHooks, ResolvedSearchSocketConfig, Scope, SearchEngine, SearchRequest, SearchResponse, SearchSocketConfig, UpstashSearchStore, VectorHit, createUpstashStore, isServerless, loadConfig, mergeConfig, mergeConfigServerless, resolveScope, runMcpServer };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
- import { R as ResolvedSearchSocketConfig, d as SearchSocketConfig, e as Scope, E as EmbeddingsProvider, f as Reranker, g as RerankCandidate, V as VectorStore, I as IndexOptions, h as IndexStats, b as SearchRequest, S as SearchResponse, c as StreamSearchEvent } from './types-z2dw3H6E.js';
2
- export { C as Chunk, M as MergeSearchOptions, a as MergeSearchResult, Q as QueryOpts, i as StreamEvent, j as StreamSearchErrorEvent, k as VectorHit, l as VectorRecord } from './types-z2dw3H6E.js';
3
- export { searchsocketHandle, searchsocketVitePlugin } from './sveltekit.js';
4
- export { createSearchClient, mergeSearchResults } from './client.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 IndexingHooks, g as IndexOptions, h as IndexStats, S as SearchRequest, a as SearchResponse, i as SiteStructureResult, j as RelatedPagesResult } from './types-029hl6P2.js';
2
+ export { A as Awaitable, C as Chunk, k as CustomRecord } from './types-029hl6P2.js';
3
+ import { Index } from '@upstash/vector';
4
+ export { s as searchsocketHandle, b as searchsocketVitePlugin } from './plugin-C61L-ykY.js';
5
+ export { createSearchClient } from './client.js';
5
6
 
6
7
  interface LoadConfigOptions {
7
8
  cwd?: string;
@@ -28,26 +29,104 @@ 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
+ /** Flat metadata stored alongside each page vector in Upstash Vector */
33
+ interface PageVectorMetadata {
34
+ projectId: string;
35
+ scopeName: string;
36
+ type: string;
37
+ title: string;
38
+ url: string;
39
+ description: string;
40
+ keywords: string[];
41
+ summary: string;
42
+ tags: string[];
43
+ markdown: string;
44
+ routeFile: string;
45
+ routeResolution: string;
46
+ incomingLinks: number;
47
+ outgoingLinks: number;
48
+ outgoingLinkUrls?: string[];
49
+ depth: number;
50
+ indexedAt: string;
51
+ contentHash: string;
52
+ publishedAt?: number | null;
53
+ [key: string]: unknown;
54
+ }
55
+ interface UpstashSearchStoreOptions {
56
+ index: Index;
57
+ pagesNamespace: string;
58
+ chunksNamespace: string;
37
59
  }
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<{
60
+ declare class UpstashSearchStore {
61
+ private readonly index;
62
+ private readonly pagesNs;
63
+ private readonly chunksNs;
64
+ constructor(opts: UpstashSearchStoreOptions);
65
+ upsertChunks(chunks: Array<{
66
+ id: string;
67
+ data: string;
68
+ metadata: Record<string, unknown>;
69
+ }>, scope: Scope): Promise<void>;
70
+ search(data: string, opts: {
71
+ limit: number;
72
+ filter?: string;
73
+ }, scope: Scope): Promise<VectorHit[]>;
74
+ searchChunksByUrl(data: string, url: string, opts: {
75
+ limit: number;
76
+ filter?: string;
77
+ }, scope: Scope): Promise<VectorHit[]>;
78
+ searchPagesByText(data: string, opts: {
79
+ limit: number;
80
+ filter?: string;
81
+ }, scope: Scope): Promise<PageHit[]>;
82
+ searchPagesByVector(vector: number[], opts: {
83
+ limit: number;
84
+ filter?: string;
85
+ }, scope: Scope): Promise<PageHit[]>;
86
+ private queryPages;
87
+ deleteByIds(ids: string[], _scope: Scope): Promise<void>;
88
+ deleteScope(scope: Scope): Promise<void>;
89
+ listScopes(projectId: string): Promise<ScopeInfo[]>;
90
+ getContentHashes(scope: Scope): Promise<Map<string, string>>;
91
+ listPages(scope: Scope, opts?: {
92
+ cursor?: string;
93
+ limit?: number;
94
+ pathPrefix?: string;
95
+ }): Promise<{
96
+ pages: Array<{
97
+ url: string;
98
+ title: string;
99
+ description: string;
100
+ routeFile: string;
101
+ }>;
102
+ nextCursor?: string;
103
+ }>;
104
+ getPageHashes(scope: Scope): Promise<Map<string, string>>;
105
+ deletePagesByIds(ids: string[], _scope: Scope): Promise<void>;
106
+ upsertPages(pages: Array<{
44
107
  id: string;
45
- score: number;
108
+ data: string;
109
+ metadata: Record<string, unknown>;
110
+ }>, scope: Scope): Promise<void>;
111
+ getPage(url: string, scope: Scope): Promise<PageRecord | null>;
112
+ fetchPageWithVector(url: string, scope: Scope): Promise<{
113
+ metadata: PageVectorMetadata;
114
+ vector: number[];
115
+ } | null>;
116
+ fetchPagesBatch(urls: string[], scope: Scope): Promise<Array<{
117
+ url: string;
118
+ title: string;
119
+ routeFile: string;
120
+ outgoingLinkUrls: string[];
46
121
  }>>;
122
+ deletePages(scope: Scope): Promise<void>;
123
+ health(): Promise<{
124
+ ok: boolean;
125
+ details?: string;
126
+ }>;
127
+ dropAllIndexes(projectId: string): Promise<void>;
47
128
  }
48
129
 
49
- declare function createReranker(config: ResolvedSearchSocketConfig): Reranker | null;
50
-
51
130
  interface LoggerOptions {
52
131
  json?: boolean;
53
132
  verbose?: boolean;
@@ -74,16 +153,16 @@ interface IndexPipelineOptions {
74
153
  cwd?: string;
75
154
  configPath?: string;
76
155
  config?: ResolvedSearchSocketConfig;
77
- embeddingsProvider?: EmbeddingsProvider;
78
- vectorStore?: VectorStore;
156
+ store?: UpstashSearchStore;
79
157
  logger?: Logger;
158
+ hooks?: IndexingHooks;
80
159
  }
81
160
  declare class IndexPipeline {
82
161
  private readonly cwd;
83
162
  private readonly config;
84
- private readonly embeddings;
85
- private readonly vectorStore;
163
+ private readonly store;
86
164
  private readonly logger;
165
+ private readonly hooks;
87
166
  private constructor();
88
167
  static create(options?: IndexPipelineOptions): Promise<IndexPipeline>;
89
168
  getConfig(): ResolvedSearchSocketConfig;
@@ -94,37 +173,55 @@ interface SearchEngineOptions {
94
173
  cwd?: string;
95
174
  configPath?: string;
96
175
  config?: ResolvedSearchSocketConfig;
97
- embeddingsProvider?: EmbeddingsProvider;
98
- vectorStore?: VectorStore;
99
- reranker?: Reranker | null;
176
+ store?: UpstashSearchStore;
100
177
  }
101
178
  declare class SearchEngine {
102
179
  private readonly cwd;
103
180
  private readonly config;
104
- private readonly embeddings;
105
- private readonly vectorStore;
106
- private readonly reranker;
181
+ private readonly store;
107
182
  private constructor();
108
183
  static create(options?: SearchEngineOptions): Promise<SearchEngine>;
109
184
  getConfig(): ResolvedSearchSocketConfig;
110
185
  search(request: SearchRequest): Promise<SearchResponse>;
111
- searchStreaming(request: SearchRequest): AsyncGenerator<StreamSearchEvent>;
186
+ private buildPageFirstResults;
187
+ private ensureSnippet;
112
188
  private buildResults;
113
189
  getPage(pathOrUrl: string, scope?: string): Promise<{
114
190
  url: string;
115
191
  frontmatter: Record<string, unknown>;
116
192
  markdown: string;
117
193
  }>;
194
+ listPages(opts?: {
195
+ pathPrefix?: string;
196
+ cursor?: string;
197
+ limit?: number;
198
+ scope?: string;
199
+ }): Promise<{
200
+ pages: Array<{
201
+ url: string;
202
+ title: string;
203
+ description: string;
204
+ routeFile: string;
205
+ }>;
206
+ nextCursor?: string;
207
+ }>;
208
+ getSiteStructure(opts?: {
209
+ pathPrefix?: string;
210
+ scope?: string;
211
+ maxPages?: number;
212
+ }): Promise<SiteStructureResult>;
213
+ getRelatedPages(pathOrUrl: string, opts?: {
214
+ topK?: number;
215
+ scope?: string;
216
+ }): Promise<RelatedPagesResult>;
118
217
  health(): Promise<{
119
218
  ok: boolean;
120
219
  details?: string;
121
220
  }>;
122
221
  private resolveInputPath;
123
- private assertModelCompatibility;
124
- private rerankHits;
125
222
  }
126
223
 
127
- declare function createVectorStore(config: ResolvedSearchSocketConfig, cwd: string): Promise<VectorStore>;
224
+ declare function createUpstashStore(config: ResolvedSearchSocketConfig): Promise<UpstashSearchStore>;
128
225
 
129
226
  interface McpServerOptions {
130
227
  cwd?: string;
@@ -132,7 +229,9 @@ interface McpServerOptions {
132
229
  transport?: "stdio" | "http";
133
230
  httpPort?: number;
134
231
  httpPath?: string;
232
+ access?: "public" | "private";
233
+ apiKey?: string;
135
234
  }
136
235
  declare function runMcpServer(options?: McpServerOptions): Promise<void>;
137
236
 
138
- export { EmbeddingsProvider, IndexOptions, IndexPipeline, IndexStats, JinaReranker, RerankCandidate, Reranker, ResolvedSearchSocketConfig, Scope, SearchEngine, SearchRequest, SearchResponse, SearchSocketConfig, StreamSearchEvent, VectorStore, createEmbeddingsProvider, createReranker, createVectorStore, isServerless, loadConfig, mergeConfig, mergeConfigServerless, resolveScope, runMcpServer };
237
+ export { IndexOptions, IndexPipeline, IndexStats, IndexingHooks, ResolvedSearchSocketConfig, Scope, SearchEngine, SearchRequest, SearchResponse, SearchSocketConfig, UpstashSearchStore, VectorHit, createUpstashStore, isServerless, loadConfig, mergeConfig, mergeConfigServerless, resolveScope, runMcpServer };