@felan-ai/ext-memory 0.0.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/LICENSE +22 -0
- package/NOTICE +7 -0
- package/README.md +69 -0
- package/dist/checkpoint.d.ts +16 -0
- package/dist/checkpoint.d.ts.map +1 -0
- package/dist/checkpoint.js +127 -0
- package/dist/checkpoint.js.map +1 -0
- package/dist/contracts.d.ts +86 -0
- package/dist/contracts.d.ts.map +1 -0
- package/dist/contracts.js +10 -0
- package/dist/contracts.js.map +1 -0
- package/dist/dreamer.d.ts +6 -0
- package/dist/dreamer.d.ts.map +1 -0
- package/dist/dreamer.js +2 -0
- package/dist/dreamer.js.map +1 -0
- package/dist/hydration.d.ts +14 -0
- package/dist/hydration.d.ts.map +1 -0
- package/dist/hydration.js +160 -0
- package/dist/hydration.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +69 -0
- package/dist/index.js.map +1 -0
- package/dist/manifest.d.ts +6 -0
- package/dist/manifest.d.ts.map +1 -0
- package/dist/manifest.js +99 -0
- package/dist/manifest.js.map +1 -0
- package/dist/schema.d.ts +19 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +109 -0
- package/dist/schema.js.map +1 -0
- package/dist/validation.d.ts +8 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +234 -0
- package/dist/validation.js.map +1 -0
- package/package.json +42 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Felan contributors
|
|
4
|
+
Copyright (c) 2026 Milko Slavov
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
@felan-ai/ext-memory
|
|
2
|
+
|
|
3
|
+
The Markdown memory schema and dreaming policy were adapted from Felan's
|
|
4
|
+
filesystem-memory implementation and local-first memory architecture.
|
|
5
|
+
|
|
6
|
+
The package otherwise contains original Felan project code and is distributed
|
|
7
|
+
under the MIT License in LICENSE.
|
package/README.md
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# @felan-ai/ext-memory
|
|
2
|
+
|
|
3
|
+
Portable local-first memory contracts, Markdown artifact policy, validation,
|
|
4
|
+
and Pi extension behavior for Felan hosts.
|
|
5
|
+
|
|
6
|
+
Applications bind the extension to their own storage and coordinator:
|
|
7
|
+
|
|
8
|
+
```ts
|
|
9
|
+
createMemoryExtension({
|
|
10
|
+
role: 'root',
|
|
11
|
+
host,
|
|
12
|
+
});
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
`root` sessions read memory and report settled transcript cursors. `reader`
|
|
16
|
+
sessions only read memory. The package does not choose a project/team scope,
|
|
17
|
+
schedule workers, call a model, publish artifacts, or import a cloud/local host.
|
|
18
|
+
After a root checkpoint is recorded, the application host decides whether to
|
|
19
|
+
schedule processing. The portable extension never wakes a worker itself.
|
|
20
|
+
|
|
21
|
+
Memory is a Markdown wiki containing `summary.md`, `index.md`, and topical
|
|
22
|
+
pages under `pages/`. The summary is orientation only: substantive claims
|
|
23
|
+
should follow the index to relevant area and topic pages and cite their paths
|
|
24
|
+
and `Sources` session IDs. Hosts project a non-authoritative copy into each
|
|
25
|
+
root session and retain canonical storage outside customer repositories.
|
|
26
|
+
|
|
27
|
+
The extension appends one hidden, persisted memory-context message when a
|
|
28
|
+
session starts. Later provider calls reuse that session context instead of
|
|
29
|
+
injecting a new message on every `context` event. If compaction or tree
|
|
30
|
+
navigation removes the message from the active branch, the extension restores
|
|
31
|
+
one copy. The message is excluded from checkpoint evidence so memory cannot
|
|
32
|
+
learn its own injected prompt.
|
|
33
|
+
|
|
34
|
+
When a user explicitly asks to remember, forget, or change memory, the session
|
|
35
|
+
prompt asks the agent to leave a concise, attributed memory note rather than
|
|
36
|
+
claim an immediate canonical update. A later dreamer treats the original
|
|
37
|
+
user-authored request as direct evidence; the assistant note is only a pointer
|
|
38
|
+
to that request.
|
|
39
|
+
|
|
40
|
+
Local Felan's host-owned coordinator runs dreaming as a disposable headless Pi
|
|
41
|
+
session over staged `.dreaming/input` and `.memory` directories. The dreamer
|
|
42
|
+
uses only read/list/edit/write file tools, has no normal extensions, skills,
|
|
43
|
+
repository access, or process execution, and returns a summary only after
|
|
44
|
+
editing the staged Markdown artifact. The host validates and publishes that
|
|
45
|
+
filesystem output; failed or cancelled work remains pending. The local worker
|
|
46
|
+
uses the host-selected authenticated session model and may fall back to another
|
|
47
|
+
authenticated available model when that selection is unavailable. It does not
|
|
48
|
+
impose separate turn, tool-call, or per-file I/O budgets; its only execution
|
|
49
|
+
failsafe is a one-hour wall-clock timeout. The host-side evidence
|
|
50
|
+
materializer is a separate boundary: it streams the checkpoint's visible
|
|
51
|
+
active-branch delta from JSONL, ignores unrelated branches, redacts it, and
|
|
52
|
+
caps each staged transcript at 256 KiB. Large source session files are not
|
|
53
|
+
rejected solely for their total size. Deterministic source failures remain
|
|
54
|
+
pending for retry, while valid checkpoints in the same batch can still be
|
|
55
|
+
published.
|
|
56
|
+
|
|
57
|
+
The memory schema asks the dreamer to update every affected topic, entity, and
|
|
58
|
+
concept page; add meaningful cross-links; preserve valid historical citations;
|
|
59
|
+
mark superseded guidance and unresolved contradictions; and run a bounded
|
|
60
|
+
semantic lint for stale, duplicate, weakly linked, or missing knowledge without
|
|
61
|
+
inventing facts, links, or sources.
|
|
62
|
+
|
|
63
|
+
Source: `packages/ext-memory` in <https://github.com/felan-ai/felan>.
|
|
64
|
+
|
|
65
|
+
```sh
|
|
66
|
+
pnpm --filter @felan-ai/ext-memory build
|
|
67
|
+
pnpm --filter @felan-ai/ext-memory type-check
|
|
68
|
+
pnpm --filter @felan-ai/ext-memory test
|
|
69
|
+
```
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ExtensionContext } from '@felan-ai/agent-core';
|
|
2
|
+
import type { SessionCheckpoint } from './contracts.js';
|
|
3
|
+
export declare const MEMORY_CONTEXT_CUSTOM_TYPE = "felan-memory-context";
|
|
4
|
+
type CheckpointSessionManager = Pick<ExtensionContext['sessionManager'], 'getBranch' | 'getLeafId' | 'getSessionFile' | 'getSessionId'>;
|
|
5
|
+
export declare function createSessionCheckpoint(sessionManager: CheckpointSessionManager): SessionCheckpoint | null;
|
|
6
|
+
export declare function isMemoryContextEntry(value: unknown): boolean;
|
|
7
|
+
export declare function removeMemoryContextEntries(entries: readonly unknown[]): readonly Record<string, unknown>[];
|
|
8
|
+
export declare function visibleMemoryContextLeafId(entries: readonly unknown[], leafId: string | null): string | null;
|
|
9
|
+
export declare function digestActiveBranch(branch: readonly unknown[]): string;
|
|
10
|
+
export interface ActiveBranchDigester {
|
|
11
|
+
update(entry: unknown): void;
|
|
12
|
+
digest(): string;
|
|
13
|
+
}
|
|
14
|
+
export declare function createActiveBranchDigester(): ActiveBranchDigester;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=checkpoint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkpoint.d.ts","sourceRoot":"","sources":["../src/checkpoint.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAExD,eAAO,MAAM,0BAA0B,yBAAyB,CAAC;AAEjE,KAAK,wBAAwB,GAAG,IAAI,CAClC,gBAAgB,CAAC,gBAAgB,CAAC,EAClC,WAAW,GAAG,WAAW,GAAG,gBAAgB,GAAG,cAAc,CAC9D,CAAC;AAEF,wBAAgB,uBAAuB,CACrC,cAAc,EAAE,wBAAwB,GACvC,iBAAiB,GAAG,IAAI,CAW1B;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAI5D;AAED,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,SAAS,OAAO,EAAE,GAC1B,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CA+BpC;AAED,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,SAAS,OAAO,EAAE,EAC3B,MAAM,EAAE,MAAM,GAAG,IAAI,GACpB,MAAM,GAAG,IAAI,CAiBf;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,OAAO,EAAE,GAAG,MAAM,CAIrE;AAED,MAAM,WAAW,oBAAoB;IACnC,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;IAC7B,MAAM,IAAI,MAAM,CAAC;CAClB;AAED,wBAAgB,0BAA0B,IAAI,oBAAoB,CAmBjE"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
export const MEMORY_CONTEXT_CUSTOM_TYPE = 'felan-memory-context';
|
|
3
|
+
export function createSessionCheckpoint(sessionManager) {
|
|
4
|
+
const sessionFile = sessionManager.getSessionFile();
|
|
5
|
+
if (!sessionFile)
|
|
6
|
+
return null;
|
|
7
|
+
const leafId = sessionManager.getLeafId();
|
|
8
|
+
const branch = removeMemoryContextEntries(sessionManager.getBranch(leafId ?? undefined));
|
|
9
|
+
return {
|
|
10
|
+
sessionId: sessionManager.getSessionId(),
|
|
11
|
+
sessionFile,
|
|
12
|
+
leafId,
|
|
13
|
+
transcriptDigest: digestActiveBranch(branch),
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export function isMemoryContextEntry(value) {
|
|
17
|
+
return isRecord(value)
|
|
18
|
+
&& value.type === 'custom_message'
|
|
19
|
+
&& value.customType === MEMORY_CONTEXT_CUSTOM_TYPE;
|
|
20
|
+
}
|
|
21
|
+
export function removeMemoryContextEntries(entries) {
|
|
22
|
+
const records = entries.filter(isRecord);
|
|
23
|
+
const byId = new Map(records
|
|
24
|
+
.filter((entry) => typeof entry.id === 'string')
|
|
25
|
+
.map((entry) => [entry.id, entry]));
|
|
26
|
+
const memoryIds = new Set(records
|
|
27
|
+
.filter((entry) => isMemoryContextEntry(entry) && typeof entry.id === 'string')
|
|
28
|
+
.map((entry) => entry.id));
|
|
29
|
+
const resolveVisibleParent = (id) => {
|
|
30
|
+
let current = id;
|
|
31
|
+
const seen = new Set();
|
|
32
|
+
while (current !== null && memoryIds.has(current)) {
|
|
33
|
+
if (seen.has(current))
|
|
34
|
+
return null;
|
|
35
|
+
seen.add(current);
|
|
36
|
+
const parent = byId.get(current)?.parentId;
|
|
37
|
+
current = typeof parent === 'string' ? parent : null;
|
|
38
|
+
}
|
|
39
|
+
return current;
|
|
40
|
+
};
|
|
41
|
+
return records
|
|
42
|
+
.filter((entry) => !isMemoryContextEntry(entry))
|
|
43
|
+
.map((entry) => {
|
|
44
|
+
if (typeof entry.parentId !== 'string' || !memoryIds.has(entry.parentId))
|
|
45
|
+
return entry;
|
|
46
|
+
return { ...entry, parentId: resolveVisibleParent(entry.parentId) };
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
export function visibleMemoryContextLeafId(entries, leafId) {
|
|
50
|
+
if (leafId === null)
|
|
51
|
+
return null;
|
|
52
|
+
const byId = new Map(entries
|
|
53
|
+
.filter(isRecord)
|
|
54
|
+
.filter((entry) => typeof entry.id === 'string')
|
|
55
|
+
.map((entry) => [entry.id, entry]));
|
|
56
|
+
let current = leafId;
|
|
57
|
+
const seen = new Set();
|
|
58
|
+
while (current !== null && isMemoryContextEntry(byId.get(current))) {
|
|
59
|
+
if (seen.has(current))
|
|
60
|
+
return null;
|
|
61
|
+
seen.add(current);
|
|
62
|
+
const parent = byId.get(current)?.parentId;
|
|
63
|
+
current = typeof parent === 'string' ? parent : null;
|
|
64
|
+
}
|
|
65
|
+
return current;
|
|
66
|
+
}
|
|
67
|
+
export function digestActiveBranch(branch) {
|
|
68
|
+
const digester = createActiveBranchDigester();
|
|
69
|
+
for (const entry of branch)
|
|
70
|
+
digester.update(entry);
|
|
71
|
+
return digester.digest();
|
|
72
|
+
}
|
|
73
|
+
export function createActiveBranchDigester() {
|
|
74
|
+
const hash = createHash('sha256');
|
|
75
|
+
let entries = 0;
|
|
76
|
+
let finalized = false;
|
|
77
|
+
hash.update('[');
|
|
78
|
+
return {
|
|
79
|
+
update(entry) {
|
|
80
|
+
if (finalized)
|
|
81
|
+
throw new Error('Active branch digest is already finalized');
|
|
82
|
+
if (entries > 0)
|
|
83
|
+
hash.update(',');
|
|
84
|
+
updateCanonicalJson(hash, entry);
|
|
85
|
+
entries += 1;
|
|
86
|
+
},
|
|
87
|
+
digest() {
|
|
88
|
+
if (finalized)
|
|
89
|
+
throw new Error('Active branch digest is already finalized');
|
|
90
|
+
finalized = true;
|
|
91
|
+
hash.update(']');
|
|
92
|
+
return hash.digest('hex');
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
function updateCanonicalJson(hash, value) {
|
|
97
|
+
if (value === null || typeof value !== 'object') {
|
|
98
|
+
hash.update(JSON.stringify(value) ?? 'null');
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
if (Array.isArray(value)) {
|
|
102
|
+
hash.update('[');
|
|
103
|
+
for (const [index, entry] of value.entries()) {
|
|
104
|
+
if (index > 0)
|
|
105
|
+
hash.update(',');
|
|
106
|
+
updateCanonicalJson(hash, entry);
|
|
107
|
+
}
|
|
108
|
+
hash.update(']');
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
const entries = Object.entries(value)
|
|
112
|
+
.filter(([, entry]) => entry !== undefined)
|
|
113
|
+
.sort(([left], [right]) => left.localeCompare(right));
|
|
114
|
+
hash.update('{');
|
|
115
|
+
for (const [index, [key, entry]] of entries.entries()) {
|
|
116
|
+
if (index > 0)
|
|
117
|
+
hash.update(',');
|
|
118
|
+
hash.update(JSON.stringify(key));
|
|
119
|
+
hash.update(':');
|
|
120
|
+
updateCanonicalJson(hash, entry);
|
|
121
|
+
}
|
|
122
|
+
hash.update('}');
|
|
123
|
+
}
|
|
124
|
+
function isRecord(value) {
|
|
125
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=checkpoint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkpoint.js","sourceRoot":"","sources":["../src/checkpoint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,MAAM,aAAa,CAAC;AAIpD,MAAM,CAAC,MAAM,0BAA0B,GAAG,sBAAsB,CAAC;AAOjE,MAAM,UAAU,uBAAuB,CACrC,cAAwC;IAExC,MAAM,WAAW,GAAG,cAAc,CAAC,cAAc,EAAE,CAAC;IACpD,IAAI,CAAC,WAAW;QAAE,OAAO,IAAI,CAAC;IAC9B,MAAM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,MAAM,CAAC,KAAK,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,IAAI,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;QACtD,IAAI,KAAK,GAAG,CAAC;YAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAChC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;QACjC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACjB,mBAAmB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACnC,CAAC;IACD,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AACnB,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
export declare const MEMORY_ARTIFACT_VERSION: 1;
|
|
2
|
+
export declare const MEMORY_INPUT_MANIFEST_VERSION: 1;
|
|
3
|
+
export type MemoryRole = 'root' | 'reader';
|
|
4
|
+
export interface MemoryFile {
|
|
5
|
+
/** POSIX path relative to the logical .memory root. */
|
|
6
|
+
readonly path: string;
|
|
7
|
+
readonly content: string;
|
|
8
|
+
}
|
|
9
|
+
export interface MemoryArtifact {
|
|
10
|
+
readonly version: typeof MEMORY_ARTIFACT_VERSION;
|
|
11
|
+
readonly files: readonly MemoryFile[];
|
|
12
|
+
}
|
|
13
|
+
export interface MemorySnapshot extends MemoryArtifact {
|
|
14
|
+
/** SHA-256 fingerprint of the complete canonical artifact. */
|
|
15
|
+
readonly fingerprint: string;
|
|
16
|
+
/** Agent-visible path of this session's non-authoritative projection. */
|
|
17
|
+
readonly memoryPath: string;
|
|
18
|
+
}
|
|
19
|
+
export interface SessionCheckpoint {
|
|
20
|
+
readonly sessionId: string;
|
|
21
|
+
readonly sessionFile: string;
|
|
22
|
+
readonly leafId: string | null;
|
|
23
|
+
readonly transcriptDigest: string;
|
|
24
|
+
}
|
|
25
|
+
export type MemoryProcessingState = 'disabled' | 'idle' | 'scheduled' | 'processing' | 'blocked' | 'error';
|
|
26
|
+
export interface MemoryStatus {
|
|
27
|
+
readonly enabled: boolean;
|
|
28
|
+
readonly state: MemoryProcessingState;
|
|
29
|
+
readonly pendingCheckpoints: number;
|
|
30
|
+
readonly memoryFingerprint?: string;
|
|
31
|
+
readonly lastProcessedAt?: string;
|
|
32
|
+
/** Sanitized diagnostic which must not contain transcript content or credentials. */
|
|
33
|
+
readonly message?: string;
|
|
34
|
+
}
|
|
35
|
+
export interface MemoryHost {
|
|
36
|
+
readCurrent(): Promise<MemorySnapshot | null>;
|
|
37
|
+
recordCheckpoint(checkpoint: SessionCheckpoint): Promise<void>;
|
|
38
|
+
status(): Promise<MemoryStatus>;
|
|
39
|
+
}
|
|
40
|
+
export interface MemoryInputSession {
|
|
41
|
+
readonly checkpoint: SessionCheckpoint;
|
|
42
|
+
readonly metadataPath: string;
|
|
43
|
+
readonly transcriptPath: string;
|
|
44
|
+
readonly materializedDigest: string;
|
|
45
|
+
readonly byteLength: number;
|
|
46
|
+
readonly redactionCount: number;
|
|
47
|
+
}
|
|
48
|
+
export interface MemoryInputManifest {
|
|
49
|
+
readonly version: typeof MEMORY_INPUT_MANIFEST_VERSION;
|
|
50
|
+
readonly createdAt: string;
|
|
51
|
+
readonly baseMemoryFingerprint: string;
|
|
52
|
+
readonly sessions: readonly MemoryInputSession[];
|
|
53
|
+
}
|
|
54
|
+
export interface MemoryArtifactLimits {
|
|
55
|
+
readonly maxFiles: number;
|
|
56
|
+
readonly maxFileBytes: number;
|
|
57
|
+
readonly maxTotalBytes: number;
|
|
58
|
+
readonly maxAreas: number;
|
|
59
|
+
readonly maxPagesPerArea: number;
|
|
60
|
+
}
|
|
61
|
+
export declare const DEFAULT_MEMORY_ARTIFACT_LIMITS: MemoryArtifactLimits;
|
|
62
|
+
export interface MemoryValidationOptions {
|
|
63
|
+
readonly limits?: Partial<MemoryArtifactLimits>;
|
|
64
|
+
readonly sourceSessionIds?: readonly string[];
|
|
65
|
+
readonly requireSources?: boolean;
|
|
66
|
+
readonly memoryPath?: string;
|
|
67
|
+
}
|
|
68
|
+
export interface MemoryValidationError {
|
|
69
|
+
readonly code: 'duplicate_path' | 'invalid_path' | 'unsupported_version' | 'invalid_file_type' | 'invalid_markdown' | 'missing_required_file' | 'file_too_large' | 'too_many_files' | 'too_many_areas' | 'too_many_pages' | 'total_too_large' | 'summary_has_links' | 'invalid_link' | 'broken_link' | 'unreachable_page' | 'missing_sources' | 'unknown_source';
|
|
70
|
+
readonly path?: string;
|
|
71
|
+
readonly message: string;
|
|
72
|
+
}
|
|
73
|
+
export interface MemoryValidationResult {
|
|
74
|
+
readonly ok: boolean;
|
|
75
|
+
readonly artifact?: MemoryArtifact;
|
|
76
|
+
readonly errors: readonly MemoryValidationError[];
|
|
77
|
+
}
|
|
78
|
+
export interface MemoryHydrationOptions extends MemoryValidationOptions {
|
|
79
|
+
readonly replace?: boolean;
|
|
80
|
+
}
|
|
81
|
+
export interface MemoryInputManifestOptions {
|
|
82
|
+
readonly baseMemoryFingerprint: string;
|
|
83
|
+
readonly sessions: readonly MemoryInputSession[];
|
|
84
|
+
readonly createdAt?: string;
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=contracts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,uBAAuB,EAAG,CAAU,CAAC;AAClD,eAAO,MAAM,6BAA6B,EAAG,CAAU,CAAC;AAExD,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,QAAQ,CAAC;AAE3C,MAAM,WAAW,UAAU;IACzB,uDAAuD;IACvD,QAAQ,CAAC,IAAI,EAAE,MAAM,C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gBAAgB,GAChB,gBAAgB,GAChB,gBAAgB,GAChB,gBAAgB,GAChB,iBAAiB,GACjB,mBAAmB,GACnB,cAAc,GACd,aAAa,GACb,kBAAkB,GAClB,iBAAiB,GACjB,gBAAgB,CAAC;IACrB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,QAAQ,CAAC,EAAE,cAAc,CAAC;IACnC,QAAQ,CAAC,MAAM,EAAE,SAAS,qBAAqB,EAAE,CAAC;CACnD;AAED,MAAM,WAAW,sBAAuB,SAAQ,uBAAuB;IACrE,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,qBAAqB,EAAE,MAAM,CAAC;IACvC,QAAQ,CAAC,QAAQ,EAAE,SAAS,kBAAkB,EAAE,CAAC;IACjD,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export const MEMORY_ARTIFACT_VERSION = 1;
|
|
2
|
+
export const MEMORY_INPUT_MANIFEST_VERSION = 1;
|
|
3
|
+
export const DEFAULT_MEMORY_ARTIFACT_LIMITS = Object.freeze({
|
|
4
|
+
maxFiles: 256,
|
|
5
|
+
maxFileBytes: 256 * 1024,
|
|
6
|
+
maxTotalBytes: 4 * 1024 * 1024,
|
|
7
|
+
maxAreas: 32,
|
|
8
|
+
maxPagesPerArea: 32,
|
|
9
|
+
});
|
|
10
|
+
//# sourceMappingURL=contracts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contracts.js","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAU,CAAC;AAClD,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAU,CAAC;AA6ExD,MAAM,CAAC,MAAM,8BAA8B,GAAyB,MAAM,CAAC,MAAM,CAAC;IAChF,QAAQ,EAAE,GAAG;IACb,YAAY,EAAE,GAAG,GAAG,IAAI;IACxB,aAAa,EAAE,CAAC,GAAG,IAAI,GAAG,IAAI;IAC9B,QAAQ,EAAE,EAAE;IACZ,eAAe,EAAE,EAAE;CACpB,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dreamer.d.ts","sourceRoot":"","sources":["../src/dreamer.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,+BAA+B,EAC/B,0BAA0B,GAC3B,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B"}
|
package/dist/dreamer.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dreamer.js","sourceRoot":"","sources":["../src/dreamer.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,+BAA+B,EAC/B,0BAA0B,GAC3B,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type MemoryArtifact, type MemoryFile, type MemoryHydrationOptions, type MemorySnapshot } from './contracts.js';
|
|
2
|
+
export declare function memoryArtifactFingerprint(artifact: MemoryArtifact | readonly MemoryFile[]): string;
|
|
3
|
+
export declare function createMemorySnapshot(artifact: MemoryArtifact | readonly MemoryFile[], memoryPath: string, options?: MemoryHydrationOptions): MemorySnapshot;
|
|
4
|
+
/**
|
|
5
|
+
* Rebase root-index navigation for an agent-visible projection while retaining
|
|
6
|
+
* the fingerprint of the unchanged canonical artifact.
|
|
7
|
+
*/
|
|
8
|
+
export declare function createMemoryProjectionSnapshot(snapshot: MemorySnapshot, memoryPath: string): MemorySnapshot;
|
|
9
|
+
export declare function createEmptyMemoryArtifact(memoryPath: string): MemoryArtifact;
|
|
10
|
+
export declare function readMemoryDirectory(root: string, options?: MemoryHydrationOptions): Promise<MemoryArtifact>;
|
|
11
|
+
export declare function hydrateMemoryDirectory(artifact: MemoryArtifact | readonly MemoryFile[], target: string, options?: MemoryHydrationOptions): Promise<void>;
|
|
12
|
+
export declare function hydrateMemorySnapshot(snapshot: MemorySnapshot, target: string, options?: MemoryHydrationOptions): Promise<void>;
|
|
13
|
+
export declare function validateMemoryDirectoryInput(artifact: MemoryArtifact | readonly MemoryFile[], options?: MemoryHydrationOptions): void;
|
|
14
|
+
//# sourceMappingURL=hydration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hydration.d.ts","sourceRoot":"","sources":["../src/hydration.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,cAAc,EAEnB,KAAK,UAAU,EACf,KAAK,sBAAsB,EAC3B,KAAK,cAAc,EACpB,MAAM,gBAAgB,CAAC;AAYxB,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,cAAc,GAAG,SAAS,UAAU,EAAE,GAAG,MAAM,CAWlG;AAED,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,cAAc,GAAG,SAAS,UAAU,EAAE,EAChD,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE,sBAA2B,GACnC,cAAc,CAOhB;AAED;;;GAGG;AACH,wBAAgB,8BAA8B,CAC5C,QAAQ,EAAE,cAAc,EACxB,UAAU,EAAE,MAAM,GACjB,cAAc,CAchB;AAED,wBAAgB,yBAAyB,CAAC,UAAU,EAAE,MAAM,GAAG,cAAc,CAQ5E;AAED,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,sBAA2B,GACnC,OAAO,CAAC,cAAc,CAAC,CAczB;AAED,wBAAsB,sBAAsB,CAC1C,QAAQ,EAAE,cAAc,GAAG,SAAS,UAAU,EAAE,EAChD,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,sBAA2B,GACnC,OAAO,CAAC,IAAI,CAAC,CAsBf;AAED,wBAAsB,qBAAqB,CACzC,QAAQ,EAAE,cAAc,EACxB,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,sBAA2B,GACnC,OAAO,CAAC,IAAI,CAAC,CAEf;AA0ED,wBAAgB,4BAA4B,CAC1C,QAAQ,EAAE,cAAc,GAAG,SAAS,UAAU,EAAE,EAChD,OAAO,GAAE,sBAA2B,GACnC,IAAI,CAGN"}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { mkdtemp, mkdir, readFile, readdir, rename, rm, writeFile, lstat } from 'node:fs/promises';
|
|
3
|
+
import { dirname, join, relative, sep } from 'node:path';
|
|
4
|
+
import { DEFAULT_MEMORY_ARTIFACT_LIMITS, } from './contracts.js';
|
|
5
|
+
import { createDefaultMemoryIndex, createMemoryNavigationGuide } from './schema.js';
|
|
6
|
+
import { assertValidMemoryArtifact, isSafeMemoryPath, resolveMemoryLink, validateMemoryArtifact, } from './validation.js';
|
|
7
|
+
const MARKDOWN_LINK_TARGET = /(!?\[[^\]]*\]\()([^)\s]+)((?:\s+['"][^'"]*['"])?\))/gu;
|
|
8
|
+
const WIKI_LINK_TARGET = /(\[\[)([^\]|#]+)((?:#[^\]|]+)?(?:\|[^\]]+)?)\]\]/gu;
|
|
9
|
+
export function memoryArtifactFingerprint(artifact) {
|
|
10
|
+
const files = 'files' in artifact ? artifact.files : artifact;
|
|
11
|
+
const sorted = [...files].sort((left, right) => left.path.localeCompare(right.path));
|
|
12
|
+
const hash = createHash('sha256');
|
|
13
|
+
for (const file of sorted) {
|
|
14
|
+
hash.update(file.path, 'utf8');
|
|
15
|
+
hash.update('\0', 'utf8');
|
|
16
|
+
hash.update(file.content, 'utf8');
|
|
17
|
+
hash.update('\0', 'utf8');
|
|
18
|
+
}
|
|
19
|
+
return hash.digest('hex');
|
|
20
|
+
}
|
|
21
|
+
export function createMemorySnapshot(artifact, memoryPath, options = {}) {
|
|
22
|
+
const normalized = assertValidMemoryArtifact(artifact, options);
|
|
23
|
+
return {
|
|
24
|
+
...normalized,
|
|
25
|
+
fingerprint: memoryArtifactFingerprint(normalized),
|
|
26
|
+
memoryPath,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Rebase root-index navigation for an agent-visible projection while retaining
|
|
31
|
+
* the fingerprint of the unchanged canonical artifact.
|
|
32
|
+
*/
|
|
33
|
+
export function createMemoryProjectionSnapshot(snapshot, memoryPath) {
|
|
34
|
+
if (snapshot.memoryPath === memoryPath)
|
|
35
|
+
return snapshot;
|
|
36
|
+
const files = snapshot.files.map((file) => file.path === 'index.md'
|
|
37
|
+
? {
|
|
38
|
+
...file,
|
|
39
|
+
content: rebaseMemoryIndex(file.content, snapshot.memoryPath, memoryPath),
|
|
40
|
+
}
|
|
41
|
+
: file);
|
|
42
|
+
const projected = assertValidMemoryArtifact(files, { memoryPath });
|
|
43
|
+
return {
|
|
44
|
+
...projected,
|
|
45
|
+
fingerprint: snapshot.fingerprint,
|
|
46
|
+
memoryPath,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
export function createEmptyMemoryArtifact(memoryPath) {
|
|
50
|
+
return {
|
|
51
|
+
version: 1,
|
|
52
|
+
files: [
|
|
53
|
+
{ path: 'summary.md', content: '' },
|
|
54
|
+
{ path: 'index.md', content: createDefaultMemoryIndex(memoryPath) },
|
|
55
|
+
],
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
export async function readMemoryDirectory(root, options = {}) {
|
|
59
|
+
const files = [];
|
|
60
|
+
let totalBytes = 0;
|
|
61
|
+
const rootStats = await lstat(root);
|
|
62
|
+
if (rootStats.isSymbolicLink() || !rootStats.isDirectory()) {
|
|
63
|
+
throw new Error('Memory root must be a regular directory');
|
|
64
|
+
}
|
|
65
|
+
await walk(root, root, files, options, (bytes) => {
|
|
66
|
+
totalBytes += bytes;
|
|
67
|
+
if (totalBytes > mergedLimits(options.limits).maxTotalBytes) {
|
|
68
|
+
throw new Error(`Memory directory exceeds the ${mergedLimits(options.limits).maxTotalBytes}-byte limit`);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
return assertValidMemoryArtifact(files, options);
|
|
72
|
+
}
|
|
73
|
+
export async function hydrateMemoryDirectory(artifact, target, options = {}) {
|
|
74
|
+
const normalized = assertValidMemoryArtifact(artifact, options);
|
|
75
|
+
const parent = dirname(target);
|
|
76
|
+
await mkdir(parent, { recursive: true, mode: 0o700 });
|
|
77
|
+
const existing = await safeLstat(target);
|
|
78
|
+
if (existing && existing.isSymbolicLink())
|
|
79
|
+
throw new Error('Refusing to hydrate through a symlink');
|
|
80
|
+
if (existing && !options.replace)
|
|
81
|
+
throw new Error(`Memory target already exists: ${target}`);
|
|
82
|
+
const temporary = await mkdtemp(join(parent, '.memory-hydration-'));
|
|
83
|
+
try {
|
|
84
|
+
for (const file of normalized.files) {
|
|
85
|
+
if (!isSafeMemoryPath(file.path))
|
|
86
|
+
throw new Error(`Unsafe memory path: ${file.path}`);
|
|
87
|
+
const path = join(temporary, ...file.path.split('/'));
|
|
88
|
+
await mkdir(dirname(path), { recursive: true, mode: 0o700 });
|
|
89
|
+
await writeFile(path, file.content, { encoding: 'utf8', mode: 0o600, flag: 'wx' });
|
|
90
|
+
}
|
|
91
|
+
if (existing)
|
|
92
|
+
await rm(target, { recursive: true, force: true });
|
|
93
|
+
await rename(temporary, target);
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
await rm(temporary, { recursive: true, force: true });
|
|
97
|
+
throw error;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
export async function hydrateMemorySnapshot(snapshot, target, options = {}) {
|
|
101
|
+
await hydrateMemoryDirectory(snapshot, target, options);
|
|
102
|
+
}
|
|
103
|
+
async function walk(root, current, files, options, onBytes) {
|
|
104
|
+
const entries = await readdir(current, { withFileTypes: true });
|
|
105
|
+
for (const entry of entries) {
|
|
106
|
+
const absolute = join(current, entry.name);
|
|
107
|
+
const relativePath = relative(root, absolute).split(sep).join('/');
|
|
108
|
+
const stats = await lstat(absolute);
|
|
109
|
+
if (stats.isSymbolicLink() || (!stats.isDirectory() && !stats.isFile())) {
|
|
110
|
+
throw new Error(`Unsafe memory entry type: ${relativePath}`);
|
|
111
|
+
}
|
|
112
|
+
if (stats.isDirectory()) {
|
|
113
|
+
await walk(root, absolute, files, options, onBytes);
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
const content = await readFile(absolute, 'utf8');
|
|
117
|
+
onBytes(Buffer.byteLength(content, 'utf8'));
|
|
118
|
+
files.push({ path: relativePath, content });
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
function safeLstat(path) {
|
|
122
|
+
return lstat(path).catch((error) => {
|
|
123
|
+
if (isMissing(error))
|
|
124
|
+
return undefined;
|
|
125
|
+
throw error;
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
function mergedLimits(overrides) {
|
|
129
|
+
return { ...DEFAULT_MEMORY_ARTIFACT_LIMITS, ...(overrides ?? {}) };
|
|
130
|
+
}
|
|
131
|
+
function rebaseMemoryIndex(content, sourceMemoryPath, targetMemoryPath) {
|
|
132
|
+
const sourceGuide = createMemoryNavigationGuide(sourceMemoryPath);
|
|
133
|
+
const targetGuide = createMemoryNavigationGuide(targetMemoryPath);
|
|
134
|
+
return content
|
|
135
|
+
.replace(sourceGuide, targetGuide)
|
|
136
|
+
.replace(MARKDOWN_LINK_TARGET, (match, opening, rawTarget, closing) => {
|
|
137
|
+
const rebased = rebaseMemoryLink(rawTarget, sourceMemoryPath, targetMemoryPath);
|
|
138
|
+
return rebased === undefined ? match : `${opening}${rebased}${closing}`;
|
|
139
|
+
})
|
|
140
|
+
.replace(WIKI_LINK_TARGET, (match, opening, rawTarget, suffix) => {
|
|
141
|
+
const rebased = rebaseMemoryLink(rawTarget, sourceMemoryPath, targetMemoryPath);
|
|
142
|
+
return rebased === undefined ? match : `${opening}${rebased}${suffix}]]`;
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
function rebaseMemoryLink(rawTarget, sourceMemoryPath, targetMemoryPath) {
|
|
146
|
+
const resolved = resolveMemoryLink('index.md', rawTarget, sourceMemoryPath);
|
|
147
|
+
if (!resolved)
|
|
148
|
+
return undefined;
|
|
149
|
+
const suffix = rawTarget.match(/[?#].*$/u)?.[0] ?? '';
|
|
150
|
+
return `${targetMemoryPath.replace(/\/$/u, '')}/${resolved}${suffix}`;
|
|
151
|
+
}
|
|
152
|
+
function isMissing(error) {
|
|
153
|
+
return typeof error === 'object' && error !== null && Reflect.get(error, 'code') === 'ENOENT';
|
|
154
|
+
}
|
|
155
|
+
export function validateMemoryDirectoryInput(artifact, options = {}) {
|
|
156
|
+
const result = validateMemoryArtifact(artifact, options);
|
|
157
|
+
if (!result.ok)
|
|
158
|
+
throw new Error(result.errors.map((error) => error.message).join('; '));
|
|
159
|
+
}
|
|
160
|
+
//# sourceMappingURL=hydration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hydration.js","sourceRoot":"","sources":["../src/hydration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACnG,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EACL,8BAA8B,GAM/B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,wBAAwB,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC;AACpF,OAAO,EACL,yBAAyB,EACzB,gBAAgB,EAChB,iBAAiB,EACjB,sBAAsB,GACvB,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AED,SAAS,SAAS,CAAC,KAAc;IAC/B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,QAAQ,CAAC;AAChG,CAAC;AAED,MAAM,UAAU,4BAA4B,CAC1C,QAAgD,EAChD,UAAkC,EAAE;IAEpC,MAAM,MAAM,GAAG,sBAAsB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACzD,IAAI,CAAC,MAAM,CAAC,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AAC1F,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { FelanExtension } from '@felan-ai/agent-core';
|
|
2
|
+
import type { MemoryHost, MemoryRole } from './contracts.js';
|
|
3
|
+
export * from './checkpoint.js';
|
|
4
|
+
export * from './contracts.js';
|
|
5
|
+
export * from './dreamer.js';
|
|
6
|
+
export * from './hydration.js';
|
|
7
|
+
export * from './manifest.js';
|
|
8
|
+
export * from './schema.js';
|
|
9
|
+
export * from './validation.js';
|
|
10
|
+
export interface CreateMemoryExtensionOptions {
|
|
11
|
+
readonly role: MemoryRole;
|
|
12
|
+
readonly host: MemoryHost;
|
|
13
|
+
readonly label?: string;
|
|
14
|
+
}
|
|
15
|
+
export declare function createMemoryExtension({ role, host, label, }: CreateMemoryExtensionOptions): FelanExtension;
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAoB,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAM7E,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAG7D,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAEhC,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAID,wBAAgB,qBAAqB,CAAC,EACpC,IAAI,EACJ,IAAI,EACJ,KAAiB,GAClB,EAAE,4BAA4B,GAAG,cAAc,CAqD/C"}
|