English | 中文
When a capability is general enough to need replaceable implementations, such as Bash execution, Harness splits it into three packages: an interface, an implementation, and a consumer. Each layer can evolve or be replaced independently.
The Bash execution capability consists of:
dsh-bash) — defines Bash request and result shapesdsh-bash-local) — executes commands on the local machineConsumer (dsh-tool-bash) — exposes the capability as a model-callable tool
┌─────────────┐ ┌──────────────────┐ ┌──────────────┐
│ dsh-bash │────▶│ dsh-bash-local │ │ dsh-tool-bash│
│ (interface) │ │ (implementation) │ │(consumer/tool)│
└─────────────┘ └──────────────────┘ └──────────────┘
▲ │
└────────────────────────────────────────────┘
inject: ['bash']
One interface can have multiple implementations selected through cordis.yml:
# Local execution
- name: '@deepseek-ai/dsh-bash-local'
# Or a future remote sandbox implementation
# - name: '@deepseek-ai/dsh-bash-remote'
# config:
# endpoint: 'https://sandbox.example.com'
The interface and tool remain unchanged while the implementation changes.
| Capability | Interface | Implementation | Consumer |
|---|---|---|---|
| Bash | dsh-bash |
dsh-bash-local |
dsh-tool-bash |
| Filesystem | dsh-fs |
dsh-fs-local + dsh-fs-policy |
dsh-tool-fs |
| Web | dsh-web |
dsh-web-fetch-local / dsh-web-search-* |
dsh-tool-web |
| Subagent | dsh-subagent |
dsh-subagent-spawn / dsh-subagent-fork |
dsh-tool-subagent |
| Compaction | dsh-compact |
dsh-compact-basic |
The implementation consumes agent-loop extension events |
// packages/my-cap/my-cap/src/index.ts
import { Service, type Context } from 'cordis'
declare module 'cordis' {
interface Context {
myCap: MyCapService
}
}
export abstract class MyCapService extends Service {
constructor(ctx: Context) {
super(ctx, 'myCap')
}
/** Execute the capability. */
abstract execute(request: MyCapRequest): Promise<MyCapResult>
}
export interface MyCapRequest {
input: string
}
export interface MyCapResult {
output: string
}
// packages/my-cap/my-cap-local/src/index.ts
import type { Context } from 'cordis'
import { MyCapService, type MyCapRequest, type MyCapResult } from '@deepseek-ai/dsh-my-cap'
class MyCapLocal extends MyCapService {
async execute(request: MyCapRequest): Promise<MyCapResult> {
// Concrete implementation.
return { output: request.input.toUpperCase() }
}
}
export const name = 'my-cap-local'
export function apply(ctx: Context) {
ctx.plugin(MyCapLocal)
}
// packages/my-cap/tool-my-cap/src/index.ts
import type { Context } from 'cordis'
import { defineTool } from '@deepseek-ai/dsh-tools'
export const name = 'tool-my-cap'
export const inject = ['tools', 'myCap']
export function apply(ctx: Context) {
ctx.tools.register(defineTool({
name: 'my_cap',
description: 'Execute my capability.',
parameters: {
input: { type: 'string', required: true },
},
async execute(args) {
const result = await ctx.myCap.execute({ input: args.input })
return [{ type: 'text', text: result.output }]
},
}))
}
- name: '@deepseek-ai/dsh-my-cap-local'
- name: '@deepseek-ai/dsh-tool-my-cap'
resolve(request): Spec step rather than hiding ?? default expressions inside run().