mirror of
https://gitee.com/mateos/mateclaw.git
synced 2026-09-13 03:13:41 +08:00
- explicit SecurityConfig authorization for /swagger-ui*, /v3/api-docs*, /webjars/** - public for local/default profile; admin-only (ROLE_ADMIN) by default in production DB profiles - override via MATECLAW_OPENAPI_EXPOSE_UI; add RANDOM_PORT integration tests and docs
357 lines
17 KiB
YAML
357 lines
17 KiB
YAML
server:
|
||
port: 18088
|
||
servlet:
|
||
context-path: /
|
||
|
||
spring:
|
||
application:
|
||
name: mateclaw-server
|
||
messages:
|
||
basename: messages
|
||
encoding: UTF-8
|
||
servlet:
|
||
multipart:
|
||
max-file-size: 100MB
|
||
max-request-size: 200MB
|
||
threads:
|
||
virtual:
|
||
enabled: true
|
||
profiles:
|
||
active: dev
|
||
|
||
# 数据源(默认 H2,生产切换为 mysql 或 kingbase profile)
|
||
datasource:
|
||
url: jdbc:h2:file:./data/mateclaw;MODE=MySQL;DATABASE_TO_LOWER=TRUE;CASE_INSENSITIVE_IDENTIFIERS=TRUE
|
||
driver-class-name: org.h2.Driver
|
||
username: sa
|
||
password:
|
||
# Issue #50: explicit Hikari sizing. Default of 10 was being exhausted
|
||
# by O(100) cron jobs firing on minute boundaries (each run holds 3-4
|
||
# connections sequentially) plus ChannelHealthMonitor's per-minute scan.
|
||
# 30 leaves headroom for HTTP / SSE / channel adapters even with the
|
||
# cron concurrency limiter (CronJobService.MAX_CONCURRENT_CRON_RUNS=8)
|
||
# at full saturation.
|
||
hikari:
|
||
maximum-pool-size: 30
|
||
minimum-idle: 5
|
||
connection-timeout: 30000
|
||
idle-timeout: 600000
|
||
max-lifetime: 1800000
|
||
leak-detection-threshold: 60000
|
||
|
||
# SQL 初始化由 DatabaseBootstrapRunner 接管,关闭 Spring 自动执行
|
||
sql:
|
||
init:
|
||
mode: never
|
||
|
||
# Flyway 数据库版本迁移
|
||
flyway:
|
||
enabled: true
|
||
baseline-on-migrate: true
|
||
baseline-version: "1"
|
||
locations:
|
||
- classpath:db/migration/h2
|
||
validate-on-migrate: true
|
||
clean-disabled: true
|
||
# Disable Flyway's built-in ${...} placeholder substitution. Some migrations
|
||
# (e.g. V85 ckjia MCP seed) intentionally store ${ENV_VAR} literals so that
|
||
# mateclaw's runtime header parser (McpClientManager.parseHeaders) can
|
||
# expand them at request time. Flyway would otherwise try to resolve those
|
||
# tokens at migration time and fail with "No value provided for placeholder".
|
||
# Safe to disable globally because no migration in this project relies on
|
||
# Flyway-side ${...} substitution.
|
||
placeholder-replacement: false
|
||
|
||
h2:
|
||
console:
|
||
enabled: ${H2_CONSOLE_ENABLED:false}
|
||
path: /h2-console
|
||
|
||
# Spring AI Alibaba (DashScope) — Spring AI Alibaba 1.1.x configuration path.
|
||
#
|
||
# The api-key here is only consumed by Spring AI Alibaba's auto-configured beans
|
||
# as a *fallback*. The real source of truth for every provider/key/model is the
|
||
# admin UI ("Settings → Models", persisted in mate_model_provider /
|
||
# mate_model_config); AgentDashScopeChatModelBuilder resolves the key per-request
|
||
# from the provider row first, only falling back to this property when the row
|
||
# is incomplete. The placeholder default keeps DashScopeChatAutoConfiguration
|
||
# happy at startup when no env var is set (Docker / fresh install) — leave it
|
||
# alone unless you know what you're doing.
|
||
ai:
|
||
dashscope:
|
||
api-key: ${DASHSCOPE_API_KEY:configure-in-admin-ui}
|
||
chat:
|
||
options:
|
||
model: qwen-max
|
||
temperature: 0.7
|
||
max-tokens: 4096
|
||
# Spring AI 1.1.x 会话记忆配置(使用内嵌 H2 时无需额外配置)
|
||
chat:
|
||
observations:
|
||
log-prompt: false
|
||
log-completion: false
|
||
memory:
|
||
repository:
|
||
jdbc:
|
||
initialize-schema: embedded
|
||
# Spring AI Retry 配置:429/503/529 归为可重试(TransientAiException),启用指数退避
|
||
# RFC-012 M1:max-attempts 从 5 调到 2,避免与 wiki 层 callLlmWithResilientRetry 的 5×N 嵌套放大;
|
||
# 真正的重试主控权交给业务层(wiki / agent),Spring AI 仅负责"一次性瞬时抖动"的快速重试
|
||
retry:
|
||
max-attempts: 2
|
||
on-http-codes: 429, 503, 529
|
||
backoff:
|
||
initial-interval: 3000
|
||
multiplier: 3
|
||
max-interval: 60000
|
||
# 禁用 Spring AI MCP Client 自动配置(由 McpClientManager 自行管理生命周期)
|
||
mcp:
|
||
client:
|
||
enabled: false
|
||
|
||
# MyBatis Plus
|
||
mybatis-plus:
|
||
configuration:
|
||
map-underscore-to-camel-case: true
|
||
log-impl: org.apache.ibatis.logging.slf4j.Slf4jImpl
|
||
|
||
# SpringDoc OpenAPI
|
||
# 注意:/swagger-ui*、/v3/api-docs*、/webjars/** 落在 SecurityConfig 的
|
||
# .anyRequest().permitAll(),即 Swagger UI 当前公开可访问。如生产需要收口,
|
||
# 在 SecurityConfig 加显式规则(不要在此处配)。
|
||
springdoc:
|
||
api-docs:
|
||
path: /v3/api-docs
|
||
swagger-ui:
|
||
path: /swagger-ui.html
|
||
# 把单个嵌套 query 参数对象(如分页 wrapper)拍平成独立字段,减少 schema 噪音
|
||
default-flat-param-object: true
|
||
|
||
# MateClaw 自定义配置
|
||
mateclaw:
|
||
server:
|
||
# Public base URL used to build absolute download links for tool-generated
|
||
# files (e.g. https://mateclaw.example.com). Leave empty to fall back to the
|
||
# current request's host, and to a relative path when no request is bound.
|
||
# Set this when agents deliver download links to channels/clients that cannot
|
||
# resolve a relative URL (IM messages, copied links, external downloads).
|
||
public-base-url: ${MATECLAW_PUBLIC_BASE_URL:}
|
||
openapi:
|
||
# SpringDoc OpenAPI 元信息(驱动 /swagger-ui.html 与 /v3/api-docs)。
|
||
# server-url 留空时由 SpringDoc 从请求 host 推导,避免 Try it out 打到错误地址。
|
||
# 生产若需固定,通过 MATECLAW_OPENAPI_SERVER_URL 覆盖(如 https://mate.example.com)。
|
||
title: ${MATECLAW_OPENAPI_TITLE:MateClaw REST API}
|
||
version: ${MATECLAW_OPENAPI_VERSION:1.0}
|
||
server-url: ${MATECLAW_OPENAPI_SERVER_URL:}
|
||
# description 留空则使用 OpenApiConfig 中的内置默认描述
|
||
description: ${MATECLAW_OPENAPI_DESCRIPTION:}
|
||
# 是否公开 Swagger UI / OpenAPI 文档路径(/swagger-ui*、/v3/api-docs*、/webjars/**)。
|
||
# true = 任何人可浏览(本地开发 / 内网默认);
|
||
# false = 需要全局管理员(ROLE_ADMIN)才能访问,由 SecurityConfig 强制。
|
||
# 生产数据库 profile(mysql/kingbase/postgres)默认覆盖为 false。
|
||
expose-ui: ${MATECLAW_OPENAPI_EXPOSE_UI:true}
|
||
jwt:
|
||
secret: ${JWT_SECRET:MateClaw-JWT-Secret-Key-2024-Please-Change-In-Production}
|
||
expiration: 86400000
|
||
# 搜索配置已迁移至数据库(mate_system_setting 表),通过 UI 系统设置管理
|
||
# MCP server 配置已迁移至数据库(mate_mcp_server 表),通过 UI 管理
|
||
mcp:
|
||
enabled: true
|
||
tools:
|
||
disclosure:
|
||
# progressive: extension-tier tools are hidden behind the extension-tools
|
||
# catalog until the model calls enable_tool. By default that's the heavy
|
||
# generative / browser tools; MCP servers default to core (visible) and
|
||
# an admin can move a noisy one to extension per server.
|
||
# legacy: advertise every bound tool up front (pre-disclosure behavior).
|
||
mode: ${MATECLAW_TOOLS_DISCLOSURE_MODE:progressive}
|
||
workspace:
|
||
sandbox:
|
||
# Global fallback filesystem boundary for file/shell tools. When a
|
||
# conversation has no per-workspace base path configured, operations are
|
||
# confined to this root instead of running unconstrained against the whole
|
||
# filesystem (fail-closed default). Set enabled=false to restore the legacy
|
||
# unconstrained behaviour for unconfigured conversations.
|
||
enabled: ${MATECLAW_WORKSPACE_SANDBOX_ENABLED:true}
|
||
root: ${MATECLAW_WORKSPACE_SANDBOX_ROOT:${user.dir}/data/workspace}
|
||
skill:
|
||
workspace:
|
||
# Skill workspace root. Override with MATECLAW_SKILL_WORKSPACE_ROOT to
|
||
# relocate it onto a persistent volume — in Docker this is pointed at
|
||
# /app/data/skills so the existing server_data volume persists installed
|
||
# skills, accumulated LESSONS.md, and skill runtime files across restarts.
|
||
root: ${MATECLAW_SKILL_WORKSPACE_ROOT:${user.home}/.mateclaw/skills}
|
||
auto-init: true
|
||
delete-policy: archive
|
||
disclosure:
|
||
load-skill-tool:
|
||
# When false, the load_skill meta tool is not advertised to agents and
|
||
# the skill catalog guidance falls back to readSkillFile. Escape hatch
|
||
# for operators who don't want the explicit skill-load entry point.
|
||
enabled: ${MATECLAW_SKILL_LOAD_SKILL_TOOL_ENABLED:true}
|
||
curator:
|
||
enabled: true
|
||
cron: "0 0 2 * * *" # daily 02:00 — staggered away from wiki / backup jobs
|
||
stale-after-days: 30
|
||
archive-after-days: 90
|
||
scope: AGENT_CREATED # AGENT_CREATED | ALL_DYNAMIC | OFF
|
||
protect-prefixes:
|
||
- "sys-"
|
||
- "ops-"
|
||
hub:
|
||
base-url: https://clawhub.ai
|
||
search-path: /api/v1/search
|
||
skills-path: /api/v1/skills
|
||
download-path: /api/v1/download
|
||
http-timeout: 15
|
||
http-retries: 3
|
||
plugin:
|
||
enabled: true
|
||
user-dir: ${user.home}/.mateclaw/plugins
|
||
# RFC-017: 声明式 Hook 系统
|
||
hooks:
|
||
enabled: true
|
||
global-rate-limit: 200 # 全局每秒最大派发数
|
||
global-concurrency: 32 # 同时活跃的派发任务上限
|
||
dispatch-deadline: 5s # 单事件派发硬预算
|
||
trusted-domains: [] # HttpAction 允许调用的域名(精确或后缀匹配),留空禁用 HTTP
|
||
http:
|
||
connect-timeout: 2s
|
||
read-timeout: 3s
|
||
audit:
|
||
enabled: true # 每次派发写 mate_hook_run
|
||
retain-days: 7
|
||
# RFC-014: Anthropic prompt cache 标记
|
||
llm:
|
||
cache:
|
||
enabled: true # 总开关;false 时全部走 NoOp
|
||
min-prompt-tokens: 1024 # 累计 prompt token 低于此值则跳过缓存(避免 cache write 倒亏)
|
||
max-breakpoints: 4 # 单请求最多打几个 cache_control 断点(Anthropic 上限 4)
|
||
ttl: DEFAULT # DEFAULT(5min) | EXTENDED_1H(需要 anthropic-beta header)
|
||
include-tools-block: true # 工具 schema 段是否独立打断点(CONVERSATION_HISTORY 策略)
|
||
adaptive:
|
||
enabled: true # 自适应降级(连续 miss 后短路到 NoOp,冷却后恢复)
|
||
miss-threshold: 5
|
||
cool-down-ms: 60000
|
||
# RFC-009 P3.3: per-provider health tracker for the multi-model failover chain.
|
||
# When a provider hits failure-threshold consecutive failures it enters a cooldown
|
||
# window during which the chain walker skips it, avoiding repeated 5-retry stalls
|
||
# against a known-broken provider on every conversation turn.
|
||
failover:
|
||
health:
|
||
enabled: true
|
||
failure-threshold: 3
|
||
cooldown-ms: 300000
|
||
# Multi-agent delegation (DelegateAgentTool).
|
||
delegation:
|
||
# Wall-clock budget for one delegateParallel batch (shared across all
|
||
# children — they run concurrently on virtual threads, so this is total
|
||
# latency, not per-child). 300 s headroom is needed because thinking
|
||
# models (Kimi / GLM / MiniMax) routinely take 90–290 s per LLM turn
|
||
# when the child must produce multi-section structured output.
|
||
parallel-timeout-seconds: 300
|
||
|
||
# MateClaw Agent 配置
|
||
mate:
|
||
agent:
|
||
# Deterministic Markdown cleanup of the final answer (heading spaces, glued
|
||
# ---, table pipe alignment) before persistence / channel delivery. Set to
|
||
# false to pass model output through verbatim.
|
||
markdown-normalize-enabled: true
|
||
graph:
|
||
observation:
|
||
# 与 GraphObservationProperties.java 默认值对齐,参考 openclaw token-budget 设计
|
||
max-single-observation-chars: 16000
|
||
max-total-observation-chars: 200000
|
||
large-result-threshold: 32000
|
||
min-rounds-for-summarize: 25
|
||
head-ratio: 0.4
|
||
truncation-marker: "\n\n...[TRUNCATED: %d chars total, middle omitted. Do NOT infer or fabricate omitted content; retrieve the full data (e.g. read_file) or tell the user the result is incomplete.]...\n\n"
|
||
tool:
|
||
timeout:
|
||
default-timeout-seconds: 300
|
||
per-category:
|
||
shell: 120
|
||
web: 30
|
||
# Tool-result budget (per-result spill + per-turn aggregate budget).
|
||
# The executor tries to spill the RAW result first so the full output is
|
||
# preserved on disk; the in-context preview points the agent at the spill
|
||
# file via read_file. When spill is disabled, the tool is on the exclusion
|
||
# list, the body is at or below the threshold, or the disk write fails,
|
||
# the executor falls back to inline hard-truncation to the same character
|
||
# cap. Per-turn aggregate caps the combined size across one tool turn.
|
||
tool-result:
|
||
enabled: true
|
||
per-result-threshold-chars: 8000 # aligned with executor hard cap; > this size → spill, ≤ → inline verbatim
|
||
per-turn-budget-chars: 32000 # headroom for multi-tool turns
|
||
preview-head-chars: 800
|
||
excluded-tool-inline-chars: 2500
|
||
storage-base-dir: ""
|
||
# Retrieval-style tools that must NEVER be spilled. Spilling read_file's
|
||
# output causes a recursion: the agent reads the spill path, that read also
|
||
# exceeds the threshold, gets spilled to a new path, agent reads that one,
|
||
# ad infinitum until MAX_TOOL_CALLS_PER_STEP is hit. Add MCP-provided
|
||
# readers here if they have the same role.
|
||
excluded-tools:
|
||
- read_file
|
||
- read_workspace_memory_file
|
||
# Spill files are deleted after this many days. Default 0 disables the
|
||
# scheduled sweep entirely so a summary/preview that points at a spill
|
||
# path stays valid for the whole life of the conversation. Files are
|
||
# still purged when the conversation is deleted explicitly via
|
||
# ConversationService.deleteConversation. Raise to a positive value if
|
||
# disk pressure outweighs recoverability for your deployment.
|
||
retention-days: 0
|
||
cleanup-cron: "0 0 3 * * ?"
|
||
conversation:
|
||
window:
|
||
# 测试时临时调低:2000 token ≈ 2000 中文字,3 轮对话即可触发压缩
|
||
# 生产环境应改回 128000
|
||
default-max-input-tokens: 128000
|
||
compact-trigger-ratio: 0.75
|
||
preserve-recent-pairs: 2
|
||
summary-max-tokens: 300
|
||
# Wiki 知识库配置
|
||
wiki:
|
||
enabled: true # 是否启用 Wiki 知识库功能
|
||
max-chunk-size: 30000 # LLM 单次处理最大字符数(超过则分块)
|
||
max-context-chars: 10000 # 注入 Agent prompt 的 Wiki 摘要最大字符数
|
||
max-pages-per-raw: 15 # 单个原始材料最多生成的 Wiki 页面数
|
||
max-parallel-phase-b-pages: 3 # RFC-012 follow-up #3:单 chunk 内 phase B 阶段并行处理的 page 数
|
||
auto-process-on-upload: true # 上传原始材料后是否自动触发 AI 消化
|
||
upload-dir: ./data/wiki-uploads # 上传文件存储目录
|
||
max-scan-files: 500 # 目录扫描最大文件数
|
||
max-scan-file-size: 52428800 # 扫描时跳过大于此大小的文件(字节,默认 50MB)
|
||
# Dream v2 feature flags — production defaults after GA validation
|
||
memory:
|
||
# Phase 1: lifecycle mediator wiring
|
||
lifecycle-mediator-enabled: true
|
||
dream:
|
||
focused-enabled: true
|
||
archive-enabled: true
|
||
archive-keep-days: 30
|
||
max-candidates-per-dream: 100
|
||
# Phase 2: SOUL auto-evolution and provider decorators
|
||
soul-update-interval: 20 # 20 writes trigger one SOUL.md LLM update (0 = off)
|
||
provider-retry-attempts: 1 # 1 = no retry (enable when external providers added)
|
||
provider-metrics-enabled: false # actuator dependency now present; enable when external providers added
|
||
# Phase 3: fact projection
|
||
fact:
|
||
projection-enabled: true
|
||
projection-rebuild-cron: "0 */30 * * * ?"
|
||
llm-extraction-enabled: false # placeholder impl, enable after Phase 3 L4+
|
||
contradiction-check-enabled: false # experimental simple detection, enable after LLM batch impl
|
||
trust-half-life-days: 60
|
||
forget-enabled: true
|
||
# Always-on injection budget — bounds the per-turn size of the user/feedback structured block
|
||
system-block-max-chars: 4000 # char cap on the always-on block; over budget drops oldest by Updated date (LRU); 0 = unlimited
|
||
system-block-max-entries-per-type: 40 # max entries injected per type (user/feedback); 0 = unlimited
|
||
# Structured-memory consolidation — separate maintenance task; LLM merges duplicate/stale user/feedback entries (shared + per-owner) to curb storage growth
|
||
structured-consolidation-enabled: true # off = injection cap only, no storage-side merge
|
||
structured-consolidation-min-entries: 8 # buckets with fewer entries skip the LLM call to save cost
|
||
structured-consolidation-cron: "0 30 3 * * ?" # own schedule, decoupled from dreaming-enabled / dreaming-cron
|
||
structured-consolidation-max-owners-per-run: 50 # cap LLM cost per agent per run; remaining owners picked up next run; 0 = unlimited
|
||
# Always-on file ceilings — deterministic backstop so PROFILE.md / MEMORY.md (LLM-rewritten) cannot grow per-turn context without bound
|
||
profile-max-chars: 4000 # PROFILE.md hard cap; truncates at a section boundary if the rewrite overruns; 0 = unlimited
|
||
memory-md-max-chars: 8000 # MEMORY.md hard cap; 0 = unlimited
|