scripts/gen-website-api.ts renders website/zh-CN/api/{cordis,harness}/* and the
api-sidebar.json fragment the VitePress config imports, so pages and navigation
can never drift from the code: signatures, @param/@returns prose, dispatch
modes, and GitHub source links are extracted, never transcribed, and the
generator hard-errors on any rendered member missing docs. verify-website-api
(doc-sync + run-gates) is the freshness gate.
Replaces the hand-written zh api pages (7 pages covering 7 of 15 services,
with phantom APIs: Context.current/Context.events, agent/post-step, tool/call,
compact/*, llm/pre-request none of which exist) with generated English
references: 5 cordis pages, 15 per-service pages, and a 35-event catalog
grouped by scope. The hand-written hub api/index.md stays and now indexes the
full surface; zh for these pages arrives with the unified translation flow.
2.1 KiB
2.1 KiB
API 参考
本节是 DeepSeek Harness 的 API 参考。除本页外,cordis/ 与 harness/ 下的所有页面由脚本从源码生成(pnpm run gen-website-api,CI 校验新鲜度),签名与说明永远与代码一致;生成页目前为英文,中文版将随统一翻译流程提供。
框架 API
Cordis 微内核提供的基础能力,所有插件开发都建立在这些 API 之上:
- Context — 上下文对象,所有服务和方法的入口
- Events — 事件系统 API(on / emit / bail / serial / waterfall)
- Fiber — 插件生命周期(状态机、effect、dispose)
- Registry — 插件注册(plugin / inject)
- Service — 服务基类
Harness API
每个 ctx.* 服务一页,按服务名索引:
- ctx.agentLoop — ReAct 循环的创建与恢复
- ctx.agents — Agent 注册表与工厂
- ctx.bash — Bash 执行接口(抽象缝)
- ctx.codeRuntime — 代码执行接口(抽象缝)
- ctx.compact — 上下文压缩接口(抽象缝)
- ctx.fs — 文件系统接口(抽象缝)
- ctx.llm — LLM 服务与适配器注册
- ctx.sessionPersistence — 会话持久化接口(抽象缝)
- ctx.sessions — 会话存储
- ctx.subagents — 子代理委派
- ctx.systemPrompt — 系统提示词组装
- ctx.tools — Tool 注册表
- ctx.userInteraction — 用户交互接口
- ctx.web — Web 搜索与抓取
- ctx.workflows — 动态工作流引擎(抽象缝)
事件总表:Harness events — 全部事件按作用域分组,含触发模式与载荷签名。
想学"怎么写一个 tool / 插件"?教程在开发指南;本节只做精确的接口参考。