@twelvehart/supermemory-runtime 1.0.0-next.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/.env.example +57 -0
- package/README.md +374 -0
- package/dist/index.js +189 -0
- package/dist/mcp/index.js +1132 -0
- package/docker-compose.prod.yml +91 -0
- package/docker-compose.yml +358 -0
- package/drizzle/0000_dapper_the_professor.sql +159 -0
- package/drizzle/0001_api_keys.sql +51 -0
- package/drizzle/meta/0000_snapshot.json +1532 -0
- package/drizzle/meta/_journal.json +13 -0
- package/drizzle.config.ts +20 -0
- package/package.json +114 -0
- package/scripts/add-extraction-job.ts +122 -0
- package/scripts/benchmark-pgvector.ts +122 -0
- package/scripts/bootstrap.sh +209 -0
- package/scripts/check-runtime-pack.ts +111 -0
- package/scripts/claude-mcp-config.ts +336 -0
- package/scripts/docker-entrypoint.sh +183 -0
- package/scripts/doctor.ts +377 -0
- package/scripts/init-db.sql +33 -0
- package/scripts/install.sh +1110 -0
- package/scripts/mcp-setup.ts +271 -0
- package/scripts/migrations/001_create_pgvector_extension.sql +31 -0
- package/scripts/migrations/002_create_memory_embeddings_table.sql +75 -0
- package/scripts/migrations/003_create_hnsw_index.sql +94 -0
- package/scripts/migrations/004_create_memory_embeddings_standalone.sql +70 -0
- package/scripts/migrations/005_create_chunks_table.sql +95 -0
- package/scripts/migrations/006_create_processing_queue.sql +45 -0
- package/scripts/migrations/generate_test_data.sql +42 -0
- package/scripts/migrations/phase1_comprehensive_test.sql +204 -0
- package/scripts/migrations/run_migrations.sh +286 -0
- package/scripts/migrations/test_hnsw_index.sql +255 -0
- package/scripts/pre-commit-secrets +282 -0
- package/scripts/run-extraction-worker.ts +46 -0
- package/scripts/run-phase1-tests.sh +291 -0
- package/scripts/setup.ts +222 -0
- package/scripts/smoke-install.sh +12 -0
- package/scripts/test-health-endpoint.sh +328 -0
- package/src/api/index.ts +2 -0
- package/src/api/middleware/auth.ts +80 -0
- package/src/api/middleware/csrf.ts +308 -0
- package/src/api/middleware/errorHandler.ts +166 -0
- package/src/api/middleware/rateLimit.ts +360 -0
- package/src/api/middleware/validation.ts +514 -0
- package/src/api/routes/documents.ts +286 -0
- package/src/api/routes/profiles.ts +237 -0
- package/src/api/routes/search.ts +71 -0
- package/src/api/stores/index.ts +58 -0
- package/src/config/bootstrap-env.ts +3 -0
- package/src/config/env.ts +71 -0
- package/src/config/feature-flags.ts +25 -0
- package/src/config/index.ts +140 -0
- package/src/config/secrets.config.ts +291 -0
- package/src/db/client.ts +92 -0
- package/src/db/index.ts +73 -0
- package/src/db/postgres.ts +72 -0
- package/src/db/schema/chunks.schema.ts +31 -0
- package/src/db/schema/containers.schema.ts +46 -0
- package/src/db/schema/documents.schema.ts +49 -0
- package/src/db/schema/embeddings.schema.ts +32 -0
- package/src/db/schema/index.ts +11 -0
- package/src/db/schema/memories.schema.ts +72 -0
- package/src/db/schema/profiles.schema.ts +34 -0
- package/src/db/schema/queue.schema.ts +59 -0
- package/src/db/schema/relationships.schema.ts +42 -0
- package/src/db/schema.ts +223 -0
- package/src/db/worker-connection.ts +47 -0
- package/src/index.ts +235 -0
- package/src/mcp/CLAUDE.md +1 -0
- package/src/mcp/index.ts +1380 -0
- package/src/mcp/legacyState.ts +22 -0
- package/src/mcp/rateLimit.ts +358 -0
- package/src/mcp/resources.ts +309 -0
- package/src/mcp/results.ts +104 -0
- package/src/mcp/tools.ts +401 -0
- package/src/queues/config.ts +119 -0
- package/src/queues/index.ts +289 -0
- package/src/sdk/client.ts +225 -0
- package/src/sdk/errors.ts +266 -0
- package/src/sdk/http.ts +560 -0
- package/src/sdk/index.ts +244 -0
- package/src/sdk/resources/base.ts +65 -0
- package/src/sdk/resources/connections.ts +204 -0
- package/src/sdk/resources/documents.ts +163 -0
- package/src/sdk/resources/index.ts +10 -0
- package/src/sdk/resources/memories.ts +150 -0
- package/src/sdk/resources/search.ts +60 -0
- package/src/sdk/resources/settings.ts +36 -0
- package/src/sdk/types.ts +674 -0
- package/src/services/chunking/index.ts +451 -0
- package/src/services/chunking.service.ts +650 -0
- package/src/services/csrf.service.ts +252 -0
- package/src/services/documents.repository.ts +219 -0
- package/src/services/documents.service.ts +191 -0
- package/src/services/embedding.service.ts +404 -0
- package/src/services/extraction.service.ts +300 -0
- package/src/services/extractors/code.extractor.ts +451 -0
- package/src/services/extractors/index.ts +9 -0
- package/src/services/extractors/markdown.extractor.ts +461 -0
- package/src/services/extractors/pdf.extractor.ts +315 -0
- package/src/services/extractors/text.extractor.ts +118 -0
- package/src/services/extractors/url.extractor.ts +243 -0
- package/src/services/index.ts +235 -0
- package/src/services/ingestion.service.ts +177 -0
- package/src/services/llm/anthropic.ts +400 -0
- package/src/services/llm/base.ts +460 -0
- package/src/services/llm/contradiction-detector.service.ts +526 -0
- package/src/services/llm/heuristics.ts +148 -0
- package/src/services/llm/index.ts +309 -0
- package/src/services/llm/memory-classifier.service.ts +383 -0
- package/src/services/llm/memory-extension-detector.service.ts +523 -0
- package/src/services/llm/mock.ts +470 -0
- package/src/services/llm/openai.ts +398 -0
- package/src/services/llm/prompts.ts +438 -0
- package/src/services/llm/types.ts +373 -0
- package/src/services/memory.repository.ts +1769 -0
- package/src/services/memory.service.ts +1338 -0
- package/src/services/memory.types.ts +234 -0
- package/src/services/persistence/index.ts +295 -0
- package/src/services/pipeline.service.ts +509 -0
- package/src/services/profile.repository.ts +436 -0
- package/src/services/profile.service.ts +560 -0
- package/src/services/profile.types.ts +270 -0
- package/src/services/relationships/detector.ts +1128 -0
- package/src/services/relationships/index.ts +268 -0
- package/src/services/relationships/memory-integration.ts +459 -0
- package/src/services/relationships/strategies.ts +132 -0
- package/src/services/relationships/types.ts +370 -0
- package/src/services/search.service.ts +761 -0
- package/src/services/search.types.ts +220 -0
- package/src/services/secrets.service.ts +384 -0
- package/src/services/vectorstore/base.ts +327 -0
- package/src/services/vectorstore/index.ts +444 -0
- package/src/services/vectorstore/memory.ts +286 -0
- package/src/services/vectorstore/migration.ts +295 -0
- package/src/services/vectorstore/mock.ts +403 -0
- package/src/services/vectorstore/pgvector.ts +695 -0
- package/src/services/vectorstore/types.ts +247 -0
- package/src/startup.ts +389 -0
- package/src/types/api.types.ts +193 -0
- package/src/types/document.types.ts +103 -0
- package/src/types/index.ts +241 -0
- package/src/types/profile.base.ts +133 -0
- package/src/utils/errors.ts +447 -0
- package/src/utils/id.ts +15 -0
- package/src/utils/index.ts +101 -0
- package/src/utils/logger.ts +313 -0
- package/src/utils/sanitization.ts +501 -0
- package/src/utils/secret-validation.ts +273 -0
- package/src/utils/synonyms.ts +188 -0
- package/src/utils/validation.ts +581 -0
- package/src/workers/chunking.worker.ts +242 -0
- package/src/workers/embedding.worker.ts +358 -0
- package/src/workers/extraction.worker.ts +346 -0
- package/src/workers/indexing.worker.ts +505 -0
- package/tsconfig.json +38 -0
package/src/sdk/types.ts
ADDED
|
@@ -0,0 +1,674 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Supermemory SDK Type Definitions
|
|
3
|
+
* Drop-in replacement for the official supermemory npm package
|
|
4
|
+
*
|
|
5
|
+
* @version 1.0.0
|
|
6
|
+
* @apiVersion v1
|
|
7
|
+
*
|
|
8
|
+
* API Version Notes:
|
|
9
|
+
* - This SDK targets API v1 endpoints (e.g., /v1/memories, /v1/search)
|
|
10
|
+
* - All types are designed to be compatible with the Supermemory API v1
|
|
11
|
+
* - For future API versions, create a separate types file (e.g., types.v2.ts)
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
// ============================================================================
|
|
15
|
+
// Common Types
|
|
16
|
+
// ============================================================================
|
|
17
|
+
|
|
18
|
+
export interface Metadata {
|
|
19
|
+
[key: string]: string | number | boolean | string[]
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface Pagination {
|
|
23
|
+
currentPage: number
|
|
24
|
+
limit: number
|
|
25
|
+
totalItems: number
|
|
26
|
+
totalPages: number
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface Chunk {
|
|
30
|
+
content: string
|
|
31
|
+
isRelevant: boolean
|
|
32
|
+
score: number
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// ============================================================================
|
|
36
|
+
// Filter Types
|
|
37
|
+
// ============================================================================
|
|
38
|
+
|
|
39
|
+
export interface FilterCondition {
|
|
40
|
+
key: string
|
|
41
|
+
value: string | number | boolean
|
|
42
|
+
filterType?: 'exact' | 'contains' | 'startsWith' | 'endsWith'
|
|
43
|
+
ignoreCase?: boolean
|
|
44
|
+
negate?: boolean
|
|
45
|
+
numericOperator?: 'eq' | 'ne' | 'gt' | 'gte' | 'lt' | 'lte'
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface OrFilter {
|
|
49
|
+
or: Array<FilterCondition | OrFilter | AndFilter>
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface AndFilter {
|
|
53
|
+
and: Array<FilterCondition | OrFilter | AndFilter>
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export type Filter = OrFilter | AndFilter
|
|
57
|
+
|
|
58
|
+
// ============================================================================
|
|
59
|
+
// Add Types
|
|
60
|
+
// ============================================================================
|
|
61
|
+
|
|
62
|
+
export interface AddParams {
|
|
63
|
+
/**
|
|
64
|
+
* The content to extract and process into a document.
|
|
65
|
+
* This can be a URL to a website, a PDF, an image, or a video.
|
|
66
|
+
*/
|
|
67
|
+
content: string
|
|
68
|
+
/**
|
|
69
|
+
* Tag for document organization (max 100 characters, alphanumeric with hyphens/underscores)
|
|
70
|
+
*/
|
|
71
|
+
containerTag?: string
|
|
72
|
+
/**
|
|
73
|
+
* @deprecated Use containerTag instead
|
|
74
|
+
*/
|
|
75
|
+
containerTags?: string[]
|
|
76
|
+
/**
|
|
77
|
+
* Custom identifier (max 100 characters, alphanumeric with hyphens/underscores)
|
|
78
|
+
*/
|
|
79
|
+
customId?: string
|
|
80
|
+
/**
|
|
81
|
+
* Key-value pairs for document metadata
|
|
82
|
+
*/
|
|
83
|
+
metadata?: Metadata
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export interface AddResponse {
|
|
87
|
+
/** Unique identifier of the document */
|
|
88
|
+
id: string
|
|
89
|
+
/** Status of the document */
|
|
90
|
+
status: string
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// ============================================================================
|
|
94
|
+
// Profile Types
|
|
95
|
+
// ============================================================================
|
|
96
|
+
|
|
97
|
+
export interface ProfileParams {
|
|
98
|
+
/**
|
|
99
|
+
* Tag to filter the profile by. This can be an ID for your user,
|
|
100
|
+
* a project ID, or any other identifier
|
|
101
|
+
*/
|
|
102
|
+
containerTag: string
|
|
103
|
+
/**
|
|
104
|
+
* Optional search query parameter
|
|
105
|
+
*/
|
|
106
|
+
q?: string
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export interface ProfileMemory {
|
|
110
|
+
id: string
|
|
111
|
+
content: string
|
|
112
|
+
createdAt: string
|
|
113
|
+
updatedAt: string
|
|
114
|
+
metadata?: Metadata | null
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export interface Profile {
|
|
118
|
+
/** Recent memories */
|
|
119
|
+
dynamic: ProfileMemory[]
|
|
120
|
+
/** Long-term relevant information */
|
|
121
|
+
static: ProfileMemory[]
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export interface SearchResultItem {
|
|
125
|
+
chunks: Chunk[]
|
|
126
|
+
createdAt: string
|
|
127
|
+
documentId: string
|
|
128
|
+
metadata: Metadata | null
|
|
129
|
+
score: number
|
|
130
|
+
title: string | null
|
|
131
|
+
type: string | null
|
|
132
|
+
updatedAt: string
|
|
133
|
+
content?: string | null
|
|
134
|
+
summary?: string | null
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export interface SearchResults {
|
|
138
|
+
results: SearchResultItem[]
|
|
139
|
+
timing: number
|
|
140
|
+
total: number
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export interface ProfileResponse {
|
|
144
|
+
profile: Profile
|
|
145
|
+
searchResults?: SearchResults
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// ============================================================================
|
|
149
|
+
// Search Types
|
|
150
|
+
// ============================================================================
|
|
151
|
+
|
|
152
|
+
export interface SearchDocumentsParams {
|
|
153
|
+
/** Search query string */
|
|
154
|
+
q: string
|
|
155
|
+
/**
|
|
156
|
+
* @deprecated Use containerTags instead
|
|
157
|
+
*/
|
|
158
|
+
categoriesFilter?: string[]
|
|
159
|
+
/** Minimum chunk relevance score threshold */
|
|
160
|
+
chunkThreshold?: number
|
|
161
|
+
/** Filter by container tags */
|
|
162
|
+
containerTags?: string[]
|
|
163
|
+
/** Filter by specific document ID */
|
|
164
|
+
docId?: string
|
|
165
|
+
/**
|
|
166
|
+
* @deprecated Use chunkThreshold instead
|
|
167
|
+
*/
|
|
168
|
+
documentThreshold?: number
|
|
169
|
+
/** Complex filter expression */
|
|
170
|
+
filters?: Filter
|
|
171
|
+
/** Include full document content in results */
|
|
172
|
+
includeFullDocs?: boolean
|
|
173
|
+
/** Include document summaries in results */
|
|
174
|
+
includeSummary?: boolean
|
|
175
|
+
/** Maximum number of results */
|
|
176
|
+
limit?: number
|
|
177
|
+
/** Return only chunks that match the query */
|
|
178
|
+
onlyMatchingChunks?: boolean
|
|
179
|
+
/** Enable result reranking for better relevance */
|
|
180
|
+
rerank?: boolean
|
|
181
|
+
/** Rewrite query for better search */
|
|
182
|
+
rewriteQuery?: boolean
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export interface SearchDocumentsResponse {
|
|
186
|
+
results: SearchResultItem[]
|
|
187
|
+
timing: number
|
|
188
|
+
total: number
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export interface SearchMemoriesParams {
|
|
192
|
+
/** Search query string */
|
|
193
|
+
q: string
|
|
194
|
+
/** Filter by container tags */
|
|
195
|
+
containerTags?: string[]
|
|
196
|
+
/** Complex filter expression */
|
|
197
|
+
filters?: Filter
|
|
198
|
+
/** Maximum number of results */
|
|
199
|
+
limit?: number
|
|
200
|
+
/** Enable result reranking */
|
|
201
|
+
rerank?: boolean
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export interface MemoryResult {
|
|
205
|
+
id: string
|
|
206
|
+
metadata: Metadata | null
|
|
207
|
+
similarity: number
|
|
208
|
+
updatedAt: string
|
|
209
|
+
chunk?: Chunk
|
|
210
|
+
chunks?: Chunk[]
|
|
211
|
+
context?: string
|
|
212
|
+
documents?: string[]
|
|
213
|
+
memory?: string
|
|
214
|
+
version?: number
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export interface SearchMemoriesResponse {
|
|
218
|
+
results: MemoryResult[]
|
|
219
|
+
timing: number
|
|
220
|
+
total: number
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// Alias for execute method (same as documents)
|
|
224
|
+
export type SearchExecuteParams = SearchDocumentsParams
|
|
225
|
+
export type SearchExecuteResponse = SearchDocumentsResponse
|
|
226
|
+
|
|
227
|
+
// ============================================================================
|
|
228
|
+
// Document Types
|
|
229
|
+
// ============================================================================
|
|
230
|
+
|
|
231
|
+
export interface Document {
|
|
232
|
+
id: string
|
|
233
|
+
content: string
|
|
234
|
+
createdAt: string
|
|
235
|
+
updatedAt: string
|
|
236
|
+
title?: string | null
|
|
237
|
+
type?: string | null
|
|
238
|
+
status: string
|
|
239
|
+
metadata?: Metadata | null
|
|
240
|
+
customId?: string | null
|
|
241
|
+
containerTag?: string | null
|
|
242
|
+
summary?: string | null
|
|
243
|
+
chunks?: Chunk[]
|
|
244
|
+
embedding?: number[]
|
|
245
|
+
source?: string | null
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
export interface DocumentListParams {
|
|
249
|
+
/** Filter by container tags */
|
|
250
|
+
containerTags?: string[]
|
|
251
|
+
/** Complex filter expression */
|
|
252
|
+
filters?: Filter
|
|
253
|
+
/** Include document content in response */
|
|
254
|
+
includeContent?: boolean
|
|
255
|
+
/** Maximum results per page */
|
|
256
|
+
limit?: number
|
|
257
|
+
/** Page number (1-indexed) */
|
|
258
|
+
page?: number
|
|
259
|
+
/** Sort field */
|
|
260
|
+
sort?: string
|
|
261
|
+
/** Sort order */
|
|
262
|
+
order?: 'asc' | 'desc'
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
export interface DocumentListResponse {
|
|
266
|
+
documents: Document[]
|
|
267
|
+
pagination: Pagination
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
export interface DocumentUpdateParams {
|
|
271
|
+
/** Updated content */
|
|
272
|
+
content?: string
|
|
273
|
+
/** Updated container tag */
|
|
274
|
+
containerTag?: string
|
|
275
|
+
/**
|
|
276
|
+
* @deprecated Use containerTag instead
|
|
277
|
+
*/
|
|
278
|
+
containerTags?: string[]
|
|
279
|
+
/** Updated custom ID */
|
|
280
|
+
customId?: string
|
|
281
|
+
/** Updated metadata */
|
|
282
|
+
metadata?: Metadata
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
export interface DocumentUpdateResponse {
|
|
286
|
+
id: string
|
|
287
|
+
status: string
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
export interface DocumentAddParams extends AddParams {}
|
|
291
|
+
|
|
292
|
+
export interface DocumentAddResponse extends AddResponse {}
|
|
293
|
+
|
|
294
|
+
export interface DocumentBatchAddParams {
|
|
295
|
+
documents: AddParams[]
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
export interface DocumentBatchAddResponse {
|
|
299
|
+
documents: AddResponse[]
|
|
300
|
+
failed: Array<{
|
|
301
|
+
index: number
|
|
302
|
+
error: string
|
|
303
|
+
}>
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
export interface DocumentDeleteBulkParams {
|
|
307
|
+
/** Document IDs to delete */
|
|
308
|
+
ids?: string[]
|
|
309
|
+
/** Delete all documents with these container tags */
|
|
310
|
+
containerTags?: string[]
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
export interface DocumentDeleteBulkResponse {
|
|
314
|
+
deleted: number
|
|
315
|
+
ids: string[]
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
export interface DocumentGetResponse extends Document {}
|
|
319
|
+
|
|
320
|
+
export interface DocumentListProcessingResponse {
|
|
321
|
+
documents: Array<{
|
|
322
|
+
id: string
|
|
323
|
+
status: string
|
|
324
|
+
progress?: number
|
|
325
|
+
createdAt: string
|
|
326
|
+
}>
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
export interface DocumentUploadFileParams {
|
|
330
|
+
/** File to upload */
|
|
331
|
+
file: Uploadable
|
|
332
|
+
/** Container tag for organization */
|
|
333
|
+
containerTag?: string
|
|
334
|
+
/** Custom ID for the document */
|
|
335
|
+
customId?: string
|
|
336
|
+
/** Document metadata */
|
|
337
|
+
metadata?: Metadata
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
export interface DocumentUploadFileResponse extends AddResponse {}
|
|
341
|
+
|
|
342
|
+
// ============================================================================
|
|
343
|
+
// Memory Types
|
|
344
|
+
// ============================================================================
|
|
345
|
+
|
|
346
|
+
export interface Memory {
|
|
347
|
+
id: string
|
|
348
|
+
content: string
|
|
349
|
+
createdAt: string
|
|
350
|
+
updatedAt: string
|
|
351
|
+
metadata?: Metadata | null
|
|
352
|
+
version?: number
|
|
353
|
+
parentMemoryId?: string | null
|
|
354
|
+
rootMemoryId?: string | null
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
export interface MemoryListParams {
|
|
358
|
+
/** Filter by container tags */
|
|
359
|
+
containerTags?: string[]
|
|
360
|
+
/** Complex filter expression */
|
|
361
|
+
filters?: Filter
|
|
362
|
+
/** Include memory content in response */
|
|
363
|
+
includeContent?: boolean
|
|
364
|
+
/** Maximum results per page */
|
|
365
|
+
limit?: number
|
|
366
|
+
/** Page number (1-indexed) */
|
|
367
|
+
page?: number
|
|
368
|
+
/** Sort field */
|
|
369
|
+
sort?: string
|
|
370
|
+
/** Sort order */
|
|
371
|
+
order?: 'asc' | 'desc'
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
export interface MemoryListResponse {
|
|
375
|
+
memories: Memory[]
|
|
376
|
+
pagination: Pagination
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
export interface MemoryAddParams extends AddParams {}
|
|
380
|
+
|
|
381
|
+
export interface MemoryAddResponse extends AddResponse {}
|
|
382
|
+
|
|
383
|
+
export interface MemoryUpdateParams {
|
|
384
|
+
/** Updated content */
|
|
385
|
+
content?: string
|
|
386
|
+
/** Updated container tag */
|
|
387
|
+
containerTag?: string
|
|
388
|
+
/**
|
|
389
|
+
* @deprecated Use containerTag instead
|
|
390
|
+
*/
|
|
391
|
+
containerTags?: string[]
|
|
392
|
+
/** Updated custom ID */
|
|
393
|
+
customId?: string
|
|
394
|
+
/** Updated metadata */
|
|
395
|
+
metadata?: Metadata
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
export interface MemoryUpdateResponse {
|
|
399
|
+
id: string
|
|
400
|
+
status: string
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
export interface MemoryForgetParams {
|
|
404
|
+
/** Memory ID to forget */
|
|
405
|
+
id: string
|
|
406
|
+
/** Optional reason for forgetting */
|
|
407
|
+
reason?: string
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
export interface MemoryForgetResponse {
|
|
411
|
+
id: string
|
|
412
|
+
forgotten: boolean
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
export interface MemoryGetResponse extends Memory {}
|
|
416
|
+
|
|
417
|
+
export interface MemoryUpdateMemoryParams {
|
|
418
|
+
/** Memory ID to update */
|
|
419
|
+
id: string
|
|
420
|
+
/** New memory content */
|
|
421
|
+
memory: string
|
|
422
|
+
/** Optional metadata update */
|
|
423
|
+
metadata?: Metadata
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
export interface MemoryUpdateMemoryResponse {
|
|
427
|
+
id: string
|
|
428
|
+
createdAt: string
|
|
429
|
+
memory: string
|
|
430
|
+
parentMemoryId: string | null
|
|
431
|
+
rootMemoryId: string | null
|
|
432
|
+
version: number
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
export interface MemoryUploadFileParams extends DocumentUploadFileParams {}
|
|
436
|
+
|
|
437
|
+
export interface MemoryUploadFileResponse extends AddResponse {}
|
|
438
|
+
|
|
439
|
+
// ============================================================================
|
|
440
|
+
// Connection Types
|
|
441
|
+
// ============================================================================
|
|
442
|
+
|
|
443
|
+
export type ConnectionProvider = 'github' | 'gmail' | 'google-drive' | 'notion' | 'onedrive' | 's3' | 'web-crawler'
|
|
444
|
+
|
|
445
|
+
export interface Connection {
|
|
446
|
+
id: string
|
|
447
|
+
createdAt: string
|
|
448
|
+
provider: ConnectionProvider | string
|
|
449
|
+
documentLimit?: number
|
|
450
|
+
email?: string
|
|
451
|
+
expiresAt?: string
|
|
452
|
+
metadata?: Metadata
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
export interface ConnectionCreateParams {
|
|
456
|
+
/** Container tags for organizing connected resources */
|
|
457
|
+
containerTags?: string[]
|
|
458
|
+
/** Maximum documents to sync */
|
|
459
|
+
documentLimit?: number
|
|
460
|
+
/** Connection metadata */
|
|
461
|
+
metadata?: Metadata
|
|
462
|
+
/** OAuth redirect URL */
|
|
463
|
+
redirectUrl?: string
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
export interface ConnectionCreateResponse {
|
|
467
|
+
id: string
|
|
468
|
+
authLink: string
|
|
469
|
+
expiresIn: number
|
|
470
|
+
redirectsTo?: string
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
export interface ConnectionListParams {
|
|
474
|
+
/** Filter by container tags */
|
|
475
|
+
containerTags?: string[]
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
export type ConnectionListResponse = Connection[]
|
|
479
|
+
|
|
480
|
+
export interface ConnectionConfigureParams {
|
|
481
|
+
/** Resources to configure */
|
|
482
|
+
resources: Array<Record<string, unknown>>
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
export interface ConnectionConfigureResponse {
|
|
486
|
+
id: string
|
|
487
|
+
configured: boolean
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
export interface ConnectionDeleteByIDResponse {
|
|
491
|
+
id: string
|
|
492
|
+
provider: string
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
export interface ConnectionDeleteByProviderParams {
|
|
496
|
+
/** Container tags to filter which connections to delete */
|
|
497
|
+
containerTags: string[]
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
export interface ConnectionDeleteByProviderResponse {
|
|
501
|
+
id: string
|
|
502
|
+
provider: string
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
export interface ConnectionGetByIDResponse extends Connection {}
|
|
506
|
+
|
|
507
|
+
export interface ConnectionGetByTagParams {
|
|
508
|
+
/** Container tags to filter */
|
|
509
|
+
containerTags: string[]
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
export interface ConnectionGetByTagResponse extends Connection {}
|
|
513
|
+
|
|
514
|
+
export interface ConnectionImportParams {
|
|
515
|
+
/** Container tags for imported resources */
|
|
516
|
+
containerTags?: string[]
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
export interface ConnectionImportResponse {
|
|
520
|
+
imported: number
|
|
521
|
+
failed: number
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
export interface ConnectionListDocumentsParams {
|
|
525
|
+
/** Filter by container tags */
|
|
526
|
+
containerTags?: string[]
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
export interface ConnectionListDocumentsResponse {
|
|
530
|
+
documents: Document[]
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
export interface ConnectionResourcesParams {
|
|
534
|
+
/** Page number */
|
|
535
|
+
page?: number
|
|
536
|
+
/** Results per page */
|
|
537
|
+
per_page?: number
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
export interface ConnectionResource {
|
|
541
|
+
id: string
|
|
542
|
+
name: string
|
|
543
|
+
type: string
|
|
544
|
+
metadata?: Metadata
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
export interface ConnectionResourcesResponse {
|
|
548
|
+
resources: ConnectionResource[]
|
|
549
|
+
total_count?: number
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
// ============================================================================
|
|
553
|
+
// Settings Types
|
|
554
|
+
// ============================================================================
|
|
555
|
+
|
|
556
|
+
export interface Settings {
|
|
557
|
+
organizationId: string
|
|
558
|
+
defaultContainerTag?: string
|
|
559
|
+
webhookUrl?: string
|
|
560
|
+
enableAutoSync?: boolean
|
|
561
|
+
syncInterval?: number
|
|
562
|
+
metadata?: Metadata
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
export interface SettingUpdateParams {
|
|
566
|
+
defaultContainerTag?: string
|
|
567
|
+
webhookUrl?: string
|
|
568
|
+
enableAutoSync?: boolean
|
|
569
|
+
syncInterval?: number
|
|
570
|
+
metadata?: Metadata
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
export interface SettingUpdateResponse extends Settings {}
|
|
574
|
+
|
|
575
|
+
export interface SettingGetResponse extends Settings {}
|
|
576
|
+
|
|
577
|
+
// ============================================================================
|
|
578
|
+
// Client Types
|
|
579
|
+
// ============================================================================
|
|
580
|
+
|
|
581
|
+
export type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'off'
|
|
582
|
+
|
|
583
|
+
export interface Logger {
|
|
584
|
+
debug: (message: string, ...args: unknown[]) => void
|
|
585
|
+
info: (message: string, ...args: unknown[]) => void
|
|
586
|
+
warn: (message: string, ...args: unknown[]) => void
|
|
587
|
+
error: (message: string, ...args: unknown[]) => void
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
export interface ClientOptions {
|
|
591
|
+
/** API key for authentication */
|
|
592
|
+
apiKey?: string
|
|
593
|
+
/** Base URL for API requests */
|
|
594
|
+
baseURL?: string
|
|
595
|
+
/** Request timeout in milliseconds */
|
|
596
|
+
timeout?: number
|
|
597
|
+
/** Maximum number of retry attempts */
|
|
598
|
+
maxRetries?: number
|
|
599
|
+
/** Default headers for all requests */
|
|
600
|
+
defaultHeaders?: Record<string, string>
|
|
601
|
+
/** Default query parameters for all requests */
|
|
602
|
+
defaultQuery?: Record<string, string>
|
|
603
|
+
/** Custom fetch implementation */
|
|
604
|
+
fetch?: typeof fetch
|
|
605
|
+
/** Additional fetch options */
|
|
606
|
+
fetchOptions?: RequestInit
|
|
607
|
+
/** Logging level */
|
|
608
|
+
logLevel?: LogLevel
|
|
609
|
+
/** Custom logger instance */
|
|
610
|
+
logger?: Logger
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
export interface RequestOptions {
|
|
614
|
+
/** Request timeout override */
|
|
615
|
+
timeout?: number
|
|
616
|
+
/** Maximum retries override */
|
|
617
|
+
maxRetries?: number
|
|
618
|
+
/** Additional headers for this request */
|
|
619
|
+
headers?: Record<string, string>
|
|
620
|
+
/** Signal for request cancellation */
|
|
621
|
+
signal?: AbortSignal
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
// ============================================================================
|
|
625
|
+
// File Upload Types
|
|
626
|
+
// ============================================================================
|
|
627
|
+
|
|
628
|
+
/**
|
|
629
|
+
* Represents content that can be uploaded as a file
|
|
630
|
+
*/
|
|
631
|
+
export type Uploadable =
|
|
632
|
+
| File
|
|
633
|
+
| Blob
|
|
634
|
+
| NodeJS.ReadableStream
|
|
635
|
+
| Buffer
|
|
636
|
+
| ArrayBuffer
|
|
637
|
+
| Uint8Array
|
|
638
|
+
| ReadableStream<Uint8Array>
|
|
639
|
+
|
|
640
|
+
export interface ToFileOptions {
|
|
641
|
+
/** Filename for the upload */
|
|
642
|
+
filename?: string
|
|
643
|
+
/** Content type of the file */
|
|
644
|
+
contentType?: string
|
|
645
|
+
/** Last modified timestamp */
|
|
646
|
+
lastModified?: number
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
// ============================================================================
|
|
650
|
+
// API Promise Types
|
|
651
|
+
// ============================================================================
|
|
652
|
+
|
|
653
|
+
/**
|
|
654
|
+
* Properties for constructing an APIPromise.
|
|
655
|
+
* Used internally by the SDK client to wrap async API responses.
|
|
656
|
+
*
|
|
657
|
+
* @template T - The expected response type after parsing
|
|
658
|
+
* @internal This type is used by the SDK infrastructure and may be
|
|
659
|
+
* removed if not used in client implementation.
|
|
660
|
+
*
|
|
661
|
+
* @example
|
|
662
|
+
* ```typescript
|
|
663
|
+
* const props: APIPromiseProps<SearchResponse> = {
|
|
664
|
+
* responsePromise: fetch('/v1/search'),
|
|
665
|
+
* parseResponse: async (res) => res.json() as SearchResponse
|
|
666
|
+
* };
|
|
667
|
+
* ```
|
|
668
|
+
*/
|
|
669
|
+
export interface APIPromiseProps<T> {
|
|
670
|
+
/** The underlying fetch promise for the API request */
|
|
671
|
+
responsePromise: Promise<Response>
|
|
672
|
+
/** Function to parse the raw Response into the expected type T */
|
|
673
|
+
parseResponse: (response: Response) => Promise<T>
|
|
674
|
+
}
|