memorio 5.1.3 → 5.2.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/AGENTS.md +22 -13
- package/CHANGELOG.md +24 -9
- package/README.md +61 -19
- package/SECURITY-HARDENING.md +258 -0
- package/SECURITY.md +67 -3
- package/SUMMARY.md +55 -59
- package/adr/002-observer-semantics.md +1 -1
- package/adr/003-deep-mutation-semantics.md +1 -1
- package/adr/004-array-mutation-semantics.md +1 -1
- package/adr/010-logic-phase-0.md +42 -0
- package/adr/README.md +16 -11
- package/bin/cli.js +82 -60
- package/examples/acquired-knowledge.ts +174 -0
- package/examples/agent-memory-demo.ts +140 -0
- package/examples/sqlite-batched-writes.ts +60 -60
- package/examples/sync.ts +90 -90
- package/examples/useObserver.tsx +2 -2
- package/global.cjs +2026 -115
- package/global.js +2021 -116
- package/index.cjs +2026 -115
- package/index.d.ts +1 -0
- package/index.js +2021 -116
- package/llms.txt +135 -4
- package/markdown/EXTENSION_VSCODE_DESIGN.md +410 -0
- package/markdown/LOGIC.md +100 -0
- package/markdown/MEMORY-ATTACHMENT.md +17 -10
- package/markdown/MEMORY.md +404 -14
- package/markdown/MEM_FORMAT.md +313 -0
- package/markdown/SQLITE.md +2 -2
- package/markdown/STATE.md +27 -3
- package/markdown/SYNC.md +19 -15
- package/markdown/TEMPORAL.md +297 -0
- package/markdown/USEOBSERVER.md +7 -4
- package/modules/redux.cjs +1188 -38
- package/modules/redux.cjs.map +1 -1
- package/modules/redux.js +1187 -38
- package/modules/redux.js.map +1 -1
- package/package.json +14 -5
- package/types/exports.d.ts +47 -3
- package/types/logic.d.ts +79 -0
- package/types/memorio.d.ts +60 -16
- package/types/memory.d.ts +118 -0
- package/types/session.d.ts +1 -4
- package/types/state.d.ts +19 -5
- package/types/store.d.ts +1 -4
- package/types/temporal.d.ts +95 -0
- package/types/useObserver.d.ts +6 -10
- package/vsix/memorio.vsix +0 -0
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "memorio",
|
|
3
3
|
"codeName": "memorio",
|
|
4
|
-
"version": "5.
|
|
5
|
-
"description": "
|
|
4
|
+
"version": "5.2.0",
|
|
5
|
+
"description": "The user-owned memory layer for AI agents and apps, with reactive state, persistence, acquired experience, discovery, and context projection.",
|
|
6
6
|
"main": "./index.cjs",
|
|
7
7
|
"browser": {
|
|
8
8
|
"./index.js": "./index.js",
|
|
@@ -50,7 +50,10 @@
|
|
|
50
50
|
"bun",
|
|
51
51
|
"cross-runtime",
|
|
52
52
|
"browser",
|
|
53
|
-
"frontend"
|
|
53
|
+
"frontend",
|
|
54
|
+
"ai-agent",
|
|
55
|
+
"agent-memory",
|
|
56
|
+
"acquired-experience"
|
|
54
57
|
],
|
|
55
58
|
"funding": [
|
|
56
59
|
{
|
|
@@ -63,8 +66,7 @@
|
|
|
63
66
|
"bun": ">=1.4.0"
|
|
64
67
|
},
|
|
65
68
|
"files": [
|
|
66
|
-
"bin",
|
|
67
|
-
"vsix",
|
|
69
|
+
"bin/**/*",
|
|
68
70
|
"markdown/**/*",
|
|
69
71
|
"types/**/*",
|
|
70
72
|
"examples/**/*",
|
|
@@ -100,6 +102,13 @@
|
|
|
100
102
|
"url": "https://dario.passariello.ca/",
|
|
101
103
|
"email": "dariopassariello@gmail.com"
|
|
102
104
|
},
|
|
105
|
+
"optionalDependencies": {
|
|
106
|
+
"sql.js": "^7.13.0"
|
|
107
|
+
},
|
|
108
|
+
"peerDependencies": {
|
|
109
|
+
"react": ">=18.0.0",
|
|
110
|
+
"sql.js": ">=7.0.0"
|
|
111
|
+
},
|
|
103
112
|
"peerDependenciesMeta": {
|
|
104
113
|
"sql.js": {
|
|
105
114
|
"optional": true
|
package/types/exports.d.ts
CHANGED
|
@@ -10,7 +10,9 @@
|
|
|
10
10
|
|
|
11
11
|
/// <reference path="./schema.d.ts" />
|
|
12
12
|
/// <reference path="./history.d.ts" />
|
|
13
|
-
/// <reference path="./mutation.d.ts" />
|
|
13
|
+
/// <reference path="./mutation.d.ts" />
|
|
14
|
+
/// <reference path="./logic.d.ts" />
|
|
15
|
+
/// <reference path="./temporal.d.ts" />
|
|
14
16
|
/// <reference path="./inspect.d.ts" />
|
|
15
17
|
/// <reference path="./memorio.d.ts" />
|
|
16
18
|
/// <reference path="./state.d.ts" />
|
|
@@ -38,8 +40,47 @@ export const useObserver: _useObserver
|
|
|
38
40
|
export const encryption: _encryption
|
|
39
41
|
export const computed: _computed
|
|
40
42
|
export const broadcast: _broadcast
|
|
41
|
-
export const security: _security
|
|
42
|
-
export const
|
|
43
|
+
export const security: _security
|
|
44
|
+
export const memory: MemoryAPI
|
|
45
|
+
export { logic, LogicEngine } from './logic'
|
|
46
|
+
export type MemInspectionStatus = 'valid' | 'invalid' | 'checksum_mismatch' | 'unsupported' | 'corrupt'
|
|
47
|
+
export interface MemInspection {
|
|
48
|
+
status: MemInspectionStatus
|
|
49
|
+
representation: 'json-v1' | 'json-v2' | 'package-v1' | 'unknown'
|
|
50
|
+
message: string
|
|
51
|
+
packageVersion?: number
|
|
52
|
+
memoryVersion?: number
|
|
53
|
+
contentId?: string
|
|
54
|
+
parts: Array<{ path: string; bytes: number; protected: boolean }>
|
|
55
|
+
knowledge?: {
|
|
56
|
+
version: number
|
|
57
|
+
claims: AcquiredClaim[]
|
|
58
|
+
}
|
|
59
|
+
unknownSemantics?: {
|
|
60
|
+
mapEntries: number
|
|
61
|
+
vocabularyEntries: number
|
|
62
|
+
extensionParts: string[]
|
|
63
|
+
}
|
|
64
|
+
integrity?: {
|
|
65
|
+
status: 'valid'
|
|
66
|
+
algorithm: 'sha256'
|
|
67
|
+
contentId: string
|
|
68
|
+
}
|
|
69
|
+
authenticity?: {
|
|
70
|
+
status: 'unsigned' | 'valid' | 'invalid' | 'unsupported'
|
|
71
|
+
trust: 'not_evaluated'
|
|
72
|
+
signatures: Array<{
|
|
73
|
+
status: 'valid' | 'invalid' | 'unsupported'
|
|
74
|
+
algorithm?: string
|
|
75
|
+
keyId?: string
|
|
76
|
+
contentId?: string
|
|
77
|
+
message: string
|
|
78
|
+
}>
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
export const inspectMem: (input: string | Uint8Array) => Promise<MemInspection>
|
|
82
|
+
export const signMemPackage: (input: Uint8Array, privateKey: CryptoKey, publicKey: CryptoKey) => Promise<Uint8Array>
|
|
83
|
+
export const dispatch: _dispatch
|
|
43
84
|
export const events: Record<string, any>
|
|
44
85
|
|
|
45
86
|
export const DEV: boolean
|
|
@@ -64,6 +105,9 @@ export const fractional: {
|
|
|
64
105
|
reindex<T extends { key: string }>(items: T[]): T[]
|
|
65
106
|
}
|
|
66
107
|
|
|
108
|
+
// ── Temporal Memory Runtime ───────────────────────────────────────────
|
|
109
|
+
export const temporal: _temporal
|
|
110
|
+
|
|
67
111
|
export const isBrowser: () => boolean
|
|
68
112
|
export const isNode: () => boolean
|
|
69
113
|
export const isDeno: () => boolean
|
package/types/logic.d.ts
ADDED
|
@@ -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 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
|
+
export const logic: LogicEngine
|
|
79
|
+
export default logic
|
package/types/memorio.d.ts
CHANGED
|
@@ -6,13 +6,21 @@ import type {
|
|
|
6
6
|
SyncConfig,
|
|
7
7
|
SyncAck,
|
|
8
8
|
SyncDirection,
|
|
9
|
-
RememberOptions,
|
|
10
|
-
RecallOptions,
|
|
11
|
-
ContextOptions,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
RememberOptions,
|
|
10
|
+
RecallOptions,
|
|
11
|
+
ContextOptions,
|
|
12
|
+
AcquiredContextOptions,
|
|
13
|
+
ContextEntry,
|
|
14
|
+
AcquireOptions,
|
|
15
|
+
AcquiredContext,
|
|
16
|
+
DiscoveryOptions,
|
|
17
|
+
DiscoveryResult,
|
|
18
|
+
ContextProjection,
|
|
19
|
+
ProjectionOptions,
|
|
20
|
+
MemoryStats,
|
|
21
|
+
PatchOperation
|
|
22
|
+
} from './memory'
|
|
23
|
+
import type { LogicEngine } from './logic'
|
|
16
24
|
|
|
17
25
|
/**
|
|
18
26
|
* Environment capabilities
|
|
@@ -111,8 +119,10 @@ interface _memorio {
|
|
|
111
119
|
stateType?: (path: string) => string
|
|
112
120
|
stateGet?: (path: string) => any
|
|
113
121
|
stateSchema?: () => Array<{ path: string; type: string; defined: boolean }>
|
|
114
|
-
|
|
115
|
-
|
|
122
|
+
memory?: MemoryAPI
|
|
123
|
+
temporal?: _temporal
|
|
124
|
+
logic?: LogicEngine
|
|
125
|
+
encryption?: _encryption
|
|
116
126
|
computed?: _computed
|
|
117
127
|
broadcast?: _broadcast
|
|
118
128
|
security?: _security
|
|
@@ -123,13 +133,19 @@ interface _memorio {
|
|
|
123
133
|
[key: string]: any
|
|
124
134
|
}
|
|
125
135
|
|
|
126
|
-
interface MemoryAPI {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
136
|
+
interface MemoryAPI {
|
|
137
|
+
/** Project discovered candidates into bounded reusable context; stored content remains untrusted data. */
|
|
138
|
+
project(discovery: DiscoveryResult, options?: ProjectionOptions): ContextProjection
|
|
139
|
+
/** Find plausible active acquired experience; candidates are not truth or applicability decisions. */
|
|
140
|
+
discover(situation: string, options?: DiscoveryOptions): Promise<DiscoveryResult>
|
|
141
|
+
acquire(opts: AcquireOptions): Promise<void>
|
|
142
|
+
remember<T>(key: string, value: T, opts?: RememberOptions<T>): Promise<void>
|
|
143
|
+
recall<T>(query: string, opts?: RecallOptions): Promise<T | null>
|
|
144
|
+
update(key: string, value: any, opts?: Partial<RememberOptions>): Promise<void>
|
|
145
|
+
forget(key: string): Promise<void>
|
|
146
|
+
patch(key: string, patches: PatchOperation[]): Promise<void>
|
|
147
|
+
context(opts: AcquiredContextOptions): Promise<AcquiredContext>
|
|
148
|
+
context(opts?: ContextOptions): Promise<ContextEntry[]>
|
|
133
149
|
stats(): Promise<MemoryStats>
|
|
134
150
|
forgetExpired(): Promise<number>
|
|
135
151
|
clear(): Promise<void>
|
|
@@ -158,6 +174,34 @@ interface MemoryJournal {
|
|
|
158
174
|
status(): Promise<'store'>
|
|
159
175
|
}
|
|
160
176
|
|
|
177
|
+
///
|
|
178
|
+
// Temporal memory runtime interface.
|
|
179
|
+
///
|
|
180
|
+
interface _temporal {
|
|
181
|
+
/** Get mutation history for a path (exact or sub-paths), or all if no path. */
|
|
182
|
+
history(path?: string): _mutation[]
|
|
183
|
+
/** Get the value at a path at a specific point in time. Does NOT mutate live state. */
|
|
184
|
+
at(path: string, timestamp: number | string): any
|
|
185
|
+
/** Diff changes between two timestamps for a given path. */
|
|
186
|
+
diff(path: string, from: number | string, to: number | string): _temporalDiff[]
|
|
187
|
+
/** Reconstruct isolated state from history within a time range. */
|
|
188
|
+
replay(options?: { from?: number | string; to?: number | string }): Record<string, any>
|
|
189
|
+
/** Explain how a value at a path came to exist (deterministic metadata). */
|
|
190
|
+
explain(path: string): _temporalExplanation
|
|
191
|
+
/** Create an isolated temporal branch. Changes do not affect live state. */
|
|
192
|
+
branch(): _temporalBranch
|
|
193
|
+
/** Enable or disable temporal tracking. */
|
|
194
|
+
enable(enabled?: boolean): void
|
|
195
|
+
/** Check if temporal tracking is enabled. */
|
|
196
|
+
isEnabled(): boolean
|
|
197
|
+
/** Clear the temporal log. Does NOT clear current state. */
|
|
198
|
+
clear(): void
|
|
199
|
+
/** Configure the temporal engine (max entries, snapshots, etc.). */
|
|
200
|
+
configure(opts: { maxEntries?: number; snapshots?: boolean; snapshotInterval?: number }): void
|
|
201
|
+
/** Get statistics about the temporal log. */
|
|
202
|
+
stats(): { total: number; byPath: Record<string, number> }
|
|
203
|
+
}
|
|
204
|
+
|
|
161
205
|
type memorio = _memorio
|
|
162
206
|
declare var memorio: _memorio
|
|
163
207
|
|
package/types/memory.d.ts
CHANGED
|
@@ -9,6 +9,105 @@ export type MemoryType =
|
|
|
9
9
|
|
|
10
10
|
export type MemoryStatus = 'active' | 'obsolete' | 'superseded'
|
|
11
11
|
|
|
12
|
+
export type JsonPrimitive = string | number | boolean | null
|
|
13
|
+
export type JsonValue = JsonPrimitive | JsonValue[] | { [key: string]: JsonValue }
|
|
14
|
+
|
|
15
|
+
export interface EvidenceReference {
|
|
16
|
+
id: string
|
|
17
|
+
source?: string
|
|
18
|
+
observedAt?: string
|
|
19
|
+
/** The bounded statement or result this evidence directly supports. */
|
|
20
|
+
supports?: string
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export type EpistemicType = 'observed' | 'inferred' | 'human-stated' | 'verified'
|
|
24
|
+
|
|
25
|
+
export interface ClaimProvenance {
|
|
26
|
+
source: string
|
|
27
|
+
detail?: string
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface RevisionRelationship {
|
|
31
|
+
kind: 'refines' | 'supersedes' | 'retracts'
|
|
32
|
+
claimIds: string[]
|
|
33
|
+
reason?: string
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface AcquiredClaim {
|
|
37
|
+
id: string
|
|
38
|
+
knowledge: JsonValue
|
|
39
|
+
applicability: Record<string, JsonPrimitive>
|
|
40
|
+
evidence: EvidenceReference[]
|
|
41
|
+
epistemicType?: EpistemicType
|
|
42
|
+
provenance?: ClaimProvenance
|
|
43
|
+
acquiredAt?: string
|
|
44
|
+
revision?: RevisionRelationship
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface AcquiredContext {
|
|
48
|
+
knowledgeVersion: number
|
|
49
|
+
claims: AcquiredClaim[]
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export type DiscoveryDepth = 'current' | 'deep'
|
|
53
|
+
export type DiscoveryField = 'id' | 'knowledge' | 'applicability' | 'evidence' | 'provenance'
|
|
54
|
+
|
|
55
|
+
export interface DiscoveryOptions {
|
|
56
|
+
depth?: DiscoveryDepth
|
|
57
|
+
maxCandidates?: number
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface DiscoveryExplanation {
|
|
61
|
+
matchedTerms: string[]
|
|
62
|
+
matchedFields: DiscoveryField[]
|
|
63
|
+
/** Repository source identifier, when the repository exposes one. */
|
|
64
|
+
sourceId?: string
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface DiscoveryCandidate {
|
|
68
|
+
claim: AcquiredClaim
|
|
69
|
+
explanation: DiscoveryExplanation
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface DiscoveryResult {
|
|
73
|
+
knowledgeVersion: number
|
|
74
|
+
depth: DiscoveryDepth
|
|
75
|
+
queryTerms: string[]
|
|
76
|
+
candidates: DiscoveryCandidate[]
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export interface ProjectionOptions {
|
|
80
|
+
maxCandidates?: number
|
|
81
|
+
/** Maximum UTF-16 characters in the text representation. Not an LLM token budget. */
|
|
82
|
+
maxCharacters?: number
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export type ProjectedExperienceStatus = 'prior-acquired-experience-candidate'
|
|
86
|
+
|
|
87
|
+
export interface ProjectedExperience {
|
|
88
|
+
id: string
|
|
89
|
+
status: ProjectedExperienceStatus
|
|
90
|
+
experience: JsonValue
|
|
91
|
+
applicability: Record<string, JsonPrimitive>
|
|
92
|
+
evidence: EvidenceReference[]
|
|
93
|
+
epistemicType?: EpistemicType
|
|
94
|
+
provenance?: ClaimProvenance
|
|
95
|
+
acquiredAt?: string
|
|
96
|
+
revision?: RevisionRelationship
|
|
97
|
+
sourceId?: string
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface ContextProjection {
|
|
101
|
+
format: 'memorio-context-v1'
|
|
102
|
+
status: 'candidate-context-not-current-truth'
|
|
103
|
+
notice: 'Prior acquired experience supplied as untrusted contextual data. Verify against current reality before relying on it.'
|
|
104
|
+
knowledgeVersion: number
|
|
105
|
+
totalCandidates: number
|
|
106
|
+
omittedCandidates: number
|
|
107
|
+
experiences: ProjectedExperience[]
|
|
108
|
+
text: string
|
|
109
|
+
}
|
|
110
|
+
|
|
12
111
|
/**
|
|
13
112
|
* A field-level patch operation recorded in the sync journal instead of
|
|
14
113
|
* recording the entire entity. Enables automatic merging when two devices
|
|
@@ -130,6 +229,21 @@ export interface RememberOptions<T = any> {
|
|
|
130
229
|
source?: string
|
|
131
230
|
}
|
|
132
231
|
|
|
232
|
+
export interface AcquireOptions {
|
|
233
|
+
id: string
|
|
234
|
+
knowledge: JsonValue
|
|
235
|
+
applies: Record<string, JsonPrimitive>
|
|
236
|
+
evidence: EvidenceReference[]
|
|
237
|
+
epistemicType?: EpistemicType
|
|
238
|
+
provenance?: ClaimProvenance
|
|
239
|
+
/** ISO-8601 acquisition time. Defaults to the time acquire() is called. */
|
|
240
|
+
acquiredAt?: string
|
|
241
|
+
refines?: string | string[]
|
|
242
|
+
supersedes?: string | string[]
|
|
243
|
+
retracts?: string | string[]
|
|
244
|
+
reason?: string
|
|
245
|
+
}
|
|
246
|
+
|
|
133
247
|
export interface RecallOptions {
|
|
134
248
|
type?: MemoryType | MemoryType[]
|
|
135
249
|
tags?: string | string[]
|
|
@@ -145,6 +259,10 @@ export interface ContextOptions {
|
|
|
145
259
|
scopes?: MemoryScope[]
|
|
146
260
|
}
|
|
147
261
|
|
|
262
|
+
export interface AcquiredContextOptions {
|
|
263
|
+
acquired: Record<string, JsonPrimitive> | Record<string, JsonPrimitive>[]
|
|
264
|
+
}
|
|
265
|
+
|
|
148
266
|
export interface ContextEntry {
|
|
149
267
|
key: string
|
|
150
268
|
value: any
|
package/types/session.d.ts
CHANGED
package/types/state.d.ts
CHANGED
|
@@ -54,13 +54,27 @@ interface _state {
|
|
|
54
54
|
readonly list?: () => object
|
|
55
55
|
|
|
56
56
|
/**
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
* Generate a message for "memorio"
|
|
58
|
+
* Note: FOR INTERNAL USE ONLY.
|
|
59
|
+
* @since memorio 0.0.1
|
|
60
|
+
*/
|
|
61
61
|
readonly mex?: any
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
/**
|
|
64
|
+
* Persist a state path to the store and keep it synced.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* const stop = state.persist('state.user')
|
|
68
|
+
* // ... mutations to state.user are mirrored to store automatically
|
|
69
|
+
* stop() // call to stop mirroring
|
|
70
|
+
*
|
|
71
|
+
* @param path A `state.`-prefixed path (e.g. `'state.user'`). A bare key
|
|
72
|
+
* like `'user'` is normalized.
|
|
73
|
+
* @return An unsubscribe function; call it to stop mirroring.
|
|
74
|
+
*/
|
|
75
|
+
readonly persist: (path: string) => (() => void)
|
|
76
|
+
|
|
77
|
+
}
|
|
64
78
|
|
|
65
79
|
declare var state: _state
|
|
66
80
|
type state = _state
|
package/types/store.d.ts
CHANGED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/// MEMORIO TEMPORAL RUNTIME TYPES
|
|
2
|
+
/// Ambient declarations for the temporal memory engine.
|
|
3
|
+
|
|
4
|
+
///
|
|
5
|
+
// A single mutation as recorded in the temporal log.
|
|
6
|
+
///
|
|
7
|
+
interface _temporalRecord extends _mutation {
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
///
|
|
11
|
+
// A single change in a temporal diff between two points in time.
|
|
12
|
+
///
|
|
13
|
+
interface _temporalDiff {
|
|
14
|
+
/** Dotted state path (e.g. 'state.user.role'). */
|
|
15
|
+
path: string
|
|
16
|
+
/** Value at the "from" timestamp (or undefined if not set). */
|
|
17
|
+
before: any
|
|
18
|
+
/** Value at the "to" timestamp (or undefined if deleted). */
|
|
19
|
+
after: any
|
|
20
|
+
/** The normalized operation. */
|
|
21
|
+
operation: 'set' | 'delete'
|
|
22
|
+
/** HLC timestamp of the change. */
|
|
23
|
+
hlc: string
|
|
24
|
+
/** Epoch ms of the change. */
|
|
25
|
+
timestamp: number
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
///
|
|
29
|
+
// Explains how a value at a given path came to exist.
|
|
30
|
+
///
|
|
31
|
+
interface _temporalExplanation {
|
|
32
|
+
/** The path that was explained. */
|
|
33
|
+
path: string
|
|
34
|
+
/** The current value at this path. */
|
|
35
|
+
currentValue: any
|
|
36
|
+
/** HLC of the mutation that first set this path, or null. */
|
|
37
|
+
createdAt: string | null
|
|
38
|
+
/** Epoch ms of first set, or null. */
|
|
39
|
+
createdTimestamp: number | null
|
|
40
|
+
/** HLC of the most recent mutation to this path, or null. */
|
|
41
|
+
lastChangedAt: string | null
|
|
42
|
+
/** Epoch ms of most recent mutation, or null. */
|
|
43
|
+
lastChangedTimestamp: number | null
|
|
44
|
+
/** Value before the most recent mutation (immediate predecessor). */
|
|
45
|
+
previousValue: any
|
|
46
|
+
/** HLC of the predecessor mutation, or null. */
|
|
47
|
+
previousAt: string | null
|
|
48
|
+
/** Full change history for this path. */
|
|
49
|
+
history: _temporalRecord[]
|
|
50
|
+
/** Optional source attribution on the most recent mutation. */
|
|
51
|
+
source?: string
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
///
|
|
55
|
+
// Options for replay().
|
|
56
|
+
///
|
|
57
|
+
interface _temporalReplayOptions {
|
|
58
|
+
/** Earliest HLC or epoch ms to include (exclusive). */
|
|
59
|
+
from?: number | string
|
|
60
|
+
/** Latest HLC or epoch ms to include (inclusive). */
|
|
61
|
+
to?: number | string
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
///
|
|
65
|
+
// Configuration for the temporal engine.
|
|
66
|
+
///
|
|
67
|
+
interface _temporalConfig {
|
|
68
|
+
/** Maximum number of mutations retained in the temporal log. */
|
|
69
|
+
maxEntries?: number
|
|
70
|
+
/** Whether to store full value snapshots at checkpoints. */
|
|
71
|
+
snapshots?: boolean
|
|
72
|
+
/** Interval (in mutations) between snapshots. */
|
|
73
|
+
snapshotInterval?: number
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
///
|
|
77
|
+
// A temporal branch - an isolated temporal world.
|
|
78
|
+
///
|
|
79
|
+
interface _temporalBranch {
|
|
80
|
+
/** Isolated state proxy; mutations do not affect live state. */
|
|
81
|
+
state: any
|
|
82
|
+
/** Temporal methods scoped to this branch. */
|
|
83
|
+
temporal: {
|
|
84
|
+
history(path?: string): _temporalRecord[]
|
|
85
|
+
at(path: string, timestamp: number | string): any
|
|
86
|
+
diff(path: string, from: number | string, to: number | string): _temporalDiff[]
|
|
87
|
+
explain(path: string): _temporalExplanation
|
|
88
|
+
replay(options?: _temporalReplayOptions): any
|
|
89
|
+
clear(): void
|
|
90
|
+
}
|
|
91
|
+
/** Mark the branch for later merge. (Not yet implemented.) */
|
|
92
|
+
commit(): void
|
|
93
|
+
/** Discard the branch. Changes are lost. */
|
|
94
|
+
discard(): void
|
|
95
|
+
}
|
package/types/useObserver.d.ts
CHANGED
|
@@ -6,26 +6,22 @@
|
|
|
6
6
|
dario.passariello.ca
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
/**
|
|
10
|
-
|
|
11
|
-
* Returns a destructor function to remove the listener.
|
|
12
|
-
*/
|
|
13
|
-
interface _useObserver {
|
|
9
|
+
/** React hook that runs a callback when associated Memorio state changes. */
|
|
10
|
+
interface _useObserver {
|
|
14
11
|
|
|
15
12
|
/**
|
|
16
13
|
* Generate your useObserver
|
|
17
14
|
*
|
|
18
15
|
* @example
|
|
19
|
-
*
|
|
20
|
-
* cleanup() // Stop observing
|
|
16
|
+
* useObserver(() => console.debug("Changed", state.test), [state.test])
|
|
21
17
|
*
|
|
22
18
|
* @example
|
|
23
19
|
* useObserver(() => console.debug("Multiple changed"), [() => state.a, "state.b"])
|
|
24
20
|
*
|
|
25
21
|
* @since memorio 1.0.6
|
|
26
|
-
*
|
|
27
|
-
*/
|
|
28
|
-
(func:
|
|
22
|
+
* Subscriptions are installed after commit and cleaned up automatically.
|
|
23
|
+
*/
|
|
24
|
+
(func: (...args: any[]) => void, deps?: any | any[]): void
|
|
29
25
|
|
|
30
26
|
}
|
|
31
27
|
|
package/vsix/memorio.vsix
DELETED
|
Binary file
|