{
  "id": "graph-memory",
  "name": "Graph Memory",
  "version": "2.0.16",
  "description": "知识图谱记忆引擎：从对话提取三元组，按当前问题进行向量/FTS5 召回并接管上下文",
  "contracts": {
    "tools": ["gm_search", "gm_record", "gm_update", "gm_stats", "gm_maintain"]
  },
  "configSchema": {
    "type": "object",
    "properties": {
      "dbPath": {
        "type": "string",
        "default": "~/.openclaw/graph-memory.db",
        "description": "SQLite 图谱数据库路径"
      },
      "dbBusyTimeoutMs": {
        "type": "integer",
        "minimum": 0,
        "maximum": 2147483647,
        "default": 5000,
        "description": "SQLite 写锁最多等待多少毫秒；0 表示立即报锁冲突，不改变 WAL 持久性"
      },
      "compactTurnCount": {
        "type": "integer",
        "default": 6,
        "description": "每隔多少轮运行 PageRank 与社区维护"
      },
      "recallMaxNodes": {
        "type": "integer",
        "minimum": 1,
        "default": 6,
        "description": "每次按当前问题排序后最多召回几个记忆节点"
      },
      "semanticScoreThreshold": {
        "type": "number",
        "minimum": -1,
        "maximum": 1,
        "description": "可选的余弦相似度下限；应按所用 embedding 模型校准，不设置时使用排序后的 Top-K"
      },
      "freshTurnCount": {
        "type": "integer",
        "minimum": 1,
        "default": 5,
        "description": "宿主上下文中原样保留的最近用户轮数"
      },
      "pagerankDamping": {
        "type": "number",
        "default": 0.85,
        "description": "PageRank 阻尼系数"
      },
      "pagerankIterations": {
        "type": "integer",
        "default": 20,
        "description": "PageRank 迭代次数"
      },
      "decay": {
        "type": "object",
        "description": "可选：遗忘曲线维护链覆盖段。不配则用默认策略（评分/自动弃用开启，30 天静默弃用，60 天硬删）",
        "properties": {
          "enabled": {
            "type": "boolean",
            "default": true,
            "description": "遗忘曲线总开关；false 时跳过评分写回与自动弃用（到期硬删仍独立执行）"
          },
          "autoDeprecate": {
            "type": "boolean",
            "default": true,
            "description": "静默外围低分节点自动弃用（断联，重新被引用可复活）"
          },
          "autoDeprecateAfterDays": {
            "type": "integer",
            "minimum": 0,
            "default": 30,
            "description": "弃用静默门槛（天）：低分外围节点连续静默满该天数才被自动弃用"
          },
          "purgeAfterDays": {
            "type": "integer",
            "minimum": 0,
            "default": 60,
            "description": "硬删窗口（天）：decay 弃用节点超过该天数后硬删；0 = 永不硬删"
          }
        }
      },
      "embedding": {
        "type": "object",
        "description": "可选：向量搜索配置。配了使用语义检索，没配使用 FTS5 全文检索",
        "properties": {
          "apiKey": { "type": "string", "description": "Embedding API Key" },
          "baseURL": { "type": "string", "description": "API 地址（兼容旧配置；不填时默认 OpenAI）" },
          "baseUrl": { "type": "string", "description": "API 地址（OpenClaw 标准拼写；与 baseURL 二选一）" },
          "model": { "type": "string", "default": "text-embedding-3-small", "description": "模型名" },
          "dimensions": { "type": "integer", "minimum": 1, "description": "可选向量维度；仅在服务明确支持时设置" }
        }
      },
      "llm": {
        "type": "object",
        "description": "可选：LLM 配置。不配则用 OpenClaw 全局 provider",
        "properties": {
          "apiKey": { "type": "string" },
          "baseURL": { "type": "string", "description": "API 地址（兼容旧配置）" },
          "baseUrl": { "type": "string", "description": "API 地址（OpenClaw 标准拼写；与 baseURL 二选一）" },
          "model": { "type": "string" },
          "maxTokens": {
            "type": "integer",
            "minimum": 1,
            "description": "仅 Anthropic 直连需要；该协议要求调用方明确设置响应上限"
          }
        }
      }
    }
  }
}
