website: generate the API reference from source (cordis + all 15 harness services)
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.
This commit is contained in:
74
website/zh-CN/api/harness/web.md
Normal file
74
website/zh-CN/api/harness/web.md
Normal file
@@ -0,0 +1,74 @@
|
||||
<!-- Generated by scripts/gen-website-api.ts — do not edit by hand. Run `pnpm run gen-website-api` to regenerate. -->
|
||||
|
||||
# ctx.web
|
||||
|
||||
`WebService` — provided by `@deepseek-ai/dsh-web`.
|
||||
|
||||
The web access service. Registered as `ctx.web` (one instance per context).
|
||||
Selection semantics (resolved at execution time, never order-dependent):
|
||||
- A configured id that is registered and `status().available` → that provider.
|
||||
- A configured id not registered → `WEB_PROVIDER_CONFIGURED_MISSING`.
|
||||
- A configured id registered but unavailable → `WEB_PROVIDER_CONFIGURED_UNAVAILABLE`.
|
||||
- No id configured, exactly one registered usable provider → that provider.
|
||||
- No id configured, multiple usable providers → `WEB_PROVIDER_AMBIGUOUS`.
|
||||
- No id configured, no usable provider → `WEB_PROVIDER_UNAVAILABLE`.
|
||||
|
||||
[Source](https://github.com/deepseek-harness/deepseek-harness/blob/master/packages/web/web/src/index.ts#L87)
|
||||
|
||||
### ctx.web.registerSearchProvider(provider)
|
||||
|
||||
```ts website-api
|
||||
registerSearchProvider(provider: WebSearchProvider): () => void
|
||||
```
|
||||
|
||||
Register a search provider. Throws WebError `WEB_DUPLICATE_PROVIDER` if its id is already registered for search. Returns a disposer; disposed with the calling fiber.
|
||||
|
||||
- `provider` — the provider; its `id` is the registry key.
|
||||
|
||||
**Returns** the disposer that unregisters the provider.
|
||||
|
||||
[Source](https://github.com/deepseek-harness/deepseek-harness/blob/master/packages/web/web/src/index.ts#L116)
|
||||
|
||||
### ctx.web.registerFetchProvider(provider)
|
||||
|
||||
```ts website-api
|
||||
registerFetchProvider(provider: WebFetchProvider): () => void
|
||||
```
|
||||
|
||||
Register a fetch provider. Throws WebError `WEB_DUPLICATE_PROVIDER` if its id is already registered for fetch. Returns a disposer; disposed with the calling fiber.
|
||||
|
||||
- `provider` — the provider; its `id` is the registry key.
|
||||
|
||||
**Returns** the disposer that unregisters the provider.
|
||||
|
||||
[Source](https://github.com/deepseek-harness/deepseek-harness/blob/master/packages/web/web/src/index.ts#L127)
|
||||
|
||||
### ctx.web.search(request, exec?)
|
||||
|
||||
```ts website-api
|
||||
async search(request: WebSearchRequest, exec?: WebExecContext): Promise<WebSearchResult>
|
||||
```
|
||||
|
||||
Run one search through the selected provider. Resolves the provider at call time with the selection rules above; throws WebError when the capability cannot run. The seam enforces `request.maxResults` on the result: if the provider over-returns, `sources[]` is truncated and `truncated` set.
|
||||
|
||||
- `request` — the query plus result-shaping options.
|
||||
- `exec` — the tool-execution context, forwarded to the provider.
|
||||
|
||||
**Returns** the provider's results, capped to `request.maxResults`.
|
||||
|
||||
[Source](https://github.com/deepseek-harness/deepseek-harness/blob/master/packages/web/web/src/index.ts#L153)
|
||||
|
||||
### ctx.web.fetch(request, exec?)
|
||||
|
||||
```ts website-api
|
||||
async fetch(request: WebFetchRequest, exec?: WebExecContext): Promise<WebFetchResult>
|
||||
```
|
||||
|
||||
Retrieve one URL through the selected provider. Resolves the provider at call time with the selection rules above; throws WebError when the capability cannot run. A non-2xx response is a result, not a throw.
|
||||
|
||||
- `request` — the URL plus retrieval options.
|
||||
- `exec` — the tool-execution context, forwarded to the provider.
|
||||
|
||||
**Returns** the retrieval outcome; non-2xx responses resolve descriptively.
|
||||
|
||||
[Source](https://github.com/deepseek-harness/deepseek-harness/blob/master/packages/web/web/src/index.ts#L170)
|
||||
Reference in New Issue
Block a user