@nuzo/memory-core 0.1.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 ADDED
@@ -0,0 +1,176 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ https://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction, and
10
+ distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by the
13
+ copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all other
16
+ entities that control, are controlled by, or are under common control with
17
+ that entity. For the purposes of this definition, "control" means (i) the
18
+ power, direct or indirect, to cause the direction or management of such
19
+ entity, whether by contract or otherwise, or (ii) ownership of fifty percent
20
+ (50%) or more of the outstanding shares, or (iii) beneficial ownership of
21
+ such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity exercising
24
+ permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation source,
28
+ and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical transformation
31
+ or translation of a Source form, including but not limited to compiled
32
+ object code, generated documentation, and conversions to other media types.
33
+
34
+ "Work" shall mean the work of authorship, whether in Source or Object form,
35
+ made available under the License, as indicated by a copyright notice that is
36
+ included in or attached to the work.
37
+
38
+ "Derivative Works" shall mean any work, whether in Source or Object form,
39
+ that is based on (or derived from) the Work and for which the editorial
40
+ revisions, annotations, elaborations, or other modifications represent, as a
41
+ whole, an original work of authorship. For the purposes of this License,
42
+ Derivative Works shall not include works that remain separable from, or
43
+ merely link (or bind by name) to the interfaces of, the Work and Derivative
44
+ Works thereof.
45
+
46
+ "Contribution" shall mean any work of authorship, including the original
47
+ version of the Work and any modifications or additions to that Work or
48
+ Derivative Works thereof, that is intentionally submitted to Licensor for
49
+ inclusion in the Work by the copyright owner or by an individual or Legal
50
+ Entity authorized to submit on behalf of the copyright owner. For the
51
+ purposes of this definition, "submitted" means any form of electronic,
52
+ verbal, or written communication sent to the Licensor or its representatives,
53
+ including but not limited to communication on electronic mailing lists,
54
+ source code control systems, and issue tracking systems that are managed by,
55
+ or on behalf of, the Licensor for the purpose of discussing and improving the
56
+ Work, but excluding communication that is conspicuously marked or otherwise
57
+ designated in writing by the copyright owner as "Not a Contribution."
58
+
59
+ "Contributor" shall mean Licensor and any individual or Legal Entity on
60
+ behalf of whom a Contribution has been received by Licensor and subsequently
61
+ incorporated within the Work.
62
+
63
+ 2. Grant of Copyright License. Subject to the terms and conditions of this
64
+ License, each Contributor hereby grants to You a perpetual, worldwide,
65
+ non-exclusive, no-charge, royalty-free, irrevocable copyright license to
66
+ reproduce, prepare Derivative Works of, publicly display, publicly perform,
67
+ sublicense, and distribute the Work and such Derivative Works in Source or
68
+ Object form.
69
+
70
+ 3. Grant of Patent License. Subject to the terms and conditions of this
71
+ License, each Contributor hereby grants to You a perpetual, worldwide,
72
+ non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this
73
+ section) patent license to make, have made, use, offer to sell, sell, import,
74
+ and otherwise transfer the Work, where such license applies only to those
75
+ patent claims licensable by such Contributor that are necessarily infringed
76
+ by their Contribution(s) alone or by combination of their Contribution(s)
77
+ with the Work to which such Contribution(s) was submitted. If You institute
78
+ patent litigation against any entity (including a cross-claim or
79
+ counterclaim in a lawsuit) alleging that the Work or a Contribution
80
+ incorporated within the Work constitutes direct or contributory patent
81
+ infringement, then any patent licenses granted to You under this License for
82
+ that Work shall terminate as of the date such litigation is filed.
83
+
84
+ 4. Redistribution. You may reproduce and distribute copies of the Work or
85
+ Derivative Works thereof in any medium, with or without modifications, and in
86
+ Source or Object form, provided that You meet the following conditions:
87
+
88
+ (a) You must give any other recipients of the Work or Derivative Works a copy
89
+ of this License; and
90
+
91
+ (b) You must cause any modified files to carry prominent notices stating that
92
+ You changed the files; and
93
+
94
+ (c) You must retain, in the Source form of any Derivative Works that You
95
+ distribute, all copyright, patent, trademark, and attribution notices from
96
+ the Source form of the Work, excluding those notices that do not pertain to
97
+ any part of the Derivative Works; and
98
+
99
+ (d) If the Work includes a "NOTICE" text file as part of its distribution,
100
+ then any Derivative Works that You distribute must include a readable copy of
101
+ the attribution notices contained within such NOTICE file, excluding those
102
+ notices that do not pertain to any part of the Derivative Works, in at least
103
+ one of the following places: within a NOTICE text file distributed as part of
104
+ the Derivative Works; within the Source form or documentation, if provided
105
+ along with the Derivative Works; or, within a display generated by the
106
+ Derivative Works, if and wherever such third-party notices normally appear.
107
+ The contents of the NOTICE file are for informational purposes only and do
108
+ not modify the License. You may add Your own attribution notices within
109
+ Derivative Works that You distribute, alongside or as an addendum to the
110
+ NOTICE text from the Work, provided that such additional attribution notices
111
+ cannot be construed as modifying the License.
112
+
113
+ You may add Your own copyright statement to Your modifications and may
114
+ provide additional or different license terms and conditions for use,
115
+ reproduction, or distribution of Your modifications, or for any such
116
+ Derivative Works as a whole, provided Your use, reproduction, and
117
+ distribution of the Work otherwise complies with the conditions stated in
118
+ this License.
119
+
120
+ 5. Submission of Contributions. Unless You explicitly state otherwise, any
121
+ Contribution intentionally submitted for inclusion in the Work by You to the
122
+ Licensor shall be under the terms and conditions of this License, without any
123
+ additional terms or conditions. Notwithstanding the above, nothing herein
124
+ shall supersede or modify the terms of any separate license agreement you may
125
+ have executed with Licensor regarding such Contributions.
126
+
127
+ 6. Trademarks. This License does not grant permission to use the trade names,
128
+ trademarks, service marks, or product names of the Licensor, except as
129
+ required for reasonable and customary use in describing the origin of the
130
+ Work and reproducing the content of the NOTICE file.
131
+
132
+ 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in
133
+ writing, Licensor provides the Work (and each Contributor provides its
134
+ Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
135
+ KIND, either express or implied, including, without limitation, any warranties
136
+ or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
137
+ PARTICULAR PURPOSE. You are solely responsible for determining the
138
+ appropriateness of using or redistributing the Work and assume any risks
139
+ associated with Your exercise of permissions under this License.
140
+
141
+ 8. Limitation of Liability. In no event and under no legal theory, whether in
142
+ tort (including negligence), contract, or otherwise, unless required by
143
+ applicable law (such as deliberate and grossly negligent acts) or agreed to
144
+ in writing, shall any Contributor be liable to You for damages, including any
145
+ direct, indirect, special, incidental, or consequential damages of any
146
+ character arising as a result of this License or out of the use or inability
147
+ to use the Work (including but not limited to damages for loss of goodwill,
148
+ work stoppage, computer failure or malfunction, or any and all other
149
+ commercial damages or losses), even if such Contributor has been advised of
150
+ the possibility of such damages.
151
+
152
+ 9. Accepting Warranty or Additional Liability. While redistributing the Work
153
+ or Derivative Works thereof, You may choose to offer, and charge a fee for,
154
+ acceptance of support, warranty, indemnity, or other liability obligations
155
+ and/or rights consistent with this License. However, in accepting such
156
+ obligations, You may act only on Your own behalf and on Your sole
157
+ responsibility, not on behalf of any other Contributor, and only if You agree
158
+ to indemnify, defend, and hold each Contributor harmless for any liability
159
+ incurred by, or claims asserted against, such Contributor by reason of your
160
+ accepting any such warranty or additional liability.
161
+
162
+ END OF TERMS AND CONDITIONS
163
+
164
+ Copyright 2026 fabionfsc
165
+
166
+ Licensed under the Apache License, Version 2.0 (the "License");
167
+ you may not use this file except in compliance with the License.
168
+ You may obtain a copy of the License at
169
+
170
+ https://www.apache.org/licenses/LICENSE-2.0
171
+
172
+ Unless required by applicable law or agreed to in writing, software
173
+ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
174
+ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
175
+ See the License for the specific language governing permissions and
176
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,12 @@
1
+ # @nuzo/memory-core
2
+
3
+ Core memory lifecycle, policy, SQLite storage, FTS recall, audit events, and
4
+ portable import/export behavior for Nuzo.
5
+
6
+ This package is the host-neutral business layer. Most users should install
7
+ Nuzo through a supported host plugin or use the Nuzo CLI instead of consuming
8
+ the core package directly.
9
+
10
+ Documentation: https://nuzo.com.br/
11
+
12
+ License: Apache-2.0
@@ -0,0 +1,6 @@
1
+ export declare class NuzoMemoryError extends Error {
2
+ readonly code: string;
3
+ readonly details: Record<string, unknown>;
4
+ constructor(code: string, message: string, details?: Record<string, unknown>);
5
+ }
6
+ export declare function invariant(condition: unknown, code: string, message: string, details?: Record<string, unknown>): asserts condition;
package/dist/errors.js ADDED
@@ -0,0 +1,15 @@
1
+ export class NuzoMemoryError extends Error {
2
+ code;
3
+ details;
4
+ constructor(code, message, details = {}) {
5
+ super(message);
6
+ this.code = code;
7
+ this.details = details;
8
+ this.name = "NuzoMemoryError";
9
+ }
10
+ }
11
+ export function invariant(condition, code, message, details = {}) {
12
+ if (!condition) {
13
+ throw new NuzoMemoryError(code, message, details);
14
+ }
15
+ }
@@ -0,0 +1,2 @@
1
+ import type { MemoryExportDocument } from "./types.js";
2
+ export declare function formatMemoryExportMarkdown(document: MemoryExportDocument): string;
@@ -0,0 +1,58 @@
1
+ export function formatMemoryExportMarkdown(document) {
2
+ const lines = [
3
+ "# Nuzo Memory Export",
4
+ "",
5
+ "This file is for human review. Use JSON exports for import.",
6
+ "",
7
+ "```yaml",
8
+ "format: nuzo-memory-export",
9
+ `version: ${document.version}`,
10
+ `exported_at: ${yamlString(document.exported_at)}`,
11
+ `count: ${document.memories.length}`,
12
+ "```",
13
+ "",
14
+ "## Memories",
15
+ "",
16
+ ];
17
+ if (document.memories.length === 0) {
18
+ lines.push("_No memories exported._", "");
19
+ return lines.join("\n");
20
+ }
21
+ document.memories.forEach((memory, index) => {
22
+ lines.push(`### Memory ${index + 1}`);
23
+ lines.push("");
24
+ lines.push(formatMemoryExportItemMetadata(memory));
25
+ lines.push("");
26
+ lines.push(memory.content);
27
+ lines.push("");
28
+ });
29
+ return lines.join("\n");
30
+ }
31
+ function formatMemoryExportItemMetadata(memory) {
32
+ const lines = [
33
+ "```yaml",
34
+ `scope: ${yamlString(memory.scope)}`,
35
+ `kind: ${yamlString(memory.kind)}`,
36
+ "tags:",
37
+ ...formatTags(memory.tags),
38
+ `source: ${yamlString(memory.source)}`,
39
+ `confidence: ${memory.confidence}`,
40
+ `created_at: ${yamlString(memory.created_at)}`,
41
+ `updated_at: ${yamlString(memory.updated_at)}`,
42
+ `last_used_at: ${yamlNullableString(memory.last_used_at)}`,
43
+ `archived_at: ${yamlNullableString(memory.archived_at)}`,
44
+ "```",
45
+ ];
46
+ return lines.join("\n");
47
+ }
48
+ function formatTags(tags) {
49
+ return tags.length === 0
50
+ ? [" []"]
51
+ : tags.map((tag) => ` - ${yamlString(tag)}`);
52
+ }
53
+ function yamlNullableString(value) {
54
+ return value === null ? "null" : yamlString(value);
55
+ }
56
+ function yamlString(value) {
57
+ return JSON.stringify(value);
58
+ }
@@ -0,0 +1,10 @@
1
+ export * from "./errors.js";
2
+ export * from "./export-format.js";
3
+ export * from "./policy.js";
4
+ export * from "./ports.js";
5
+ export * from "./runtime.js";
6
+ export * from "./secrets.js";
7
+ export * from "./service.js";
8
+ export * from "./sqlite/adapter.js";
9
+ export * from "./sqlite/schema.js";
10
+ export * from "./types.js";
package/dist/index.js ADDED
@@ -0,0 +1,10 @@
1
+ export * from "./errors.js";
2
+ export * from "./export-format.js";
3
+ export * from "./policy.js";
4
+ export * from "./ports.js";
5
+ export * from "./runtime.js";
6
+ export * from "./secrets.js";
7
+ export * from "./service.js";
8
+ export * from "./sqlite/adapter.js";
9
+ export * from "./sqlite/schema.js";
10
+ export * from "./types.js";
@@ -0,0 +1,12 @@
1
+ import type { PolicyEngine, SecretScanner } from "./ports.js";
2
+ import type { ListMemoriesInput, MemoryRecord, RecallMemoriesInput, RememberMemoryInput, UpdateMemoryInput } from "./types.js";
3
+ export declare const memoryScopePattern: RegExp;
4
+ export declare const memoryTagPattern: RegExp;
5
+ export declare class DefaultPolicyEngine implements PolicyEngine {
6
+ private readonly secretScanner;
7
+ constructor(secretScanner: SecretScanner);
8
+ assertCanRemember(input: RememberMemoryInput): Promise<void>;
9
+ assertCanUpdate(input: UpdateMemoryInput, current: MemoryRecord): Promise<void>;
10
+ assertCanRecall(input: RecallMemoriesInput): Promise<void>;
11
+ assertCanList(input: ListMemoriesInput): Promise<void>;
12
+ }
package/dist/policy.js ADDED
@@ -0,0 +1,63 @@
1
+ import { invariant } from "./errors.js";
2
+ import { memoryKinds } from "./types.js";
3
+ export const memoryScopePattern = /^(user|project|agent|team):[A-Za-z0-9._~:/-]+$/;
4
+ export const memoryTagPattern = /^[a-z0-9][a-z0-9._-]{0,63}$/;
5
+ export class DefaultPolicyEngine {
6
+ secretScanner;
7
+ constructor(secretScanner) {
8
+ this.secretScanner = secretScanner;
9
+ }
10
+ async assertCanRemember(input) {
11
+ invariant(input.content.trim().length > 0, "MEMORY_CONTENT_EMPTY", "Memory content cannot be empty.");
12
+ invariant(input.content.length <= 8000, "MEMORY_CONTENT_TOO_LONG", "Memory content is too long.", { maxLength: 8000 });
13
+ invariant(memoryKinds.includes(input.kind), "MEMORY_KIND_UNSUPPORTED", "Memory kind is not supported.", { kind: input.kind });
14
+ assertScope(input.scope);
15
+ invariant(input.source.trim().length > 0, "MEMORY_SOURCE_EMPTY", "Memory source cannot be empty.");
16
+ const confidence = input.confidence ?? 1;
17
+ invariant(confidence >= 0 && confidence <= 1, "MEMORY_CONFIDENCE_INVALID", "Memory confidence must be between 0 and 1.", { confidence });
18
+ for (const tag of input.tags ?? []) {
19
+ assertTag(tag);
20
+ }
21
+ const secretScan = await this.secretScanner.scan(input.content);
22
+ invariant(secretScan.ok, "MEMORY_SECRET_DETECTED", "Memory content looks sensitive.", {
23
+ findings: secretScan.findings,
24
+ });
25
+ }
26
+ async assertCanUpdate(input, current) {
27
+ await this.assertCanRemember({
28
+ content: input.content ?? current.content,
29
+ kind: input.kind ?? current.kind,
30
+ scope: input.scope ?? current.scope,
31
+ tags: input.tags ?? current.tags,
32
+ source: current.source,
33
+ confidence: input.confidence ?? current.confidence,
34
+ });
35
+ invariant(input.actor.trim().length > 0, "MEMORY_ACTOR_EMPTY", "Memory actor cannot be empty.");
36
+ }
37
+ async assertCanRecall(input) {
38
+ invariant(input.query.trim().length > 0, "RECALL_QUERY_EMPTY", "Recall query cannot be empty.");
39
+ assertScope(input.scope);
40
+ const limit = input.limit ?? 8;
41
+ invariant(limit > 0 && limit <= 50, "RECALL_LIMIT_INVALID", "Recall limit must be 1-50.", {
42
+ limit,
43
+ });
44
+ }
45
+ async assertCanList(input) {
46
+ if (input.scope !== undefined) {
47
+ assertScope(input.scope);
48
+ }
49
+ for (const tag of input.tags ?? []) {
50
+ assertTag(tag);
51
+ }
52
+ }
53
+ }
54
+ function assertScope(scope) {
55
+ invariant(memoryScopePattern.test(scope), "MEMORY_SCOPE_INVALID", "Memory scope is invalid.", {
56
+ scope,
57
+ });
58
+ }
59
+ function assertTag(tag) {
60
+ invariant(memoryTagPattern.test(tag), "MEMORY_TAG_INVALID", "Memory tag is invalid.", {
61
+ tag,
62
+ });
63
+ }
@@ -0,0 +1,45 @@
1
+ import type { ListMemoriesInput, MemoryEvent, MemoryRecord, RecallMemoriesInput, RecallMemoryResult, RememberMemoryInput, UpdateMemoryInput } from "./types.js";
2
+ export interface MemoryStore {
3
+ create(memory: MemoryRecord): Promise<void>;
4
+ update(memory: MemoryRecord): Promise<void>;
5
+ findById(id: string): Promise<MemoryRecord | null>;
6
+ list(filter: ListMemoriesInput): Promise<MemoryRecord[]>;
7
+ archive(id: string, archivedAt: Date): Promise<void>;
8
+ delete(id: string): Promise<void>;
9
+ }
10
+ export interface SearchIndex {
11
+ index(memory: MemoryRecord): Promise<void>;
12
+ remove(memoryId: string): Promise<void>;
13
+ search(input: RecallMemoriesInput): Promise<RecallMemoryResult[]>;
14
+ }
15
+ export interface AuditLog {
16
+ append(event: MemoryEvent): Promise<void>;
17
+ list(memoryId: string): Promise<MemoryEvent[]>;
18
+ }
19
+ export interface TransactionManager {
20
+ run<T>(operation: () => Promise<T>): Promise<T>;
21
+ }
22
+ export interface Clock {
23
+ now(): Date;
24
+ }
25
+ export interface IdGenerator {
26
+ memoryId(): string;
27
+ eventId(): string;
28
+ }
29
+ export interface SecretScanner {
30
+ scan(content: string): Promise<SecretScanResult>;
31
+ }
32
+ export interface SecretScanResult {
33
+ ok: boolean;
34
+ findings: SecretFinding[];
35
+ }
36
+ export interface SecretFinding {
37
+ kind: string;
38
+ message: string;
39
+ }
40
+ export interface PolicyEngine {
41
+ assertCanRemember(input: RememberMemoryInput): Promise<void>;
42
+ assertCanUpdate(input: UpdateMemoryInput, current: MemoryRecord): Promise<void>;
43
+ assertCanRecall(input: RecallMemoriesInput): Promise<void>;
44
+ assertCanList(input: ListMemoriesInput): Promise<void>;
45
+ }
package/dist/ports.js ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ import type { Clock, IdGenerator } from "./ports.js";
2
+ export declare class SystemClock implements Clock {
3
+ now(): Date;
4
+ }
5
+ export declare class RandomIdGenerator implements IdGenerator {
6
+ memoryId(): string;
7
+ eventId(): string;
8
+ }
@@ -0,0 +1,14 @@
1
+ import { randomUUID } from "node:crypto";
2
+ export class SystemClock {
3
+ now() {
4
+ return new Date();
5
+ }
6
+ }
7
+ export class RandomIdGenerator {
8
+ memoryId() {
9
+ return `mem_${randomUUID()}`;
10
+ }
11
+ eventId() {
12
+ return `evt_${randomUUID()}`;
13
+ }
14
+ }
@@ -0,0 +1,4 @@
1
+ import type { SecretScanner, SecretScanResult } from "./ports.js";
2
+ export declare class RegexSecretScanner implements SecretScanner {
3
+ scan(content: string): Promise<SecretScanResult>;
4
+ }
@@ -0,0 +1,64 @@
1
+ const patterns = [
2
+ {
3
+ kind: "private_key",
4
+ regex: /-----BEGIN (?:RSA |EC |OPENSSH |DSA )?PRIVATE KEY-----/,
5
+ message: "Private key material should not be stored as memory.",
6
+ },
7
+ {
8
+ kind: "github_token",
9
+ regex: /\b(?:ghp|gho|ghu|ghs|ghr)_[A-Za-z0-9_]{20,}\b/,
10
+ message: "GitHub tokens should not be stored as memory.",
11
+ },
12
+ {
13
+ kind: "provider_api_key",
14
+ regex: /\b(?:sk-(?:proj-|ant-[A-Za-z0-9-]+-)?[A-Za-z0-9_-]{20,}|sk_live_[A-Za-z0-9]{20,}|AIza[A-Za-z0-9_-]{30,})\b/,
15
+ message: "Provider API keys should not be stored as memory.",
16
+ },
17
+ {
18
+ kind: "aws_access_key",
19
+ regex: /\b(?:AKIA|ASIA)[A-Z0-9]{16}\b/,
20
+ message: "AWS access keys should not be stored as memory.",
21
+ },
22
+ {
23
+ kind: "jwt",
24
+ regex: /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/,
25
+ message: "JSON Web Tokens should not be stored as memory.",
26
+ },
27
+ {
28
+ kind: "bearer_token",
29
+ regex: /\bBearer\s+(?!(?:redacted|placeholder|example)\b)[A-Za-z0-9._~+/-]{20,}=*\b/i,
30
+ message: "Bearer tokens should not be stored as memory.",
31
+ },
32
+ {
33
+ kind: "credential_url",
34
+ regex: /\b(?:postgres(?:ql)?|mysql|mariadb|mongodb(?:\+srv)?|redis|rediss):\/\/[^:\s/@]+:(?!(?:redacted|password|placeholder|changeme|\*+)@)[^@\s/]{4,}@/i,
35
+ message: "Database URLs containing credentials should not be stored as memory.",
36
+ },
37
+ {
38
+ kind: "session_cookie",
39
+ regex: /\b(?:cookie|set-cookie|session(?:_?id)?)\s*[:=]\s*['"]?(?!(?:redacted|placeholder|example|\*+)\b)[A-Za-z0-9%._~+/=-]{16,}/i,
40
+ message: "Cookie and session values should not be stored as memory.",
41
+ },
42
+ {
43
+ kind: "generic_api_key",
44
+ regex: /\b(?:api[_-]?key|token|secret|password)\s*[:=]\s*['"]?(?!(?:redacted|placeholder|example|changeme|\*+)\b)[A-Za-z0-9._~/-]{16,}/i,
45
+ message: "Credentials should not be stored as memory.",
46
+ },
47
+ ];
48
+ export class RegexSecretScanner {
49
+ async scan(content) {
50
+ const findings = [];
51
+ for (const pattern of patterns) {
52
+ if (pattern.regex.test(content)) {
53
+ findings.push({
54
+ kind: pattern.kind,
55
+ message: pattern.message,
56
+ });
57
+ }
58
+ }
59
+ return {
60
+ ok: findings.length === 0,
61
+ findings,
62
+ };
63
+ }
64
+ }
@@ -0,0 +1,23 @@
1
+ import type { AuditLog, Clock, IdGenerator, MemoryStore, PolicyEngine, SearchIndex, TransactionManager } from "./ports.js";
2
+ import type { ExportMemoriesInput, ForgetMemoryInput, ForgetMemoriesInput, ForgetMemoriesResult, ImportMemoriesInput, ImportMemoriesResult, ListMemoriesInput, MemoryExportDocument, MemoryEvent, MemoryRecord, RecallMemoriesInput, RecallMemoryResult, RememberMemoryInput, UpdateMemoryInput } from "./types.js";
3
+ export interface MemoryServiceDependencies {
4
+ store: MemoryStore;
5
+ searchIndex: SearchIndex;
6
+ auditLog: AuditLog;
7
+ clock: Clock;
8
+ ids: IdGenerator;
9
+ policy: PolicyEngine;
10
+ transactions?: TransactionManager;
11
+ }
12
+ export interface MemoryService {
13
+ remember(input: RememberMemoryInput): Promise<MemoryRecord>;
14
+ recall(input: RecallMemoriesInput): Promise<RecallMemoryResult[]>;
15
+ list(input?: ListMemoriesInput): Promise<MemoryRecord[]>;
16
+ update(input: UpdateMemoryInput): Promise<MemoryRecord>;
17
+ history(memoryId: string): Promise<MemoryEvent[]>;
18
+ exportMemories(input: ExportMemoriesInput): Promise<MemoryExportDocument>;
19
+ importMemories(input: ImportMemoriesInput): Promise<ImportMemoriesResult>;
20
+ forget(input: ForgetMemoryInput): Promise<void>;
21
+ forgetMany(input: ForgetMemoriesInput): Promise<ForgetMemoriesResult>;
22
+ }
23
+ export declare function createMemoryService(dependencies: MemoryServiceDependencies): MemoryService;