SDK HTTP client factory. Builds an OpencodeClient that talks to a running closedcode server, injecting the active directory as a request header / query parameter so server-side resolution stays scoped to the caller's project.

Methods

(static) createClosedcodeClient(configopt) → {OpencodeClient}

Create a typed client for a running closedcode server.

Parameters:
NameTypeAttributesDescription
configObject<optional>

Client configuration.

Properties
NameTypeAttributesDescription
baseUrlstring<optional>

Base URL of the closedcode server.

fetchfunction<optional>

Custom fetch implementation; defaults to global fetch with timeouts disabled.

directorystring<optional>

Project directory to scope requests to; sent as the x-closedcode-directory header / directory query parameter.

headersObject<optional>

Additional headers to send with every request.

Returns:

A configured client instance.

Type: 
OpencodeClient

(inner) pick(value, fallback) → {string|undefined}

Return value unless it is just an (encoded) restatement of fallback, in which case the canonical fallback is preferred.

Parameters:
NameTypeDescription
valuestring | null | undefined

Candidate value (e.g. from a header).

fallbackstring | undefined

Canonical directory value to compare against.

Returns:

The resolved value, or undefined when none is set.

Type: 
string | undefined

(inner) rewrite(request, directory) → {Request}

Move the x-closedcode-directory hint onto the URL as a directory query parameter for GET/HEAD requests (which cannot carry a body), then strip the header so it is not sent twice.

Parameters:
NameTypeDescription
requestRequest

The outgoing fetch request.

directorystring | undefined

Fallback directory when the header is absent.

Returns:

The original request, or a rewritten copy carrying the directory.

Type: 
Request