一、项目概览
| 指标 | 数据 |
|------|------|
| GitHub Stars | 26.4k |
| Forks | 1.9k |
| License | MIT |
| 主语言 | TypeScript |
| 当前状态 | Developer Preview (v0.1) |
| 仓库地址 | github.com/deepseek-ai/harness |
DeepSeek Harness是DeepSeek团队开源的一款AI Agent框架,目前处于开发者预览阶段。它基于Cordis插件系统构建,将模型、工具、技能、会话、沙箱、存储、循环、调度等所有运行时组件抽象为可插拔的插件。
一个值得注意的细节是:DeepSeek为Harness创建了一个带有黑色鲸鱼标志的独立微信账号,与DeepSeek主品牌的蓝色鲸鱼形成刻意的品牌分离。开源运行时,拥有品牌,让社区构建插件——这是一个清晰的生态战略信号。
二、Cordis插件系统:设计哲学
"一切皆插件"的含义
传统AI Agent框架通常将核心功能(模型调用、工具管理、上下文处理等)硬编码在框架内部,而将可扩展部分留给插件。Cordis反转了这一设计:运行时中没有任何硬编码功能,所有功能——包括模型调用本身——都是插件。
// Cordis核心接口定义
interface Plugin<T = any> {
// 插件唯一标识
id: string;
// 插件名称
name: string;
// 插件版本
version: string;
// 依赖的其他插件
dependencies?: string[];
// 插件能力声明
capabilities: PluginCapability[];
// 初始化函数
activate(context: PluginContext): Promise<T>;
// 清理函数
deactivate?(): Promise<void>;
}
interface PluginContext {
// 插件间通信总线
bus: EventBus;
// 依赖注入容器
container: DIContainer;
// 配置管理器
config: ConfigManager;
// 日志系统
logger: Logger;
// 生命周期管理
lifecycle: LifecycleManager;
}
interface PluginCapability {
type: 'model' | 'tool' | 'skill' | 'sandbox' | 'storage' | 'loop' | 'scheduler';
name: string;
handler: (...args: any[]) => Promise<any>;
schema?: object; // JSON Schema描述参数
}微内核架构
Cordis采用微内核架构,运行时组件作为隔离的、可互换的插件运行,而非单体系统模块。这意味着:
// 微内核核心:仅负责插件加载和生命周期管理
export class CordisKernel {
private plugins: Map<string, PluginInstance> = new Map();
private bus: EventBus;
async bootstrap() {
// 1. 加载核心插件(本身也是插件)
await this.loadPlugin(coreLifecyclePlugin);
await this.loadPlugin(coreEventBusPlugin);
await this.loadPlugin(coreDIContainerPlugin);
// 2. 从配置加载用户插件
const config = await this.loadConfig();
for (const pluginConfig of config.plugins) {
await this.loadPlugin(pluginConfig);
}
// 3. 激活所有插件
for (const [id, instance] of this.plugins) {
await this.activatePlugin(id);
}
}
async loadPlugin(config: PluginConfig): Promise<void> {
const plugin = await this.resolvePlugin(config);
const context = this.createContext(plugin);
const instance = await plugin.activate(context);
this.plugins.set(plugin.id, { plugin, instance, context });
}
async activatePlugin(id: string): Promise<void> {
const entry = this.plugins.get(id);
if (!entry) throw new Error(`Plugin not found: ${id}`);
// 检查依赖
for (const dep of entry.plugin.dependencies || []) {
if (!this.plugins.has(dep)) {
throw new Error(`Missing dependency: ${dep} for plugin ${id}`);
}
}
// 注册能力
for (const cap of entry.plugin.capabilities) {
this.bus.emit(`capability:register`, { pluginId: id, ...cap });
}
}
}三、创建自定义插件
模型插件示例
// 自定义模型插件:支持DeepSeek V4 Pro
import { Plugin, PluginContext, PluginCapability } from '@deepseek/harness';
export class DeepSeekModelPlugin implements Plugin {
id = 'model:deepseek-v4-pro';
name = 'DeepSeek V4 Pro';
version = '1.0.0';
dependencies = ['storage:conversation', 'config:api-keys'];
private client: APIClient;
capabilities: PluginCapability[] = [
{
type: 'model',
name: 'deepseek-v4-pro',
handler: this.chat.bind(this),
schema: {
type: 'object',
properties: {
messages: { type: 'array' },
thinking: { type: 'object' },
max_tokens: { type: 'number' },
tools: { type: 'array' }
}
}
}
];
async activate(ctx: PluginContext) {
const apiKey = await ctx.config.get('deepseek.api_key');
this.client = new APIClient({
baseURL: 'https://api.deepseek.com',
apiKey,
timeout: 120000
});
// 监听配置变更
ctx.bus.on('config:changed', (event) => {
if (event.key === 'deepseek.api_key') {
this.client.updateApiKey(event.value);
}
});
ctx.logger.info('DeepSeek V4 Pro model plugin activated');
return this;
}
async chat(params: ChatParams): Promise<ChatResponse> {
const response = await this.client.post('/chat/completions', {
model: 'deepseek-v4-pro',
...params,
thinking: params.thinking || { type: 'enabled', level: 'high' }
});
return {
content: response.choices[0].message.content,
usage: response.usage,
thinking: response.thinking
};
}
async deactivate() {
await this.client.close();
}
}工具插件示例
// 代码执行工具插件
export class CodeExecutorPlugin implements Plugin {
id = 'tool:code-executor';
name = 'Code Executor';
version = '1.0.0';
dependencies = ['sandbox:docker'];
capabilities: PluginCapability[] = [
{
type: 'tool',
name: 'execute_code',
handler: this.execute.bind(this),
schema: {
type: 'object',
properties: {
language: { type: 'string', enum: ['python', 'javascript', 'rust'] },
code: { type: 'string' },
input: { type: 'string' }
},
required: ['language', 'code']
}
}
];
async activate(ctx: PluginContext) {
this.sandbox = await ctx.container.resolve('sandbox:docker');
this.logger = ctx.logger;
return this;
}
async execute(params: { language: string; code: string; input?: string }) {
this.logger.info(`Executing ${params.language} code`, {
codeLength: params.code.length
});
const result = await this.sandbox.run({
language: params.language,
code: params.code,
input: params.input,
timeout: 30000,
memoryLimit: 256
});
return {
stdout: result.stdout,
stderr: result.stderr,
exitCode: result.exitCode,
duration: result.duration
};
}
}技能插件示例
// 技能插件:定义Agent可以执行的复合任务
export class CodeReviewSkillPlugin implements Plugin {
id = 'skill:code-review';
name = 'Code Review Skill';
version = '1.0.0';
dependencies = ['model:deepseek-v4-pro', 'tool:code-executor'];
capabilities: PluginCapability[] = [
{
type: 'skill',
name: 'review_code',
handler: this.review.bind(this),
schema: {
type: 'object',
properties: {
repository: { type: 'string' },
pullRequest: { type: 'string' },
focus: { type: 'array', items: { type: 'string' } }
},
required: ['repository']
}
}
];
async activate(ctx: PluginContext) {
this.model = await ctx.container.resolve('model:deepseek-v4-pro');
this.executor = await ctx.container.resolve('tool:code-executor');
this.bus = ctx.bus;
return this;
}
async review(params: ReviewParams) {
// 步骤1:获取代码变更
const diff = await this.getDiff(params.repository, params.pullRequest);
// 步骤2:分析代码质量
const analysis = await this.model.chat({
messages: [
{ role: 'system', content: '你是资深代码审查专家。分析以下代码变更,识别问题并给出建议。' },
{ role: 'user', content: `代码变更:
${diff}
重点关注: ${params.focus.join(', ')}` }
],
thinking: { type: 'enabled', level: 'max' }
});
// 步骤3:验证建议(运行测试代码)
const testResult = await this.executor.execute({
language: 'python',
code: this.extractTestCode(analysis.content)
});
// 步骤4:生成审查报告
return {
summary: this.extractSummary(analysis.content),
issues: this.extractIssues(analysis),
testResult,
recommendations: this.extractRecommendations(analysis.content)
};
}
}四、与其他Agent框架对比
| 特性 | DeepSeek Harness | LangChain | AutoGen | CrewAI |
|------|-----------------|-----------|---------|--------|
| 核心架构 | 微内核+插件 | 链式组合 | 多Agent对话 | 角色协作 |
| 插件系统 | 一切皆插件 | 集成式 | 模块化 | 任务驱动 |
| 语言 | TypeScript | Python | Python | Python |
| 模型支持 | 可插拔 | 内置多种 | 内置多种 | 有限 |
| 沙箱隔离 | 原生支持 | 需外部 | 需外部 | 无 |
| 子Agent模式 | 支持 | 有限 | 核心特性 | 支持 |
| 开源协议 | MIT | MIT | MIT | MIT |
| 生产就绪 | Developer Preview | 成熟 | 成熟 | 较新 |
Harness的独特优势
五、配置与启动
# harness.config.yml - Harness配置文件
kernel:
version: "0.1"
logLevel: info
plugins:
# 核心插件
- id: core:lifecycle
path: @deepseek/harness/plugins/core-lifecycle
- id: core:event-bus
path: @deepseek/harness/plugins/core-event-bus
- id: core:di-container
path: @deepseek/harness/plugins/core-di
# 模型插件
- id: model:deepseek-v4-pro
path: @deepseek/harness/plugins/model-deepseek
config:
apiKey: ${DEEPSEEK_API_KEY}
thinking:
type: enabled
level: high
- id: model:deepseek-v4-flash
path: @deepseek/harness/plugins/model-deepseek
config:
apiKey: ${DEEPSEEK_API_KEY}
model: deepseek-v4-flash
# 工具插件
- id: tool:code-executor
path: @deepseek/harness/plugins/tool-code-executor
config:
sandbox:
type: docker
image: node:20-slim
memory: 256MB
timeout: 30000
- id: tool:web-search
path: @deepseek/harness/plugins/tool-web-search
config:
engine: brave
apiKey: ${BRAVE_API_KEY}
# 技能插件
- id: skill:code-review
path: ./plugins/skill-code-review
dependencies:
- model:deepseek-v4-pro
- tool:code-executor
- id: skill:data-analysis
path: ./plugins/skill-data-analysis
dependencies:
- model:deepseek-v4-flash
- tool:code-executor
# Agent配置
agents:
- name: code-reviewer
model: model:deepseek-v4-pro
skills:
- skill:code-review
systemPrompt: |
你是一个专业的代码审查助手。
请仔细分析代码变更,识别安全漏洞、性能问题和最佳实践偏离。// 启动Harness Agent
import { Harness } from '@deepseek/harness';
async function main() {
// 创建Harness实例
const harness = new Harness({
configPath: './harness.config.yml'
});
// 启动内核(加载所有插件)
await harness.start();
// 获取Agent实例
const reviewer = harness.getAgent('code-reviewer');
// 执行代码审查
const result = await reviewer.execute('review_code', {
repository: 'https://github.com/my-org/my-repo',
pullRequest: '#123',
focus: ['security', 'performance', 'best-practices']
});
console.log('审查摘要:', result.summary);
console.log('发现问题:', result.issues);
console.log('测试结果:', result.testResult);
console.log('改进建议:', result.recommendations);
// 优雅关闭
await harness.stop();
}
main().catch(console.error);六、社区生态与路线图
当前状态
Harness目前处于Developer Preview阶段(v0.1),但已经展现出强大的社区吸引力。26.4k的Star数在短时间内达成,表明开发者社区对"一切皆插件"的Agent工程范式有强烈需求。
子Agent集成
DeepSeek已经将Harness的子Agent模式扩展到更多Agent框架。当前支持将以下工具作为子Agent集成:
// 子Agent集成示例:将Claude Code作为子Agent
export class ClaudeCodeSubAgentPlugin implements Plugin {
id = 'subagent:claude-code';
name = 'Claude Code Sub-Agent';
version = '1.0.0';
capabilities: PluginCapability[] = [
{
type: 'skill',
name: 'delegate_to_claude',
handler: this.delegate.bind(this),
schema: {
type: 'object',
properties: {
task: { type: 'string' },
context: { type: 'string' },
files: { type: 'array', items: { type: 'string' } }
},
required: ['task']
}
}
];
async delegate(params: { task: string; context?: string; files?: string[] }) {
// 启动Claude Code作为子进程
const result = await this.runClaudeCode({
prompt: params.task,
context: params.context,
files: params.files,
model: 'claude-fable-5', // 使用Fable 5作为后端
maxTurns: 10
});
return {
output: result.stdout,
filesModified: result.filesChanged,
summary: result.summary
};
}
}未来路线图
根据DeepSeek发布的信息和社区讨论,Harness的未来方向包括:
七、总结:Agent工程的范式转变
DeepSeek Harness的开源标志着AI Agent工程从"框架即应用"向"框架即运行时"的范式转变。Cordis插件系统证明,当运行时中的每一个组件——从模型调用到存储后端——都是可插拔的插件时,开发者获得了前所未有的灵活性和控制力。
"一切皆插件"不是一句口号,而是一种工程哲学:它意味着你可以用DeepSeek V4 Pro替换GPT-5.6而无需修改任何业务代码;意味着你可以用WASM沙箱替换Docker沙箱而无需重新配置Agent;意味着你可以添加新的技能而无需触碰框架核心。
对于开发者来说,Harness提供了一个干净的起点:不需要从零构建Agent基础设施,也不需要被框架的预设架构所束缚。MIT协议确保了最大的自由度,而TypeScript的运用则保证了类型安全和开发体验。
AI Agent的竞争正在从"谁的模型更强"转向"谁的工程基础设施更灵活"。DeepSeek Harness以Cordis插件架构给出了自己的答案——而26.4k的Star数表明,这个答案正在被越来越多的开发者所认可。
💬 评论区 (0)
暂无评论,快来抢沙发吧!