Skip to main content

Mink

Crates.io MIT licensed Rust 1.94+ Python SDK

Rust 原生 · 终端优先 · 可嵌入

Mink 是一个 Rust 实现的 AI agent runtime:面向终端,也面向系统。既适合在终端中直接 工作(REPL / Full TUI / Inline TUI),也适合嵌入到服务端、桌面端或内部工具中 —— Rust 嵌入通过 mink::runtime in-process 运行;Python SDK 通过 wheel 内置的 mink-core --agent-jsonl 子进程复用同一运行时内核与语义。


[TOC]


快速开始

终端使用

# 前置:Rust 1.94+,设置 DEEPSEEK_API_KEY 或通过配置指定 OpenAI-compatible 端点

# 编译
cargo build --release        # 或 make build

# REPL 交互模式
./target/release/mink -m flash -i

# Full TUI 全屏模式
./target/release/mink -m flash --tui

# Inline TUI 原生 scrollback 模式
./target/release/mink -m flash --tui=inline

# 单次查询 / 恢复最近会话
./target/release/mink -m flash "explain this project"
./target/release/mink -m flash --continue -i

# 使用自定义系统提示词
./target/release/mink --mission ./my-task.mission.md -i

Python SDK

pip install mink-agent
from mink_agent import AgentSession, SandboxConfig

session = AgentSession(SandboxConfig(
    api_key="sk-...",               # 或设置 DEEPSEEK_API_KEY 环境变量
    read_dirs=["src"],
    signal_policy="full",             # off/evidence/state_ops/restart/full
))
result = session.run("scan this repo and summarize")
print(result["text"])
session.close()

Rust 嵌入

[dependencies]
mink = { package = "mink-core", version = "0.6.6", default-features = false, features = ["runtime"] }
use mink::prelude::{AgentOptions, AgentRuntime};

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let rt = AgentRuntime::start(
        AgentOptions::new("/tmp/mink-home", ".")
            .with_api_key(std::env::var("DEEPSEEK_API_KEY")?)
            .with_model("flash"),
    ).await?;

    let outcome = rt.run_turn("hello").await?;
    println!("{}", outcome.text);

    rt.shutdown().await?;
    Ok(())
}

核心特点

  • 可嵌入的运行时内核 — AgentRuntime::start() → run_turn() / stream_turn() → shutdown() 完整生命周期。CLI、REPL、TUI 和 Rust 嵌入共享 in-process 运行时;Python SDK 通过内置 mink-core 二进制复用同一 Rust 内核,不需要维护多套 agent 内核。
  • 长上下文与长任务可控 — 显式压缩参数 + LLM 摘要非破坏式投影 + 持久化 session 共同工作,上下文不无限膨胀,长任务可持续推进;enabled_tools 统一工具边界。
  • 编辑与状态管理更可靠 — Hashline / Replace 双模式编辑(Read snapshot + 行锚定,或 exact/fuzzy 内容匹配)、artifact 超长输出回读、Plan/Todo revision 原子提交和 session 恢复机制,不把正确性交给运气。

特性

⚙️ 核心引擎

  • OpenAI-compatible 默认后端 — 内置 DeepSeek / OpenAI 流式客户端,支持 reasoning、usage、工具调用和扩展参数(openai_tool_choice、openai_extra_body)
  • 可注入 LLM backend — 实现 mink::runtime::LlmBackend trait,接入私有模型、内网网关、厂商 SDK 或非 HTTP transport
  • 信号驱动的信念系统 — 自动检测工具执行错误,低信念时注入修正提示并约束恢复首步;MINK_SIGNAL_POLICY=off 可完全关闭
  • 显式上下文压缩 — 百分比阈值、响应预留、热尾部和摘要输出预算全参数化;可选摘要输入降噪(过滤 thinking、压缩工具结果)
  • 三段维修流水线 — Scavenge(回收遗漏调用)→ Truncation(修复残缺消息)→ StormBreaker(抑制重复调用),自动闭环修复

🖥️ 终端与界面

  • 三种交互 surface — REPL 行模式(-i)、Full TUI 全屏模式(--tui)、Inline TUI 原生 scrollback 模式(--tui=inline)
  • Hashline / Replace 双模式编辑 — Hashline 使用 Read 生成的 [PATH#TAG] 快照和行/文本锚点;Replace 使用唯一 old_text exact/fuzzy 匹配;两者都在歧义时 fail closed
  • 结构化 transcript — 统一的工具卡片渲染、Markdown 子集、自动折叠、实时信念 / token 状态栏
  • 图片粘贴 — Full/Inline TUI 中 Ctrl+V 读取剪贴板 PNG(macOS),内容寻址暂存到 session attachments/ 并随消息附带绝对路径;模型 Read 后走既有读图链路
  • 机器协议 — --print 输出 ndjson 事件流;--agent-jsonl 提供 single-shot Agent JSONL 协议

🛠️ 工具系统

  • 内置工具 — Read / Write / Edit / Bash / Python / Glob / Grep / PlanDraft / PlanConfirm / PlanClear / TodoRead / TodoWrite / TodoAdvance / SubAgent
  • 多模态读图 — 视觉会话中 Read 捕获图片(本地文件 / image://sha256:<id> 引用)、 内容寻址缓存、请求时以 OpenAI image_url data-URL 注入一次(单次消费);MIME 双层 校验与数量/字节/尺寸/像素配额 fail closed。CLI 经 [provider] image_input / vision_models 配置,Rust 经 with_image_input() / with_vision_models() / with_image_limits()
  • 统一工具选择 — enabled_tools 是唯一启用入口,同时决定模型可见 schema、能力工作流和真实执行边界;PythonSandbox 仅在显式列出时启用
  • 语义能力模型 — 工具按语义能力分类,自动组合工作流提示;不可用工具不会出现在 schema、提示词或组合链路中
  • 注册式轻量资源 — Read 通过 ResourceRouter 统一分发 artifact://、skill://、rule://、session:// 等 scheme
  • 技能系统 — 按需加载 skill 文件,不污染后续 prompt;skill_discovery_policy 控制发现策略

🔒 沙箱与安全

  • 进程级沙箱 — Linux nsjail / bubblewrap(完整文件系统隔离)、macOS sandbox-exec(写入隔离)
  • CPython WASI 沙箱 — PythonSandbox 工具在 wasmtime + CPython WASI 中执行,WASI 级进程隔离,无网络、无 C 扩展
  • 危险命令过滤 — Bash 危险命令拦截与误用软提示,可选审批策略

🗃️ 持久化与状态

  • Session 持久化 — Append-only JSONL 完整历史,活跃后缀内存缓存,--continue 无缝恢复
  • 非破坏式压缩 — 只更新 context-state.json 投影边界,不重写 conversation.jsonl;压缩统一使用 LLM 摘要
  • Plan & Todo 状态 — Plan 使用 append-only transition 与压缩后 checkpoint;Todo 使用稳定 ID、revision 和原子批量提交
  • Artifact 超长输出 — 工具结果超限自动落盘至 artifacts/,序号可恢复且禁止覆盖;Read artifact://<id> 读取
  • Token 用量 — LLM 请求级 usage.jsonl journal,覆盖主 Agent、自动压缩和子代理

🔌 集成与扩展

  • Rust 库 API — mink::runtime::{AgentRuntime, AgentOptions, LlmBackend, ReadOnlyFileSystem},完整同步/流式 turn 生命周期
  • Python SDK — pip install mink-agent,内置无 TUI 的 mink-core 二进制,支持全参数配置
  • 嵌入式只读 VFS — 为 Read/Glob/Grep 注入数据库后端,按 resource_session_id 隔离多租户知识库
  • 子代理(SubAgent) — 隔离或目录级 fork 完整 session 状态,复用父 runtime 的 LLM backend,支持并发执行
  • 自定义提示词 — --mission 加载 MISSION.md,允许覆盖白名单 core section,runtime 保留 section fail closed
  • 模型别名系统 — flash / pro 内置 DeepSeek 别名,model_aliases 可覆盖;任意模型名未命中时原样传递
  • Server 与 Web — mink-server 单二进制 Web 工作区服务器:REST + SSE 实时流,前端构建产物嵌入二进制,与 TUI 共享会话,浏览器里继续终端里的工作

Workspace Packages

路径 职责
crates/mink-core Rust 发布包 mink-core,库 crate 名 mink,包含可嵌入 runtime、工具核心、session、sandbox 和 SDK 协议
crates/mink-cli workspace 内部二进制包,生成 mink 终端二进制和 mink-core SDK 精简二进制,持有 REPL/TUI 实现
mink_agent Python SDK,wheel 内置无 TUI 的 mink-core 二进制
crates/mink-server Web 工作区服务器:REST + SSE + 嵌入前端,build.rs 自动构建并嵌入 web 产物

参考项目

项目 说明
oh-my-pi 开源 CLI agent(Bun/TypeScript),Edit 工具的行号锚定与快照协议参考实现
bash-agent 终端 Agent(Bash 优先),交互与工具执行参考

文档索引

文档 说明
使用手册 面向终端用户:CLI 交互、配置、沙箱、session、工具和常见工作流
嵌入与 SDK Rust 库 / Python SDK 嵌入、Token 用量
机器协议 --print stream-json 与 --agent-jsonl 协议
工具参考 面向工具协议:内置工具参数、结果通道、资源 URL、审批和构建裁剪
架构说明 运行时分层、模块职责、资源/能力系统、核心数据流
设计文档 设计总纲与关键不变式;信号与工具能力细节见对应设计哲学文档
变更日志 版本变更记录
Server 与 Web mink-server:REST/SSE API、嵌入构建、配置与部署
工具能力与提示词解耦 工具 surface、语义能力、自由组合和前向求值算法
信号系统设计 控制论 + 贝叶斯、冷却机制、信念度展示
Agent 开发指南 面向 AI agent:项目结构、模块索引、开发惯例

许可

MIT License

Metadata

Release files for mink-agent 0.6.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for mink-agent 0.6.6
File Interpreter ABI Platform Actions
mink_agent-0.6.6-py3-none-musllinux_1_2_x86_64.whl Python 3 none Linux musl 1.2+ x86-64 Details for mink_agent-0.6.6-py3-none-musllinux_1_2_x86_64.whl
mink_agent-0.6.6-py3-none-manylinux_2_35_x86_64.whl Python 3 none Linux glibc 2.35+ x86-64 Details for mink_agent-0.6.6-py3-none-manylinux_2_35_x86_64.whl
mink_agent-0.6.6-py3-none-macosx_26_0_arm64.whl Python 3 none macOS 26.0+ ARM64 Details for mink_agent-0.6.6-py3-none-macosx_26_0_arm64.whl

Total release size: 11.5 MB

Release files / mink_agent-0.6.6-py3-none-musllinux_1_2_x86_64.whl

Download URL mink_agent-0.6.6-py3-none-musllinux_1_2_x86_64.whl
Size 4.0 MB
Tags Linux musl 1.2+ x86-64 Python 3
SHA-256 checksum
How to use checksums
b298d79b63b4dccc164132a1a24798f29c0ea30f0751af4ff0e2dd806f235159
BLAKE2b-256 checksum
How to use checksums
3882d6dbbbe2b42822519c63a482759e74373f73c276acabbecffc1595470716
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 2, 2026.

Transparency log

Release files / mink_agent-0.6.6-py3-none-manylinux_2_35_x86_64.whl

Download URL mink_agent-0.6.6-py3-none-manylinux_2_35_x86_64.whl
Size 4.0 MB
Tags Linux glibc 2.35+ x86-64 Python 3
SHA-256 checksum
How to use checksums
5837d443e37eb56f0cb59751c323ab900ae1f4697f7afd86d9a314d1103d7f4c
BLAKE2b-256 checksum
How to use checksums
0841a24c19b1847efd95a3aa15f9231ae3b0806767b1f4e0f10d1f7ac3a778c6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 2, 2026.

Transparency log

Release files / mink_agent-0.6.6-py3-none-macosx_26_0_arm64.whl

Download URL mink_agent-0.6.6-py3-none-macosx_26_0_arm64.whl
Size 3.5 MB
Tags Python 3 macOS 26.0+ ARM64
SHA-256 checksum
How to use checksums
94b758172e25eccc2f0de6237cbfbc70034ea17bdea8f6f740bc116c96aeab47
BLAKE2b-256 checksum
How to use checksums
c06304e2fa46e9e7de36503e3f1e48313f6d7e2878a01f52ce5be5d95a769b8c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 2, 2026.

Transparency log

Security for mink-agent 0.6.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 3 files in this release have been uploaded with provenance metadata.

Select from 3 files

Attestation for mink_agent-0.6.6-py3-none-musllinux_1_2_x86_64.whl

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 2, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.6.6 This release

3 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page