Skip to content

Commit db6caea

Browse files
author
matevip
committed
release: v1.6.0
1 parent 84375da commit db6caea

574 files changed

Lines changed: 39361 additions & 7714 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.env.example

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ JWT_SECRET=
2929
# 若留空,服务器会允许所有 origin 并在启动日志里 WARN。生产部署务必设置。
3030
MATECLAW_CORS_ALLOWED_ORIGINS=
3131

32+
# 公开访问基址(如 https://mateclaw.example.com)。用于把智能体生成文件的下载
33+
# 链接拼成绝对地址,便于在 Web 之外(IM 消息、复制链接、外部下载)直接打开。
34+
# 留空时回退到当前请求的 host,再退回相对路径。反代后部署建议显式设置。
35+
MATECLAW_PUBLIC_BASE_URL=
36+
3237
# SearXNG 会话密钥(容器内部用,留空会用开发默认值)。生产部署请设成 32+ 位随机串。
3338
# openssl rand -hex 32
3439
SEARXNG_SECRET=
@@ -69,6 +74,36 @@ MATECLAW_BROWSER_CHANNEL=
6974
MATECLAW_OAUTH_OPENAI_DEPLOYMENT_MODE=
7075
MATECLAW_OAUTH_OPENAI_CALLBACK_BIND_HOST=
7176

77+
# ==================== Wiki 知识库目录白名单(Docker 模式,可选)====================
78+
#
79+
# Docker 生产部署开启了路径安全校验(fail-closed)。
80+
# 知识库使用「目录扫描」功能时,扫描路径必须在此白名单内,否则返回 400 错误。
81+
# 多个路径用英文逗号分隔;留空则禁止所有目录扫描。
82+
#
83+
# 示例:MATE_WIKI_ALLOWED_SOURCE_ROOTS=/data/wiki,/opt/docs
84+
#
85+
# 同时在 docker-compose.yml 的 volumes 里把宿主机目录挂进容器,例如:
86+
# volumes:
87+
# - /your/host/path:/data/wiki
88+
MATE_WIKI_ALLOWED_SOURCE_ROOTS=
89+
90+
# ── Wiki 知识源自动同步(变更监测)总开关 ────────────────────────
91+
# 定时扫描各知识库的源目录、自动消化新文件。默认关闭,运维主动开启。
92+
# AND 语义:全局这个开关开 *且* 某知识库自己的「自动同步」开关也开,
93+
# 该库才会被定时扫描;手动「立即扫描」不受此开关影响。
94+
# 间隔单位毫秒,默认 5 分钟(目前为全局,暂不支持按库配置)。
95+
MATE_WIKI_WATCHER_ENABLED=false
96+
MATE_WIKI_WATCHER_INTERVAL_MS=300000
97+
98+
# ── Skill 工作区目录 ─────────────────────────────────────────────
99+
# 已安装的 skill、运行时积累的 LESSONS.md、skill 运行产物都落在这个目录。
100+
# 默认(容器内)已指向 /app/data/skills,由 docker-compose 的 server_data 卷
101+
# 持久化,容器重启不丢,无需额外挂卷。一般无需修改。
102+
# 内置 skill 由 JAR classpath 每次启动现场释放,挂空卷也不会丢内置文件。
103+
# 仅当你想把 skill 目录放到别处(如独立的 bind mount)时才覆盖此项,
104+
# 并记得在 docker-compose.yml 的 volumes 里把对应宿主机目录挂进容器。
105+
MATECLAW_SKILL_WORKSPACE_ROOT=
106+
72107
# ── Maven 镜像(国内加速)─────────────────────────────────────────
73108
# 在中国大陆构建时取消注释,将 Aliyun 仓库优先级提前,大幅提速 mvn 拉包。
74109
# 空值(默认)使用 US Maven Central → Google CDN → Aliyun 的顺序。

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,8 @@ scripts/.*-sync-state.json
111111
# Sandbox / external client work that lives in this directory
112112
# but should not ship in the repo.
113113
outputs/
114+
115+
# This is a pnpm monorepo — pnpm-lock.yaml is the only lockfile we track.
116+
# Ignore stray npm/yarn lockfiles so they are not committed by mistake.
117+
package-lock.json
118+
yarn.lock

README.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,20 @@ Full docs at **[claw.mate.vip/docs](https://claw.mate.vip/docs)** — setup, arc
217217

218218
## Roadmap
219219

220-
**v1.3.0 (shipped 2026-05-13)**Workflow engine · 6-pattern trigger system · Wiki transformations · per-agent MCP binding · multimodal sidecar routing · four JVM-native document generation tools · image edit. See the [v1.3.0 release notes](https://claw.mate.vip/docs/en/releases/1.3.0) for the full story.
220+
**v1.5.0 (shipped 2026-06-04)**Goal checklists (fuzzy score → ticked boxes) · self-maintaining Wiki (`[[wikilinks]]` · fact/experience layers · pageType profiles & permissions · KB pipelines · local-directory ingest) · per-owner memory isolation (`owner_key` + visibility scope + `endUserId` passthrough) · per-agent primary knowledge base · provider-preference model routing. Full story in the [v1.5.0 release notes](https://claw.mate.vip/docs/en/releases/1.5.0).
221221

222-
**Next** — Drag-to-edit workflow canvas · run replay timeline · `loop` and `invoke_skill` step modes · trigger priorities and event replay · industry scenario marketplace · more ACP upstream integrations.
222+
**v1.4.0 (shipped 2026-05-23)** — Persistent Goals (lock a goal, self-evaluate every turn) · subagent delegation tree (3 levels deep · sync / parallel / async · one-sentence team builder) · progressive tool/skill disclosure · Workspace RBAC (Owner / Admin / Member / Viewer) · Feishu first-class (interactive / approval / streaming cards · channel-native tools). See the [v1.4.0 release notes](https://claw.mate.vip/docs/en/releases/1.4.0).
223+
224+
**v1.3.0 (shipped 2026-05-13)** — Workflow engine · 6-pattern trigger system · Wiki transformations · per-agent MCP binding · multimodal sidecar routing · four JVM-native document-generation tools · image edit. See the [v1.3.0 release notes](https://claw.mate.vip/docs/en/releases/1.3.0).
225+
226+
**v1.6.0 (in progress)** — make the autonomous employee *fast, sharp-eyed, and embeddable*:
227+
228+
- **Faster first token** — two-stage skill loading (base skills resident, scenario skills retrieved on demand by a relevance scorer) plus prefix compression, cutting the cold-start payload that used to blow past a million characters
229+
- **Native code execution**`execute_code` lets an employee write and run sandboxed code to compute, transform data, and assemble multi-format reports, all JVM-side
230+
- **Vision that persists** — images stay in context across turns; `image_analyze` re-reads an attachment on demand, so "zoom into that chart" follow-ups work without re-uploading
231+
- **Embeddable & headless** — the webchat widget becomes a Web/API surface with multi-session support and per-end-user identity (`endUserId`), isolating memory per end user
232+
- **A Wiki you actually read** — reading split from management, a unified Sources tab with per-KB auto-sync, and clickable cross-KB `[[wikilinks]]`
233+
- **Steadier under load** — self-healing MCP connections · tool-call recovery on interleaved-thinking models · evidence-gated plan execution
223234

224235
## Contributing
225236

README_zh.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,20 @@ mateclaw/
217217

218218
## 路线图
219219

220-
**v1.3.0(2026-05-13 发布)**工作流引擎 · 6 种 pattern 触发器 · Wiki 加工器 · 每员工独立 MCP 绑定 · 多模态旁路路由 · 4 个 JVM 原生文档生成工具 · 图像编辑。完整故事见 [v1.3.0 release notes](https://claw.mate.vip/docs/zh/releases/1.3.0)
220+
**v1.5.0(2026-06-04 发布)**Goal 可勾选清单(模糊评分 → 逐项打勾)· Wiki 自维护(`[[wikilinks]]` · 事实层/经验层 · pageType 模板与权限 · 知识库流水线 · 本地目录接入)· 按拥有者隔离记忆(`owner_key` + 可见域 + `endUserId` 透传)· 每员工绑定主知识库 · 偏好 provider 驱动选型。完整故事见 [v1.5.0 release notes](https://claw.mate.vip/docs/zh/releases/1.5.0)
221221

222-
**下一步** — 工作流画布可拖拉编辑 · 运行回放时间线 · `loop` / `invoke_skill` step mode · 触发器优先级 + 事件回放 · 行业场景应用市场 · 更多 ACP 上游集成。
222+
**v1.4.0(2026-05-23 发布)** — 持续目标(锁定目标,每轮自评)· 子员工委派树(最深 3 层 · 同步 / 并行 / 异步 · 一句话组队)· 工具/技能渐进式披露 · 工作空间 RBAC(Owner / Admin / Member / Viewer)· 飞书一等公民(交互卡 / 审批卡 / 流式卡 · 渠道原生工具)。详见 [v1.4.0 release notes](https://claw.mate.vip/docs/zh/releases/1.4.0)
223+
224+
**v1.3.0(2026-05-13 发布)** — 工作流引擎 · 6 种 pattern 触发器 · Wiki 加工器 · 每员工独立 MCP 绑定 · 多模态旁路路由 · 4 个 JVM 原生文档生成工具 · 图像编辑。详见 [v1.3.0 release notes](https://claw.mate.vip/docs/zh/releases/1.3.0)
225+
226+
**v1.6.0(开发中)** — 让自驱的数字员工*更快、更会看、更易嵌入*
227+
228+
- **首字节更快** — 技能两段式载入(基础技能常驻,场景技能由相关性评分器按需检索)+ prefix 压缩,砍掉过去单请求动辄上百万字符的冷启动负载
229+
- **原生代码执行**`execute_code` 让员工自己写、自己跑沙箱代码,完成计算、数据加工与多格式报告生成,全程在 JVM 内
230+
- **能记住图的视觉** — 图片跨轮次保留在上下文里;`image_analyze` 按需重新解析某张附件,"放大看那张图表"这类追问无需重新上传
231+
- **可嵌入、可无头** — webchat 组件升级为 Web/API 接入面,支持多会话与按终端用户身份(`endUserId`)隔离记忆
232+
- **真正可读的 Wiki** — 阅读与管理分离、统一的 Sources 标签页(按知识库自动同步)、可点击的跨库 `[[wikilinks]]`
233+
- **高负载更稳** — MCP 连接自愈 · interleaved-thinking 模型的工具调用恢复 · 计划执行的证据闸门
223234

224235
## 参与贡献
225236

docker-compose.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,19 @@ services:
9696
# 本机 Docker 若要强制使用 localhost:1455 回调,可在 .env 显式设为 local。
9797
MATECLAW_OAUTH_OPENAI_DEPLOYMENT_MODE: ${MATECLAW_OAUTH_OPENAI_DEPLOYMENT_MODE:-}
9898
MATECLAW_OAUTH_OPENAI_CALLBACK_BIND_HOST: ${MATECLAW_OAUTH_OPENAI_CALLBACK_BIND_HOST:-0.0.0.0}
99+
# Wiki 知识库目录扫描白名单(逗号分隔,留空则禁止所有目录扫描)。
100+
# 示例:MATE_WIKI_ALLOWED_SOURCE_ROOTS=/data/wiki,/opt/docs
101+
# 记得同步在 volumes 里把宿主机路径挂进容器。
102+
MATE_WIKI_ALLOWED_SOURCE_ROOTS: ${MATE_WIKI_ALLOWED_SOURCE_ROOTS:-}
103+
# Wiki 知识源自动同步总开关(运维总闸,默认关)。AND 语义:全局开关与
104+
# 每个知识库自己的「自动同步」开关都开,该库才会被定时扫描。
105+
# 间隔单位毫秒,默认 5 分钟。
106+
MATE_WIKI_WATCHER_ENABLED: ${MATE_WIKI_WATCHER_ENABLED:-false}
107+
MATE_WIKI_WATCHER_INTERVAL_MS: ${MATE_WIKI_WATCHER_INTERVAL_MS:-300000}
108+
# Skill 工作区根目录。放在 /app/data 下,让现有的 server_data 卷一并持久化
109+
# 已安装的 skill、运行时积累的 LESSONS.md 以及 skill 运行产物,容器重启不丢。
110+
# 内置 skill 仍由 JAR classpath 每次启动现场释放,空卷不会丢内置文件。
111+
MATECLAW_SKILL_WORKSPACE_ROOT: ${MATECLAW_SKILL_WORKSPACE_ROOT:-/app/data/skills}
99112
# Chromium needs a real /dev/shm. Docker defaults to 64MB which causes
100113
# SIGBUS / "Target page closed" errors under load. 2GB is the usual
101114
# recommendation for Playwright / headless chrome.
@@ -104,6 +117,9 @@ services:
104117
- "18080:18088" # host:container — app listens on 18088 inside the container
105118
- "1455:1455"
106119
volumes:
120+
# server_data covers /app/data — H2 DB, wiki-uploads, AND the skill
121+
# workspace (MATECLAW_SKILL_WORKSPACE_ROOT=/app/data/skills above), so a
122+
# single volume persists everything. No separate skills volume needed.
107123
- server_data:/app/data
108124

109125
volumes:

mateclaw-server/Dockerfile

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,18 @@ RUN apt-get update \
105105
# BrowserLauncher's BUNDLED strategy will then succeed without extra config.
106106
ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright \
107107
TZ=Asia/Shanghai \
108-
JAVA_TOOL_OPTIONS="-Duser.timezone=Asia/Shanghai"
108+
LANG=C.UTF-8 \
109+
LC_ALL=C.UTF-8 \
110+
JAVA_TOOL_OPTIONS="-Duser.timezone=Asia/Shanghai -Dsun.jnu.encoding=UTF-8"
111+
112+
# Default DB profile, overridable by the SPRING_PROFILES_ACTIVE env var
113+
# (compose sets it explicitly: mysql / postgres / kingbase). It must be an ENV,
114+
# not a -D system property on the ENTRYPOINT: a hardcoded
115+
# -Dspring.profiles.active outranks the SPRING_PROFILES_ACTIVE env var and would
116+
# silently pin the profile regardless of what compose passes.
117+
ENV SPRING_PROFILES_ACTIVE=mysql
109118

110119
COPY --from=builder /build/mateclaw-server/target/*.jar app.jar
111120
EXPOSE 18088
112121
EXPOSE 1455
113-
ENTRYPOINT ["java", "-jar", "-Dspring.profiles.active=mysql", "app.jar"]
122+
ENTRYPOINT ["java", "-jar", "app.jar"]

mateclaw-server/pom.xml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,30 @@
337337
<groupId>org.flywaydb</groupId>
338338
<artifactId>flyway-mysql</artifactId>
339339
</dependency>
340+
<!-- Flyway PostgreSQL support (used by KingbaseES as well since KingbaseES is PostgreSQL-compatible) -->
341+
<dependency>
342+
<groupId>org.flywaydb</groupId>
343+
<artifactId>flyway-database-postgresql</artifactId>
344+
</dependency>
345+
<dependency>
346+
<groupId>org.postgresql</groupId>
347+
<artifactId>postgresql</artifactId>
348+
<version>42.7.7</version>
349+
<scope>runtime</scope>
350+
</dependency>
351+
352+
<!--
353+
KingbaseES (人大金仓) JDBC driver is NOT on Maven Central, so it is
354+
declared in the opt-in `kingbase` Maven profile instead of here.
355+
The default build never resolves it. To build with KingbaseES:
356+
1. install the driver: mvn install:install-file \
357+
-Dfile=${KINGBASE_HOME}/Interface/jdbc/kingbase8-8.6.0.jar \
358+
-DgroupId=com.kingbase8 -DartifactId=kingbase8 \
359+
-Dversion=8.6.0 -Dpackaging=jar
360+
2. build with the profile: mvn package -Pkingbase
361+
No Java code imports com.kingbase8.* — the driver is loaded at
362+
runtime via spring.datasource.driver-class-name only.
363+
-->
340364

341365
<!-- ===== Spring Boot Test ===== -->
342366
<dependency>
@@ -470,5 +494,24 @@
470494
</plugins>
471495
</build>
472496
</profile>
497+
498+
<!--
499+
Profile: KingbaseES (人大金仓) JDBC driver.
500+
The driver is not published to Maven Central, so it is kept out of the
501+
default build to keep `mvn package` resolvable for everyone. Install the
502+
driver into the local repository, then build with `mvn package -Pkingbase`.
503+
Runtime selection is via the `kingbase` Spring profile (application-kingbase.yml).
504+
-->
505+
<profile>
506+
<id>kingbase</id>
507+
<dependencies>
508+
<dependency>
509+
<groupId>com.kingbase8</groupId>
510+
<artifactId>kingbase8</artifactId>
511+
<version>8.6.0</version>
512+
<scope>runtime</scope>
513+
</dependency>
514+
</dependencies>
515+
</profile>
473516
</profiles>
474517
</project>

mateclaw-server/src/main/java/vip/mate/MateClawApplication.java

Lines changed: 73 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,29 @@
11
package vip.mate;
22

3+
import com.baomidou.mybatisplus.annotation.DbType;
34
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
45
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
6+
import jakarta.annotation.PostConstruct;
7+
import lombok.extern.slf4j.Slf4j;
58
import org.mybatis.spring.annotation.MapperScan;
9+
import org.springframework.beans.factory.annotation.Autowired;
610
import org.springframework.boot.SpringApplication;
711
import org.springframework.boot.autoconfigure.SpringBootApplication;
12+
import org.springframework.boot.context.event.ApplicationReadyEvent;
813
import org.springframework.context.annotation.Bean;
14+
import org.springframework.context.event.EventListener;
915
import org.springframework.scheduling.annotation.EnableScheduling;
1016

17+
import javax.sql.DataSource;
18+
import java.sql.Connection;
19+
1120
/**
1221
* MateClaw - Personal AI Assistant
1322
* Powered by Spring AI Alibaba
1423
*
1524
* @author MateClaw Team
1625
*/
26+
@Slf4j
1727
@SpringBootApplication(exclude = {
1828
// Disable Spring AI MCP Client auto-configuration (lifecycle owned by McpClientManager).
1929
org.springframework.ai.mcp.client.common.autoconfigure.McpClientAutoConfiguration.class,
@@ -33,22 +43,80 @@
3343
@MapperScan("vip.mate.**.repository")
3444
public class MateClawApplication {
3545

46+
@Autowired
47+
private DataSource dataSource;
48+
49+
/** Cached DbType for the PaginationInnerInterceptor. */
50+
private volatile DbType resolvedDbType;
51+
3652
public static void main(String[] args) {
3753
SpringApplication.run(MateClawApplication.class, args);
3854
}
3955

56+
/**
57+
* Detect the actual database type from the live DataSource so the
58+
* {@link PaginationInnerInterceptor} always uses the correct dialect,
59+
* even when the JDBC URL is wrapped by a proxy (HikariCP, P6Spy, etc.).
60+
*
61+
* <p>DbType is cached after the first successful detection; a failure
62+
* falls back to the value set in {@code mybatis-plus.global-config.db-config.db-type},
63+
* or eventually to {@link DbType#MYSQL} — but by then the connection
64+
* pool would already have failed.
65+
*/
66+
@PostConstruct
67+
void detectDbType() {
68+
try (Connection conn = dataSource.getConnection()) {
69+
String productName = conn.getMetaData().getDatabaseProductName().toLowerCase();
70+
if (productName.contains("kingbase")) {
71+
resolvedDbType = DbType.KINGBASE_ES;
72+
} else if (productName.contains("postgresql")) {
73+
resolvedDbType = DbType.POSTGRE_SQL;
74+
} else if (productName.contains("mysql") || productName.contains("mariadb")) {
75+
resolvedDbType = DbType.MYSQL;
76+
} else if (productName.contains("h2")) {
77+
resolvedDbType = DbType.H2;
78+
} else {
79+
// Let the PaginationInnerInterceptor auto-detect at query time
80+
resolvedDbType = null;
81+
}
82+
if (resolvedDbType != null) {
83+
log.info("Detected database type: {} (product={})", resolvedDbType, productName);
84+
}
85+
} catch (Exception e) {
86+
log.warn("Could not detect database type — PaginationInnerInterceptor will auto-detect on first query: {}",
87+
e.getMessage());
88+
}
89+
}
90+
4091
/**
4192
* MyBatis Plus pagination plugin.
4293
*
43-
* <p>DbType is auto-detected from the JDBC connection at runtime rather
44-
* than hardcoded. Hardcoding H2 here meant the MySQL deployment used
45-
* the H2 dialect for the count query, which silently returned 0 —
46-
* frontends saw records but total=0 and couldn't paginate (RFC-042 P0).
94+
* <p>When {@code resolvedDbType} is available the interceptor uses it directly;
95+
* otherwise it falls back to JDBC-URL auto-detection, which works for
96+
* {@code jdbc:kingbase8://} but not for proxied DataSources (RFC-042 P0).
4797
*/
4898
@Bean
4999
public MybatisPlusInterceptor mybatisPlusInterceptor() {
50100
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
51-
interceptor.addInnerInterceptor(new PaginationInnerInterceptor());
101+
PaginationInnerInterceptor pagination = resolvedDbType != null
102+
? new PaginationInnerInterceptor(resolvedDbType)
103+
: new PaginationInnerInterceptor();
104+
interceptor.addInnerInterceptor(pagination);
52105
return interceptor;
53106
}
107+
108+
/**
109+
* Print a clear "READY" banner after all post-startup initialization,
110+
* so operators can tell at a glance when the application is ready to serve.
111+
*/
112+
@EventListener(ApplicationReadyEvent.class)
113+
public void onReady() {
114+
log.info("");
115+
log.info("╔══════════════════════════════════════════════════════════════════════╗");
116+
log.info("║ MateClaw is READY ✓ ║");
117+
log.info("║ Web UI → http://localhost:18088 ║");
118+
log.info("║ Swagger → http://localhost:18088/swagger-ui.html ║");
119+
log.info("╚══════════════════════════════════════════════════════════════════════╝");
120+
log.info("");
121+
}
54122
}

0 commit comments

Comments
 (0)