efba9fab0a
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.
1.8 KiB
1.8 KiB
ctx.llm
LlmService — provided by @deepseek-ai/dsh-llm.
The abstract llm service: an adapter registry plus a streaming model-call surface, interceptable via the llm/stream waterfall.
ctx.llm.registerAdapter(models, adapter)
registerAdapter(models: string[], adapter: LlmAdapter): () => void
Register an adapter for the given model names. Throws LlmError with code DUPLICATE_ADAPTER if any model already has an adapter (all-or-nothing). Disposed with the fiber.
models— every model name this adapter should serve.adapter— the adapter that streams calls for those models.
Returns the disposer that unregisters all of them.
ctx.llm.models()
models(): string[]
Model names with a registered adapter.
Returns the registered names, in registration order.
ctx.llm.stream(options)
stream(options: GenerateOptions): AsyncIterable<StreamChunk>
Stream one model call as raw chunks (token-level deltas). Throws LlmError with code NO_ADAPTER if no adapter is registered for options.model. Dispatches through the llm/stream waterfall.
options— the full request;options.modelselects the adapter.
Returns the chunk stream, possibly wrapped by llm/stream listeners.