host-api/node
host-api/node
此内容目前仅提供英文版。
导入自 @norbital-ai/host-api/node
@norbital-ai/host-api/node: the Node-only parts of the contract — signed host operations — and the one Node implementation of the ports every host (Colony, bolt-server, bolt-cli) supplies. Nothing here enters the cell bundle.
node
Address type
type Address = {
address: string;
family: number;
}; A resolved IP address and its family (4 or 6).
成员
| 名称 | 类型 | 说明 |
|---|---|---|
address | string | |
family | number |
源码: packages/host-api/src/node/net.ts:71
DownloadOptions type
type DownloadOptions = {
/** A development host's own loopback origin (`localhost`, `127.0.0.1`) is reachable; nothing else private, ever. */
allow_loopback?: boolean;
max_bytes?: number;
idle_ms?: number;
/** The `cookie` header a request to this URL carries: asked per redirect hop, so each host gets only its own. */
cookie?: (url: URL) => string;
}; How download fetches: loopback reach, its byte and idle bounds, and the cookie each redirect hop carries.
成员
| 名称 | 类型 | 说明 |
|---|---|---|
allow_loopback? | boolean | A development host's own loopback origin ( |
max_bytes? | number | |
idle_ms? | number | |
cookie? | (url: URL) => string | The |
源码: packages/host-api/src/node/download.ts:22
DownloadSink type
type DownloadSink<U> = {
begin(mime: string): Effect.Effect<U, PortFailure>;
part(upload: U, bytes: Uint8Array): Effect.Effect<void, PortFailure>;
/** Answers the stored file's key. */
complete(upload: U, sha256: string): Effect.Effect<string, PortFailure>;
abort(upload: U): Effect.Effect<void>;
}; Where a download streams: an upload begun once the body is media, its parts in order, then completed or aborted.
成员
| 名称 | 类型 | 说明 |
|---|---|---|
begin | (mime: string) => Effect.Effect<U, PortFailure> | |
part | (upload: U, bytes: Uint8Array) => Effect.Effect<void, PortFailure> | |
complete | (upload: U, sha256: string) => Effect.Effect<string, PortFailure> | Answers the stored file's key. |
abort | (upload: U) => Effect.Effect<void> |
源码: packages/host-api/src/node/download.ts:14
GUEST_CONSOLE const
const GUEST_CONSOLE: { readonly lines: 200; readonly lineChars: 8000; readonly chars: number; } What one guest turn keeps of its console: lines, characters per line and in all; past them, lines are counted.
成员
| 名称 | 类型 | 说明 |
|---|---|---|
lines | 200 | |
lineChars | 8000 | |
chars | number |
源码: packages/host-api/src/node/guest-hooks.ts:19
GUEST_CRYPTO const
const GUEST_CRYPTO: { readonly maxDigestBytes: number; readonly maxSessionDigestBytes: number; readonly maxSessionRandomBytes: number; } Host-side caps on synchronous guest crypto hooks so an isolate cannot stall the host event loop.
成员
| 名称 | 类型 | 说明 |
|---|---|---|
maxDigestBytes | number | |
maxSessionDigestBytes | number | |
maxSessionRandomBytes | number |
源码: packages/host-api/src/node/guest-hooks.ts:44
GuestHooks type
type GuestHooks = readonly [
say: (level: unknown, line: unknown) => void,
random: (n: unknown) => Uint8Array,
digest: (name: unknown, bytes: unknown) => Uint8Array,
asset: (sha: unknown) => Uint8Array | undefined
]; The prelude's hooks as the host serves them (GuestSessionOptions.prelude).
源码: packages/host-api/src/node/guest-hooks.ts:175
GuestSaid type
type GuestSaid = {
readonly lines: [level: string, line: string][];
chars: number;
dropped: number;
}; A session's console lines since its last turn; the runner resets chars and dropped with each turn it reads.
成员
| 名称 | 类型 | 说明 |
|---|---|---|
lines | [level: string, line: string][] | |
chars | number | |
dropped | number |
源码: packages/host-api/src/node/guest-hooks.ts:21
HOST_FILE const
const HOST_FILE: "norbital.host.ts" The host file a workspace serves untethered with; never part of its source.
源码: packages/host-api/src/node/host-file.ts:259
ImportDeclaration type
type ImportDeclaration = Extract<Statement, {
type: 'ImportDeclaration';
}>; An import statement of the parsed guest module, as module_script hands it to its imports rewriter.
源码: packages/host-api/src/node/guest-hooks.ts:104
NodeGuestsOptions type
type NodeGuestsOptions = {
/** Each session's CPU budget, its module evaluation included (default `HOST_LIMITS.guestCpuMs`); past it, `cpu_budget`. */
readonly cpu_ms?: number | undefined;
/** Every run's CPU, by session. */
readonly meter?: ((session: string, nanos: bigint) => void) | undefined;
/** Every wave of `ctx` calls a session sends the host (one round trip), by session: how many calls it carries. */
readonly crossed?: ((session: string, calls: number) => void) | undefined;
}; node_guests's options: each session's CPU budget, a CPU meter and a crossing meter.
成员
| 名称 | 类型 | 说明 |
|---|---|---|
cpu_ms? | number | undefined | Each session's CPU budget, its module evaluation included (default |
meter? | ((session: string, nanos: bigint) => void) | undefined | Every run's CPU, by session. |
crossed? | ((session: string, calls: number) => void) | undefined | Every wave of |
源码: packages/host-api/src/node/guests.ts:291
op
NonceStore interface
interface NonceStore<E = never> {
claim(nonce: string, at: number): Effect.Effect<boolean, E>;
} Where a host keeps the nonces it has accepted. claim succeeds with true the first time a nonce is offered and false after, across restarts; at (epoch ms) lets the store prune nonces older than OP_WINDOW_MS.
成员
| 名称 | 类型 | 说明 |
|---|---|---|
claim | (nonce: string, at: number) => Effect.Effect<boolean, E> |
源码: packages/host-api/src/op.ts:23
OP_HEADERS const
const OP_HEADERS: { readonly op: "bolt-op-name"; readonly ts: "bolt-op-ts"; readonly nonce: "bolt-op-nonce"; readonly mac: "bolt-op-mac"; } The request headers a signed operation travels in: its name, timestamp (epoch ms), nonce and MAC.
成员
| 名称 | 类型 | 说明 |
|---|---|---|
op | 'bolt-op-name' | |
ts | 'bolt-op-ts' | |
nonce | 'bolt-op-nonce' | |
mac | 'bolt-op-mac' |
源码: packages/host-api/src/op.ts:9
OP_WINDOW_MS const
const OP_WINDOW_MS: number How far a signature's timestamp may be from the verifier's clock, either way.
源码: packages/host-api/src/op.ts:16
OpKey type
type OpKey = {
readonly secret: string | Uint8Array;
readonly scope: string;
}; The secret and the scope it signs for: a workspace handle (bolt-server) or a platform deployment environment.
成员
| 名称 | 类型 | 说明 |
|---|---|---|
secret | string | Uint8Array | |
scope | string |
源码: packages/host-api/src/op.ts:18
OpRefused class
class OpRefused extends OpRefused_base {
} Why a signed operation was refused: no or malformed signature, outside the window, a bad MAC, or a replayed nonce.
成员
| 名称 | 类型 | 说明 |
|---|---|---|
reason | Schema.Literals<readonly ["unsigned", "stale", "bad_signature", "replayed"]> |
源码: packages/host-api/src/op.ts:28
node
PageWrite type
type PageWrite = Readonly<{
method: string;
body?: string | Uint8Array;
}>; A request that writes to a page: its method and body.
成员
| 名称 | 类型 | 说明 |
|---|---|---|
method | string | |
body? | string | Uint8Array |
源码: packages/host-api/src/node/net.ts:243
PgClient type
type PgClient = {
query(q: PgQuery): Promise<PgResult | PgResult[]>;
release(destroy?: boolean): void;
end?(): Promise<void>;
connection?: {
readonly stream: {
destroy(): void;
};
};
on?(event: 'error' | 'end', listener: (error?: unknown) => void): unknown;
removeListener?(event: 'error' | 'end', listener: (error?: unknown) => void): unknown;
}; The part of a pg pool client the native database uses.
成员
| 名称 | 类型 | 说明 |
|---|---|---|
query | (q: PgQuery) => Promise<PgResult | PgResult[]> | |
release | (destroy?: boolean) => void | |
end? | (() => Promise<void>) | undefined | |
connection? | { readonly stream: { destroy(): void; }; } | |
on? | ((event: "error" | "end", listener: (error?: unknown) => void) => unknown) | undefined | |
removeListener? | ((event: "error" | "end", listener: (error?: unknown) => void) => unknown) | undefined |
源码: packages/host-api/src/node/db/postgres.ts:26
PgliteClient type
type PgliteClient = {
query<Row>(text: string, params?: unknown[]): Promise<{
rows: Row[];
affectedRows?: number;
}>;
/** Parameter-free migration scripts use PostgreSQL's simple protocol. */
exec?(text: string): Promise<{
rows: unknown[];
affectedRows?: number;
}[]>;
transaction<A>(body: (tx: Pick<PgliteClient, 'query' | 'exec'>) => Promise<A>): Promise<A>;
} & Pick<PGlite, 'execProtocol' | 'parsers'>; Native driver calls only: each release creates its own Effect adapter and database failures.
成员
| 名称 | 类型 | 说明 |
|---|---|---|
query | <Row>(text: string, params?: unknown[]) => Promise<{ rows: Row[]; affectedRows?: number; }> | |
exec? | ((text: string) => Promise<{ rows: unknown[]; affectedRows?: number; }[]>) | undefined | Parameter-free migration scripts use PostgreSQL's simple protocol. |
transaction | <A>(body: (tx: Pick<PgliteClient, "query" | "exec">) => Promise<A>) => Promise<A> |
源码: packages/host-api/src/node/db/pglite.ts:26
PgliteDb const
const PgliteDb: { make: (pg: PgliteClient) => RawDb; dump: typeof checkpointed; open: (from?: PgliteSource) => Effect.Effect<PGlite, DbError, Pristine | Scope.Scope>; } The tenant database adapter over an in-process PGlite, for local and test hosts.
成员
| 名称 | 类型 | 说明 |
|---|---|---|
make | (pg: PgliteClient) => RawDb | The adapter over an open PGlite (its session zone must be UTC; |
dump | typeof checkpointed | The open database as a dump to load ( |
open | (from?: PgliteSource) => Effect.Effect<PGlite, DbError, Pristine | Scope.Scope> | Scope-owned PGlite; close settles uninterruptibly and an uncertain close remains a canonical DbError defect. |
源码: packages/host-api/src/node/db/pglite.ts:250
PostgresDb const
const PostgresDb: { make: typeof raw; } The tenant database adapter over a host-owned pg pool, as deployed hosts use.
成员
| 名称 | 类型 | 说明 |
|---|---|---|
make | typeof raw | The adapter over a pool the host keeps (a multi-workspace host shares its pool across a cell's work); each batch owns a connection until settlement. |
源码: packages/host-api/src/node/db/postgres.ts:157
Pristine class
class Pristine extends Pristine_base {
static readonly layer: Layer.Layer<Pristine, never, never>;
} One initdb per machine and PGlite build: an in-memory database starts from this dump (~13× cheaper than initdb).
源码: packages/host-api/src/node/db/pglite.ts:219
Resolve type
type Resolve = (hostname: string) => Promise<readonly Address[]>; A hostname's addresses: DNS lookup by default; a caller with its own resolver passes it.
源码: packages/host-api/src/node/net.ts:73
VmCell type
type VmCell = {
readonly api: HostApi;
close(): void;
}; A cell this process runs: its HOST_API, and close (pending calls reject, timers stop).
成员
| 名称 | 类型 | 说明 |
|---|---|---|
api | HostApi | |
close | () => void |
源码: packages/host-api/src/node/cell.ts:80
artifact_port function
function artifact_port(release: string, docs: string): ArtifactPort The ArtifactPort over a release directory on disk, plus its seed packs at ../seed/<pack>/… and the API reference at ../docs/<file> (docs: a Bolt build's build/docs/). Symlinks resolve here, and a path that resolves outside its root fails invalid.
参数
| 名称 | 类型 | 说明 |
|---|---|---|
release | string | |
docs | string |
源码: packages/host-api/src/node/artifact.ts:30
asset_hook function
function asset_hook(assets: GuestProgram["assets"]): (sha: unknown) => Uint8Array | undefined The prelude's $3: a ?bytes import's bytes by sha256, or undefined (the guest then throws naming the sha).
参数
| 名称 | 类型 | 说明 |
|---|---|---|
assets | GuestProgram['assets'] |
源码: packages/host-api/src/node/guest-hooks.ts:11
bundler function
function bundler(options?: BundlerOptions | undefined): Effect.Effect<{ port: (tenant: string) => { bundle: (request: BundleRequest, signal: AbortSignal) => Promise<Bundled>; }; counts: () => { started: number; built: number; pid: number | undefined; }; }, never, import("effect/Scope").Scope> The host's bundler, alive until the scope closes; port(tenant) is one tenant's view of it.
参数
| 名称 | 类型 | 说明 |
|---|---|---|
options? | BundlerOptions | undefined |
源码: packages/host-api/src/node/bundler/index.ts:223
cell_api function
function cell_api(decoded: unknown): HostApi A cell's api, decoded by the kernel's side of the membrane, as the HostApi it marshals.
参数
| 名称 | 类型 | 说明 |
|---|---|---|
decoded | unknown |
源码: packages/host-api/src/node/cell.ts:46
cell_version function
function cell_version(decoded: unknown): number | undefined A cell's declared HOST_API version, read before its api is decoded, so a host refuses another version by number.
参数
| 名称 | 类型 | 说明 |
|---|---|---|
decoded | unknown |
源码: packages/host-api/src/node/cell.ts:41
connect_public function
function connect_public(hostname: string, port: number, resolve?: Resolve | undefined): Effect.Effect<Socket, PortFailure, import("effect/Scope").Scope> Every invocation resolves again; only checked numeric addresses reach the actual socket.
参数
| 名称 | 类型 | 说明 |
|---|---|---|
hostname | string | |
port | number | |
resolve? | Resolve | undefined |
源码: packages/host-api/src/node/net.ts:130
console_hook function
function console_hook(said: GuestSaid): (level: unknown, line: unknown) => void The prelude's $0, host side. The guest's own clip is guest code it can replace, so the bound is here: only strings are kept (never a guest object's toString), each clipped to its share before the host keeps it.
参数
| 名称 | 类型 | 说明 |
|---|---|---|
said | GuestSaid |
|
源码: packages/host-api/src/node/guest-hooks.ts:26
cron_clock function
function cron_clock<E>(source: { readonly crons: Effect.Effect<readonly CronEntry[]>; readonly fire: (id: string, slot: string) => Effect.Effect<CronFired, E>; }): Effect.Effect<void, never, Scope.Scope> Fires each cron of source at its slots for as long as the scope lives (a single-process host's clock).
参数
| 名称 | 类型 | 说明 |
|---|---|---|
source | { readonly crons: Effect.Effect<readonly CronEntry[]>; readonly fire: (id: string, slot: string) => Effect.Effect<CronFired, E>; } |
|
源码: packages/host-api/src/node/cron-clock.ts:11
digest function
function digest(name: unknown, bytes: unknown): Uint8Array crypto.subtle.digest's host half, capped per call so a guest cannot stall the host event loop.
参数
| 名称 | 类型 | 说明 |
|---|---|---|
name | unknown | |
bytes | unknown |
源码: packages/host-api/src/node/guest-hooks.ts:58
digest_hook function
function digest_hook(maxBytes?: number): (name: unknown, bytes: unknown) => Uint8Array Stateful crypto.subtle.digest hook with a per-invocation cumulative byte ceiling.
参数
| 名称 | 类型 | 说明 |
|---|---|---|
maxBytes? | number |
源码: packages/host-api/src/node/guest-hooks.ts:68
download_media function
function download_media<U>(url: string, sink: DownloadSink<U>, options?: DownloadOptions): Effect.Effect<Downloaded, PortFailure> Fetches url under the policy and streams its body into sink when its first bytes are media.
参数
| 名称 | 类型 | 说明 |
|---|---|---|
url | string | |
sink | DownloadSink<U> |
|
options? | DownloadOptions |
源码: packages/host-api/src/node/download.ts:103
extractDocumentText function
function extractDocumentText(bytes: Uint8Array<ArrayBufferLike>, contentType: string): Effect.Effect<{ body: string; pageCount?: number; sha256: string; }, FacilityFailure, never> Parser CPU and memory are bounded in a scoped worker; cancelling a request terminates it.
参数
| 名称 | 类型 | 说明 |
|---|---|---|
bytes | Uint8Array<ArrayBufferLike> | |
contentType | string |
源码: packages/host-api/src/node/documents.ts:57
host_file_of function
function host_file_of(root: string, flag: string | undefined): Effect.Effect<Option.Option<string>, import("effect/PlatformError").PlatformError, FileSystem.FileSystem | Path.Path> flag's host file, else root's own norbital.host.ts; none means the tethered loop.
参数
| 名称 | 类型 | 说明 |
|---|---|---|
root | string | |
flag | string | undefined |
源码: packages/host-api/src/node/host-file.ts:262
host_module function
function host_module(input: unknown): { readonly facilities: Facilities; readonly serving: Serving; } A host file's module, validated: its Facilities and optional serving parts.
参数
| 名称 | 类型 | 说明 |
|---|---|---|
input | unknown |
源码: packages/host-api/src/node/host-file.ts:253
http_port const
const http_port: HttpPort The engine's outbound HTTP (HttpPort); the wall is the engine's (Port.call).
成员
| 名称 | 类型 | 说明 |
|---|---|---|
fetch | (request: HttpRequest, options: HttpFetchOptions, signal: AbortSignal) => Promise<HttpResponse> |
源码: packages/host-api/src/node/net.ts:500
images_port const
const images_port: ImagesPort The ImagesPort for Node hosts: facts, JPEG, crop and preview, each in a memory-capped worker under the image wall.
成员
| 名称 | 类型 | 说明 |
|---|---|---|
facts | (bytes: Uint8Array, signal: AbortSignal) => Promise<ImageMetadata> | |
jpeg | (bytes: Uint8Array, maxEdge: number, signal: AbortSignal) => Promise<Uint8Array> | |
crop | (bytes: Uint8Array, box: ImageCrop, signal: AbortSignal) => Promise<Uint8Array> | Lossless PNG of the selected oriented pixels, at most 5 MiB; the source stays unchanged. |
preview | (bytes: Uint8Array, mime: ImagePreviewMime, maxEdge: ImagePreviewSize, signal: AbortSignal) => Promise<ImagePreview> |
源码: packages/host-api/src/node/images.ts:105
keys_port function
function keys_port(key: Uint8Array): KeysPort The KeysPort over a 32-byte tenant secrets key: AES-256-GCM envelopes bound to their aad. An envelope opened under different aad answers null; a key of another length throws.
参数
| 名称 | 类型 | 说明 |
|---|---|---|
key | Uint8Array |
源码: packages/host-api/src/node/keys.ts:12
load_host function
function load_host(file: string): Effect.Effect<{ readonly facilities: Facilities; readonly serving: Serving; }, FacilityFailure, import("effect/Scope").Scope> A host file's Facilities and serving, validated; its serving.close runs when the scope closes.
参数
| 名称 | 类型 | 说明 |
|---|---|---|
file | string |
源码: packages/host-api/src/node/host-file.ts:274
loopback_http_port const
const loopback_http_port: HttpPort Outbound HTTP to this machine only (the test kit): every hop to another host is refused.
成员
| 名称 | 类型 | 说明 |
|---|---|---|
fetch | (request: HttpRequest, options: HttpFetchOptions, signal: AbortSignal) => Promise<HttpResponse> |
源码: packages/host-api/src/node/net.ts:504
loopback_mcp_port const
const loopback_mcp_port: Effect.Effect<McpPort, never, Scope.Scope> MCP to this machine only (the test kit): every request to another host is refused.
源码: packages/host-api/src/node/mcp.ts:120
loopback_tcp_port const
const loopback_tcp_port: TcpPort Outbound TCP/TLS to this machine only (the test kit's fake servers); any other host is refused.
成员
| 名称 | 类型 | 说明 |
|---|---|---|
connect | (endpoint: TcpEndpoint, signal: AbortSignal) => Promise<TcpSocket> |
源码: packages/host-api/src/node/tcp.ts:147
mcp_port const
const mcp_port: Effect.Effect<McpPort, never, Scope.Scope> The McpPort over the MCP SDK's streamable HTTP client, one client per session; every session closes with the scope.
源码: packages/host-api/src/node/mcp.ts:118
module_hash function
function module_hash(...entries: ReadonlyArray<string>): Effect.Effect<string> The modules' content key (absolute paths), computed once per process.
参数
| 名称 | 类型 | 说明 |
|---|---|---|
entries | ReadonlyArray<string> |
源码: packages/host-api/src/node/module-hash.ts:39
module_script function
function module_script(source: string, imports: (node: ImportDeclaration) => string): string guest.mjs as a classic script whose completion value is its namespace, for a runner that evaluates scripts only. An import becomes imports' statement, import.meta an empty object; exports stay live bindings. Replacements keep their spans' columns, and the wrapper is a line of its own (lineOffset: -1).
参数
| 名称 | 类型 | 说明 |
|---|---|---|
source | string | |
imports | (node: ImportDeclaration) => string |
源码: packages/host-api/src/node/guest-hooks.ts:115
node_guests function
function node_guests(options?: NodeGuestsOptions): GuestIsolatesPort A host's guest sessions as node:vm contexts in this process: bolt-server's and bolt dev's runner, and the test kit's. Each call runs under a timeout of what is left of the session's CPU budget. A vm context shares the host's heap and is no security boundary: it caps no guest memory and runs operator-trusted code only; a multi-tenant host brings native isolates.
参数
| 名称 | 类型 | 说明 |
|---|---|---|
options? | NodeGuestsOptions |
源码: packages/host-api/src/node/guests.ts:313
pinned_lookup function
function pinned_lookup(addresses: readonly Address[]): LookupFunction Node's connector receives only the already validated set, including Happy Eyeballs' all-address lookup.
参数
| 名称 | 类型 | 说明 |
|---|---|---|
addresses | readonly Address[] |
源码: packages/host-api/src/node/net.ts:109
publicWeb function
function publicWeb(read?: (url: string) => Effect.Effect<PublicPage, PortFailure>): WebReader Public web reads with document extraction and the host network policy.
参数
| 名称 | 类型 | 说明 |
|---|---|---|
read? | (url: string) => Effect.Effect<PublicPage, PortFailure> |
源码: packages/host-api/src/node/web.ts:61
public_addresses function
function public_addresses(url: URL, resolve?: Resolve, allowLoopback?: boolean): Effect.Effect<readonly Address[], PortFailure, never> The addresses url may be reached on: HTTPS on 443 without credentials, every resolved address public. allowLoopback (a development host only) also admits this machine's own names (localhost, *.localhost, 127.0.0.1, ::1) over HTTP or HTTPS on any port, when every address they resolve to is loopback; nothing else private, ever.
参数
| 名称 | 类型 | 说明 |
|---|---|---|
url | URL | |
resolve? | Resolve | |
allowLoopback? | boolean |
源码: packages/host-api/src/node/net.ts:191
public_destination function
function public_destination(hostname: string, port: number, resolve?: Resolve | undefined): Effect.Effect<{ hostname: string; port: number; address: Address; addresses: readonly Address[]; }, PortFailure, never> A TCP destination is checked independently of HTTP's protocol and port restrictions.
参数
| 名称 | 类型 | 说明 |
|---|---|---|
hostname | string | |
port | number | |
resolve? | Resolve | undefined |
源码: packages/host-api/src/node/net.ts:77
public_fetch function
function public_fetch(run: (effect: Effect.Effect<Response, PortFailure>, options?: { readonly signal?: AbortSignal | undefined; }) => Promise<Response>, options?: PublicRequestOptions): typeof fetch The provider's fetch ABI runs guarded work on its already supplied scoped host runner.
参数
| 名称 | 类型 | 说明 |
|---|---|---|
run | (effect: Effect.Effect<Response, PortFailure>, options?: { readonly signal?: AbortSignal | undefined; }) => Promise<Response> | |
options? | PublicRequestOptions |
源码: packages/host-api/src/node/net.ts:512
random_stream function
function random_stream(seed: string, maxBytes?: number): (n: unknown) => Uint8Array The invocation's deterministic entropy stream (AES-256-CTR keyed by sha256(seed)), capped per invocation.
参数
| 名称 | 类型 | 说明 |
|---|---|---|
seed | string | |
maxBytes? | number |
源码: packages/host-api/src/node/guest-hooks.ts:84
read_public_page function
function read_public_page(url: string, options?: { readonly resolve?: Resolve; readonly request?: RequestPage; } | undefined): Effect.Effect<{ url: string; contentType: string; bytes: Uint8Array<ArrayBufferLike>; }, PortFailure, never> A host's web reader: one public page's bytes, every redirect hop re-checked, at most WEB_PAGE_BYTE_LIMIT.
参数
| 名称 | 类型 | 说明 |
|---|---|---|
url | string | |
options? | { readonly resolve?: Resolve; readonly request?: RequestPage; } | undefined |
源码: packages/host-api/src/node/net.ts:561
refuse_platform_addresses function
function refuse_platform_addresses(addresses: Iterable<string>): void The host's own public addresses: once refused, no outbound request, redirect hop, tunnel or TCP connection reaches the platform itself on any port, published or not. A host calls it once at start.
参数
| 名称 | 类型 | 说明 |
|---|---|---|
addresses | Iterable<string> |
源码: packages/host-api/src/node/net.ts:62
op
sign_op function
function sign_op(key: OpKey, host: string, op: string, body: string | Uint8Array, now: number, nonce?: string): { readonly [header: string]: string; } The headers one operation carries to host (the Host the verifier sees in the request URL).
参数
| 名称 | 类型 | 说明 |
|---|---|---|
key | OpKey |
|
host | string | |
op | string | |
body | string | Uint8Array | |
now | number | |
nonce? | string |
源码: packages/host-api/src/op.ts:50
node
store_media function
function store_media<U, E>(name: string, next: Effect.Effect<Uint8Array | undefined, E>, sink: DownloadSink<U>, maxBytes?: number): Effect.Effect<Downloaded, E | PortFailure> Streams a body (next answers its chunks in order, undefined at the end) into sink when its first bytes are media; anything else is refused before an upload begins. The browser's download feeds it the page's parts.
参数
| 名称 | 类型 | 说明 |
|---|---|---|
name | string | |
next | Effect.Effect<Uint8Array | undefined, E> | |
sink | DownloadSink<U> |
|
maxBytes? | number |
源码: packages/host-api/src/node/download.ts:184
tcp_port const
const tcp_port: TcpPort Outbound TCP/TLS under the public guard: DNS resolved once, every address public, high-abuse ports refused, the checked set pinned.
成员
| 名称 | 类型 | 说明 |
|---|---|---|
connect | (endpoint: TcpEndpoint, signal: AbortSignal) => Promise<TcpSocket> |
源码: packages/host-api/src/node/tcp.ts:130
tenant_db_port function
function tenant_db_port(db: RawDb): HostTenantDb A same-graph RawDb as the Host API's Promise-based HostTenantDb; aborting signal interrupts the batch.
参数
| 名称 | 类型 | 说明 |
|---|---|---|
db | RawDb |
|
源码: packages/host-api/src/node/db/port.ts:6
type_service const
const type_service: { PROBE: string; root_of: typeof root_of; refresh: typeof refresh; filesystem: typeof filesystem; holder: typeof holder; offset_in: typeof offset_in; view: typeof view; check_workspace: (files: ReadonlyMap<string, string>, modules: string | undefined, options?: { readonly timeout_ms?: number; readonly tsserver_path?: string; } | undefined) => Effect.Effect<LangDiagnostic[], TypeCheckError, never>; } A host's language service over these workspaces: holder a workspace, refresh it, serve it through filesystem, read it through view; check_workspace checks a whole program in a process of its own. Positions, diagnostics and holders derive from these (Parameters<typeof type_service.offset_in>[1], ReturnType<typeof type_service.holder>).
成员
| 名称 | 类型 | 说明 |
|---|---|---|
PROBE | string | |
root_of | typeof root_of | |
refresh | typeof refresh | |
filesystem | typeof filesystem | |
holder | typeof holder | |
offset_in | typeof offset_in | |
view | typeof view | |
check_workspace | (files: ReadonlyMap<string, string>, modules: string | undefined, options?: { readonly timeout_ms?: number; readonly tsserver_path?: string; } | undefined) => Effect.Effect<LangDiagnostic[], TypeCheckError, never> |
源码: packages/host-api/src/node/typing/workspace.ts:474
op
verify_op function
function verify_op<E>(key: OpKey, request: Request, body: string | Uint8Array, nonces: NonceStore<E>): Effect.Effect<string, OpRefused | E> The operation name of an authentic, fresh, first-seen request; else OpRefused (the nonce is claimed last).
参数
| 名称 | 类型 | 说明 |
|---|---|---|
key | OpKey |
|
request | Request | |
body | string | Uint8Array | |
nonces | NonceStore<E> |
|
源码: packages/host-api/src/op.ts:68
node
vm_cell function
function vm_cell(source: string, log: (error: boolean, line: string) => void): VmCell source (a release's build/cell.js) opened in a fresh node:vm context; log takes its console lines.
参数
| 名称 | 类型 | 说明 |
|---|---|---|
source | string | |
log | (error: boolean, line: string) => void |