Conflict resolution notes: - package.json/run-gates: both sides' new doc-sync gates kept (master's scoped-events/readme gates + this branch's website-api/website-yaml); js-yaml devDeps deduped (master added them independently). - pnpm-workspace/knip: website AND python/sdk-runtime entries kept. - doc-typecheck/verify-type-equiv: master's condensed headers kept, website glob retained in both scan scopes. - vendor/cordis/src/fiber.ts: master's lifecycle-hardening code taken; this branch's richer FiberState JSDoc reapplied on top. vendor/README.md logs both local modifications (hardening = 6, JSDoc enrichment = 7). - pnpm-lock: regenerated from master's side (pnpm install). Post-merge sync the gates forced (the system working as designed): - verify-website-yaml caught 4 stale plugin names from master's package reorg (dsh-stdio-agent -> dsh-stdio-demo, dsh-acp-agent -> dsh-acp-demo); 8 references fixed across guide/ and develop/. - gen-website-api picked up master's 6 new services automatically (ctx.approval/permission/sandbox/sessionQuery/skills/tasks -> 6 new pages + sidebar); api/index.md hub updated to list them. - AGENTS.md budget ceiling 1370 -> 1400: the website rows (layout line + two command lines) and master's own growth collided with the old ceiling; all three website rows are load-bearing (new top-level dir, new CI command).
2.4 KiB
2.4 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.approval — 用户审批
- ctx.bash — Bash 执行接口(抽象缝)
- ctx.codeRuntime — 代码执行接口(抽象缝)
- ctx.compact — 上下文压缩接口(抽象缝)
- ctx.fs — 文件系统接口(抽象缝)
- ctx.llm — LLM 服务与适配器注册
- ctx.permission — 权限策略
- ctx.sandbox — 沙箱执行接口(抽象缝)
- ctx.sessionPersistence — 会话持久化接口(抽象缝)
- ctx.sessionQuery — 会话检索
- ctx.sessions — 会话存储
- ctx.skills — 技能加载
- ctx.subagents — 子代理委派
- ctx.systemPrompt — 系统提示词组装
- ctx.tasks — 后台任务
- ctx.tools — Tool 注册表
- ctx.userInteraction — 用户交互接口
- ctx.web — Web 搜索与抓取
- ctx.workflows — 动态工作流引擎(抽象缝)
事件总表:Harness events — 全部事件按作用域分组,含触发模式与载荷签名。
想学"怎么写一个 tool / 插件"?教程在开发指南;本节只做精确的接口参考。