dotmem 0.0.1 → 0.0.2

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.
@@ -0,0 +1,285 @@
1
+ export * from './memory'
2
+ export * from './agent'
3
+ export * from './logic'
4
+ export * from './policy'
5
+ export * from './profile'
6
+ export * from './llm-cache'
7
+
8
+ // ── Memory facade type ───────────────────────────────────────────────────
9
+ export interface MemoryFacade {
10
+ init(): Promise<void>
11
+ discover(situation: string | import('./memory').Situation, options?: import('./memory').DiscoveryOptions): Promise<import('./memory').DiscoveryResult>
12
+ context(options?: ContextQueryOptions): Promise<import('./memory').AcquiredContext>
13
+ project(discovery: import('./memory').DiscoveryResult, options?: import('./memory').ProjectionOptions): import('./memory').ContextProjection
14
+ acquire(opts: import('./memory').AcquireOptions): Promise<void>
15
+ acquireStaged(opts: import('./memory').AcquireOptions): Promise<void>
16
+ remember<T>(key: string, value: T, opts?: import('./memory').RememberOptions<T>): Promise<void>
17
+ recall<T = any>(query: string | number, opts?: import('./memory').RecallOptions): Promise<T | null>
18
+ update(key: string, value: any, opts?: Partial<import('./memory').RememberOptions>): Promise<void>
19
+ forget(key: string): Promise<void>
20
+ patch(key: string, patches: import('./memory').PatchOperation[]): Promise<void>
21
+ stats(): Promise<import('./memory').MemoryStats>
22
+ forgetExpired(): Promise<number>
23
+ clear(): Promise<void>
24
+ fingerprint(): Promise<string>
25
+ journal: MemoryJournal
26
+ profile: MemoryProfile
27
+ note: MemoryNotes
28
+ seed: MemorySeed
29
+ policy: MemoryPolicyAPI
30
+ brain: MemoryBrainAPI
31
+ configure(config: import('./memory').SyncConfig): void
32
+ configureSync(config: import('./memory').SyncConfig): void
33
+ resetBrainPathCache(): void
34
+ resetPolicyStoreCache(): void
35
+ _getEntry(key: string): Promise<import('./memory').MemoryEntry | null>
36
+ _loadAll(): Promise<import('./memory').MemoryEntry[]>
37
+ _save(entry: import('./memory').MemoryEntry): Promise<void>
38
+ }
39
+
40
+ export interface LlmCacheAPI {
41
+ llm<T>(opts: import('./llm-cache').LlmCacheOptions<T>): Promise<import('./llm-cache').LlmCacheResult<T>>
42
+ llmStats(): import('./llm-cache').LlmCacheStats
43
+ llmPurge(selector: import('./llm-cache').LlmCachePurgeSelector): number
44
+ [key: string]: any
45
+ }
46
+
47
+ type Situation = string
48
+
49
+ export interface ContextQueryOptions {
50
+ tags?: string | string[]
51
+ types?: import('./memory').MemoryType | import('./memory').MemoryType[]
52
+ minConfidence?: number
53
+ maxEntries?: number
54
+ scopes?: import('./memory').MemoryScope[]
55
+ project?: boolean
56
+ }
57
+
58
+ export interface MemoryJournal {
59
+ read: (opts?: { limit?: number }) => Promise<JournalEntry[]>
60
+ write: (entry: JournalEntry | JournalEntry[]) => Promise<void>
61
+ clear: () => Promise<void>
62
+ }
63
+
64
+ export interface JournalEntry {
65
+ id: string
66
+ key: string
67
+ type: import('./memory').MemoryType
68
+ operation: string
69
+ hlc?: string
70
+ createdAt: number
71
+ payload?: unknown
72
+ }
73
+
74
+ export interface MemoryProfile {
75
+ get(): import('./profile').DotMemProfile
76
+ }
77
+
78
+ export interface MemoryNotes {
79
+ add(text: string, opts?: { id?: string; tags?: string[] }): Promise<void>
80
+ get(id: string): Promise<NoteContent | null>
81
+ list(): Promise<NoteEntry[]>
82
+ forget(id: string): Promise<void>
83
+ }
84
+
85
+ export interface NoteContent {
86
+ id: string
87
+ title: string
88
+ content: string
89
+ tags: string[]
90
+ createdAt: number
91
+ sha256: string
92
+ }
93
+
94
+ export interface NoteEntry {
95
+ id: string
96
+ title: string
97
+ size: number
98
+ sha256: string
99
+ origin: string
100
+ tag?: string
101
+ acquiredAt?: string
102
+ scope?: string
103
+ type?: import('./memory').MemoryType
104
+ version?: number
105
+ updatedAt?: number
106
+ previousId?: string | null
107
+ patches?: import('./memory').PatchOperation[]
108
+ hlc?: string
109
+ key?: string
110
+ value?: unknown
111
+ status?: string
112
+ createdAt?: number
113
+ lastConfirmedAt?: number
114
+ supersededId?: string | null
115
+ confidence?: number
116
+ source?: string
117
+ ttl?: number | null
118
+ }
119
+
120
+ export interface MemorySeed {
121
+ id: string
122
+ title: string
123
+ content: string
124
+ origin: string
125
+ }
126
+
127
+ // ── dotmem public runtime exports ────────────────────────────────────────
128
+ declare const memory: MemoryFacade
129
+ declare const logic: any
130
+ declare const continuity: any
131
+ declare const security: any
132
+
133
+ // ── User identity surface ────────────────────────────────────────────────
134
+ export interface UserIdentity {
135
+ id: string
136
+ name?: string
137
+ email?: string
138
+ }
139
+ declare function resolveUserIdentity(): UserIdentity | null
140
+ declare function setUserIdentity(id: string, identity: UserIdentity): void
141
+ declare function clearUserIdentity(): void
142
+
143
+ // ── User paths surface ───────────────────────────────────────────────────
144
+ declare function resolveUserDotMemPath(): string
145
+ declare function resolveUserProjectMemoryPath(projectId?: string): string
146
+ declare function resolveUserAnchor(): string
147
+ declare function resolveUserBrainPath(): string
148
+ declare function resolveUserContractPath(): string
149
+ declare function resolveUserAgentMemoryPath(): string
150
+ declare function resolveUserReadmePath(): string
151
+ declare function resolveUserExperiencePath(): string
152
+
153
+ // ── Storage location surface ─────────────────────────────────────────────
154
+ export interface DotMemStorageLocationError extends Error {
155
+ readonly storageRoot: string
156
+ readonly source: string
157
+ }
158
+ declare const DOTMEM_STORAGE_ROOT_ENV_VAR: string
159
+ declare const DOTMEM_USER_ANCHOR_DIR_NAME: string
160
+ declare const DOTMEM_STORAGE_LOCATOR_FILE_NAME: string
161
+ declare const DOTMEM_STORAGE_LOCATOR_VERSION: number
162
+ declare function resolveDotMemStorageRoot(): string
163
+ declare function describeDotMemStorage(): unknown
164
+ declare function readDotMemStorageLocator(): unknown
165
+ declare function relocateDotMemStorage(target: string): unknown
166
+ declare function restoreDefaultDotMemStorage(): unknown
167
+
168
+ // ── Project identity surface ─────────────────────────────────────────────
169
+ declare function resolveProjectIdentity(id?: string): Promise<string>
170
+
171
+ // ── Mem package inspection ──────────────────────────────────────────────
172
+ declare function inspectMem(mem: unknown, opts?: Record<string, unknown>): unknown
173
+ declare function signMemPackage(mem: unknown, key: unknown): unknown
174
+ export interface MemInspection {
175
+ status: 'inspected'
176
+ version: number
177
+ entries: unknown[]
178
+ }
179
+ export interface MemInspectionStatus {
180
+ valid: boolean
181
+ errors?: string[]
182
+ }
183
+
184
+ // ── Profile ──────────────────────────────────────────────────────────────
185
+ export interface DotMemProfileDocument {
186
+ readonly name: string
187
+ readonly content: string
188
+ }
189
+ export interface DotMemProfile {
190
+ readonly format: 'dotmem.profile'
191
+ readonly version: 1
192
+ readonly id: 'joy'
193
+ readonly name: 'Joy'
194
+ readonly alternative: ['Jo']
195
+ readonly documents: ReadonlyArray<DotMemProfileDocument>
196
+ readonly type: 'ai-persona'
197
+ readonly role: string
198
+ readonly immutable: true
199
+ readonly description: string
200
+ }
201
+ declare const JO_PROFILE: Readonly<DotMemProfile>
202
+
203
+ // ── Mutation engine extras ──────────────────────────────────────────────
204
+ declare function currentTimestamp(): string
205
+ declare function activeTransactionId(): string | null
206
+
207
+ // ── Foundation re-exports (runtime values) from memorio ──────────────────
208
+ declare const state: any
209
+ declare const store: any
210
+ declare const session: any
211
+ declare const cache: LlmCacheAPI
212
+ declare const idb: any
213
+ declare const sqlite: any
214
+ declare const observer: any
215
+ declare const schema: any
216
+ declare function registerSchema(path: string, schema: any): void
217
+ declare function validate(path: string, value: any): { valid: boolean; errors?: string[] }
218
+ declare function unregisterSchema(path: string): boolean
219
+ declare function listSchemas(): string[]
220
+ declare const typed: <T extends Record<string, any>>() => T
221
+ declare const computed: any
222
+ declare const broadcast: any
223
+ declare const message: (...args: unknown[]) => void
224
+ declare const logger: any
225
+ declare const snapshot: () => Record<string, any>
226
+ declare function diff(snap: Record<string, any>): Array<{ path: string; oldValue: any; newValue: any }>
227
+ declare function undo(): any
228
+ declare function redo(): any
229
+ declare function canUndo(): boolean
230
+ declare function canRedo(): boolean
231
+ declare function rollback(snap: Record<string, any>): void
232
+ declare function trace(): any[]
233
+ declare function enableHistory(enabled?: boolean): void
234
+ declare function clearHistory(): void
235
+ declare function clearRedo(): void
236
+ declare function createMutation(path: string, operation: any, before: any, after: any, opts?: { context?: string; source?: string; transactionId?: string }): unknown
237
+ declare function recordMutation(mutation: unknown): void
238
+ declare function toPatch(mutation: unknown): unknown | null
239
+ declare function mutate(path: string, value: any, opts?: { source?: string; transactionId?: string }): unknown
240
+ declare function beginTransaction(source?: string, message?: string, metadata?: Record<string, any>): unknown
241
+ declare function commitTransaction(): unknown
242
+ declare function abortTransaction(): unknown
243
+ declare function currentTransaction(): unknown
244
+ declare function listTransactions(): unknown[]
245
+ declare const transaction: (source?: string, message?: string, metadata?: Record<string, any>) => unknown
246
+ declare function generateMutationId(): string
247
+ declare function generateTransactionId(): string
248
+ declare function generateCommitId(): string
249
+ declare function mutationToPatch(mutation: unknown): unknown | null
250
+ declare function diffToPatch(path: string, before: any, after: any): unknown | null
251
+ declare function canMerge(p1: unknown, p2: unknown): boolean
252
+ declare function mergePatches(p1: unknown, p2: unknown): unknown
253
+ declare function dispatch(event: string, payload?: unknown): Promise<void>
254
+ declare function isDotMemCodename(value: string): boolean
255
+ declare function codenameKeyFor(value: string): string | undefined
256
+ declare function renderCodenames(): string
257
+ declare const CODENAMES: Record<string, string>
258
+ declare const CODENAME_DETAILS: Record<string, unknown>
259
+ declare function propertyName(container: any, object: any): string | null
260
+ declare const internal: any
261
+ declare function setContext(id: string): void
262
+ declare function getContext(): string | null
263
+ declare const hlc: any
264
+ declare const fractional: any
265
+ declare const encryption: any
266
+ declare const securityEncryption: any
267
+ declare const devtools: any
268
+ declare function help(): void
269
+ declare const temporal: any
270
+ declare const events: Record<string, any>
271
+ declare const dotmem: any
272
+ declare const DEV: boolean
273
+ declare const PROD: boolean
274
+ declare function isBrowser(): boolean
275
+ declare function isNode(): boolean
276
+ declare function isDeno(): boolean
277
+ declare function isBun(): boolean
278
+ declare function isEdge(): boolean
279
+ declare function getCapabilities(): unknown
280
+ declare function createContext(name?: string, opts?: { encryptionKey?: any }): unknown
281
+ declare function listContexts(): unknown[]
282
+ declare function deleteContext(id: string): void
283
+ declare function isolate(name?: string, opts?: { encryptionKey?: any }): void
284
+
285
+ export default dotmem
@@ -0,0 +1,7 @@
1
+ declare module 'fflate/browser' {
2
+ export {
3
+ Unzip,
4
+ UnzipInflate,
5
+ zipSync
6
+ } from 'fflate'
7
+ }
@@ -0,0 +1,14 @@
1
+ /// DOTMEM INSPECT TYPES
2
+ /// Ambient declarations for the state introspection API.
3
+
4
+ ///
5
+ // Schema report entry describing a single state path.
6
+ ///
7
+ interface _stateSchemaEntry {
8
+ /** Dotted path relative to `state`. */
9
+ path: string
10
+ /** Runtime type: 'string', 'number', 'boolean', 'object', 'array', 'undefined'. */
11
+ type: string
12
+ /** Whether the path resolves to a defined value. */
13
+ defined: boolean
14
+ }
@@ -0,0 +1,53 @@
1
+ ///
2
+ // LLM RESPONSE CACHE TYPES
3
+ // Opt-in token-avoidance cache for LLM responses.
4
+ ///
5
+
6
+ export type LlmCacheScope = 'session' | 'persist'
7
+
8
+ export type LlmCacheMatchedBy = 'exact' | 'normalized' | 'embedding'
9
+
10
+ export interface LlmCacheOptions<T = any> {
11
+ key: {
12
+ prompt: string
13
+ model: string
14
+ params?: Record<string, unknown>
15
+ context?: string
16
+ }
17
+ compute: () => Promise<T>
18
+ ttl?: string | number
19
+ scope?: LlmCacheScope
20
+ cacheable?: boolean | ((value: T) => boolean)
21
+ deterministicOnly?: boolean
22
+ similarity?: {
23
+ mode: 'off' | 'normalized' | 'embedding'
24
+ threshold?: number
25
+ embed?: (text: string) => Promise<number[]>
26
+ }
27
+ estimateTokens?: (value: T) => number
28
+ }
29
+
30
+ export interface LlmCacheResult<T = any> {
31
+ value: T
32
+ hit: boolean
33
+ matchedBy?: LlmCacheMatchedBy
34
+ score?: number
35
+ key: string
36
+ createdAt: number
37
+ savedTokens?: number
38
+ provenance: 'CACHED' | 'FRESH'
39
+ }
40
+
41
+ export interface LlmCacheStats {
42
+ hits: number
43
+ misses: number
44
+ savedTokens: number
45
+ entries: number
46
+ }
47
+
48
+ export interface LlmCachePurgeSelector {
49
+ key?: string
50
+ model?: string
51
+ olderThan?: string
52
+ all?: true
53
+ }
@@ -0,0 +1,79 @@
1
+ import type {
2
+ AcquiredClaim,
3
+ AcquiredContext,
4
+ ClaimProvenance,
5
+ EpistemicType,
6
+ EvidenceReference,
7
+ JsonPrimitive,
8
+ JsonValue
9
+ } from './memory'
10
+
11
+ export type LogicEpistemicType = EpistemicType
12
+
13
+ export interface LogicExperienceInput {
14
+ situation: JsonValue
15
+ action: JsonValue
16
+ outcome: JsonValue
17
+ evidence: EvidenceReference[]
18
+ }
19
+
20
+ export interface LogicExperienceOptions extends LogicExperienceInput {
21
+ id: string
22
+ applicability: Record<string, JsonPrimitive>
23
+ epistemicType?: LogicEpistemicType
24
+ provenance?: ClaimProvenance
25
+ acquiredAt?: string
26
+ refines?: string | string[]
27
+ supersedes?: string | string[]
28
+ retracts?: string | string[]
29
+ reason?: string
30
+ }
31
+
32
+ export interface LogicQuery {
33
+ context: Record<string, JsonPrimitive>
34
+ }
35
+
36
+ export interface LogicMeasurement {
37
+ total: number
38
+ selected: number
39
+ selectedIds: string[]
40
+ knowledgeVersion: number
41
+ temporalMutations: number
42
+ }
43
+
44
+ export interface LogicRule {
45
+ id: string
46
+ condition: JsonValue
47
+ recommendation: JsonValue
48
+ evidence: EvidenceReference[]
49
+ confidence: number
50
+ }
51
+
52
+ export interface LogicStats {
53
+ experiences: number
54
+ version: number
55
+ }
56
+
57
+ export interface LogicEngineAPI {
58
+ experience(opts: LogicExperienceOptions): Promise<void>
59
+ precedents(query: LogicQuery): Promise<AcquiredClaim[]>
60
+ context(query: LogicQuery): Promise<AcquiredContext>
61
+ measure(query: LogicQuery): Promise<LogicMeasurement>
62
+ learn(query: LogicQuery): Promise<LogicRule[]>
63
+ clear(): Promise<void>
64
+ stats(): Promise<LogicStats>
65
+ }
66
+
67
+ export declare class LogicEngine implements LogicEngineAPI {
68
+ experience(opts: LogicExperienceOptions): Promise<void>
69
+ precedents(query: LogicQuery): Promise<AcquiredClaim[]>
70
+ context(query: LogicQuery): Promise<AcquiredContext>
71
+ measure(query: LogicQuery): Promise<LogicMeasurement>
72
+ learn(query: LogicQuery): Promise<LogicRule[]>
73
+ clear(): Promise<void>
74
+ stats(): Promise<LogicStats>
75
+ configure(opts: { disabled?: boolean }): void
76
+ }
77
+
78
+ declare const logic: LogicEngine
79
+ export default logic