@clude/sdk 3.0.4 → 3.3.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/cli/index.js +3992 -661
- package/dist/mcp/local-store.d.ts +74 -0
- package/dist/mcp/server.d.ts +1 -0
- package/dist/mcp/server.js +2450 -274
- package/dist/sdk/cortex-v2.d.ts +120 -0
- package/dist/sdk/cortex.d.ts +63 -0
- package/dist/sdk/http-transport.d.ts +14 -0
- package/dist/sdk/index.d.ts +4 -0
- package/dist/sdk/index.js +2523 -408
- package/dist/sdk/memory-types.d.ts +321 -0
- package/dist/sdk/sdk-mode.d.ts +1 -0
- package/dist/sdk/shared-constants.d.ts +53 -0
- package/dist/sdk/types.d.ts +47 -0
- package/package.json +8 -17
- package/supabase-schema.sql +276 -12
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
import type { MemoryLinkType } from './shared-constants';
|
|
2
|
+
/** @internal Set the owner wallet address for tagging memories. */
|
|
3
|
+
export declare function _setOwnerWallet(wallet: string): void;
|
|
4
|
+
/** Get the configured owner wallet, if any. Checks async context first (hosted API), then module-level (SDK/bot). */
|
|
5
|
+
export declare function getOwnerWallet(): string | null;
|
|
6
|
+
/**
|
|
7
|
+
* Apply owner_wallet scoping to a Supabase query builder.
|
|
8
|
+
* When an owner wallet is set, filters to only that wallet's memories.
|
|
9
|
+
* When null, no filter is applied (backward-compatible).
|
|
10
|
+
*/
|
|
11
|
+
/** Sentinel value: scope to memories where owner_wallet IS NULL (bot's own). */
|
|
12
|
+
export declare const SCOPE_BOT_OWN = "__BOT_OWN__";
|
|
13
|
+
/**
|
|
14
|
+
* Owner-scope fail-closed flag (Memory 3.0 C0). Read live so benchmarks and
|
|
15
|
+
* staged rollouts can flip it without a rebuild. When ON, "no owner in scope"
|
|
16
|
+
* resolves to SCOPE_BOT_OWN (the bot's own memories) instead of null (no
|
|
17
|
+
* filter = every tenant's memories, the fail-open half of the PR #290 class).
|
|
18
|
+
*/
|
|
19
|
+
export declare function isOwnerScopeFailClosed(): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Effective owner scope for READ paths: a tenant wallet, SCOPE_BOT_OWN, or null.
|
|
22
|
+
* Null (legacy fail-open) survives only while the flag is off. Migration 019
|
|
23
|
+
* teaches the recall RPCs the sentinel; against an older RPC the sentinel
|
|
24
|
+
* matches zero rows, so an early flip fails CLOSED, never cross-tenant.
|
|
25
|
+
*
|
|
26
|
+
* WRITE paths must keep using getOwnerWallet() (the sentinel is a filter,
|
|
27
|
+
* never a value to store — bot rows stay owner_wallet NULL).
|
|
28
|
+
*/
|
|
29
|
+
export declare function getOwnerScope(): string | null;
|
|
30
|
+
export declare function scopeToOwner<T>(query: T): T;
|
|
31
|
+
/**
|
|
32
|
+
* Owner post-guard (defense-in-depth, Memory 3.0 C0): strips rows that escaped
|
|
33
|
+
* RPC-level scoping via the entity / graph / fragment expansion paths. Pure so
|
|
34
|
+
* it is directly testable; recallMemories applies it after every phase merged.
|
|
35
|
+
*/
|
|
36
|
+
export declare function applyOwnerPostGuard<T extends {
|
|
37
|
+
owner_wallet?: string | null;
|
|
38
|
+
}>(results: T[], scope: string | null): {
|
|
39
|
+
kept: T[];
|
|
40
|
+
stripped: number;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* BENCH_MODE (Memory 3.0 C0): read-only recall. Benchmarks must observe the
|
|
44
|
+
* corpus, not mutate it — access boosts (access_count / last_accessed /
|
|
45
|
+
* decay_factor bumps) and Hebbian link reinforcement change retrieval state on
|
|
46
|
+
* every read, which is why a reused seeded wallet drifts (+2.6pp measured from
|
|
47
|
+
* data freshness alone). The harness preflight asserts this is set; prod never
|
|
48
|
+
* sets it.
|
|
49
|
+
*/
|
|
50
|
+
export declare function isBenchMode(): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Should this recall mutate read-state? Callers pass RecallOptions; BENCH_MODE
|
|
53
|
+
* overrides everything. Pure, exported for tests.
|
|
54
|
+
*/
|
|
55
|
+
export declare function shouldTrackAccess(opts: {
|
|
56
|
+
trackAccess?: boolean;
|
|
57
|
+
}): boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Fragment-lane RPC args (Memory 3.0 C0 / P0.3 fragment parity). The extended
|
|
60
|
+
* filters (min_decay, filter_types) exist only in the migration-043 signature
|
|
61
|
+
* of match_memory_fragments; PostgREST matches RPCs by named args, so sending
|
|
62
|
+
* them to the old 4-arg function finds no match and the lane dies. Flip
|
|
63
|
+
* MEMORY_FRAGMENT_FILTERS=true only AFTER 043 is applied. The reverse is safe:
|
|
64
|
+
* old-style 4-arg calls keep working against the new function via parameter
|
|
65
|
+
* defaults, so the flip is one-way and the flag can be retired later.
|
|
66
|
+
*/
|
|
67
|
+
export declare function buildFragmentRpcArgs(opts: {
|
|
68
|
+
embeddingJson: string;
|
|
69
|
+
matchThreshold: number;
|
|
70
|
+
matchCount: number;
|
|
71
|
+
minDecay: number;
|
|
72
|
+
memoryTypes?: string[] | null;
|
|
73
|
+
}): Record<string, unknown>;
|
|
74
|
+
/**
|
|
75
|
+
* Generate a collision-resistant hash ID for a memory.
|
|
76
|
+
* Format: clude-xxxxxxxx (8 hex chars = 4 bytes = 4 billion possibilities)
|
|
77
|
+
*/
|
|
78
|
+
export declare function generateHashId(): string;
|
|
79
|
+
/**
|
|
80
|
+
* Validate a hash ID format.
|
|
81
|
+
*/
|
|
82
|
+
export declare function isValidHashId(id: string): boolean;
|
|
83
|
+
export type MemoryType = 'episodic' | 'semantic' | 'procedural' | 'self_model' | 'introspective';
|
|
84
|
+
export interface Memory {
|
|
85
|
+
id: number;
|
|
86
|
+
hash_id: string;
|
|
87
|
+
memory_type: MemoryType;
|
|
88
|
+
content: string;
|
|
89
|
+
summary: string;
|
|
90
|
+
tags: string[];
|
|
91
|
+
concepts: string[];
|
|
92
|
+
emotional_valence: number;
|
|
93
|
+
importance: number;
|
|
94
|
+
access_count: number;
|
|
95
|
+
source: string;
|
|
96
|
+
source_id: string | null;
|
|
97
|
+
related_user: string | null;
|
|
98
|
+
related_wallet: string | null;
|
|
99
|
+
metadata: Record<string, unknown>;
|
|
100
|
+
created_at: string;
|
|
101
|
+
last_accessed: string;
|
|
102
|
+
decay_factor: number;
|
|
103
|
+
evidence_ids: number[];
|
|
104
|
+
solana_signature: string | null;
|
|
105
|
+
compacted: boolean;
|
|
106
|
+
compacted_into: string | null;
|
|
107
|
+
encrypted: boolean;
|
|
108
|
+
encryption_pubkey: string | null;
|
|
109
|
+
owner_wallet?: string | null;
|
|
110
|
+
link_path?: Array<'vector' | 'bm25' | 'entity' | 'jepa'>;
|
|
111
|
+
}
|
|
112
|
+
/** Lightweight memory summary for progressive disclosure (no content field). */
|
|
113
|
+
export interface MemorySummary {
|
|
114
|
+
id: number;
|
|
115
|
+
memory_type: MemoryType;
|
|
116
|
+
summary: string;
|
|
117
|
+
tags: string[];
|
|
118
|
+
concepts: string[];
|
|
119
|
+
importance: number;
|
|
120
|
+
decay_factor: number;
|
|
121
|
+
created_at: string;
|
|
122
|
+
source: string;
|
|
123
|
+
}
|
|
124
|
+
export interface StoreMemoryOptions {
|
|
125
|
+
type: MemoryType;
|
|
126
|
+
content: string;
|
|
127
|
+
summary: string;
|
|
128
|
+
tags?: string[];
|
|
129
|
+
concepts?: string[];
|
|
130
|
+
emotionalValence?: number;
|
|
131
|
+
importance?: number;
|
|
132
|
+
source: string;
|
|
133
|
+
sourceId?: string;
|
|
134
|
+
relatedUser?: string;
|
|
135
|
+
relatedWallet?: string;
|
|
136
|
+
metadata?: Record<string, unknown>;
|
|
137
|
+
evidenceIds?: number[];
|
|
138
|
+
}
|
|
139
|
+
export interface RecallOptions {
|
|
140
|
+
query?: string;
|
|
141
|
+
tags?: string[];
|
|
142
|
+
relatedUser?: string;
|
|
143
|
+
relatedWallet?: string;
|
|
144
|
+
memoryTypes?: MemoryType[];
|
|
145
|
+
limit?: number;
|
|
146
|
+
minImportance?: number;
|
|
147
|
+
minDecay?: number;
|
|
148
|
+
/** Skip access tracking (prevents decay reset). Use for internal processing like dream cycles. */
|
|
149
|
+
trackAccess?: boolean;
|
|
150
|
+
/** Pre-computed vector similarity scores from hybrid search (internal use). */
|
|
151
|
+
_vectorScores?: Map<number, number>;
|
|
152
|
+
/** Pre-computed BM25 rank scores from full-text search (internal use). */
|
|
153
|
+
_bm25Scores?: Map<number, number>;
|
|
154
|
+
/** Skip LLM-based query expansion for faster recall (saves ~500-800ms). */
|
|
155
|
+
skipExpansion?: boolean;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Auto-classify memories into structured concepts using keyword heuristics.
|
|
159
|
+
* Provides consistent cross-cutting knowledge labels without LLM cost.
|
|
160
|
+
* Concepts are additive to freeform tags, not a replacement.
|
|
161
|
+
*/
|
|
162
|
+
export declare function inferConcepts(summary: string, source: string, tags: string[]): string[];
|
|
163
|
+
export declare function scoreImportanceOnWrite(opts: StoreMemoryOptions): number;
|
|
164
|
+
/** Test/admin helper: clear the installed-packs cache (e.g. after install/uninstall). */
|
|
165
|
+
export declare function invalidateInstalledPacksCache(ownerWallet?: string): void;
|
|
166
|
+
export declare function storeMemory(opts: StoreMemoryOptions): Promise<number | null>;
|
|
167
|
+
/** @internal test-only reset for the once-guard. */
|
|
168
|
+
export declare function _resetOutboxDegradeLog(): void;
|
|
169
|
+
/**
|
|
170
|
+
* Memory 3.0 C2: the enrichment pipeline the outbox worker runs for an 'enrich' job, in
|
|
171
|
+
* dependency order (autoLinkMemory reads the memory's own embedding, written by embedMemory).
|
|
172
|
+
* Sequential + awaited (unlike the fire-and-forget triad) so a whole-job retry re-runs all three;
|
|
173
|
+
* each step is idempotent (embed delete-before-insert, link unique-index upsert, extract
|
|
174
|
+
* upsert-RPC). The caller (outbox-worker) wraps this in withOwnerWallet(job owner) so the
|
|
175
|
+
* ambient owner scope is correct off the poller tick.
|
|
176
|
+
*/
|
|
177
|
+
export declare function runEnrichPipeline(memoryId: number, opts: StoreMemoryOptions): Promise<void>;
|
|
178
|
+
/**
|
|
179
|
+
* storeMemory + outbox status, for callers that want the {hash_id, jobs_queued} shape (the design
|
|
180
|
+
* contract). storeMemory itself keeps its number|null signature (zero call-site churn); this thin
|
|
181
|
+
* wrapper reads the ground truth back: jobs_queued counts the memory's outbox rows (1 when the
|
|
182
|
+
* enrich job enqueued, 0 when the flag is off or the enqueue degraded to fire-and-forget).
|
|
183
|
+
*/
|
|
184
|
+
export declare function storeMemoryWithOutbox(opts: StoreMemoryOptions): Promise<{
|
|
185
|
+
id: number;
|
|
186
|
+
hash_id: string;
|
|
187
|
+
jobs_queued: number;
|
|
188
|
+
} | null>;
|
|
189
|
+
export declare function recallMemories(opts: RecallOptions): Promise<Memory[]>;
|
|
190
|
+
/**
|
|
191
|
+
* Enhanced scoring function with optional vector similarity component.
|
|
192
|
+
*
|
|
193
|
+
* Unified formula (vector weight always in denominator when search was performed):
|
|
194
|
+
* score = (w_recency * recency + w_relevance * keyword_rel
|
|
195
|
+
* + w_importance * importance + w_vector * vector_sim) / sum(weights) * decay
|
|
196
|
+
*
|
|
197
|
+
* When vector search wasn't performed (graceful fallback):
|
|
198
|
+
* score = (w_recency * recency + w_relevance * keyword_rel
|
|
199
|
+
* + w_importance * importance) / sum(weights_no_vector) * decay
|
|
200
|
+
*
|
|
201
|
+
* Key: memories not found by vector search score lower (vectorSim=0 in numerator,
|
|
202
|
+
* but VECTOR weight still in denominator), naturally penalizing noise.
|
|
203
|
+
*/
|
|
204
|
+
export declare function scoreMemory(mem: Memory, opts: RecallOptions): number;
|
|
205
|
+
/**
|
|
206
|
+
* Lightweight recall that returns only summaries (~50 tokens each).
|
|
207
|
+
* Use for dream cycle focal point generation, overview scans, and
|
|
208
|
+
* anywhere full content isn't needed. 10x more token-efficient than full recall.
|
|
209
|
+
*
|
|
210
|
+
* Call hydrateMemories() to fetch full content for selected IDs.
|
|
211
|
+
*/
|
|
212
|
+
export declare function recallMemorySummaries(opts: RecallOptions): Promise<MemorySummary[]>;
|
|
213
|
+
/**
|
|
214
|
+
* Fetch full memory content for specific IDs (second stage of progressive disclosure).
|
|
215
|
+
* Use after recallMemorySummaries() to hydrate only the memories you actually need.
|
|
216
|
+
*/
|
|
217
|
+
export declare function hydrateMemories(ids: number[]): Promise<Memory[]>;
|
|
218
|
+
export type MemoryLinkRow = {
|
|
219
|
+
source_id: number;
|
|
220
|
+
target_id: number;
|
|
221
|
+
link_type: MemoryLinkType;
|
|
222
|
+
strength: number;
|
|
223
|
+
};
|
|
224
|
+
/**
|
|
225
|
+
* Create a typed, weighted link between two memories.
|
|
226
|
+
* Idempotent — upserts on (source_id, target_id, link_type).
|
|
227
|
+
*/
|
|
228
|
+
export declare function createMemoryLink(sourceId: number, targetId: number, linkType: MemoryLinkType, strength?: number): Promise<void>;
|
|
229
|
+
/**
|
|
230
|
+
* Batch-create multiple memory links in a single upsert.
|
|
231
|
+
* Filters out self-links and deduplicates by (source, target, type).
|
|
232
|
+
*/
|
|
233
|
+
export declare function createMemoryLinksBatch(links: MemoryLinkRow[]): Promise<void>;
|
|
234
|
+
/**
|
|
235
|
+
* Apply type-specific memory decay.
|
|
236
|
+
* Episodic memories fade fastest (0.93/day), self-model slowest (0.99/day).
|
|
237
|
+
* This mirrors human cognition: events are forgotten but identity persists.
|
|
238
|
+
*/
|
|
239
|
+
export declare function decayMemories(): Promise<number>;
|
|
240
|
+
export declare function deleteMemory(id: number): Promise<boolean>;
|
|
241
|
+
export declare function updateMemory(id: number, patches: {
|
|
242
|
+
summary?: string;
|
|
243
|
+
content?: string;
|
|
244
|
+
tags?: string[];
|
|
245
|
+
importance?: number;
|
|
246
|
+
memory_type?: MemoryType;
|
|
247
|
+
}): Promise<boolean>;
|
|
248
|
+
export declare function listMemories(opts: {
|
|
249
|
+
page?: number;
|
|
250
|
+
page_size?: number;
|
|
251
|
+
memory_type?: MemoryType;
|
|
252
|
+
min_importance?: number;
|
|
253
|
+
order?: 'created_at' | 'importance' | 'last_accessed';
|
|
254
|
+
}): Promise<{
|
|
255
|
+
memories: Memory[];
|
|
256
|
+
total: number;
|
|
257
|
+
}>;
|
|
258
|
+
export interface MemoryStats {
|
|
259
|
+
total: number;
|
|
260
|
+
byType: Record<MemoryType, number>;
|
|
261
|
+
avgImportance: number;
|
|
262
|
+
avgDecay: number;
|
|
263
|
+
oldestMemory: string | null;
|
|
264
|
+
newestMemory: string | null;
|
|
265
|
+
totalDreamSessions: number;
|
|
266
|
+
uniqueUsers: number;
|
|
267
|
+
topTags: {
|
|
268
|
+
tag: string;
|
|
269
|
+
count: number;
|
|
270
|
+
}[];
|
|
271
|
+
topConcepts: {
|
|
272
|
+
concept: string;
|
|
273
|
+
count: number;
|
|
274
|
+
}[];
|
|
275
|
+
embeddedCount: number;
|
|
276
|
+
}
|
|
277
|
+
export declare function getMemoryStats(): Promise<MemoryStats>;
|
|
278
|
+
export declare function getRecentMemories(hours: number, types?: MemoryType[], limit?: number): Promise<Memory[]>;
|
|
279
|
+
export declare function getSelfModel(): Promise<Memory[]>;
|
|
280
|
+
export declare function storeDreamLog(sessionType: 'consolidation' | 'reflection' | 'emergence' | 'compaction' | 'contradiction_resolution', inputMemoryIds: number[], output: string, newMemoryIds: number[]): Promise<void>;
|
|
281
|
+
export declare function formatMemoryContext(memories: Memory[]): string;
|
|
282
|
+
export declare function calculateImportance(opts: {
|
|
283
|
+
tier?: string;
|
|
284
|
+
feature?: string;
|
|
285
|
+
mood?: string;
|
|
286
|
+
isFirstInteraction?: boolean;
|
|
287
|
+
}): number;
|
|
288
|
+
/**
|
|
289
|
+
* Score importance using LLM (Park et al. 2023).
|
|
290
|
+
* Falls back to rule-based calculateImportance() on failure.
|
|
291
|
+
*/
|
|
292
|
+
export declare function scoreImportanceWithLLM(description: string, fallbackOpts?: Parameters<typeof calculateImportance>[0]): Promise<number>;
|
|
293
|
+
/**
|
|
294
|
+
* Returns the set of memory IDs already linked FROM the given memory
|
|
295
|
+
* (i.e. rows in memory_links where memory_a_id = memoryId).
|
|
296
|
+
*/
|
|
297
|
+
export declare function fetchExistingLinkTargets(memoryId: number): Promise<Set<number>>;
|
|
298
|
+
/**
|
|
299
|
+
* Upserts a row in jepa_queried_memories marking this memory as queried now.
|
|
300
|
+
*/
|
|
301
|
+
export declare function markJepaQueried(memoryId: number): Promise<void>;
|
|
302
|
+
/**
|
|
303
|
+
* Returns the set of memory IDs that have been JEPA-queried at or after sinceMs (epoch ms).
|
|
304
|
+
*/
|
|
305
|
+
export declare function fetchJepaQueriedSince(sinceMs: number): Promise<Set<number>>;
|
|
306
|
+
/**
|
|
307
|
+
* Vector similarity search via the match_memories RPC.
|
|
308
|
+
* NOTE: query_embedding must be JSON-stringified per existing RPC convention.
|
|
309
|
+
* ownerWallet filtering is not forwarded to the RPC (no matching param in this
|
|
310
|
+
* codebase's match_memories signature); callers should filter client-side if needed.
|
|
311
|
+
*/
|
|
312
|
+
export declare function matchByEmbedding(opts: {
|
|
313
|
+
embedding: number[];
|
|
314
|
+
threshold: number;
|
|
315
|
+
limit: number;
|
|
316
|
+
ownerWallet?: string;
|
|
317
|
+
}): Promise<Array<{
|
|
318
|
+
id: number;
|
|
319
|
+
similarity: number;
|
|
320
|
+
}>>;
|
|
321
|
+
export declare function moodToValence(mood: string): number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Centralized constants — magic numbers, well-known addresses, and configuration defaults.
|
|
3
|
+
*/
|
|
4
|
+
export declare const MEMO_PROGRAM_ID = "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr";
|
|
5
|
+
export declare const JUPITER_PRICE_URL = "https://api.jup.ag/price/v2";
|
|
6
|
+
export declare const SOLSCAN_TX_BASE_URL = "https://solscan.io/tx";
|
|
7
|
+
export declare const TWEET_MAX_LENGTH = 4000;
|
|
8
|
+
export declare const TWEET_SAFE_LENGTH = 3900;
|
|
9
|
+
export declare const BOT_X_HANDLE: string;
|
|
10
|
+
export declare const MEMORY_DECAY_RATE = 0.95;
|
|
11
|
+
export declare const MEMORY_MIN_DECAY = 0.05;
|
|
12
|
+
export declare const MEMORY_MAX_CONTENT_LENGTH = 5000;
|
|
13
|
+
export declare const MEMORY_MAX_SUMMARY_LENGTH = 500;
|
|
14
|
+
export declare const DECAY_RATES: Record<string, number>;
|
|
15
|
+
export declare const RECENCY_DECAY_BASE = 0.995;
|
|
16
|
+
export declare const RETRIEVAL_WEIGHT_RECENCY: number;
|
|
17
|
+
export declare const RETRIEVAL_WEIGHT_RELEVANCE: number;
|
|
18
|
+
export declare const RETRIEVAL_WEIGHT_IMPORTANCE: number;
|
|
19
|
+
export declare const RETRIEVAL_WEIGHT_VECTOR: number;
|
|
20
|
+
export declare const RETRIEVAL_WEIGHT_BM25: number;
|
|
21
|
+
export declare const KNOWLEDGE_TYPE_BOOST: Record<string, number>;
|
|
22
|
+
export declare const VECTOR_MATCH_THRESHOLD = 0.15;
|
|
23
|
+
export declare const MEMORY_CONCEPTS: readonly ["market_event", "holder_behavior", "self_insight", "social_interaction", "community_pattern", "token_economics", "sentiment_shift", "recurring_user", "whale_activity", "price_action", "engagement_pattern", "identity_evolution"];
|
|
24
|
+
export type MemoryConcept = typeof MEMORY_CONCEPTS[number];
|
|
25
|
+
export declare const BOND_TYPE_WEIGHTS: Record<MemoryLinkType, number>;
|
|
26
|
+
export declare const RETRIEVAL_WEIGHT_GRAPH = 1.5;
|
|
27
|
+
export declare const RETRIEVAL_WEIGHT_COOCCURRENCE = 0.4;
|
|
28
|
+
export declare const LINK_SIMILARITY_THRESHOLD = 0.6;
|
|
29
|
+
export declare const MAX_AUTO_LINKS = 5;
|
|
30
|
+
export declare const LINK_CO_RETRIEVAL_BOOST = 0.05;
|
|
31
|
+
export declare const INTERNAL_MEMORY_SOURCES: Set<string>;
|
|
32
|
+
export declare const EXTERNAL_MEMORY_SOURCES: Set<string>;
|
|
33
|
+
export declare const INTERNAL_REINFORCEMENT_GATE = 0.3;
|
|
34
|
+
export declare const INTERNAL_IMPORTANCE_BOOST = 0.005;
|
|
35
|
+
export type MemoryLinkType = 'supports' | 'contradicts' | 'elaborates' | 'causes' | 'follows' | 'relates' | 'resolves' | 'supersedes' | 'happens_before' | 'happens_after' | 'concurrent_with';
|
|
36
|
+
export declare const EMBEDDING_DIMENSIONS = 1024;
|
|
37
|
+
export declare const EMBEDDING_FRAGMENT_MAX_LENGTH = 2000;
|
|
38
|
+
export declare const REFLECTION_IMPORTANCE_THRESHOLD = 2;
|
|
39
|
+
export declare const REFLECTION_MIN_INTERVAL_MS: number;
|
|
40
|
+
export declare const PRICE_SNAPSHOT_RETENTION_HOURS = 48;
|
|
41
|
+
export declare const WHALE_SELL_COOLDOWN_MS: number;
|
|
42
|
+
export declare const PUMP_DUMP_THRESHOLD_PERCENT = 10;
|
|
43
|
+
export declare const SIDEWAYS_THRESHOLD_PERCENT = 2;
|
|
44
|
+
export declare const BASE_CHAIN_ID = 8453;
|
|
45
|
+
export declare const BASESCAN_TX_BASE_URL = "https://basescan.org/tx";
|
|
46
|
+
export declare const BASESCAN_API_BASE_URL = "https://api.basescan.org/api";
|
|
47
|
+
export declare const DEXSCREENER_PRICE_URL = "https://api.dexscreener.com/latest/dex/tokens";
|
|
48
|
+
export declare const BASE_WETH_ADDRESS = "0x4200000000000000000000000000000000000006";
|
|
49
|
+
export declare const ERC20_BALANCE_ABI: string[];
|
|
50
|
+
export declare const MEMO_MAX_LENGTH = 100;
|
|
51
|
+
export declare const MAJOR_TOKENS: Set<string>;
|
|
52
|
+
export declare const KNOWN_MEMECOINS: Set<string>;
|
|
53
|
+
export declare function isNoteworthyToken(symbol: string): boolean;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { MemoryType, Memory, MemorySummary, StoreMemoryOptions, RecallOptions, MemoryStats } from './memory-types';
|
|
2
|
+
import type { MemoryLinkType, MemoryConcept } from './shared-constants';
|
|
3
|
+
export interface CortexConfig {
|
|
4
|
+
/** Supabase connection. Required for self-hosted mode. Mutually exclusive with `hosted`. */
|
|
5
|
+
supabase?: {
|
|
6
|
+
url: string;
|
|
7
|
+
serviceKey: string;
|
|
8
|
+
};
|
|
9
|
+
/** Hosted mode — memories stored on CLUDE infrastructure. Mutually exclusive with `supabase`. */
|
|
10
|
+
hosted?: {
|
|
11
|
+
/** API key from `npx @clude/sdk register` or POST /api/cortex/register. */
|
|
12
|
+
apiKey: string;
|
|
13
|
+
/** API base URL. Defaults to 'https://clude.io'. */
|
|
14
|
+
baseUrl?: string;
|
|
15
|
+
};
|
|
16
|
+
/** Anthropic API config. Required for dream cycles and LLM importance scoring. Self-hosted only. */
|
|
17
|
+
anthropic?: {
|
|
18
|
+
apiKey: string;
|
|
19
|
+
model?: string;
|
|
20
|
+
};
|
|
21
|
+
/** Embedding provider config. Optional — falls back to keyword-only retrieval. Self-hosted only. */
|
|
22
|
+
embedding?: {
|
|
23
|
+
provider: 'voyage' | 'openai';
|
|
24
|
+
apiKey: string;
|
|
25
|
+
model?: string;
|
|
26
|
+
dimensions?: number;
|
|
27
|
+
};
|
|
28
|
+
/** Owner wallet address (Solana public key). Tags all memories with ownership. */
|
|
29
|
+
ownerWallet?: string;
|
|
30
|
+
/** Solana on-chain commit config. Optional — memories won't be committed on-chain. Self-hosted only. */
|
|
31
|
+
solana?: {
|
|
32
|
+
rpcUrl?: string;
|
|
33
|
+
botWalletPrivateKey?: string;
|
|
34
|
+
/** Program ID for the on-chain memory registry (Anchor program). Optional — falls back to memo writes. */
|
|
35
|
+
memoryRegistryProgramId?: string;
|
|
36
|
+
};
|
|
37
|
+
/** Client-side encryption config. Optional — memories stored plaintext if not provided. Self-hosted only. */
|
|
38
|
+
encryption?: {
|
|
39
|
+
/** User's 64-byte Ed25519 secret key (Solana keypair). Used to derive encryption key via HKDF. */
|
|
40
|
+
solanaSecretKey: Uint8Array;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
export interface DreamOptions {
|
|
44
|
+
/** Custom handler for emergence output (replaces posting to X). */
|
|
45
|
+
onEmergence?: (text: string) => Promise<void>;
|
|
46
|
+
}
|
|
47
|
+
export type { MemoryType, Memory, MemorySummary, StoreMemoryOptions, RecallOptions, MemoryStats, MemoryLinkType, MemoryConcept, };
|
package/package.json
CHANGED
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clude/sdk",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"mcpName": "io.github.sebbsssss/clude",
|
|
5
5
|
"description": "Persistent memory SDK for AI agents — Stanford Generative Agents architecture on Supabase + pgvector",
|
|
6
6
|
"main": "dist/sdk/index.js",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": {
|
|
9
|
+
"types": "./dist/sdk/index.d.ts",
|
|
9
10
|
"require": "./dist/sdk/index.js"
|
|
10
11
|
},
|
|
11
12
|
"./schema": "./supabase-schema.sql",
|
|
12
13
|
"./local": {
|
|
14
|
+
"types": "./dist/mcp/local-store.d.ts",
|
|
13
15
|
"require": "./dist/mcp/local-store.js"
|
|
14
16
|
},
|
|
15
17
|
"./mcp": {
|
|
18
|
+
"types": "./dist/mcp/server.d.ts",
|
|
16
19
|
"require": "./dist/mcp/server.js"
|
|
17
|
-
}
|
|
20
|
+
},
|
|
21
|
+
"./package.json": "./package.json"
|
|
18
22
|
},
|
|
19
23
|
"bin": {
|
|
20
24
|
"clude": "dist/cli/index.js"
|
|
@@ -72,33 +76,19 @@
|
|
|
72
76
|
},
|
|
73
77
|
"packageManager": "pnpm@10.18.1",
|
|
74
78
|
"dependencies": {
|
|
75
|
-
"@ai-sdk/anthropic": "^3.0.64",
|
|
76
|
-
"@ai-sdk/google": "^3.0.55",
|
|
77
|
-
"@ai-sdk/openai": "^3.0.49",
|
|
78
|
-
"@ai-sdk/xai": "^3.0.75",
|
|
79
79
|
"@anthropic-ai/sdk": "^0.39.0",
|
|
80
80
|
"@huggingface/transformers": "^4.1.0",
|
|
81
81
|
"@modelcontextprotocol/sdk": "^1.26.0",
|
|
82
|
-
"@openrouter/ai-sdk-provider": "^2.3.3",
|
|
83
|
-
"@privy-io/node": "^0.12.0",
|
|
84
82
|
"@solana/web3.js": "^1.98.4",
|
|
85
83
|
"@supabase/supabase-js": "^2.95.3",
|
|
86
|
-
"ai": "^6.0.142",
|
|
87
84
|
"better-sqlite3": "^12.9.0",
|
|
88
85
|
"bs58": "^6.0.0",
|
|
89
86
|
"dotenv": "^16.4.0",
|
|
90
|
-
"express": "^4.21.0",
|
|
91
|
-
"express-rate-limit": "^8.2.1",
|
|
92
|
-
"jose": "^6.1.3",
|
|
93
|
-
"multer": "^2.1.1",
|
|
94
87
|
"murmurhash3js": "^3.0.1",
|
|
95
88
|
"node-cron": "^3.0.3",
|
|
96
89
|
"pino": "^9.0.0",
|
|
97
90
|
"sqlite-vec": "^0.1.9",
|
|
98
91
|
"tweetnacl": "^1.0.3",
|
|
99
|
-
"twitter-api-v2": "^1.29.0",
|
|
100
|
-
"unpdf": "^1.4.0",
|
|
101
|
-
"vercel-minimax-ai-provider": "^0.0.2",
|
|
102
92
|
"zod": "^4.3.6"
|
|
103
93
|
},
|
|
104
94
|
"devDependencies": {
|
|
@@ -111,5 +101,6 @@
|
|
|
111
101
|
},
|
|
112
102
|
"optionalDependencies": {
|
|
113
103
|
"utf-8-validate": "^5.0.10"
|
|
114
|
-
}
|
|
104
|
+
},
|
|
105
|
+
"types": "./dist/sdk/index.d.ts"
|
|
115
106
|
}
|