@dsh-enhanced/personal-memory 0.1.3

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/lib/store.d.ts ADDED
@@ -0,0 +1,98 @@
1
+ import type { ApprovedMemoryMutation, MemoryAgentContext, MemoryExportDocument, MemoryIdentity, MemoryMutation, MemoryProposalInput, MemoryRecord, MemorySearchHit, MemorySearchRequest, MemorySnapshot, MemorySnapshotRequest, StoredMemoryProposal, StoredMemoryProposalIntent } from './types.js';
2
+ export type MemoryStoreErrorCode = 'content-too-large' | 'duplicate-content' | 'idempotency-conflict' | 'invalid-entry' | 'invalid-identity' | 'invalid-path' | 'not-found' | 'record-limit' | 'schema-too-new' | 'version-conflict';
3
+ export declare class MemoryStoreError extends Error {
4
+ readonly code: MemoryStoreErrorCode;
5
+ constructor(code: MemoryStoreErrorCode, message: string);
6
+ }
7
+ export interface MemoryStoreOptions {
8
+ path: string;
9
+ maxContentBytes?: number;
10
+ maxRecordsPerIdentity?: number;
11
+ now?: () => number;
12
+ }
13
+ export interface PrepareMemoryProposalIntentInput extends MemoryProposalInput {
14
+ proposalId: string;
15
+ mutationHash: string;
16
+ }
17
+ export type PrepareMemoryProposalStateResult = Readonly<{
18
+ kind: 'proposal';
19
+ proposal: StoredMemoryProposal;
20
+ }> | Readonly<{
21
+ kind: 'intent';
22
+ intent: StoredMemoryProposalIntent;
23
+ replayed: boolean;
24
+ }> | Readonly<{
25
+ kind: 'conflict';
26
+ }>;
27
+ export interface SaveMemoryProposalInput {
28
+ proposalId: string;
29
+ policyProposalId: string;
30
+ idempotencyKey: string;
31
+ requester: string;
32
+ principal: string;
33
+ mutation: MemoryMutation;
34
+ mutationHash: string;
35
+ expiresAt: number;
36
+ version: number;
37
+ }
38
+ export type SettleMemoryProposalInput = {
39
+ proposalId: string;
40
+ policyStatus: 'approved' | 'expired' | 'rejected';
41
+ policyVersion: number;
42
+ } | {
43
+ proposalId: string;
44
+ policyStatus: 'conflicted';
45
+ };
46
+ export interface SettleMemoryProposalResult {
47
+ proposal: StoredMemoryProposal;
48
+ record?: MemoryRecord;
49
+ replayed: boolean;
50
+ }
51
+ export declare function hashMemoryMutation(mutation: MemoryMutation): string;
52
+ export declare function missingPolicyProposalId(proposalId: string, ttlMs: number, dispatch: MemoryProposalInput['dispatch']): string;
53
+ export declare function isMissingPolicyProposalId(proposalId: string): boolean;
54
+ export declare class MemoryStore {
55
+ #private;
56
+ constructor(options: MemoryStoreOptions);
57
+ close(): void;
58
+ get(identity: MemoryIdentity, id: string): MemoryRecord | undefined;
59
+ list(identity: MemoryIdentity, options?: {
60
+ includeRemoved?: boolean;
61
+ }): MemoryRecord[];
62
+ read(context: MemoryAgentContext, ids: readonly string[]): MemoryRecord[];
63
+ health(): {
64
+ activeRecords: number;
65
+ removedRecords: number;
66
+ expiredRecords: number;
67
+ pendingProposals: number;
68
+ };
69
+ search(request: MemorySearchRequest): MemorySearchHit[];
70
+ snapshot(request: MemorySnapshotRequest): MemorySnapshot;
71
+ exportDocument(context: MemoryAgentContext): MemoryExportDocument;
72
+ normalizeMutation(mutation: MemoryMutation, options?: {
73
+ preflight?: boolean;
74
+ }): MemoryMutation;
75
+ prepareProposalIntent(input: PrepareMemoryProposalIntentInput): PrepareMemoryProposalStateResult;
76
+ getProposalIntent(proposalId: string): StoredMemoryProposalIntent | undefined;
77
+ listProposalIntents(limit: number): StoredMemoryProposalIntent[];
78
+ deferProposalIntent(proposalId: string): void;
79
+ /** Fail closed after Policy atomically abandons or rejects exact recovery. */
80
+ conflictProposalIntent(proposalId: string): {
81
+ proposal: StoredMemoryProposal;
82
+ replayed: boolean;
83
+ };
84
+ saveProposal(input: SaveMemoryProposalInput): {
85
+ proposal: StoredMemoryProposal;
86
+ replayed: boolean;
87
+ };
88
+ getProposal(proposalId: string): StoredMemoryProposal | undefined;
89
+ /**
90
+ * List proposals still pending locally, oldest first. A reconciler pairs these
91
+ * with the policy decision to commit approvals that were decided out of band.
92
+ */
93
+ listPendingProposals(limit: number): StoredMemoryProposal[];
94
+ deferPendingProposal(proposalId: string): void;
95
+ settleProposal(input: SettleMemoryProposalInput): SettleMemoryProposalResult;
96
+ applyApprovedMutation(mutation: ApprovedMemoryMutation): MemoryRecord;
97
+ }
98
+ //# sourceMappingURL=store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,sBAAsB,EACtB,kBAAkB,EAElB,oBAAoB,EACpB,cAAc,EAEd,cAAc,EACd,mBAAmB,EAEnB,YAAY,EACZ,eAAe,EACf,mBAAmB,EAGnB,cAAc,EACd,qBAAqB,EAErB,oBAAoB,EACpB,0BAA0B,EAC3B,MAAM,YAAY,CAAA;AAEnB,MAAM,MAAM,oBAAoB,GAC5B,mBAAmB,GACnB,mBAAmB,GACnB,sBAAsB,GACtB,eAAe,GACf,kBAAkB,GAClB,cAAc,GACd,WAAW,GACX,cAAc,GACd,gBAAgB,GAChB,kBAAkB,CAAA;AAEtB,qBAAa,gBAAiB,SAAQ,KAAK;IAC7B,QAAQ,CAAC,IAAI,EAAE,oBAAoB;gBAA1B,IAAI,EAAE,oBAAoB,EAAE,OAAO,EAAE,MAAM;CAIjE;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAA;IACZ,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B,GAAG,CAAC,EAAE,MAAM,MAAM,CAAA;CACnB;AA4DD,MAAM,WAAW,gCAAiC,SAAQ,mBAAmB;IAC3E,UAAU,EAAE,MAAM,CAAA;IAClB,YAAY,EAAE,MAAM,CAAA;CACrB;AAED,MAAM,MAAM,gCAAgC,GACxC,QAAQ,CAAC;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,EAAE,oBAAoB,CAAA;CAAE,CAAC,GAC9D,QAAQ,CAAC;IAAE,IAA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