迪斯特里
  
Distri是一个用Rust构建的开源AI代理框架。在markdown中定义代理,将产品功能连接为工具,并从CLI、API服务器或嵌入React UI中运行它们。
______________________________________________________________________
为什么分心
- 代理作为降价 --在单一界面中定义行为、工具和模型设置
.md使用TOML frontmatter文件 - 内置工具系统 --内置(搜索、shell、浏览器)、动态HTTP工具、外部客户端工具和MCP支持
- 技能 --按需知识文档代理在运行时通过以下方式加载
load_skill,在上下文压缩后自动重新注入 - 分代理 --代理将任务委托给具有独立上下文和令牌预算的专门子代理
- 远程执行 --在沙盒容器中运行代理,以隔离不受信任的代码或资源
- React SDK --进来吧 `` 具有流媒体、工具渲染器、语音和开发人员模式的组件
- A2A兼容 --实施 A2A协议 用于代理发现和调用
- 自托管 --使用SQLite在您自己的基础设施上运行。不需要外部依赖。
______________________________________________________________________
安装
# Install script (macOS / Linux)
curl -fsSL https://distri.dev/install.sh | sh
# Homebrew
brew tap distrihub/distri && brew install distri
# Verify
distri --versionOther platforms
直接下载:
# darwin-arm64 | darwin-x86_64 | linux-arm64 | linux-x86_64
TARGET=darwin-arm64
curl -L "https://github.com/distrihub/distri/releases/latest/download/distri-${TARGET}.tar.gz" -o distri.tar.gz
sudo tar -xzf distri.tar.gz -C /usr/local/bin distriWindows(PowerShell):
Invoke-WebRequest https://github.com/distrihub/distri/releases/latest/download/distri-windows-x86_64.zip -OutFile distri.zip
Expand-Archive distri.zip -DestinationPath $Env:LOCALAPPDATA\distri -Force
$Env:Path += ";$Env:LOCALAPPDATA\distri"______________________________________________________________________
跑
安装后,启动服务器和web UI:
distri serve第一次运行会下载匹配的 distri-server 二进制和UI捆绑包来自
进入 ~/.distri/。自动打开浏览器 http://localhost:7777.
服务选项
| 标志 | 行为 |
|---|---|
distri serve | 默认:解析+生成分布式服务器,提供用户界面,打开浏览器 |
--port 8080 | 覆盖端口(默认7777) |
--no-ui | API开启模式(无web界面) |
--no-browser | 不要自动打开浏览器 |
--server-version 0.5.3 | 固定特定服务器版本 |
--ui-version 0.5.7 | 固定特定UI版本 |
生命周期命令
| 命令 | 行为 |
|---|---|
distri serve | 解析+生成分发服务器,提供用户界面 |
distri update | 在兼容范围内拉取最新的服务器+UI |
distri update --pre | 允许预发布版本 |
distri version | 打印已安装的CLI/服务器/UI版本 |
distri uninstall | 擦拭 ~/.distri/{bin, ui, cache} |
______________________________________________________________________
快速开始
运行内置代理
distri run search --task "What are the top programming languages in 2026?"定义自己的代理
创建 agents/my_agent.md:
---
name = "my_agent"
description = "A helpful assistant with web search"
max_iterations = 15
[tools]
builtin = ["final", "search"]
---
# My Agent
You are a helpful assistant. Use the search tool to find current information.
{{task}}运行它
# Interactive chat
distri tui my_agent
# Single task
distri run --agent my_agent --task "Find the latest SpaceX launch date"
# Start as API server
distri serve --port 8080推送到Distri Cloud
distri login
distri agents push agents/my_agent.md______________________________________________________________________
内置代理
| 代理 | 目的 | 示例 |
|---|---|---|
| 搜索 | 网络搜索+抓取 | distri run search --task "latest AI news" |
| 快速搜索 | 快速单查询查找 | distri run fast_search --task "population of Tokyo" |
| 网络 | 浏览器自动化+抓取 | distri run web --task "scrape HN top 5 stories" |
| 代码 | 沙盒代码执行 | distri run code --task "sum of primes below 1000" |
| 深度研究 | 分代理委托的多阶段研究 | distri run deepresearch --task "state of quantum computing" |
| 分布 | 指挥大师 | distri run distri --task "find and calculate..." |
| 编码员 | 全编码代理(shell+web+文件) | distri run coder --task "build a REST API" |
| 代理设计者 | 设计新的代理定义 | distri run agent_designer --task "design a stock alert agent" |
需要BROWSR_BASE_URL和BROWSR_API_KEY用于搜索、浏览器和shell工具。在Distri Cloud上自动配置。
______________________________________________________________________
代理定义格式
代理是TOML frontmatter的markdown文件:
---
name = "my_agent"
description = "What this agent does"
max_iterations = 25
context_size = 80000
sub_agents = ["search", "code"] # delegate to other agents
[tools]
builtin = ["final", "search", "load_skill"]
external = ["Read", "Write", "Edit"] # client-side tools
[[tools.dynamic]]
name = "my_api"
type = "http"
description = "Call my API"
config = { base_url = "$API_URL", headers = { "Authorization" = "Bearer $TOKEN" } }
[[available_skills]]
id = "*"
name = "*"
---
# System Prompt
Your instructions here. Supports Handlebars templates:
- {{task}} — the user's message
- {{> skills}} — available skills listing
- {{> connections}} — available connections看 代理定义文档 对于完整的模式。
______________________________________________________________________
技能
技能是代理按需加载的可重用指令文档:
---
name = "data_pipeline"
description = "How to run the data transformation pipeline"
tags = ["data", "etl"]
context = "inline"
---
# Data Pipeline
## Steps
1. Fetch data with `my_api` tool...
2. Transform using Python...# Push skills
distri skills push skills/data_pipeline.md
distri skills list客服电话 load_skill("data_pipeline") 在运行时。两种模式:
- 内联 (默认)--注入对话的内容在上下文压缩后仍然有效
- 叉子 --以技巧为指导培养孤立的儿童代理
______________________________________________________________________
React SDK(DistriJS)
在React应用程序中嵌入代理:
npm install @distri/reactimport { useAgent, Chat } from '@distri/react';
function App() {
const { agent } = useAgent({ agentIdOrDef: 'my_agent' });
return ;
}功能:SSE流媒体、使用自定义渲染器执行工具、语音I/O、开发人员模式、浏览器端文件工具(IndexedDB支持的读/写/编辑/Glob/Grep)。
看 DistriJS文档 完整的集成指南。
______________________________________________________________________
CLI参考
服务器和UI
distri serve # Start server + UI on port 7777
distri serve --port 8080 # Custom port
distri serve --no-ui # API-only
distri update # Pull latest server + UI
distri version # Show versions
distri uninstall # Clean ~/.distri/代理与技能管理
distri # Interactive TUI
distri run --task "..." [--agent A] # Run a task
distri run --task "..." --remote # Run in sandboxed container
distri agents list / push / delete # Manage agents
distri skills list [-a] / push # Manage skills调试和工具
distri traces list / show ID [-v] # Debug with trace viewer
distri tools list / invoke # Inspect and test tools连接和配置
distri connections list / token # OAuth connections
distri secrets list / set / delete # Manage secrets
distri workflows run / push # DAG workflows
distri login # Auth with Distri Cloud
distri profile list / use / config # Multi-profile management______________________________________________________________________
建筑
distri/
├── distri-types/ # Shared type definitions
├── distri-cli/ # CLI binary
├── distri/ # Client library
├── distri-formatter/ # Output formatting
│
├── server/
│ ├── distri-core/ # Agent engine (orchestrator, loop, tools, LLM)
│ ├── distri-server/ # HTTP server (actix-web, A2A endpoints)
│ ├── distri-stores/ # Storage backends (SQLite, Postgres)
│ ├── distri-auth/ # Auth providers
│ ├── distri-parsers/ # Parsing utilities
│ └── agents/ # Built-in agent definitions (.md)
│
├── distrijs/ # TypeScript SDK
│ ├── @distri/core # Agent client, A2A streaming
│ ├── @distri/react # React hooks, Chat component, browser tools
│ └── @distri/components # Shared UI (shadcn/ui)
│
└── samples/ # Example applications
├── maps-demo/ # Google Maps + AI chat
└── scraper/ # Web scraping agent执行流程
User message → AgentOrchestrator
→ Load agent definition
→ Create ExecutorContext (thread, task, run)
→ AgentLoop
→ PlanningStrategy.plan() → LLM produces plan
→ ExecutionStrategy.execute_step() per step
→ Tool calls (builtin, dynamic, external, MCP)
→ Event streaming (SSE)
→ Loop until final tool or max iterations
→ Return result______________________________________________________________________
发展
# Build
cargo build
# Run tests
cargo test
# Test a specific crate
cargo test -p distri-core
# DistriJS development
cd distrijs && pnpm install && pnpm dev______________________________________________________________________
样品
______________________________________________________________________
许可
______________________________________________________________________

