Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions src/core/conversation/l0-recorder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import fs from "node:fs/promises";
import path from "node:path";
import crypto from "node:crypto";
import { sanitizeText, stripCodeBlocks, shouldCaptureL0 } from "../../utils/sanitize.js";
import type { Logger } from "../types.js";

// ============================
// Types
Expand Down Expand Up @@ -63,13 +64,6 @@ export interface L0ConversationRecord {
messages: ConversationMessage[];
}

interface Logger {
debug?: (message: string) => void;
info: (message: string) => void;
warn: (message: string) => void;
error: (message: string) => void;
}

const TAG = "[memory-tdai][l0]";

// ============================
Expand Down
9 changes: 2 additions & 7 deletions src/core/hooks/auto-capture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,9 @@ import type { ConversationMessage } from "../conversation/l0-recorder.js";
import type { IMemoryStore, L0Record } from "../store/types.js";
import type { EmbeddingService } from "../store/embedding.js";

const TAG = "[memory-tdai] [capture]";
import type { Logger } from "../types.js";

interface Logger {
debug?: (message: string) => void;
info: (message: string) => void;
warn: (message: string) => void;
error: (message: string) => void;
}
const TAG = "[memory-tdai] [capture]";

export interface AutoCaptureResult {
/** Whether the scheduler was notified (conversation count incremented) */
Expand Down
8 changes: 1 addition & 7 deletions src/core/hooks/auto-recall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import type { IMemoryStore, L1SearchResult, L1FtsResult } from "../store/types.j
import { buildFtsQuery } from "../store/sqlite.js";
import type { EmbeddingService, EmbeddingCallOptions } from "../store/embedding.js";
import { sanitizeText } from "../../utils/sanitize.js";
import type { Logger } from "../types.js";

const TAG = "[memory-tdai] [recall]";

Expand All @@ -42,13 +43,6 @@ const MEMORY_TOOLS_GUIDE = `<memory-tools-guide>
- 若 3 次搜索后仍无结果,说明该信息不在记忆中,请直接根据已有信息回复用户,不要继续搜索。
</memory-tools-guide>`

interface Logger {
debug?: (message: string) => void;
info: (message: string) => void;
warn: (message: string) => void;
error: (message: string) => void;
}

/** A single recalled L1 memory with its search score and type. */
export interface RecalledMemory {
content: string;
Expand Down
9 changes: 1 addition & 8 deletions src/core/persona/persona-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,10 @@ import { buildPersonaPrompt } from "../prompts/persona-generation.js";
import { BackupManager } from "../../utils/backup.js";
import { escapeXmlTags } from "../../utils/sanitize.js";
import { report } from "../report/reporter.js";
import type { LLMRunner } from "../types.js";
import type { LLMRunner, Logger } from "../types.js";

const TAG = "[memory-tdai] [persona]";

interface Logger {
debug?: (message: string) => void;
info: (message: string) => void;
warn: (message: string) => void;
error: (message: string) => void;
}

export class PersonaGenerator {
private dataDir: string;
private runner: LLMRunner;
Expand Down
9 changes: 3 additions & 6 deletions src/core/persona/persona-trigger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,11 @@ import path from "node:path";
import { CheckpointManager } from "../../utils/checkpoint.js";
import { stripSceneNavigation } from "../scene/scene-navigation.js";

import type { Logger } from "../types.js";

const TAG = "[memory-tdai] [trigger]";

interface TriggerLogger {
debug?: (message: string) => void;
info: (message: string) => void;
warn: (message: string) => void;
error: (message: string) => void;
}
type TriggerLogger = Logger;

export interface TriggerResult {
should: boolean;
Expand Down
8 changes: 1 addition & 7 deletions src/core/profile/profile-sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import path from "node:path";
import type { IMemoryStore, ProfileRecord, ProfileSyncRecord } from "../store/types.js";
import { readSceneIndex, syncSceneIndex } from "../scene/scene-index.js";
import { generateSceneNavigation, stripSceneNavigation } from "../scene/scene-navigation.js";
import type { Logger } from "../types.js";

const PROFILE_SCOPE = "global";

Expand All @@ -13,13 +14,6 @@ function isRenameRaceError(err: unknown): boolean {
return code === "ENOTEMPTY" || code === "EEXIST";
}

interface Logger {
debug?: (message: string) => void;
info: (message: string) => void;
warn: (message: string) => void;
error: (message: string) => void;
}

export interface ProfileBaseline {
version: number;
contentMd5: string;
Expand Down
9 changes: 1 addition & 8 deletions src/core/record/l1-dedup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,7 @@ import { sanitizeJsonForParse } from "../../utils/sanitize.js";
import type { IMemoryStore } from "../store/types.js";
import { buildFtsQuery } from "../store/sqlite.js";
import type { EmbeddingService } from "../store/embedding.js";
import type { LLMRunner } from "../types.js";

interface Logger {
debug?: (message: string) => void;
info: (message: string) => void;
warn: (message: string) => void;
error: (message: string) => void;
}
import type { LLMRunner, Logger } from "../types.js";

const TAG = "[memory-tdai][l1-dedup]";

Expand Down
9 changes: 1 addition & 8 deletions src/core/record/l1-extractor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,7 @@ import { sanitizeJsonForParse, shouldExtractL1 } from "../../utils/sanitize.js";
import type { IMemoryStore } from "../store/types.js";
import type { EmbeddingService } from "../store/embedding.js";
import { report } from "../report/reporter.js";
import type { LLMRunner } from "../types.js";

interface Logger {
debug?: (message: string) => void;
info: (message: string) => void;
warn: (message: string) => void;
error: (message: string) => void;
}
import type { LLMRunner, Logger } from "../types.js";

const TAG = "[memory-tdai][l1-extractor]";

Expand Down
8 changes: 1 addition & 7 deletions src/core/record/l1-reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,7 @@ import type { IMemoryStore, L1RecordRow, L1QueryFilter } from "../store/types.js
// Re-export types that readers need
export type { MemoryRecord, MemoryType, EpisodicMetadata } from "./l1-writer.js";
export type { L1QueryFilter } from "../store/types.js";

interface Logger {
debug?: (message: string) => void;
info: (message: string) => void;
warn: (message: string) => void;
error: (message: string) => void;
}
import type { Logger } from "../types.js";

const TAG = "[memory-tdai] [l1-reader]";

Expand Down
8 changes: 1 addition & 7 deletions src/core/record/l1-writer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import path from "node:path";
import crypto from "node:crypto";
import type { IMemoryStore } from "../store/types.js";
import type { EmbeddingService } from "../store/embedding.js";
import type { Logger } from "../types.js";

// ============================
// Types
Expand Down Expand Up @@ -110,13 +111,6 @@ export interface DedupDecision {
merged_timestamps?: string[];
}

interface Logger {
debug?: (message: string) => void;
info: (message: string) => void;
warn: (message: string) => void;
error: (message: string) => void;
}

const TAG = "[memory-tdai][l1-writer]";

// ============================
Expand Down
9 changes: 2 additions & 7 deletions src/core/scene/scene-extractor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,11 @@ import { parseSceneBlock } from "../scene/scene-format.js";
import { generateSceneNavigation, stripSceneNavigation } from "../scene/scene-navigation.js";
import { buildSceneExtractionPrompt } from "../prompts/scene-extraction.js";
import { report } from "../report/reporter.js";
import type { LLMRunner } from "../types.js";
import type { LLMRunner, Logger } from "../types.js";

const TAG = "[memory-tdai] [extractor]";

interface ExtractorLogger {
debug?: (message: string) => void;
info: (message: string) => void;
warn: (message: string) => void;
error: (message: string) => void;
}
type ExtractorLogger = Logger;

export interface ExtractionResult {
memoriesProcessed: number;
Expand Down
9 changes: 2 additions & 7 deletions src/core/store/bm25-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,15 @@
* check health to dynamically downgrade to pure semantic search.
*/

import type { Logger } from "../types.js";

// ============================
// Types
// ============================

/** Sparse vector: array of [token_hash, weight] pairs. */
export type SparseVector = Array<[number, number]>;

interface Logger {
debug?: (message: string) => void;
info: (message: string) => void;
warn: (message: string) => void;
error: (message: string) => void;
}

export interface BM25ClientConfig {
/** Sidecar service URL (default: "http://127.0.0.1:8084") */
serviceUrl: string;
Expand Down
8 changes: 1 addition & 7 deletions src/core/store/bm25-local.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,10 @@

import { BM25Encoder } from "@tencentdb-agent-memory/tcvdb-text";
import type { SparseVector } from "@tencentdb-agent-memory/tcvdb-text";
import type { Logger } from "../types.js";

export type { SparseVector };

interface Logger {
debug?: (message: string) => void;
info: (message: string) => void;
warn: (message: string) => void;
error: (message: string) => void;
}

export interface BM25LocalConfig {
/** Whether BM25 sparse encoding is enabled (default: true) */
enabled: boolean;
Expand Down
13 changes: 2 additions & 11 deletions src/core/store/embedding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* - Throws on failure; callers decide fallback strategy.
*/

import type { Logger } from "../types.js";

// ============================
// Types
// ============================
Expand Down Expand Up @@ -97,17 +99,6 @@ export class EmbeddingNotReadyError extends Error {
}
}

// ============================
// Logger interface
// ============================

interface Logger {
debug?: (message: string) => void;
info: (message: string) => void;
warn: (message: string) => void;
error: (message: string) => void;
}

const TAG = "[memory-tdai][embedding]";

// ============================
Expand Down
8 changes: 1 addition & 7 deletions src/core/store/sqlite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import type {
L0SearchResult,
L0FtsResult,
} from "./types.js";
import type { Logger } from "../types.js";

// ============================
// Types
Expand Down Expand Up @@ -106,13 +107,6 @@ export interface L1QueryFilter {
updatedAfter?: string;
}

interface Logger {
debug?: (message: string) => void;
info: (message: string) => void;
warn: (message: string) => void;
error: (message: string) => void;
}

const TAG = "[memory-tdai][sqlite]";

/** Persisted metadata about the embedding provider used to generate stored vectors. */
Expand Down
8 changes: 2 additions & 6 deletions src/core/store/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import type { MemoryRecord } from "../record/l1-writer.js";
import type { EmbeddingProviderInfo } from "./embedding.js";
import type { Logger } from "../types.js";

// Re-export so consumers can import everything from types.ts
export type { MemoryRecord, EmbeddingProviderInfo };
Expand All @@ -26,12 +27,7 @@ export type { MemoryRecord, EmbeddingProviderInfo };
// ============================

/** Minimal logger interface accepted by store implementations. */
export interface StoreLogger {
debug?: (message: string) => void;
info: (message: string) => void;
warn: (message: string) => void;
error: (message: string) => void;
}
export type StoreLogger = Logger;

// ============================
// L1 Types (Structured Memories)
Expand Down
8 changes: 1 addition & 7 deletions src/core/tools/conversation-search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,12 @@
import type { IMemoryStore, L0SearchResult } from "../store/types.js";
import { buildFtsQuery } from "../store/sqlite.js";
import type { EmbeddingService } from "../store/embedding.js";
import type { Logger } from "../types.js";

// ============================
// Types
// ============================

interface Logger {
debug?: (message: string) => void;
info: (message: string) => void;
warn: (message: string) => void;
error: (message: string) => void;
}

export interface ConversationSearchResultItem {
id: string;
session_key: string;
Expand Down
8 changes: 1 addition & 7 deletions src/core/tools/memory-search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,12 @@
import type { IMemoryStore, L1SearchResult } from "../store/types.js";
import { buildFtsQuery } from "../store/sqlite.js";
import type { EmbeddingService } from "../store/embedding.js";
import type { Logger } from "../types.js";

// ============================
// Types
// ============================

interface Logger {
debug?: (message: string) => void;
info: (message: string) => void;
warn: (message: string) => void;
error: (message: string) => void;
}

export interface MemorySearchResultItem {
id: string;
content: string;
Expand Down
9 changes: 3 additions & 6 deletions src/offload/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
* Ported from context-offload-plugin with updated runtime defaults.
*/

import type { Logger } from "../core/types.js";

// ============================
// Data types
// ============================
Expand Down Expand Up @@ -212,12 +214,7 @@ export interface PluginConfig {
// ============================

/** Logger interface used by offload plugin components */
export interface PluginLogger {
info: (msg: string) => void;
warn: (msg: string) => void;
error: (msg: string) => void;
debug?: (msg: string) => void;
}
export type PluginLogger = Logger;

// ============================
// Plugin defaults
Expand Down
Loading