@chude/memory 4.0.0 → 4.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.
- package/README.md +58 -11
- package/dist/application/services/embedding-service.d.ts +8 -1
- package/dist/application/services/friction-service.d.ts +18 -2
- package/dist/application/services/index.d.ts +11 -1
- package/dist/application/services/memory-governance-service.d.ts +65 -0
- package/dist/application/services/memory-ranking-service.d.ts +65 -0
- package/dist/application/services/persona-profile-service.d.ts +29 -0
- package/dist/application/services/projection-registry.d.ts +18 -0
- package/dist/application/services/remote-event-sync-service.d.ts +76 -0
- package/dist/application/services/smart-context-service.d.ts +34 -1
- package/dist/application/services/temporal-graph-service.d.ts +30 -0
- package/dist/domain/entities/graph-edge.d.ts +87 -0
- package/dist/domain/entities/index.d.ts +5 -0
- package/dist/domain/entities/memory-event.d.ts +101 -0
- package/dist/domain/entities/memory-governance.d.ts +100 -0
- package/dist/domain/entities/memory-utility-metric.d.ts +65 -0
- package/dist/domain/entities/persona-entry.d.ts +67 -0
- package/dist/domain/ports/capability.d.ts +35 -0
- package/dist/domain/ports/embedding.d.ts +21 -0
- package/dist/domain/ports/index.d.ts +1 -0
- package/dist/domain/ports/redactor.d.ts +3 -0
- package/dist/domain/ports/repositories.d.ts +155 -1
- package/dist/domain/ports/sources.d.ts +1 -1
- package/dist/domain/services/path-decoder.d.ts +1 -1
- package/dist/domain/value-objects/project-path.d.ts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +774 -328
- package/dist/infrastructure/capabilities/capability-status.d.ts +10 -0
- package/dist/infrastructure/capabilities/index.d.ts +1 -0
- package/dist/infrastructure/database/event-log.d.ts +40 -8
- package/dist/infrastructure/database/health-checker.d.ts +22 -1
- package/dist/infrastructure/database/index.d.ts +3 -3
- package/dist/infrastructure/database/repositories/embedding-repository.d.ts +18 -4
- package/dist/infrastructure/database/repositories/friction-repository.d.ts +2 -1
- package/dist/infrastructure/database/repositories/graph-repository.d.ts +17 -0
- package/dist/infrastructure/database/repositories/index.d.ts +4 -0
- package/dist/infrastructure/database/repositories/memory-governance-repository.d.ts +21 -0
- package/dist/infrastructure/database/repositories/memory-utility-repository.d.ts +15 -0
- package/dist/infrastructure/database/repositories/persona-repository.d.ts +16 -0
- package/dist/infrastructure/database/schema.d.ts +40 -0
- package/dist/infrastructure/embedding/embedding-provider-factory.d.ts +3 -2
- package/dist/infrastructure/embedding/ollama-provider.d.ts +1 -0
- package/dist/infrastructure/hooks/config-manager.d.ts +17 -0
- package/dist/infrastructure/providers/provider-egress-policy.d.ts +21 -0
- package/dist/infrastructure/providers/provider-registry.d.ts +8 -4
- package/dist/infrastructure/remote/git-remote-event-transport.d.ts +40 -0
- package/dist/infrastructure/security/pattern-redactor.d.ts +3 -0
- package/dist/infrastructure/security/secret-audit-service.d.ts +57 -0
- package/dist/infrastructure/sources/project-name-resolver.d.ts +2 -2
- package/dist/presentation/cli/commands/audit-secrets.d.ts +54 -0
- package/dist/presentation/cli/commands/friction/types.d.ts +13 -0
- package/dist/presentation/cli/commands/governance.d.ts +27 -0
- package/dist/presentation/cli/commands/index.d.ts +6 -0
- package/dist/presentation/cli/commands/profile.d.ts +23 -0
- package/dist/presentation/cli/commands/remote.d.ts +21 -3
- package/dist/presentation/cli/commands/sync/ambient.d.ts +7 -0
- package/dist/presentation/cli/commands/sync/types.d.ts +8 -12
- package/dist/presentation/cli/formatters/envelope.d.ts +2 -2
- package/dist/presentation/cli/index.js +918 -351
- package/package.json +9 -6
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CapabilityInteropStatus, MaskedCapabilityReference } from "../../domain/ports/capability.js";
|
|
2
|
+
import type { MemoryConfig } from "../hooks/config-manager.js";
|
|
3
|
+
export type CapabilityCommandResolver = (command: string) => string | null;
|
|
4
|
+
export interface CapabilityStatusOptions {
|
|
5
|
+
env?: NodeJS.ProcessEnv | undefined;
|
|
6
|
+
platform?: NodeJS.Platform | undefined;
|
|
7
|
+
commandResolver?: CapabilityCommandResolver | undefined;
|
|
8
|
+
}
|
|
9
|
+
export declare function checkCapabilityInterop(config: MemoryConfig, options?: CapabilityStatusOptions): CapabilityInteropStatus;
|
|
10
|
+
export declare function maskCapabilityReference(rawReference: string): MaskedCapabilityReference;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { checkCapabilityInterop, maskCapabilityReference, type CapabilityCommandResolver, type CapabilityStatusOptions, } from "./capability-status.js";
|
|
@@ -1,22 +1,54 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Event-
|
|
2
|
+
* Event-log SSOT manager.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* v2 JSONL records are canonical MemoryEventEnvelope entries. Legacy v1
|
|
5
|
+
* fact-shaped records remain readable through the adapter below.
|
|
6
6
|
*/
|
|
7
7
|
import type { Database } from "bun:sqlite";
|
|
8
|
+
import { type ProjectionReplayResult } from "../../application/services/projection-registry.js";
|
|
8
9
|
import { Fact } from "../../domain/entities/fact.js";
|
|
10
|
+
import { MemoryEventEnvelope } from "../../domain/entities/memory-event.js";
|
|
11
|
+
export interface InvalidEventLogLine {
|
|
12
|
+
filePath: string;
|
|
13
|
+
lineNumber: number;
|
|
14
|
+
line: string;
|
|
15
|
+
reason: string;
|
|
16
|
+
}
|
|
17
|
+
export interface EventReadReport {
|
|
18
|
+
events: MemoryEventEnvelope[];
|
|
19
|
+
invalidEvents: InvalidEventLogLine[];
|
|
20
|
+
}
|
|
21
|
+
export interface ProjectionRebuildReport {
|
|
22
|
+
invalidEvents: number;
|
|
23
|
+
invalidEventLines: InvalidEventLogLine[];
|
|
24
|
+
replay: ProjectionReplayResult;
|
|
25
|
+
}
|
|
9
26
|
/**
|
|
10
|
-
* Append a
|
|
27
|
+
* Append a Fact through the canonical v2 event envelope.
|
|
11
28
|
*/
|
|
12
29
|
export declare function appendEvent(fact: Fact, logPath?: string): Promise<void>;
|
|
13
30
|
/**
|
|
14
|
-
*
|
|
15
|
-
|
|
31
|
+
* Append a canonical memory event envelope into the plain-text event log.
|
|
32
|
+
*/
|
|
33
|
+
export declare function appendMemoryEvent(memoryEvent: MemoryEventEnvelope, logPath?: string): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Read canonical memory events from one explicit log file or all known event
|
|
36
|
+
* logs. Invalid lines are skipped; use readMemoryEventsWithReport for evidence.
|
|
37
|
+
*/
|
|
38
|
+
export declare function readMemoryEvents(logPath?: string, eventsDir?: string): AsyncGenerator<MemoryEventEnvelope, void, unknown>;
|
|
39
|
+
/**
|
|
40
|
+
* Read canonical memory events with structured invalid-line reporting.
|
|
41
|
+
*/
|
|
42
|
+
export declare function readMemoryEventsWithReport(logPath?: string, eventsDir?: string): Promise<EventReadReport>;
|
|
43
|
+
/**
|
|
44
|
+
* Compatibility API: read event log records as Fact entities.
|
|
16
45
|
*/
|
|
17
46
|
export declare function readEvents(logPath?: string, eventsDir?: string): AsyncGenerator<Fact, void, unknown>;
|
|
18
47
|
/**
|
|
19
|
-
*
|
|
20
|
-
* plain-text events.jsonl timeline sequentially to rebuild the SQLite database.
|
|
48
|
+
* Rebuild derived database projections from the canonical event log.
|
|
21
49
|
*/
|
|
22
50
|
export declare function rebuildProjections(db: Database, logPath?: string, eventsDir?: string): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Rebuild derived database projections and return replay evidence.
|
|
53
|
+
*/
|
|
54
|
+
export declare function rebuildProjectionsWithReport(db: Database, logPath?: string, eventsDir?: string): Promise<ProjectionRebuildReport>;
|
|
@@ -11,7 +11,10 @@
|
|
|
11
11
|
* - Configuration validation
|
|
12
12
|
*/
|
|
13
13
|
import { Database } from "bun:sqlite";
|
|
14
|
-
import { type HookStatus } from "../hooks/index.js";
|
|
14
|
+
import { type MemoryConfig, type HookStatus } from "../hooks/index.js";
|
|
15
|
+
import { type ProviderEgressAssessment } from "../providers/provider-egress-policy.js";
|
|
16
|
+
import { type CapabilityStatusOptions } from "../capabilities/index.js";
|
|
17
|
+
import type { CapabilityInteropStatus } from "../../domain/ports/capability.js";
|
|
15
18
|
/**
|
|
16
19
|
* Database health status
|
|
17
20
|
*/
|
|
@@ -118,6 +121,16 @@ export interface LlmExtractionHealth {
|
|
|
118
121
|
/** Reason for readiness status */
|
|
119
122
|
readyReason?: string | undefined;
|
|
120
123
|
}
|
|
124
|
+
export interface ProviderEgressHealth {
|
|
125
|
+
/** Configured consent state */
|
|
126
|
+
consent: MemoryConfig["providerEgress"]["consent"];
|
|
127
|
+
/** Embedding provider egress assessment, or disabled when embeddings are off */
|
|
128
|
+
embedding: ProviderEgressAssessment;
|
|
129
|
+
/** LLM extraction provider egress assessment */
|
|
130
|
+
llmExtraction: ProviderEgressAssessment;
|
|
131
|
+
/** User-visible warnings for allowed remote egress */
|
|
132
|
+
warnings: string[];
|
|
133
|
+
}
|
|
121
134
|
/**
|
|
122
135
|
* Complete health check result
|
|
123
136
|
*/
|
|
@@ -138,6 +151,10 @@ export interface HealthCheckResult {
|
|
|
138
151
|
searchCapability: SearchCapability;
|
|
139
152
|
/** LLM extraction provider status */
|
|
140
153
|
llmExtraction: LlmExtractionHealth;
|
|
154
|
+
/** Remote provider egress consent and allowlist status */
|
|
155
|
+
providerEgress: ProviderEgressHealth;
|
|
156
|
+
/** Optional capability provider diagnostics with masked references only */
|
|
157
|
+
capabilityInterop: CapabilityInteropStatus;
|
|
141
158
|
}
|
|
142
159
|
/**
|
|
143
160
|
* Test path overrides for testing
|
|
@@ -155,6 +172,8 @@ export interface HealthCheckOverrides {
|
|
|
155
172
|
hookOverrides?: import("../hooks/settings-manager.js").PathOverrides | undefined;
|
|
156
173
|
/** Optional pre-calculated hook status to avoid redundant file reads */
|
|
157
174
|
preCalculatedHookStatus?: HookStatus | undefined;
|
|
175
|
+
/** Optional capability-status overrides for deterministic tests */
|
|
176
|
+
capabilityInterop?: CapabilityStatusOptions | undefined;
|
|
158
177
|
}
|
|
159
178
|
/**
|
|
160
179
|
* Check database integrity using PRAGMA integrity_check
|
|
@@ -231,6 +250,8 @@ export declare function checkEmbeddingConfig(configPath?: string): EmbeddingHeal
|
|
|
231
250
|
* @returns LLM extraction health status
|
|
232
251
|
*/
|
|
233
252
|
export declare function checkLlmExtractionHealth(configPath?: string): LlmExtractionHealth;
|
|
253
|
+
export declare function checkProviderEgressHealth(configPath?: string): ProviderEgressHealth;
|
|
254
|
+
export declare function checkCapabilityInteropHealth(configPath?: string, options?: CapabilityStatusOptions): CapabilityInteropStatus;
|
|
234
255
|
/**
|
|
235
256
|
* Run comprehensive health check
|
|
236
257
|
*
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* Provides SQLite database initialization, schema management,
|
|
5
5
|
* and connection utilities for memory.
|
|
6
6
|
*/
|
|
7
|
-
export { SCHEMA_SQL, createSchema, checkFts5Support, SESSIONS_TABLE, MESSAGES_META_TABLE, MESSAGES_FTS_TABLE, TOOL_USES_TABLE, LINKS_TABLE, TOPICS_TABLE, EXTRACTION_STATE_TABLE, EMBEDDING_STATE_TABLE, EMBEDDING_STATE_ADD_MODEL_NAME, MESSAGE_EMBEDDINGS_TABLE, FRICTION_LOG_TABLE, BACKFILL_STATE_TABLE, type SchemaOptions, } from "./schema.js";
|
|
7
|
+
export { SCHEMA_SQL, createSchema, checkFts5Support, SESSIONS_TABLE, MESSAGES_META_TABLE, MESSAGES_FTS_TABLE, TOOL_USES_TABLE, LINKS_TABLE, TOPICS_TABLE, EXTRACTION_STATE_TABLE, EMBEDDING_STATE_TABLE, EMBEDDING_STATE_ADD_MODEL_NAME, MESSAGE_EMBEDDINGS_TABLE, FRICTION_LOG_TABLE, BACKFILL_STATE_TABLE, MEMORY_GOVERNANCE_TABLE, MEMORY_GOVERNANCE_EVENTS_TABLE, PERSONA_ENTRIES_TABLE, GRAPH_EDGES_TABLE, MEMORY_UTILITY_METRICS_TABLE, type SchemaOptions, } from "./schema.js";
|
|
8
8
|
export { initializeDatabase, initializeDatabaseSafe, closeDatabase, checkpointDatabase, bulkOperationCheckpoint, getDefaultDbPath, type DatabaseConfig, type DatabaseInitResult, type CheckpointResult, } from "./connection.js";
|
|
9
|
-
export { SqliteSessionRepository, SqliteMessageRepository, SqliteExtractionStateRepository, SqliteToolUseRepository, SqliteLinkRepository, type BatchResult, type BatchOptions, type RelatedLink, EmbeddingRepository, type UnembeddedMessage, type EmbeddingBatchItem, SqliteFrictionRepository, SqliteBackfillStateRepository, } from "./repositories/index.js";
|
|
9
|
+
export { SqliteSessionRepository, SqliteMessageRepository, SqliteExtractionStateRepository, SqliteToolUseRepository, SqliteLinkRepository, type BatchResult, type BatchOptions, type RelatedLink, EmbeddingRepository, type UnembeddedMessage, type EmbeddingBatchItem, SqliteFrictionRepository, SqliteBackfillStateRepository, SqliteMemoryGovernanceRepository, SqlitePersonaRepository, SqliteGraphRepository, SqliteMemoryUtilityRepository, } from "./repositories/index.js";
|
|
10
10
|
export { Fts5SearchService, HybridSearchService, type HybridSearchDeps, type SearchMeta, SqliteStatsService, SqliteContextService, SqliteProjectResolver, type ProjectContext, type ContextOptions, type ToolUsage, } from "./services/index.js";
|
|
11
|
-
export { checkDatabaseIntegrity, checkQuickIntegrity, checkDirectoryPermissions, checkConfigValidity, checkHookStatus, checkSqliteVecAvailability, checkEmbeddingConfig, runHealthCheck, type DatabaseHealth, type PermissionsHealth, type HooksHealth, type ConfigHealth, type EmbeddingHealth, type SqliteVecHealth, type HealthCheckResult, type HealthCheckOverrides, type SearchCapability, } from "./health-checker.js";
|
|
11
|
+
export { checkDatabaseIntegrity, checkQuickIntegrity, checkDirectoryPermissions, checkConfigValidity, checkHookStatus, checkSqliteVecAvailability, checkEmbeddingConfig, checkProviderEgressHealth, checkCapabilityInteropHealth, runHealthCheck, type DatabaseHealth, type PermissionsHealth, type HooksHealth, type ConfigHealth, type EmbeddingHealth, type SqliteVecHealth, type HealthCheckResult, type HealthCheckOverrides, type SearchCapability, type ProviderEgressHealth, } from "./health-checker.js";
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
* table is a vec0 virtual table storing the actual vector data.
|
|
11
11
|
*/
|
|
12
12
|
import type { Database } from "bun:sqlite";
|
|
13
|
-
import type { IEmbeddingRepository, UnembeddedMessage, EmbeddingBatchItem } from "../../../domain/ports/repositories.js";
|
|
14
|
-
export type { UnembeddedMessage, EmbeddingBatchItem };
|
|
13
|
+
import type { IEmbeddingRepository, UnembeddedMessage, EmbeddingBatchItem, EmbeddingSkipRecordInput } from "../../../domain/ports/repositories.js";
|
|
14
|
+
export type { UnembeddedMessage, EmbeddingBatchItem, EmbeddingSkipRecordInput };
|
|
15
15
|
/**
|
|
16
16
|
* A vector KNN search result row.
|
|
17
17
|
*/
|
|
@@ -35,12 +35,26 @@ export declare class EmbeddingRepository implements IEmbeddingRepository {
|
|
|
35
35
|
* Find messages that have not yet been embedded.
|
|
36
36
|
*
|
|
37
37
|
* Uses LEFT JOIN on messages_meta and embedding_state to find
|
|
38
|
-
* messages without a corresponding embedding_state row.
|
|
38
|
+
* messages without a corresponding embedding_state row. When a model hash
|
|
39
|
+
* is supplied, rows skipped for that exact model are also excluded so
|
|
40
|
+
* deterministic oversize failures do not block later batches.
|
|
39
41
|
*
|
|
40
42
|
* @param limit Maximum number of messages to return
|
|
43
|
+
* @param modelHash Optional model hash for model-scoped skip filtering
|
|
41
44
|
* @returns Array of unembedded messages ordered by rowid ASC
|
|
42
45
|
*/
|
|
43
|
-
findUnembedded(limit: number): UnembeddedMessage[];
|
|
46
|
+
findUnembedded(limit: number, modelHash?: string): UnembeddedMessage[];
|
|
47
|
+
/**
|
|
48
|
+
* Persist a sanitized skip record for a message/model pair.
|
|
49
|
+
*
|
|
50
|
+
* The record is idempotent for message + model + reason. It stores a hash
|
|
51
|
+
* and byte count instead of raw content.
|
|
52
|
+
*/
|
|
53
|
+
markSkipped(record: EmbeddingSkipRecordInput): void;
|
|
54
|
+
/**
|
|
55
|
+
* Count skipped messages, optionally for a specific model hash.
|
|
56
|
+
*/
|
|
57
|
+
getSkippedCount(modelHash?: string): number;
|
|
44
58
|
/**
|
|
45
59
|
* Store a batch of embeddings in a single transaction.
|
|
46
60
|
*
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Provides full CRUD, stats aggregation via SQL, and weekly trend analysis.
|
|
6
6
|
*/
|
|
7
7
|
import type { Database } from "bun:sqlite";
|
|
8
|
-
import type { IFrictionRepository, FrictionStats, FrictionPattern } from "../../../domain/ports/repositories.js";
|
|
8
|
+
import type { IFrictionRepository, FrictionStats, FrictionPattern, FrictionQueryOptions, FrictionQueryResult } from "../../../domain/ports/repositories.js";
|
|
9
9
|
import { FrictionEntry, type FrictionCategory, type FrictionStatus } from "../../../domain/entities/friction-entry.js";
|
|
10
10
|
/**
|
|
11
11
|
* SQLite implementation of IFrictionRepository.
|
|
@@ -26,6 +26,7 @@ export declare class SqliteFrictionRepository implements IFrictionRepository {
|
|
|
26
26
|
sourceProject?: string;
|
|
27
27
|
limit?: number;
|
|
28
28
|
}): Promise<FrictionEntry[]>;
|
|
29
|
+
query(options?: FrictionQueryOptions): Promise<FrictionQueryResult>;
|
|
29
30
|
resolve(id: number, resolution: string): Promise<void>;
|
|
30
31
|
updateStatus(id: number, status: FrictionStatus): Promise<void>;
|
|
31
32
|
getStats(): Promise<FrictionStats>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Database } from "bun:sqlite";
|
|
2
|
+
import { GraphEdge } from "../../../domain/entities/graph-edge.js";
|
|
3
|
+
import type { GraphEdgeQueryOptions, IGraphRepository } from "../../../domain/ports/repositories.js";
|
|
4
|
+
export declare class SqliteGraphRepository implements IGraphRepository {
|
|
5
|
+
private readonly db;
|
|
6
|
+
constructor(db: Database);
|
|
7
|
+
save(edge: GraphEdge): Promise<GraphEdge>;
|
|
8
|
+
saveMany(edges: GraphEdge[]): Promise<GraphEdge[]>;
|
|
9
|
+
findByEdgeId(edgeId: string): Promise<GraphEdge | null>;
|
|
10
|
+
findCurrent(options?: GraphEdgeQueryOptions): Promise<GraphEdge[]>;
|
|
11
|
+
pruneStale(cutoff: Date): Promise<number>;
|
|
12
|
+
deleteByProject(project: string): Promise<void>;
|
|
13
|
+
clearAll(): Promise<void>;
|
|
14
|
+
private toSqlParams;
|
|
15
|
+
private toEntity;
|
|
16
|
+
private nodeFromRow;
|
|
17
|
+
}
|
|
@@ -15,3 +15,7 @@ export { SqliteFrictionRepository } from "./friction-repository.js";
|
|
|
15
15
|
export { SqliteBackfillStateRepository } from "./backfill-state-repository.js";
|
|
16
16
|
export { SqliteFactRepository } from "./fact-repository.js";
|
|
17
17
|
export { SqliteExtractionLogRepository } from "./extraction-log-repository.js";
|
|
18
|
+
export { SqliteMemoryGovernanceRepository, governanceEntryFromFactEvent, } from "./memory-governance-repository.js";
|
|
19
|
+
export { SqlitePersonaRepository } from "./persona-repository.js";
|
|
20
|
+
export { SqliteGraphRepository } from "./graph-repository.js";
|
|
21
|
+
export { SqliteMemoryUtilityRepository } from "./memory-utility-repository.js";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SQLite implementation of IMemoryGovernanceRepository.
|
|
3
|
+
*/
|
|
4
|
+
import type { Database } from "bun:sqlite";
|
|
5
|
+
import { MemoryGovernanceEntry, type MemoryGovernanceSurface } from "../../../domain/entities/memory-governance.js";
|
|
6
|
+
import type { MemoryEventEnvelope } from "../../../domain/entities/memory-event.js";
|
|
7
|
+
import type { IMemoryGovernanceRepository, MemoryGovernanceListOptions } from "../../../domain/ports/repositories.js";
|
|
8
|
+
export declare class SqliteMemoryGovernanceRepository implements IMemoryGovernanceRepository {
|
|
9
|
+
private readonly db;
|
|
10
|
+
constructor(db: Database);
|
|
11
|
+
save(entry: MemoryGovernanceEntry): Promise<MemoryGovernanceEntry>;
|
|
12
|
+
findByTarget(surface: MemoryGovernanceSurface, targetId: string): Promise<MemoryGovernanceEntry | null>;
|
|
13
|
+
findByTargetIds(surface: MemoryGovernanceSurface, targetIds: string[]): Promise<MemoryGovernanceEntry[]>;
|
|
14
|
+
findAll(options?: MemoryGovernanceListOptions): Promise<MemoryGovernanceEntry[]>;
|
|
15
|
+
applyMemoryEvent(event: MemoryEventEnvelope): Promise<MemoryGovernanceEntry | null>;
|
|
16
|
+
clearAll(): Promise<void>;
|
|
17
|
+
private toSqlParams;
|
|
18
|
+
private toEntity;
|
|
19
|
+
private recordGovernanceEvent;
|
|
20
|
+
}
|
|
21
|
+
export declare function governanceEntryFromFactEvent(event: MemoryEventEnvelope, factUuid: string, project: string): MemoryGovernanceEntry;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Database } from "bun:sqlite";
|
|
2
|
+
import { MemoryUtilityMetric, type MemoryUtilitySurface } from "../../../domain/entities/memory-utility-metric.js";
|
|
3
|
+
import type { IMemoryUtilityRepository } from "../../../domain/ports/repositories.js";
|
|
4
|
+
export declare class SqliteMemoryUtilityRepository implements IMemoryUtilityRepository {
|
|
5
|
+
private readonly db;
|
|
6
|
+
constructor(db: Database);
|
|
7
|
+
save(metric: MemoryUtilityMetric): Promise<MemoryUtilityMetric>;
|
|
8
|
+
findByTarget(surface: MemoryUtilitySurface, targetId: string): Promise<MemoryUtilityMetric | null>;
|
|
9
|
+
findByTargetIds(surface: MemoryUtilitySurface, targetIds: string[]): Promise<MemoryUtilityMetric[]>;
|
|
10
|
+
recordAccess(surface: MemoryUtilitySurface, targetId: string, accessedAt: Date): Promise<MemoryUtilityMetric>;
|
|
11
|
+
deleteByProject(project: string): Promise<void>;
|
|
12
|
+
clearAll(): Promise<void>;
|
|
13
|
+
private toSqlParams;
|
|
14
|
+
private toEntity;
|
|
15
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Database } from "bun:sqlite";
|
|
2
|
+
import { PersonaEntry } from "../../../domain/entities/persona-entry.js";
|
|
3
|
+
import type { IPersonaRepository, PersonaContextOptions, PersonaListOptions } from "../../../domain/ports/repositories.js";
|
|
4
|
+
export declare class SqlitePersonaRepository implements IPersonaRepository {
|
|
5
|
+
private readonly db;
|
|
6
|
+
constructor(db: Database);
|
|
7
|
+
save(entry: PersonaEntry): Promise<PersonaEntry>;
|
|
8
|
+
saveMany(entries: PersonaEntry[]): Promise<PersonaEntry[]>;
|
|
9
|
+
findByEntryId(entryId: string): Promise<PersonaEntry | null>;
|
|
10
|
+
findAll(options?: PersonaListOptions): Promise<PersonaEntry[]>;
|
|
11
|
+
findForContext(project: string, options?: PersonaContextOptions): Promise<PersonaEntry[]>;
|
|
12
|
+
deleteByProject(project: string): Promise<void>;
|
|
13
|
+
clearAll(): Promise<void>;
|
|
14
|
+
private toSqlParams;
|
|
15
|
+
private toEntity;
|
|
16
|
+
}
|
|
@@ -128,6 +128,44 @@ export declare const FACTS_FTS_TRIGGERS = "\nCREATE TRIGGER IF NOT EXISTS facts_
|
|
|
128
128
|
* Extraction log table - tracks run logs of LLM fact extraction.
|
|
129
129
|
*/
|
|
130
130
|
export declare const EXTRACTION_LOG_TABLE = "\nCREATE TABLE IF NOT EXISTS extraction_log (\n session_id TEXT PRIMARY KEY,\n mode TEXT NOT NULL,\n facts_added INTEGER DEFAULT 0,\n facts_updated INTEGER DEFAULT 0,\n facts_superseded INTEGER DEFAULT 0,\n facts_skipped INTEGER DEFAULT 0,\n provider TEXT NOT NULL,\n model TEXT NOT NULL,\n tokens_consumed INTEGER DEFAULT 0,\n extracted_at TEXT NOT NULL\n);\n";
|
|
131
|
+
/**
|
|
132
|
+
* Governance projection table - current consent/provenance/control state for
|
|
133
|
+
* derived memory entries across all user-visible and agent-visible surfaces.
|
|
134
|
+
*/
|
|
135
|
+
export declare const MEMORY_GOVERNANCE_TABLE = "\nCREATE TABLE IF NOT EXISTS memory_governance (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n surface TEXT NOT NULL CHECK (surface IN ('fact', 'context', 'provider_egress', 'remote_sync', 'friction', 'evaluation', 'persona', 'graph', 'ranking', 'dream', 'projection')),\n target_id TEXT NOT NULL,\n project TEXT,\n visibility TEXT NOT NULL CHECK (visibility IN ('project', 'workspace', 'global')),\n source_event_ids TEXT NOT NULL,\n transformation_method TEXT NOT NULL,\n actor TEXT NOT NULL,\n confidence REAL NOT NULL CHECK (confidence >= 0 AND confidence <= 1),\n redaction_state TEXT NOT NULL CHECK (redaction_state IN ('none', 'redacted', 'quarantined')),\n consent_status TEXT NOT NULL CHECK (consent_status IN ('not_required', 'granted', 'denied', 'revoked')),\n consent_scopes TEXT NOT NULL,\n scope TEXT NOT NULL,\n status TEXT NOT NULL CHECK (status IN ('active', 'pending_review', 'suppressed', 'invalidated', 'expired')),\n status_reason TEXT,\n created_at TEXT NOT NULL,\n updated_at TEXT NOT NULL,\n reviewed_at TEXT,\n expires_at TEXT,\n last_event_id TEXT,\n UNIQUE(surface, target_id)\n);\nCREATE INDEX IF NOT EXISTS idx_memory_governance_surface ON memory_governance(surface);\nCREATE INDEX IF NOT EXISTS idx_memory_governance_project ON memory_governance(project);\nCREATE INDEX IF NOT EXISTS idx_memory_governance_status ON memory_governance(status);\nCREATE INDEX IF NOT EXISTS idx_memory_governance_target ON memory_governance(surface, target_id);\n";
|
|
136
|
+
/**
|
|
137
|
+
* Governance event audit table - every replayed governance/consent control
|
|
138
|
+
* event. This keeps manual controls inspectable without reading JSONL logs.
|
|
139
|
+
*/
|
|
140
|
+
export declare const MEMORY_GOVERNANCE_EVENTS_TABLE = "\nCREATE TABLE IF NOT EXISTS memory_governance_events (\n event_id TEXT PRIMARY KEY,\n kind TEXT NOT NULL CHECK (kind IN ('governance', 'consent')),\n control TEXT NOT NULL,\n surface TEXT NOT NULL,\n target_id TEXT NOT NULL,\n actor TEXT NOT NULL,\n reason TEXT,\n occurred_at TEXT NOT NULL,\n payload TEXT NOT NULL\n);\nCREATE INDEX IF NOT EXISTS idx_memory_governance_events_target ON memory_governance_events(surface, target_id);\nCREATE INDEX IF NOT EXISTS idx_memory_governance_events_occurred ON memory_governance_events(occurred_at);\n";
|
|
141
|
+
/**
|
|
142
|
+
* Persona/profile projection table.
|
|
143
|
+
*
|
|
144
|
+
* Derived from canonical fact events and friction patterns. Governance for
|
|
145
|
+
* whether entries may be used lives in memory_governance(surface='persona').
|
|
146
|
+
*/
|
|
147
|
+
export declare const PERSONA_ENTRIES_TABLE = "\nCREATE TABLE IF NOT EXISTS persona_entries (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n entry_id TEXT UNIQUE NOT NULL,\n kind TEXT NOT NULL CHECK (kind IN ('preference', 'procedure', 'correction', 'decision_pattern', 'friction_pattern')),\n content TEXT NOT NULL,\n project TEXT,\n visibility TEXT NOT NULL CHECK (visibility IN ('project', 'workspace', 'global')),\n source_event_ids TEXT NOT NULL,\n source_kinds TEXT NOT NULL,\n confidence REAL NOT NULL CHECK (confidence >= 0 AND confidence <= 1),\n scope TEXT NOT NULL,\n review_status TEXT NOT NULL CHECK (review_status IN ('pending_review', 'reviewed')),\n review_after TEXT NOT NULL,\n expires_at TEXT,\n why TEXT NOT NULL,\n created_at TEXT NOT NULL,\n updated_at TEXT NOT NULL\n);\nCREATE INDEX IF NOT EXISTS idx_persona_entries_project ON persona_entries(project);\nCREATE INDEX IF NOT EXISTS idx_persona_entries_kind ON persona_entries(kind);\nCREATE INDEX IF NOT EXISTS idx_persona_entries_visibility ON persona_entries(visibility);\n";
|
|
148
|
+
/**
|
|
149
|
+
* Temporal semantic graph edge projection table.
|
|
150
|
+
*
|
|
151
|
+
* Derived from canonical fact events and extraction metadata. Governance for
|
|
152
|
+
* whether edges may be used lives in memory_governance(surface='graph').
|
|
153
|
+
*/
|
|
154
|
+
export declare const GRAPH_EDGES_TABLE = "\nCREATE TABLE IF NOT EXISTS graph_edges (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n edge_id TEXT UNIQUE NOT NULL,\n source_type TEXT NOT NULL CHECK (source_type IN ('project', 'tool', 'person', 'decision', 'error', 'plan', 'file', 'command', 'capability')),\n source_id TEXT NOT NULL,\n source_label TEXT NOT NULL,\n target_type TEXT NOT NULL CHECK (target_type IN ('project', 'tool', 'person', 'decision', 'error', 'plan', 'file', 'command', 'capability')),\n target_id TEXT NOT NULL,\n target_label TEXT NOT NULL,\n relationship TEXT NOT NULL,\n project TEXT,\n visibility TEXT NOT NULL CHECK (visibility IN ('project', 'workspace', 'global')),\n source_event_ids TEXT NOT NULL,\n source_kinds TEXT NOT NULL,\n confidence REAL NOT NULL CHECK (confidence >= 0 AND confidence <= 1),\n valid_from TEXT NOT NULL,\n valid_to TEXT,\n why TEXT NOT NULL,\n metadata TEXT,\n created_at TEXT NOT NULL,\n updated_at TEXT NOT NULL\n);\nCREATE INDEX IF NOT EXISTS idx_graph_edges_edge_id ON graph_edges(edge_id);\nCREATE INDEX IF NOT EXISTS idx_graph_edges_project ON graph_edges(project);\nCREATE INDEX IF NOT EXISTS idx_graph_edges_scope ON graph_edges(project, visibility);\nCREATE INDEX IF NOT EXISTS idx_graph_edges_source ON graph_edges(source_type, source_id);\nCREATE INDEX IF NOT EXISTS idx_graph_edges_target ON graph_edges(target_type, target_id);\nCREATE INDEX IF NOT EXISTS idx_graph_edges_relationship ON graph_edges(relationship);\nCREATE INDEX IF NOT EXISTS idx_graph_edges_temporal ON graph_edges(valid_from, valid_to, confidence);\n";
|
|
155
|
+
/**
|
|
156
|
+
* Utility/ranking metrics for governed memory surfaces.
|
|
157
|
+
*
|
|
158
|
+
* The table is surface-agnostic so Phase 41 can rank current fact/persona/graph
|
|
159
|
+
* projections and future link/dream projections without schema churn.
|
|
160
|
+
*/
|
|
161
|
+
export declare const MEMORY_UTILITY_METRICS_TABLE = "\nCREATE TABLE IF NOT EXISTS memory_utility_metrics (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n surface TEXT NOT NULL CHECK (surface IN ('fact', 'persona', 'graph', 'link', 'dream')),\n target_id TEXT NOT NULL,\n project TEXT,\n access_count INTEGER NOT NULL DEFAULT 0 CHECK (access_count >= 0),\n last_accessed_at TEXT,\n last_ranked_at TEXT,\n utility_score REAL NOT NULL DEFAULT 0.5 CHECK (utility_score >= 0 AND utility_score <= 1),\n importance_score REAL NOT NULL DEFAULT 0.5 CHECK (importance_score >= 0 AND importance_score <= 1),\n evergreen INTEGER NOT NULL DEFAULT 0 CHECK (evergreen IN (0, 1)),\n pinned INTEGER NOT NULL DEFAULT 0 CHECK (pinned IN (0, 1)),\n half_life_days REAL CHECK (half_life_days IS NULL OR half_life_days > 0),\n metadata TEXT,\n created_at TEXT NOT NULL,\n updated_at TEXT NOT NULL,\n UNIQUE(surface, target_id)\n);\nCREATE INDEX IF NOT EXISTS idx_memory_utility_metrics_target ON memory_utility_metrics(surface, target_id);\nCREATE INDEX IF NOT EXISTS idx_memory_utility_metrics_project ON memory_utility_metrics(project);\nCREATE INDEX IF NOT EXISTS idx_memory_utility_metrics_rank ON memory_utility_metrics(surface, evergreen, pinned, utility_score, importance_score);\n";
|
|
162
|
+
/**
|
|
163
|
+
* Model-scoped embedding skip ledger.
|
|
164
|
+
*
|
|
165
|
+
* Stores only sanitized metadata for messages that a provider/model cannot
|
|
166
|
+
* embed, so deterministic provider-limit failures do not wedge future syncs.
|
|
167
|
+
*/
|
|
168
|
+
export declare const EMBEDDING_SKIPS_TABLE = "\nCREATE TABLE IF NOT EXISTS embedding_skips (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n message_id INTEGER NOT NULL,\n model_hash TEXT NOT NULL,\n model_name TEXT NOT NULL,\n provider TEXT NOT NULL,\n reason TEXT NOT NULL CHECK (reason IN ('payload_too_large')),\n retryable INTEGER NOT NULL CHECK (retryable IN (0, 1)),\n content_hash TEXT NOT NULL,\n content_bytes INTEGER NOT NULL CHECK (content_bytes >= 0),\n safe_error TEXT,\n skipped_at TEXT NOT NULL,\n FOREIGN KEY (message_id) REFERENCES messages_meta(rowid) ON DELETE CASCADE,\n UNIQUE(message_id, model_hash, reason)\n);\nCREATE INDEX IF NOT EXISTS idx_embedding_skips_model ON embedding_skips(model_hash);\nCREATE INDEX IF NOT EXISTS idx_embedding_skips_message_model ON embedding_skips(message_id, model_hash);\n";
|
|
131
169
|
/**
|
|
132
170
|
* Schema options for conditional table creation
|
|
133
171
|
*/
|
|
@@ -174,6 +212,8 @@ export declare const SESSIONS_FTS_TRIGGERS = "\nCREATE TRIGGER IF NOT EXISTS ses
|
|
|
174
212
|
* 17. memory_files FTS triggers (depend on both memory_files tables)
|
|
175
213
|
* 18. friction_log (no dependencies)
|
|
176
214
|
* 19. backfill_state (no dependencies)
|
|
215
|
+
* 20. facts / governance / derived memory projections
|
|
216
|
+
* 21. embedding skip ledger (depends on messages_meta)
|
|
177
217
|
*
|
|
178
218
|
* Note: message_embeddings (vec0) is NOT in this array.
|
|
179
219
|
* It is conditionally created in createSchema() when sqliteVecAvailable is true.
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* - "ollama" -> OllamaProvider
|
|
12
12
|
*/
|
|
13
13
|
import type { IEmbeddingProvider } from "../../domain/ports/embedding.js";
|
|
14
|
-
import type { EmbeddingConfigData } from "../hooks/config-manager.js";
|
|
14
|
+
import type { EmbeddingConfigData, ProviderEgressPolicyData } from "../hooks/config-manager.js";
|
|
15
15
|
export declare class EmbeddingProviderFactory {
|
|
16
16
|
private cache;
|
|
17
17
|
/**
|
|
@@ -27,7 +27,7 @@ export declare class EmbeddingProviderFactory {
|
|
|
27
27
|
*
|
|
28
28
|
* @throws Error if provider type is unsupported
|
|
29
29
|
*/
|
|
30
|
-
create(config: EmbeddingConfigData): IEmbeddingProvider;
|
|
30
|
+
create(config: EmbeddingConfigData, providerEgress?: ProviderEgressPolicyData): IEmbeddingProvider;
|
|
31
31
|
/**
|
|
32
32
|
* Create an embedding provider from a MemoryConfig object.
|
|
33
33
|
*
|
|
@@ -36,6 +36,7 @@ export declare class EmbeddingProviderFactory {
|
|
|
36
36
|
*/
|
|
37
37
|
createFromConfig(memoryConfig: {
|
|
38
38
|
embedding?: EmbeddingConfigData;
|
|
39
|
+
providerEgress?: ProviderEgressPolicyData;
|
|
39
40
|
}): IEmbeddingProvider | null;
|
|
40
41
|
/**
|
|
41
42
|
* Dispose all cached providers and clear the cache.
|
|
@@ -33,6 +33,7 @@ export declare class OllamaProvider implements IEmbeddingProvider {
|
|
|
33
33
|
embedBatch(texts: string[]): Promise<EmbeddingResult[]>;
|
|
34
34
|
isReady(): boolean;
|
|
35
35
|
dispose(): Promise<void>;
|
|
36
|
+
private requestEmbeddings;
|
|
36
37
|
/**
|
|
37
38
|
* Throw an error with an actionable hint for model-not-found cases.
|
|
38
39
|
*/
|
|
@@ -23,6 +23,8 @@ export interface EmbeddingConfigData {
|
|
|
23
23
|
dimensions: number;
|
|
24
24
|
/** Number of messages to embed per batch */
|
|
25
25
|
batchSize: number;
|
|
26
|
+
/** Maximum estimated JSON payload bytes per embedding provider request */
|
|
27
|
+
maxBatchBytes: number;
|
|
26
28
|
/** @deprecated Prefer apiKeyEnv or runtime environment injection. */
|
|
27
29
|
apiKey?: string;
|
|
28
30
|
/** Environment variable name that contains the provider API key */
|
|
@@ -100,6 +102,18 @@ export interface RemoteSyncConfigData {
|
|
|
100
102
|
* Default remote sync configuration
|
|
101
103
|
*/
|
|
102
104
|
export declare const DEFAULT_REMOTE_SYNC_CONFIG: RemoteSyncConfigData;
|
|
105
|
+
export type ProviderEgressConsent = "unset" | "granted" | "denied";
|
|
106
|
+
export interface ProviderEgressPolicyData {
|
|
107
|
+
/** Consent state for sending redacted memory content to remote providers */
|
|
108
|
+
consent: ProviderEgressConsent;
|
|
109
|
+
/** Remote hosts allowed to receive provider payloads after consent is granted */
|
|
110
|
+
allowedHosts: string[];
|
|
111
|
+
/** Hostless remote provider ids allowed after consent is granted */
|
|
112
|
+
allowedProviders: string[];
|
|
113
|
+
/** Optional ISO timestamp for when consent was granted */
|
|
114
|
+
grantedAt?: string | undefined;
|
|
115
|
+
}
|
|
116
|
+
export declare const DEFAULT_PROVIDER_EGRESS_POLICY: ProviderEgressPolicyData;
|
|
103
117
|
export interface LegacyMemoryFilesConfigData {
|
|
104
118
|
/** Whether legacy ~/.memory / MEMORY_HOME markdown indexing and writes are enabled */
|
|
105
119
|
enabled: boolean;
|
|
@@ -121,6 +135,7 @@ export declare const DEFAULT_LEGACY_MEMORY_FILES_CONFIG: LegacyMemoryFilesConfig
|
|
|
121
135
|
* - ambientContext: Ambient context generation configuration
|
|
122
136
|
* - machineId: Unique identifier for the local machine
|
|
123
137
|
* - remoteSync: Remote sync configuration
|
|
138
|
+
* - providerEgress: Remote provider egress consent and allowlist policy
|
|
124
139
|
* - legacyMemoryFiles: Explicit opt-in for pre-v4 ~/.memory / MEMORY_HOME sidecar files
|
|
125
140
|
*/
|
|
126
141
|
export interface MemoryConfig {
|
|
@@ -148,6 +163,8 @@ export interface MemoryConfig {
|
|
|
148
163
|
machineId: string;
|
|
149
164
|
/** Remote sync configuration */
|
|
150
165
|
remoteSync: RemoteSyncConfigData;
|
|
166
|
+
/** Remote provider egress consent and allowlist policy */
|
|
167
|
+
providerEgress: ProviderEgressPolicyData;
|
|
151
168
|
/** Legacy memory-file sidecar compatibility */
|
|
152
169
|
legacyMemoryFiles: LegacyMemoryFilesConfigData;
|
|
153
170
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { EmbeddingConfigData, MemoryConfig, ProviderEgressPolicyData } from "../hooks/config-manager.js";
|
|
2
|
+
import { DEFAULT_PROVIDER_EGRESS_POLICY } from "../hooks/config-manager.js";
|
|
3
|
+
export declare const DEFAULT_ALLOWED_REMOTE_HOSTS: string[];
|
|
4
|
+
export declare const DEFAULT_ALLOWED_REMOTE_PROVIDERS: string[];
|
|
5
|
+
export interface ProviderEgressAssessment {
|
|
6
|
+
required: boolean;
|
|
7
|
+
allowed: boolean;
|
|
8
|
+
target: string;
|
|
9
|
+
capability: "embedding" | "extraction";
|
|
10
|
+
provider: string;
|
|
11
|
+
host?: string | undefined;
|
|
12
|
+
reason?: string | undefined;
|
|
13
|
+
warnings: string[];
|
|
14
|
+
}
|
|
15
|
+
type ConfigWithProviderEgress = Pick<MemoryConfig, "embedding"> & {
|
|
16
|
+
providerEgress?: ProviderEgressPolicyData | undefined;
|
|
17
|
+
};
|
|
18
|
+
export { DEFAULT_PROVIDER_EGRESS_POLICY };
|
|
19
|
+
export declare function assessEmbeddingProviderEgress(embedding: EmbeddingConfigData, policy?: ProviderEgressPolicyData): ProviderEgressAssessment;
|
|
20
|
+
export declare function assessExtractionProviderEgress(config: ConfigWithProviderEgress, providerId: string): ProviderEgressAssessment;
|
|
21
|
+
export declare function requireProviderEgressAllowed(assessment: ProviderEgressAssessment): void;
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import type { IEmbeddingProvider } from "../../domain/ports/embedding.js";
|
|
9
9
|
import type { IExtractionProvider } from "../../domain/ports/extraction.js";
|
|
10
|
-
import type { EmbeddingConfigData, MemoryConfig } from "../hooks/config-manager.js";
|
|
10
|
+
import type { EmbeddingConfigData, MemoryConfig, ProviderEgressPolicyData } from "../hooks/config-manager.js";
|
|
11
11
|
export interface ProviderReadiness {
|
|
12
12
|
ready: boolean;
|
|
13
13
|
readyReason?: string | undefined;
|
|
@@ -20,9 +20,13 @@ export declare function getEmbeddingProviderDefaults(providerId: string): {
|
|
|
20
20
|
model: string;
|
|
21
21
|
dimensions: number;
|
|
22
22
|
} | undefined;
|
|
23
|
-
export declare function
|
|
24
|
-
export declare function
|
|
23
|
+
export declare function getEmbeddingProviderSecretEnvVars(providerId: string): string[];
|
|
24
|
+
export declare function getExtractionProviderSecretEnvVars(providerId: string): string[];
|
|
25
|
+
export declare function checkEmbeddingProviderReadiness(config: EmbeddingConfigData, providerEgress?: ProviderEgressPolicyData): ProviderReadiness;
|
|
26
|
+
export declare function createEmbeddingProvider(config: EmbeddingConfigData, providerEgress?: ProviderEgressPolicyData): IEmbeddingProvider;
|
|
25
27
|
export declare function resolveExtractionProviderId(config: Pick<MemoryConfig, "embedding">, env?: NodeJS.ProcessEnv): string;
|
|
26
28
|
export declare function getExtractionModel(_config: Pick<MemoryConfig, "embedding">, providerId: string, env?: NodeJS.ProcessEnv): string;
|
|
27
29
|
export declare function checkExtractionProviderReadiness(config: Pick<MemoryConfig, "embedding">, providerId?: string): ProviderReadiness;
|
|
28
|
-
export declare function createExtractionProvider(config: Pick<MemoryConfig, "embedding">
|
|
30
|
+
export declare function createExtractionProvider(config: Pick<MemoryConfig, "embedding"> & {
|
|
31
|
+
providerEgress?: ProviderEgressPolicyData;
|
|
32
|
+
}): IExtractionProvider;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { RemoteEventTransport, RemoteGitIdentity, RemoteTransportCommandResult } from "../../application/services/remote-event-sync-service.js";
|
|
2
|
+
export interface GitCommandResult {
|
|
3
|
+
success: boolean;
|
|
4
|
+
stdout: string;
|
|
5
|
+
stderr: string;
|
|
6
|
+
exitCode: number;
|
|
7
|
+
}
|
|
8
|
+
export interface RunGitCommandOptions {
|
|
9
|
+
env?: NodeJS.ProcessEnv;
|
|
10
|
+
}
|
|
11
|
+
export interface GitRemoteEventTransportDeps {
|
|
12
|
+
runGit?: (args: string[], cwd: string) => Promise<GitCommandResult>;
|
|
13
|
+
env?: NodeJS.ProcessEnv;
|
|
14
|
+
existsSync?: (path: string) => boolean;
|
|
15
|
+
mkdirSync?: (path: string, options?: {
|
|
16
|
+
recursive?: boolean;
|
|
17
|
+
}) => void;
|
|
18
|
+
readFileSync?: (path: string, encoding: BufferEncoding) => string;
|
|
19
|
+
getAllLogFiles?: (eventsDir?: string) => string[];
|
|
20
|
+
}
|
|
21
|
+
export declare function sanitizeGitEnvironment(env?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
|
|
22
|
+
export declare function runGitCommand(args: string[], cwd: string, options?: RunGitCommandOptions): Promise<GitCommandResult>;
|
|
23
|
+
export declare class GitRemoteEventTransport implements RemoteEventTransport {
|
|
24
|
+
private readonly eventsDir;
|
|
25
|
+
private readonly runGit;
|
|
26
|
+
private readonly deps;
|
|
27
|
+
constructor(eventsDir: string, deps?: GitRemoteEventTransportDeps);
|
|
28
|
+
isRepository(): Promise<boolean>;
|
|
29
|
+
initRepository(identity: RemoteGitIdentity): Promise<RemoteTransportCommandResult>;
|
|
30
|
+
getRemoteUrl(): Promise<string | null>;
|
|
31
|
+
setRemoteUrl(remoteUrl: string): Promise<RemoteTransportCommandResult>;
|
|
32
|
+
listEventLogFingerprints(): Promise<Record<string, string>>;
|
|
33
|
+
hasEventLog(machineId: string): Promise<boolean>;
|
|
34
|
+
commitEventLog(machineId: string, message: string): Promise<RemoteTransportCommandResult>;
|
|
35
|
+
fetch(remoteName: string): Promise<RemoteTransportCommandResult>;
|
|
36
|
+
hasRemoteRef(remoteName: string, ref: string): Promise<boolean>;
|
|
37
|
+
pullRebase(remoteName: string, ref: string): Promise<RemoteTransportCommandResult>;
|
|
38
|
+
abortRebase(): Promise<RemoteTransportCommandResult>;
|
|
39
|
+
push(remoteName: string, ref: string): Promise<RemoteTransportCommandResult>;
|
|
40
|
+
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { IRedactor, JsonRedactionResult, RedactionResult } from "../../domain/ports/redactor.js";
|
|
2
|
+
export declare const PATTERN_REDACTOR_RULE_VERSION = "pattern-redactor-v2";
|
|
2
3
|
export declare class PatternRedactor implements IRedactor {
|
|
3
4
|
redactText(input: string): RedactionResult;
|
|
4
5
|
redactJson<T>(input: T): JsonRedactionResult<T>;
|
|
5
6
|
private redactUnknown;
|
|
7
|
+
private redactObjectValue;
|
|
8
|
+
private redactFlagAdjacentValue;
|
|
6
9
|
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { Database } from "bun:sqlite";
|
|
2
|
+
import type { IRedactor, RedactionFinding } from "../../domain/ports/redactor.js";
|
|
3
|
+
export type SecretAuditSurface = "database" | "event_log";
|
|
4
|
+
export interface SecretAuditFinding {
|
|
5
|
+
surface: SecretAuditSurface;
|
|
6
|
+
kind: RedactionFinding["kind"];
|
|
7
|
+
placeholder: string;
|
|
8
|
+
hash?: string | undefined;
|
|
9
|
+
ruleVersion?: string | undefined;
|
|
10
|
+
table?: string | undefined;
|
|
11
|
+
column?: string | undefined;
|
|
12
|
+
rowId?: string | number | undefined;
|
|
13
|
+
filePath?: string | undefined;
|
|
14
|
+
lineNumber?: number | undefined;
|
|
15
|
+
}
|
|
16
|
+
export interface SecretAuditReport {
|
|
17
|
+
schemaVersion: 1;
|
|
18
|
+
generatedAt: string;
|
|
19
|
+
redactionPolicy: string;
|
|
20
|
+
summary: {
|
|
21
|
+
totalFindings: number;
|
|
22
|
+
databaseFindings: number;
|
|
23
|
+
eventLogFindings: number;
|
|
24
|
+
};
|
|
25
|
+
findings: SecretAuditFinding[];
|
|
26
|
+
remediation: {
|
|
27
|
+
database: {
|
|
28
|
+
requested: boolean;
|
|
29
|
+
updatedFields: number;
|
|
30
|
+
rebuiltFtsIndexes: string[];
|
|
31
|
+
};
|
|
32
|
+
eventLogs: {
|
|
33
|
+
requested: boolean;
|
|
34
|
+
sanitizedFiles: string[];
|
|
35
|
+
quarantinedFiles: Array<{
|
|
36
|
+
originalPath: string;
|
|
37
|
+
quarantinedPath: string;
|
|
38
|
+
}>;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
export interface SecretAuditOptions {
|
|
43
|
+
db?: Database | undefined;
|
|
44
|
+
eventLogPaths?: string[] | undefined;
|
|
45
|
+
redactDatabase?: boolean | undefined;
|
|
46
|
+
quarantineEvents?: boolean | undefined;
|
|
47
|
+
quarantineDir?: string | undefined;
|
|
48
|
+
reportPath?: string | undefined;
|
|
49
|
+
}
|
|
50
|
+
export declare class SecretAuditService {
|
|
51
|
+
private readonly redactor;
|
|
52
|
+
constructor(redactor: IRedactor);
|
|
53
|
+
audit(options?: SecretAuditOptions): Promise<SecretAuditReport>;
|
|
54
|
+
private scanDatabase;
|
|
55
|
+
private scanEventLogs;
|
|
56
|
+
private redactEventLine;
|
|
57
|
+
}
|
|
@@ -31,7 +31,7 @@ export declare class ProjectNameResolver implements IProjectNameResolver {
|
|
|
31
31
|
* Resolve the project name from an encoded path (without drive prefix).
|
|
32
32
|
* Walks the filesystem matching encoded segments against real directory names.
|
|
33
33
|
*
|
|
34
|
-
* @param encodedSegments - The encoded path without drive prefix (e.g., "
|
|
34
|
+
* @param encodedSegments - The encoded path without drive prefix (e.g., "Projects-memory-nexus")
|
|
35
35
|
* @returns The actual name of the last matched directory
|
|
36
36
|
*/
|
|
37
37
|
resolveProjectName(encodedSegments: string): string;
|
|
@@ -43,7 +43,7 @@ export declare class ProjectNameResolver implements IProjectNameResolver {
|
|
|
43
43
|
/**
|
|
44
44
|
* Probe for hidden/virtual directories that readdirSync does not enumerate.
|
|
45
45
|
*
|
|
46
|
-
|
|
46
|
+
* Some directories (for example, cloud-synced Windows folders) are valid and traversable
|
|
47
47
|
* but invisible to readdirSync. This method tries progressively longer
|
|
48
48
|
* dash-separated prefixes of the remaining encoded string as candidate
|
|
49
49
|
* directory names, checking each via statSync.
|