v2 SDK HTTP client factory. Like module:sdk/client but also threads an experimental workspace id alongside the project directory onto outgoing requests, and rejects responses that indicate an incompatible server version.
Methods
(static) createClosedcodeClient(configopt) → {OpencodeClient}
Create a typed v2 client for a running closedcode server.
| Name | Type | Attributes | Description | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
config | Object | <optional> | Client configuration. Properties
|
A configured client instance that rejects responses from incompatible server versions.
- Type:
- OpencodeClient
(inner) pick(value, fallback, encodeopt) → {string|undefined}
Return value unless it is merely an (optionally encoded) restatement of fallback, in which case the canonical fallback is preferred.
| Name | Type | Attributes | Description |
|---|---|---|---|
value | string | | Candidate value (e.g. from a header). | |
fallback | string | | Canonical value to compare against. | |
encode | function | <optional> | Optional encoder ( |
The resolved value, or undefined when none is set.
- Type:
- string |
undefined
(inner) rewrite(request, values) → {Request}
Move the x-closedcode-directory / x-closedcode-workspace hints onto the URL as directory / workspace query parameters for GET/HEAD requests, then strip the headers so they are not sent twice.
| Name | Type | Description |
|---|---|---|
request | Request | The outgoing fetch request. |
values | Object | Fallback directory and workspace (both optional) used when the corresponding header is absent. |
The original request, or a rewritten copy carrying the hints.
- Type:
- Request