mirror of
https://github.com/TencentCloud/TencentDB-Agent-Memory
synced 2026-07-10 20:34:30 +00:00
refactor: unify duplicate Logger interfaces into single canonical type (#14)
* refactor: unify duplicate Logger interfaces into single canonical type
23 files had local Logger/StoreLogger/PluginLogger/PipelineLogger/RunnerLogger/ExtractorLogger/TriggerLogger
interface definitions with identical shapes ({debug?, info, warn, error}).
Replace all with imports from the canonical `Logger` in `src/core/types.ts`:
- 17 files: local `interface Logger` → `import type { Logger }`
- 6 files: named variants (StoreLogger, PluginLogger, etc.) → `type X = Logger` alias
Two intentionally different interfaces are preserved:
- `CheckpointLogger` (only info + optional warn) — different contract
- `ensure-hook-policy.ts` Logger (no error) — different contract
Net: -120 lines, zero behavioral change.
Signed-off-by: yuanrengu <heyonggang0811@126.com>
* docs: update Logger JSDoc to reflect canonical relationship
StoreLogger, PluginLogger, etc. are now type aliases of Logger, not the
other way around. Update the comment to clarify this inverted relationship.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Signed-off-by: yuanrengu <heyonggang0811@126.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -17,6 +17,7 @@ import { fileURLToPath, pathToFileURL } from "node:url";
|
||||
import type { OpenClawPluginApi } from "openclaw/plugin-sdk/core";
|
||||
import { getEnv } from "./env.js";
|
||||
import { report } from "../core/report/reporter.js";
|
||||
import type { Logger } from "../core/types.js";
|
||||
|
||||
/**
|
||||
* Resolve a preferred temporary directory for memory-tdai operations.
|
||||
@@ -49,12 +50,7 @@ function resolveOpenClawTmpDir(): string {
|
||||
|
||||
const TAG = "[memory-tdai] [runner]";
|
||||
|
||||
interface RunnerLogger {
|
||||
debug?: (message: string) => void;
|
||||
info: (message: string) => void;
|
||||
warn: (message: string) => void;
|
||||
error: (message: string) => void;
|
||||
}
|
||||
type RunnerLogger = Logger;
|
||||
|
||||
// Dynamic import type — runEmbeddedPiAgent is an internal API
|
||||
// Prefer the public plugin runtime signature so host-injected runtimes stay assignable.
|
||||
|
||||
@@ -3,13 +3,7 @@ import path from "node:path";
|
||||
|
||||
import type { IMemoryStore } from "../core/store/types.js";
|
||||
import { ManagedTimer } from "./managed-timer.js";
|
||||
|
||||
interface Logger {
|
||||
debug?: (message: string) => void;
|
||||
info: (message: string) => void;
|
||||
warn: (message: string) => void;
|
||||
error: (message: string) => void;
|
||||
}
|
||||
import type { Logger } from "../core/types.js";
|
||||
|
||||
export interface MemoryCleanerOptions {
|
||||
baseDir: string;
|
||||
|
||||
@@ -36,6 +36,7 @@ import { SceneExtractor } from "../core/scene/scene-extractor.js";
|
||||
import { PersonaTrigger } from "../core/persona/persona-trigger.js";
|
||||
import { PersonaGenerator } from "../core/persona/persona-generator.js";
|
||||
import { pullProfilesToLocal, syncLocalProfilesToStore } from "../core/profile/profile-sync.js";
|
||||
import type { Logger } from "../core/types.js";
|
||||
|
||||
const TAG = "[memory-tdai] [pipeline-factory]";
|
||||
|
||||
@@ -47,12 +48,8 @@ function supportsProfileSyncWrite(store?: IMemoryStore): boolean {
|
||||
// Logger interface
|
||||
// ============================
|
||||
|
||||
export interface PipelineLogger {
|
||||
debug?: (message: string) => void;
|
||||
info: (message: string) => void;
|
||||
warn: (message: string) => void;
|
||||
error: (message: string) => void;
|
||||
}
|
||||
/** @deprecated Use `Logger` from `../core/types.js` directly. */
|
||||
export type PipelineLogger = Logger;
|
||||
|
||||
// ============================
|
||||
// Factory options
|
||||
|
||||
@@ -81,18 +81,12 @@ import { SessionFilter } from "./session-filter.js";
|
||||
import { ManagedTimer } from "./managed-timer.js";
|
||||
import { SerialQueue } from "./serial-queue.js";
|
||||
import { report } from "../core/report/reporter.js";
|
||||
import type { Logger } from "../core/types.js";
|
||||
|
||||
// ============================
|
||||
// Types
|
||||
// ============================
|
||||
|
||||
interface Logger {
|
||||
debug?: (message: string) => void;
|
||||
info: (message: string) => void;
|
||||
warn: (message: string) => void;
|
||||
error: (message: string) => void;
|
||||
}
|
||||
|
||||
/** A single captured message ready for L1 processing. */
|
||||
export interface CapturedMessage {
|
||||
role: "user" | "assistant" | "tool";
|
||||
|
||||
Reference in New Issue
Block a user