跳到主要内容

host-api

host-api

此内容目前仅提供英文版。

导入自 @norbital-ai/host-api

@norbital-ai/host-api: the contract between a host and a Bolt release. A host (Colony, bolt-server, a third party's) depends on this package, never on Bolt's engine; a release's Bolt depends on it and answers it. It owns every type that crosses: the HostApi a release answers (host.ts), the facilities and ports a host supplies (facilities.ts, ai.ts, browser.ts, guest.ts, media.ts, integrations.ts, db.ts, logs.ts, audit.ts), the authority a host reads (authority.ts), what a host adds to the agent (tools.ts) and Studio's port (studio.ts), with the failures they share (errors.ts), the Port helpers that call them and the SQL wire both database adapters and the engine share (wire.ts). It also holds the adapters every host binds the same way: System 1 (system-1.ts), Norbital Convert (convert.ts), the deadline timer (deadline-timer.ts) and the recovery storage contract's reads of a branch without its release (storage.ts). Versioning: the protocol version is HOST_API_VERSION, one integer bumped on any change either side could misread. The package version follows the oss release line for publication; what a host checks is the HOST_API number a release reports (HostApiCore.version), which must equal its own (supports). Bolt package versions are independent. Node-only parts (signed host operations and the Node port implementations) are @norbital-ai/host-api/node; everything here also runs inside a cell.

audit

AUDIT_ACTOR_KINDS const

const AUDIT_ACTOR_KINDS: readonly ["member", "envoy", "visitor", "api_key", "system"]

The existing native actor families, projected without credentials or session data.

源码: packages/host-api/src/audit.ts:23

AUDIT_CATEGORIES const

const AUDIT_CATEGORIES: readonly ["write", "approval", "identity", "automation", "integration"]

Native event families offered by the administrator's audit filters.

源码: packages/host-api/src/audit.ts:5

AUDIT_STATUSES const

const AUDIT_STATUSES: readonly ["prepared", "committed", "pending_approval", "refused", "conflict", "failed", "unknown"]

An event's observed lifecycle; prepared and unknown never claim a committed database change.

源码: packages/host-api/src/audit.ts:13

host

ActiveWorkspace type

type ActiveWorkspace = {
    /**
     * The release's routes for this generation, the request as the workspace sees it (no host prefix): the shell host
     * (`/__bolt/session/*`, `/__bolt/shell*`, the PWA manifest), files, the data protocol and `/hooks/<path>` automation
     * webhooks; `null` when none is the release's. Event streams end when the generation closes.
     */
    handle(request: Request, options: {
        readonly address: string;
    }): Promise<Response | null>;
    /**
     * Protected public-page loading and HTML rendering share one read-only guest invocation. A host routes public
     * documents here before static client serving, passing the original request and keeping the returned cookies,
     * status, cache and content-security headers; serving `index.html` for a public route bypasses rendering.
     */
    render(request: Request, options: Signal & {
        readonly address: string;
    }): Promise<Response | null>;
    /** One deadline wake: every due run of the environment, then `deadlines.settle`. */
    wake(options: Signal): Promise<void>;
    /** Signal work due during an existing wake without entering another compute envelope. */
    pulse(options: Signal): Promise<boolean>;
    /** Every cron the manifest declares; the host's clock computes their slots. */
    crons(): Promise<readonly CronEntry[]>;
    /** Runs cron `id` for `slot` (an ISO minute), once per `(id, slot)`; `ran: false` for a repeat or a run that wrote nothing. */
    fi…

A release activated for one workspace: the routes it serves, its renders, crons and lifecycle as the host drives them.

成员

名称类型说明
handle(request: Request, options: { readonly address: string; }) => Promise<Response | null>

The release's routes for this generation, the request as the workspace sees it (no host prefix): the shell host (/__bolt/session/*, /__bolt/shell*, the PWA manifest), files, the data protocol and /hooks/<path> automation webhooks; null when none is the release's. Event streams end when the generation closes.

render(request: Request, options: Signal & { readonly address: string; }) => Promise<Response | null>

Protected public-page loading and HTML rendering share one read-only guest invocation. A host routes public documents here before static client serving, passing the original request and keeping the returned cookies, status, cache and content-security headers; serving index.html for a public route bypasses rendering.

wake(options: Signal) => Promise<void>

One deadline wake: every due run of the environment, then deadlines.settle.

pulse(options: Signal) => Promise<boolean>

Signal work due during an existing wake without entering another compute envelope.

crons() => Promise<readonly CronEntry[]>

Every cron the manifest declares; the host's clock computes their slots.

fire(id: string, slot: string, options: Signal) => Promise<CronFired>

Runs cron id for slot (an ISO minute), once per (id, slot); ran: false for a repeat or a run that wrote nothing.

park(options: Signal & { readonly automations_ms: number; }) => Promise<void>

A planned close: ordinary pages and requests go on; no new job or automation call starts. Active automations get automations_ms to end, while turns work on; then every turn holds at its next step. Answers once no step is running; the host then closes the generation and the next one takes the turns over. A host bounds the wait.

close() => Promise<void>

Interrupts every guest invocation and in-flight crossing of this generation; the host then ends its pool.

notify(note: { readonly conversation: string; readonly text: string; readonly id: string; }, options: Signal) => Promise<boolean>

The host's word to an agent conversation (the end of work it carried on for a turn, such as a host tool's job): one queued system note that wakes the conversation. id makes it once: a repeat of (conversation, id) adds nothing, across restarts, and answers false. A conversation that does not exist is refused.

task(task: TaskStart, options: Signal) => Promise<string>

Starts a system agent on task under the policies the workspace's administrator set for host tasks, and answers its conversation. Once per run: a repeat answers the same conversation and starts nothing. Refused at the workspace's system spending limit. Its end is told through AgentPorts.task_ended.

identity{ /** The caller's authority from the request's session, or `null`. */ authority(request: Request, options: Signal): Promise<Authority | null>; /** `session.mint` for an active member; `null` for none. `agent`: minted for the agent's browser (`Authority.agent`). */ mint(user: string, options: Signal & { readonly agent?: AgentMark; }): Promise<MintedSession | null>; }

源码: packages/host-api/src/host.ts:294

authority

Actor const

const Actor: Schema.Union<readonly [Schema.Struct<{ readonly kind: Schema.Literal<"member">; readonly id: Schema.String; readonly email: Schema.NullOr<Schema.String>; readonly phone: Schema.NullOr<Schema.String>; readonly external: Schema.Boolean; readonly admin: Schema.Boolean; }>, Schema.Struct<{ readonly kind: Schema.Literal<"envoy">; readonly envoy: Schema.String; }>, Schema.Struct<{ readonly kind: Schema.Literal<"visitor">; readonly app: Schema.String; readonly visitor: Schema.String; }>, Schema.Struct<{ readonly kind: Schema.Literal<"api_key">; readonly key: Schema.String; }>, Schema.Struct<{ readon…

The person or work a call is for: a member, an envoy's turn, a visitor, an API key or the system identity's run.

源码: packages/host-api/src/authority.ts:14

AgentMark const

const AgentMark: Schema.Struct<{ readonly conversation: Schema.String; }>

The agent's mark: requests made with a session minted for the agent's browser act for the member in conversation.

源码: packages/host-api/src/authority.ts:31

host

AgentPorts type

type AgentPorts = {
    /** The person's current working source (the default for source tools); none where they author nothing. */
    readonly draft?: (a: Authority) => Promise<WorkspacePort | undefined>;
    /** ripgrep over this author's working tree (`workspace_grep`). */
    readonly search?: (a: Authority, request: SearchRequest) => Promise<SearchAnswer | undefined>;
    /**
     * Host tools (Workspace Studio authoring, browser, personal skills): a fixed list, or the actor's catalogue per turn.
     * `subject` is what the tools work for: an agent conversation, or an automation run's inference.
     */
    readonly host_tools?: readonly HostTool[] | ((a: Authority, subject: ToolSubject) => Promise<readonly HostTool[]>);
    /** A system agent's task ended (`ActiveWorkspace.task`, `ctx.ai.sys_2.task`): told once, whatever ended it. */
    readonly task_ended?: (end: TaskEnd) => Promise<void>;
    /** An administrator turned the host's own tasks on (`ActiveWorkspace.task` was refused until now): it may start what waits. */
    readonly tasks_enabled?: () => Promise<void>;
    /** Host skills merged into `skill` on in-app staff turns: the platform authoring skill, the person's own skills. */
    readonly skills?: (a: Authority) => Promise<{
        readonly [name: string]: HostSkill;
    }>;
    /** Reject pending host tool approvals from the previous turn; return only IDs actually rejected. */
    readonly on_turn_start?: (conversation: string) => Promise<readonly strin…

The agent's host parts; the release's own source (workspace_grep) and attachments are the release's.

成员

名称类型说明
draft?(a: Authority) => Promise<WorkspacePort | undefined>

The person's current working source (the default for source tools); none where they author nothing.

search?(a: Authority, request: SearchRequest) => Promise<SearchAnswer | undefined>

ripgrep over this author's working tree (workspace_grep).

host_tools?readonly HostTool[] | ((a: Authority, subject: ToolSubject) => Promise<readonly HostTool[]>)

Host tools (Workspace Studio authoring, browser, personal skills): a fixed list, or the actor's catalogue per turn. subject is what the tools work for: an agent conversation, or an automation run's inference.

task_ended?(end: TaskEnd) => Promise<void>

A system agent's task ended (ActiveWorkspace.task, ctx.ai.sys_2.task): told once, whatever ended it.

tasks_enabled?() => Promise<void>

An administrator turned the host's own tasks on (ActiveWorkspace.task was refused until now): it may start what waits.

skills?(a: Authority) => Promise<{ readonly [name: string]: HostSkill; }>

Host skills merged into skill on in-app staff turns: the platform authoring skill, the person's own skills.

on_turn_start?(conversation: string) => Promise<readonly string[]>

Reject pending host tool approvals from the previous turn; return only IDs actually rejected.

events?(since: string) => Promise<readonly WorkspaceNote[]>

Workspace events after since (ISO), oldest first: an in-app conversation hears each one once, at its next step. The release's wake also delivers them to the inbox.

源码: packages/host-api/src/host.ts:158

ai

AiAssistantContent const

const AiAssistantContent: Schema.Struct<{ readonly text: Schema.optionalKey<Schema.String>; readonly reasoning: Schema.optionalKey<Schema.String>; readonly toolCalls: Schema.optionalKey<Schema.$Array<Schema.Struct<{ readonly id: Schema.String; readonly name: Schema.String; readonly input: Schema.Codec<Schema.Json, Schema.Json, never, never>; readonly invalid: Schema.optionalKey<Schema.String>; }>>>; }>

Assistant text, preserved reasoning and tool calls passed to the provider.

源码: packages/host-api/src/ai.ts:14

AiCatalogSchema const

const AiCatalogSchema: Schema.Struct<{ readonly models: Schema.$Array<Schema.Struct<{ readonly id: Schema.String; readonly label: Schema.String; readonly provider: Schema.optionalKey<Schema.String>; readonly context: Schema.optionalKey<Schema.Number>; readonly price: Schema.optionalKey<Schema.Struct<{ readonly input: Schema.Number; readonly output: Schema.Number; readonly cached: Schema.optionalKey<Schema.Number>; }>>; }>>; readonly default: Schema.String; }>

A provider's listing: its models and the one it uses unless told otherwise.

源码: packages/host-api/src/ai.ts:242

AiEvent type

type AiEvent = {
    readonly _tag: 'Delta';
    readonly text: string;
} | {
    readonly _tag: 'Progress';
    readonly reasoning: string | undefined;
} | {
    readonly _tag: 'Response';
    readonly response: AiResponse;
};

One sys_2 call as it streams: text as it arrives, progress that is not text (a tool call's arguments, reasoning), then the response.

源码: packages/host-api/src/ai.ts:284

AiMessage type

type AiMessage = {
    role: 'user' | 'assistant' | 'tool';
    content: Json;
};

One transcript message the AI port sends the model: who said it and its content.

成员

名称类型说明
role'user' | 'assistant' | 'tool'
contentJson

源码: packages/host-api/src/ai.ts:184

AiModel type

type AiModel = typeof AiModelSchema.Type;

One model a provider lists (AiModelSchema): its id, label, vendor, window and price.

成员

名称类型说明
labelSchema.String
idSchema.String
context?Schema.optionalKey<Schema.Number>
provider?Schema.optionalKey<Schema.String>
price?Schema.optionalKey<Schema.Struct<{ readonly input: Schema.Number; readonly output: Schema.Number; readonly cached: Schema.optionalKey<Schema.Number>; }>>

源码: packages/host-api/src/ai.ts:238

AiModelSchema const

const AiModelSchema: Schema.Struct<{ readonly id: Schema.String; readonly label: Schema.String; readonly provider: Schema.optionalKey<Schema.String>; readonly context: Schema.optionalKey<Schema.Number>; readonly price: Schema.optionalKey<Schema.Struct<{ readonly input: Schema.Number; readonly output: Schema.Number; readonly cached: Schema.optionalKey<Schema.Number>; }>>; }>

One model a provider lists (the panel shows label, grouped by provider); context is its window in tokens, price USD per million tokens (input, output, cached input): what a call costs when the endpoint reports no charge.

源码: packages/host-api/src/ai.ts:224

AiPort interface

interface AiPort {
    sys_1: System1Port;
    sys_2: {
        /** The model classes the host maps (`default fast strong`). */
        models: readonly string[];
        /**
         * Every model the provider can reach that the agent can run on (images in, tools), as the provider lists them, and
         * the id a new conversation starts on; cached as the host likes, answering even offline. `infer` takes any of their
         * ids as `model`, beside the classes.
         */
        catalog(): Promise<{
            models: readonly AiModel[];
            default: string;
        }>;
        /**
         * `onDelta` streams text as it arrives; on the wall the agent keeps it as a cut step. `onProgress`: the stream
         * produced something that is not text (a tool call's arguments, or `reasoning` as it arrives).
         */
        infer(request: AiRequest, signal: AbortSignal, onDelta?: (text: string) => void, onProgress?: (reasoning?: string) => void): Promise<AiResponse>;
    };
    embed?: EmbeddingsPort['embed'];
}

The AI facility: sys_1 (fast structured decisions over text, JSON, and resolved inline PNG/JPEG images) and sys_2 (the multimodal LLM) are both required when the port is bound; embed (multimodal) is present when the host maps an embedding model. The host verifies at activation that every sys_2 and embed model takes images; nothing here branches on modality.

成员

名称类型说明
sys_1System1Port
sys_2{ /** The model classes the host maps (`default fast strong`). */ models: readonly string[]; /** * Every model the provider can reach that the agent can run on (images in, tools), as the provider lists them, and * the id a new conversation starts on; cached as the host likes, answering even offline. `infer` takes any of their * ids as `model`, beside the classes. */ catalog(): Promise<{ models: r…
embed?EmbeddingsPort['embed']

源码: packages/host-api/src/ai.ts:259

AiPortResponseSchema const

const AiPortResponseSchema: Schema.Struct<{ readonly content: Schema.Codec<Schema.Json, Schema.Json, never, never>; readonly tool_calls: Schema.$Array<Schema.Struct<{ readonly id: Schema.String; readonly name: Schema.String; readonly input: Schema.Codec<Schema.Json, Schema.Json, never, never>; readonly invalid: Schema.optionalKey<Schema.String>; }>>; readonly finish: Schema.Literals<readonly ["stop", "tool", "cut"]>; readonly continuation: Schema.optionalKey<Schema.String>; readonly reasoning: Schema.optionalKey<Schema.String>; readonly usage: Schema.Struct<{ readonly input: Schema.Number; readonly output: Schema.Number…

The host's system-2 answer; transcript storage keeps its native toolCalls projection behind the adapter.

源码: packages/host-api/src/ai.ts:33

AiPrice type

type AiPrice = NonNullable<AiModel['price']>;

A model's listed price in USD per million tokens: input, output and cached input.

成员

名称类型说明
inputSchema.Number
outputSchema.Number
cached?Schema.optionalKey<Schema.Number>

源码: packages/host-api/src/ai.ts:240

AiRequest type

type AiRequest = {
    model: string;
    /** Host usage attribution; omitted for utility inference, set by the conversation engine for chat work. */
    purpose?: 'chat';
    system?: string;
    messages: readonly AiMessage[];
    tools?: readonly {
        name: string;
        description: string;
        input: Json;
    }[];
    output?: Json;
    /** Images and documents for the model to see; `call` is the tool call that opened one, which it follows. */
    files?: readonly {
        mime: string;
        bytes: Uint8Array;
        call?: string;
    }[];
    continuation?: string;
    /** Reasoning effort hint for fast/structured utility calls; omitted uses the provider default. */
    reasoning_effort?: 'low' | 'medium' | 'high';
};

One model call the engine hands the AI port: model, system prompt, messages, tools, optional output schema and files.

成员

名称类型说明
modelstring
purpose?'chat'

Host usage attribution; omitted for utility inference, set by the conversation engine for chat work.

system?string
messagesreadonly AiMessage[]
tools?readonly { name: string; description: string; input: Json; }[]
output?Json
files?readonly { mime: string; bytes: Uint8Array; call?: string; }[]

Images and documents for the model to see; call is the tool call that opened one, which it follows.

continuation?string
reasoning_effort?'low' | 'medium' | 'high'

Reasoning effort hint for fast/structured utility calls; omitted uses the provider default.

源码: packages/host-api/src/ai.ts:186

AiResponse type

type AiResponse = typeof AiPortResponseSchema.Type;

The host's system-2 answer (AiPortResponseSchema): content, tool calls, how it finished and its usage.

成员

名称类型说明
contentSchema.Codec<Schema.Json, Schema.Json, never, never>
tool_callsSchema.$Array<Schema.Struct<{ readonly id: Schema.String; readonly name: Schema.String; readonly input: Schema.Codec<Schema.Json, Schema.Json, never, never>; readonly invalid: Schema.optionalKey<Schema.String>; }>>
finishSchema.Literals<readonly ["stop", "tool", "cut"]>
usageSchema.Struct<{ readonly input: Schema.Number; readonly output: Schema.Number; readonly cost: Schema.optionalKey<Schema.Number>; readonly call: Schema.optionalKey<Schema.String>; readonly provider: Schema.optionalKey<Schema.String>; readonly cached: Schema.optionalKey<Schema.Number>; readonly reasoning: Schema.optionalKey<Schema.Number>; readonly prompt: Schema.optionalKey<Schema.Struct<{ readonl…

Tokens and the call's charge in USD under the provider's call id: a host's provider reports both cost and call for every call (from the endpoint's own charge, else its listed price); only a recorded test answer omits them.

continuation?Schema.optionalKey<Schema.String>
reasoning?Schema.optionalKey<Schema.String>

源码: packages/host-api/src/ai.ts:55

AiToolCallSchema const

const AiToolCallSchema: Schema.Struct<{ readonly id: Schema.String; readonly name: Schema.String; readonly input: Schema.Codec<Schema.Json, Schema.Json, never, never>; readonly invalid: Schema.optionalKey<Schema.String>; }>

Fields every AI provider receives; engine transcript metadata is not part of this contract.

源码: packages/host-api/src/ai.ts:7

AiToolResult const

const AiToolResult: Schema.Struct<{ readonly id: Schema.String; readonly name: Schema.String; readonly result: Schema.optionalKey<Schema.Codec<Schema.Json, Schema.Json, never, never>>; }>

A tool call result passed back to the provider.

源码: packages/host-api/src/ai.ts:20

membrane

Answer const

const Answer: Schema.UndefinedOr<Schema.Tuple<readonly [Schema.Literals<readonly ["ok", "fail"]>, Schema.Unknown]>>

A call's answer when its function answered at once; none means a resolve or reject message follows.

源码: packages/host-api/src/membrane.ts:33

answers

ArtifactHeader const

const ArtifactHeader: Schema.Struct<{ readonly contract: Schema.String; readonly host_api: Schema.Number; readonly handle: Schema.String; readonly name: Schema.String; readonly schema: Schema.String; readonly client: Schema.optionalKey<Schema.Struct<{ readonly immutable: Schema.optionalKey<Schema.$Array<Schema.String>>; readonly public_routes: Schema.optionalKey<Schema.$Array<Schema.String>>; readonly has_embeds: Schema.optionalKey<Schema.Boolean>; }>>; readonly hash: Schema.String; }>

The header of a release's artifact.json a host reads before any cell runs; the release's verify checks the rest.

源码: packages/host-api/src/answers.ts:7

ports

ArtifactPort interface

interface ArtifactPort {
    read(path: string, signal: AbortSignal): Promise<Uint8Array>;
    list(dir: string, signal: AbortSignal): Promise<readonly string[]>;
    stat(path: string, signal: AbortSignal): Promise<ArtifactStat | null>;
}

The release's files, read-only. Paths are posix and relative to the release directory (artifact.json, client/index.html), with no ., empty, \ or NUL segment; .. only as ../seed/<pack>/…, the build's seed packs beside the release (.norbital/bundle + .norbital/seed/<pack>), or ../docs/<file>, the API reference of the Bolt release it pins (build/docs/<file>, for the agent's docs tool). The host refuses any other path and resolves symlinks itself, so a path never leaves those roots. stat answers null for nothing there; list answers every file (never a directory) under dir, recursively, relative to dir, sorted.

成员

名称类型说明
read(path: string, signal: AbortSignal) => Promise<Uint8Array>
list(dir: string, signal: AbortSignal) => Promise<readonly string[]>
stat(path: string, signal: AbortSignal) => Promise<ArtifactStat | null>

源码: packages/host-api/src/ports.ts:17

ArtifactStat type

type ArtifactStat = {
    readonly kind: 'file' | 'directory';
    readonly size: number;
};

A release path's kind and byte size.

成员

名称类型说明
kind'file' | 'directory'
sizenumber

源码: packages/host-api/src/ports.ts:8

integrations

Attachment type

type Attachment = {
    readonly id?: string;
    readonly name: string;
    readonly mime: string;
    readonly bytes: number;
};

A file a message carries: id names the stored file; none when the row could not store its bytes (too large, never received).

成员

名称类型说明
id?string
namestring
mimestring
bytesnumber

源码: packages/host-api/src/integrations.ts:633

audit

AuditActor const

const AuditActor: Schema.Struct<{ readonly kind: Schema.Literals<readonly ["member", "envoy", "visitor", "api_key", "system"]>; readonly id: Schema.NullOr<Schema.NonEmptyString>; readonly label: Schema.NullOr<Schema.String>; }>

A stable actor identity and its optional display label at the time of the event.

源码: packages/host-api/src/audit.ts:26

AuditEvent const

const AuditEvent: Schema.Struct<{ readonly id: Schema.NonEmptyString; readonly operation_id: Schema.NonEmptyString; readonly at: Schema.String; readonly category: Schema.Literals<readonly ["write", "approval", "identity", "automation", "integration"]>; readonly action: Schema.NonEmptyString; readonly status: Schema.Literals<readonly ["prepared", "committed", "pending_approval", "refused", "conflict", "failed", "unknown"]>; readonly actor: Schema.Struct<{ readonly kind: Schema.Literals<readonly ["member", "envoy", "visitor", "api_key", "system"]>; readonly id: Schema.NullOr<Schema.NonEmptyString>; readonly labe…

An immutable native event; committed or held states require database acknowledgement before append.

源码: packages/host-api/src/audit.ts:56

AuditPage const

const AuditPage: Schema.Struct<{ readonly rows: Schema.$Array<Schema.Struct<{ readonly id: Schema.NonEmptyString; readonly operation_id: Schema.NonEmptyString; readonly at: Schema.String; readonly category: Schema.Literals<readonly ["write", "approval", "identity", "automation", "integration"]>; readonly action: Schema.NonEmptyString; readonly status: Schema.Literals<readonly ["prepared", "committed", "pending_approval", "refused", "conflict", "failed", "unknown"]>; readonly actor: Schema.Struct<{ readonly kind: Schema.Literals<readonly ["member", "envoy", "visitor", "api_key", "system"]>; readonly id: Schema…

A bounded page in stable occurrence-time and event-id order, with no exact-count scan.

源码: packages/host-api/src/audit.ts:102

AuditPendingPage const

const AuditPendingPage: Schema.Struct<{ readonly rows: Schema.$Array<Schema.Struct<{ readonly id: Schema.NonEmptyString; readonly operation_id: Schema.NonEmptyString; readonly at: Schema.String; readonly category: Schema.Literals<readonly ["write", "approval", "identity", "automation", "integration"]>; readonly action: Schema.NonEmptyString; readonly actor: Schema.Struct<{ readonly kind: Schema.Literals<readonly ["member", "envoy", "visitor", "api_key", "system"]>; readonly id: Schema.NullOr<Schema.NonEmptyString>; readonly label: Schema.NullOr<Schema.String>; }>; readonly subject: Schema.NullOr<Schema.Struct<{ read…

Full prepared records without their operation's terminal marker, in stable oldest-first cursor order.

源码: packages/host-api/src/audit.ts:116

AuditPendingQuery const

const AuditPendingQuery: Schema.Struct<{ readonly after: Schema.optionalKey<Schema.NonEmptyString>; readonly limit: Schema.optionalKey<Schema.Int>; }>

Host-only reconciliation pages proceed oldest first, without letting one unresolved operation block later ones.

源码: packages/host-api/src/audit.ts:109

AuditPort interface

interface AuditPort {
    /** Buffered facilities acknowledge before disk flush; a host crash can lose accepted records. Disabled hosts refuse audited writes. */
    readonly mode: 'durable' | 'buffered' | 'disabled';
    /** Append with the host's declared persistence guarantee; identical ids deduplicate, changed content conflicts. */
    append(events: readonly AuditEvent[], signal: AbortSignal): Promise<void>;
    /** Search includes the full stored payload; list answers contain summaries only. */
    query(query: AuditQuery, signal: AbortSignal): Promise<AuditPage>;
    /** One full event from this facility's environment, or null when that id is absent. */
    detail(id: string, signal: AbortSignal): Promise<AuditRecord | null>;
    /** Prepared operations without `${operation_id}:terminal`; this facility is not exposed to page or tenant code. */
    pending(query: AuditPendingQuery, signal: AbortSignal): Promise<AuditPendingPage>;
}

The environment-bound host facility; callers cannot supply tenant or environment scope.

A separate store from the control and tenant databases (bolt_history stays in the tenant for restore and rollback). Records expire 30 days after recorded_at; permanent tenant deletion purges them earlier, while a tenant erase sanitizes history but leaves appended payloads until expiry. Workspace code has no append facility. The stores share no atomic commit: an audited write's prepared intent is acknowledged before the tenant lease, and recovery reconciles unresolved intents from the tenant's receipt and retained revisions.

成员

名称类型说明
mode'durable' | 'buffered' | 'disabled'

Buffered facilities acknowledge before disk flush; a host crash can lose accepted records. Disabled hosts refuse audited writes.

append(events: readonly AuditEvent[], signal: AbortSignal) => Promise<void>

Append with the host's declared persistence guarantee; identical ids deduplicate, changed content conflicts.

query(query: AuditQuery, signal: AbortSignal) => Promise<AuditPage>

Search includes the full stored payload; list answers contain summaries only.

detail(id: string, signal: AbortSignal) => Promise<AuditRecord | null>

One full event from this facility's environment, or null when that id is absent.

pending(query: AuditPendingQuery, signal: AbortSignal) => Promise<AuditPendingPage>

Prepared operations without ${operation_id}:terminal; this facility is not exposed to page or tenant code.

源码: packages/host-api/src/audit.ts:131

AuditPreparedRecord const

const AuditPreparedRecord: Schema.Struct<{ readonly id: Schema.NonEmptyString; readonly operation_id: Schema.NonEmptyString; readonly at: Schema.String; readonly category: Schema.Literals<readonly ["write", "approval", "identity", "automation", "integration"]>; readonly action: Schema.NonEmptyString; readonly actor: Schema.Struct<{ readonly kind: Schema.Literals<readonly ["member", "envoy", "visitor", "api_key", "system"]>; readonly id: Schema.NullOr<Schema.NonEmptyString>; readonly label: Schema.NullOr<Schema.String>; }>; readonly subject: Schema.NullOr<Schema.Struct<{ readonly model: Schema.NonEmptyString; readonly i…

A durable preparation awaiting a confirmed terminal event; its full payload is host-only reconciliation input.

源码: packages/host-api/src/audit.ts:71

AuditQuery const

const AuditQuery: Schema.Struct<{ readonly after: Schema.optionalKey<Schema.NonEmptyString>; readonly order: Schema.optionalKey<Schema.Literals<readonly ["newest", "oldest"]>>; readonly since: Schema.optionalKey<Schema.String>; readonly until: Schema.optionalKey<Schema.String>; readonly text: Schema.optionalKey<Schema.String>; readonly actor_kind: Schema.optionalKey<Schema.Literals<readonly ["member", "envoy", "visitor", "api_key", "system"]>>; readonly actor_id: Schema.optionalKey<Schema.String>; readonly category: Schema.optionalKey<Schema.Literals<readonly ["write", "approval", "identity", "automation", "in…

Typed server filters; after is an opaque cursor bound to these filters and the requested time order.

源码: packages/host-api/src/audit.ts:82

AuditRecord const

const AuditRecord: Schema.Struct<{ readonly id: Schema.NonEmptyString; readonly operation_id: Schema.NonEmptyString; readonly at: Schema.String; readonly category: Schema.Literals<readonly ["write", "approval", "identity", "automation", "integration"]>; readonly action: Schema.NonEmptyString; readonly status: Schema.Literals<readonly ["prepared", "committed", "pending_approval", "refused", "conflict", "failed", "unknown"]>; readonly actor: Schema.Struct<{ readonly kind: Schema.Literals<readonly ["member", "envoy", "visitor", "api_key", "system"]>; readonly id: Schema.NullOr<Schema.NonEmptyString>; readonly labe…

The full event returned only when its administrator opens the detail.

源码: packages/host-api/src/audit.ts:67

AuditSummary const

const AuditSummary: Schema.Struct<{ readonly id: Schema.NonEmptyString; readonly operation_id: Schema.NonEmptyString; readonly at: Schema.String; readonly category: Schema.Literals<readonly ["write", "approval", "identity", "automation", "integration"]>; readonly action: Schema.NonEmptyString; readonly status: Schema.Literals<readonly ["prepared", "committed", "pending_approval", "refused", "conflict", "failed", "unknown"]>; readonly actor: Schema.Struct<{ readonly kind: Schema.Literals<readonly ["member", "envoy", "visitor", "api_key", "system"]>; readonly id: Schema.NullOr<Schema.NonEmptyString>; readonly labe…

One list row, without its potentially large payload.

源码: packages/host-api/src/audit.ts:64

authority

Authority const

const Authority: Schema.Struct<{ readonly actor: Schema.Union<readonly [Schema.Struct<{ readonly kind: Schema.Literal<"member">; readonly id: Schema.String; readonly email: Schema.NullOr<Schema.String>; readonly phone: Schema.NullOr<Schema.String>; readonly external: Schema.Boolean; readonly admin: Schema.Boolean; }>, Schema.Struct<{ readonly kind: Schema.Literal<"envoy">; readonly envoy: Schema.String; }>, Schema.Struct<{ readonly kind: Schema.Literal<"visitor">; readonly app: Schema.String; readonly visitor: Schema.String; }>, Schema.Struct<{ readonly kind: Schema.Literal<"api_key">; readonly key: Schema.St…

A caller's authority as a host reads it.

源码: packages/host-api/src/authority.ts:35

browser

BROWSER_RUN_PROFILE const

const BROWSER_RUN_PROFILE: "\u0001run:"

An automation run's browser profile: this prefix and the run id. The host discards it when the run's session ends.

源码: packages/host-api/src/browser.ts:8

facilities

Blob type

type Blob = {
    key: string;
    bytes: number;
    sha256: string;
    mime: string;
};

A stored blob; the sys_file row is the release's.

成员

名称类型说明
keystring
bytesnumber
sha256string
mimestring

源码: packages/host-api/src/facilities.ts:52

host

BranchPorts type

type BranchPorts = {
    readonly release: Release;
    readonly database: HostTenantDb;
    /** The environment's durable host store; founder bootstrap, which mutates identity, refuses without it. */
    readonly audit?: AuditPort;
    /** As `LinkHost.keys`: credential restore seals through it, and refuses without it. */
    readonly keys?: KeysPort;
};

A branch the host works on outside any serving generation: the lifecycle prepares one (provision, reset, probe, restore), and an operator changes a live one's integration instances. No guest code runs.

成员

名称类型说明
releaseRelease
databaseHostTenantDb
audit?AuditPort

The environment's durable host store; founder bootstrap, which mutates identity, refuses without it.

keys?KeysPort

As LinkHost.keys: credential restore seals through it, and refuses without it.

源码: packages/host-api/src/host.ts:226

browser

BrowserCaller type

type BrowserCaller = {
    readonly actor: Actor;
    readonly conversation: string;
    readonly agent?: AgentMark;
};

Who a workspace page is opened for: the person, the conversation, and the agent's mark when it has one.

成员

名称类型说明
actorActor
conversationstring
agent?AgentMark

源码: packages/host-api/src/browser.ts:50

BrowserPort interface

interface BrowserPort {
    /** Open the profile's isolated tab. A failed open is an error, and close must release any partial resources. */
    open(profile: string, signal: AbortSignal): Promise<void>;
    navigate(profile: string, to: BrowserTarget, find: string | undefined, signal: AbortSignal, viewport?: BrowserViewport): Promise<BrowserSnapshot>;
    /**
     * Open a page of the workspace as the person, signed in by the host's hand-off: the internal half of `browser`.
     * A host that cannot sign its browser in omits it, and the agent is not offered workspace pages.
     */
    open_workspace?(profile: string, target: BrowserWorkspaceTarget, caller: BrowserCaller, signal: AbortSignal): Promise<BrowserSnapshot>;
    /** Close this profile's tab and release its page resources; its sealed sign-ins stay for the next open. */
    close(profile: string, signal: AbortSignal): Promise<void>;
    snapshot(profile: string, options: {
        find?: string;
        from?: number;
    }, signal: AbortSignal): Promise<BrowserSnapshot>;
    act(profile: string, steps: readonly BrowserStep[], signal: AbortSignal): Promise<BrowserSnapshot>;
    evaluate(profile: string, expression: string, signal: AbortSignal): Promise<Json>;
    screenshot(profile: string, signal: AbortSignal): Promise<Uint8Array>;
    /**
     * A media file at `url` fetched in the profile's session (its sign-ins) and stored as `FilesPort.download` stores one:
     * classified by its first bytes, streamed into t…

The browsing facility the built-in browser_* tools drive. Each profile is one browser of its own, its sign-ins and site data kept between calls: a person's id, or the release's run profile prefix + <run id>:<inference id> for one inference of a run. Pages answer as text with a ref on every control; a PDF answers its extracted text, page by page.

成员

名称类型说明
open(profile: string, signal: AbortSignal) => Promise<void>

Open the profile's isolated tab. A failed open is an error, and close must release any partial resources.

navigate(profile: string, to: BrowserTarget, find: string | undefined, signal: AbortSignal, viewport?: BrowserViewport) => Promise<BrowserSnapshot>
open_workspace?((profile: string, target: BrowserWorkspaceTarget, caller: BrowserCaller, signal: AbortSignal) => Promise<BrowserSnapshot>) | undefined

Open a page of the workspace as the person, signed in by the host's hand-off: the internal half of browser. A host that cannot sign its browser in omits it, and the agent is not offered workspace pages.

close(profile: string, signal: AbortSignal) => Promise<void>

Close this profile's tab and release its page resources; its sealed sign-ins stay for the next open.

snapshot(profile: string, options: { find?: string; from?: number; }, signal: AbortSignal) => Promise<BrowserSnapshot>
act(profile: string, steps: readonly BrowserStep[], signal: AbortSignal) => Promise<BrowserSnapshot>
evaluate(profile: string, expression: string, signal: AbortSignal) => Promise<Json>
screenshot(profile: string, signal: AbortSignal) => Promise<Uint8Array>
download(profile: string, url: string, signal: AbortSignal) => Promise<Downloaded>

A media file at url fetched in the profile's session (its sign-ins) and stored as FilesPort.download stores one: classified by its first bytes, streamed into the store, never held whole.

源码: packages/host-api/src/browser.ts:60

BrowserSnapshot type

type BrowserSnapshot = typeof BrowserSnapshotSchema.Type;

The readable page and its control refs (BrowserSnapshotSchema).

成员

名称类型说明
urlSchema.String
titleSchema.NullOr<Schema.String>
textSchema.String

源码: packages/host-api/src/browser.ts:19

BrowserSnapshotSchema const

const BrowserSnapshotSchema: Schema.StructWithRest<Schema.Struct<{ readonly url: Schema.String; readonly title: Schema.NullOr<Schema.String>; readonly text: Schema.String; }>, readonly [Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>]>

The readable page and its control refs, with host-provided page metadata retained.

源码: packages/host-api/src/browser.ts:14

BrowserStep type

type BrowserStep = typeof BrowserStepSchema.Type;

One action on a ref from the current snapshot (BrowserStepSchema).

源码: packages/host-api/src/browser.ts:32

BrowserStepSchema const

const BrowserStepSchema: Schema.Union<readonly [Schema.Struct<{ readonly click: Schema.String; }>, Schema.Struct<{ readonly type: Schema.Struct<{ readonly ref: Schema.String; readonly text: Schema.String; readonly submit: Schema.optionalKey<Schema.Boolean>; }>; }>, Schema.Struct<{ readonly select: Schema.Struct<{ readonly ref: Schema.String; readonly value: Schema.String; }>; }>, Schema.Struct<{ readonly press: Schema.String; }>, Schema.Struct<{ readonly hover: Schema.String; }>, Schema.Struct<{ readonly scroll: Schema.Struct<{ readonly ref: Schema.optionalKey<Schema.String>; readonly y: Schema.optionalKey<Schema.Fin…

One action on a ref from the current snapshot.

源码: packages/host-api/src/browser.ts:22

BrowserTarget type

type BrowserTarget = {
    readonly url: string;
} | {
    readonly go: 'back' | 'forward' | 'reload';
};

Where the agent's browser goes: a page, or back, forward or a reload of the one open.

源码: packages/host-api/src/browser.ts:35

BrowserViewport type

type BrowserViewport = {
    width: number;
    height: number;
    device_scale_factor?: number;
};

The page's own CSS size and pixel density: what the person's browser would lay out at.

成员

名称类型说明
widthnumber
heightnumber
device_scale_factor?number

源码: packages/host-api/src/browser.ts:38

BrowserWorkspaceTarget type

type BrowserWorkspaceTarget = {
    readonly environment: string;
    readonly path?: string;
    readonly device?: 'desktop' | 'tablet' | 'phone';
};

A workspace page the agent's browser opens: live, or a preview environment by its name.

成员

名称类型说明
environmentstring
path?string
device?'desktop' | 'tablet' | 'phone'

源码: packages/host-api/src/browser.ts:44

facilities

BundleRequest type

type BundleRequest = {
    /** sha256 hex of the sorted `<path>\0<sha256 hex of its bytes>` lines, `\n`-joined. */
    readonly digest: string;
    readonly entry: string;
    readonly files: readonly (readonly [path: string, bytes: Uint8Array])[];
};

A file run's tree (a skill's folder): its digest, the entry's path in it, and every file by its path in the tree.

成员

名称类型说明
digeststring

sha256 hex of the sorted <path>\0<sha256 hex of its bytes> lines, \n-joined.

entrystring
filesreadonly (readonly [path: string, bytes: Uint8Array])[]

源码: packages/host-api/src/facilities.ts:312

Bundled type

type Bundled = {
    readonly code: string;
    readonly map: string;
} | {
    readonly errors: readonly string[];
};

One ES module that imports nothing, with its source map (sources are tree paths), or the errors that stopped it, each file:line:column: message and the line. The module's default export is { run(input) }, which calls globalThis[Symbol.for('norbital.node')].run(input, load) with load evaluating the entry; each Node built-in a run provides (fs, fs/promises, path, buffer, process, util) is …builtin(name), and a require that does not resolve throws when called, naming the requirer.

源码: packages/host-api/src/facilities.ts:325

BundlerPort interface

interface BundlerPort {
    bundle(request: BundleRequest, signal: AbortSignal): Promise<Bundled>;
}

The confined bundler ("Running a file"): the host resolves the entry's imports inside the tree by Node's rules and bundles them in a confined process that serves one tenant, caching by (digest, entry, bundler version).

成员

名称类型说明
bundle(request: BundleRequest, signal: AbortSignal) => Promise<Bundled>

源码: packages/host-api/src/facilities.ts:331

membrane

CELL_ABI_VERSION const

const CELL_ABI_VERSION: 1

The kernel refuses a cell whose number differs from its own.

源码: packages/host-api/src/membrane.ts:20

facilities

CONVERT_MIME const

const CONVERT_MIME: Record<"pdf" | "docx" | "pptx" | "odt" | "epub" | "html", string>

Each conversion target's media type.

源码: packages/host-api/src/facilities.ts:76

CONVERT_TARGETS const

const CONVERT_TARGETS: readonly ["pdf", "docx", "pptx", "odt", "epub", "html"]

Every conversion target, in the order hosts report them.

源码: packages/host-api/src/facilities.ts:72

integrations

CalendarEvent type

type CalendarEvent = {
    readonly id: string;
    readonly summary: string | null;
    readonly description: string | null;
    readonly location: string | null;
    readonly url: string | null;
    readonly status: 'confirmed' | 'tentative' | 'cancelled';
    readonly start: CalendarTime;
    readonly end: CalendarTime;
    /** Original provider event, including attendees, recurrence and identifiers needed by authored business rules. */
    readonly source: Json;
};

One event a calendar driver pushes to a sync's read (items); the read's partition is its calendar (a sync's partitions names the text-many configuration field listing them, one cursor each). A changed calendar wakes its partition; lost history (retained: false) starts a fresh snapshot. All-day events keep their dates, timed events their instants and source zones.

成员

名称类型说明
idstring
summarystring | null
descriptionstring | null
locationstring | null
urlstring | null
status'confirmed' | 'tentative' | 'cancelled'
startCalendarTime
endCalendarTime
sourceJson

Original provider event, including attendees, recurrence and identifiers needed by authored business rules.

源码: packages/host-api/src/integrations.ts:649

host

CarriedMigration const

const CarriedMigration: Schema.Struct<{ readonly path: Schema.String; readonly target: Schema.String; readonly text: Schema.optionalKey<Schema.String>; readonly merge: Schema.optionalKey<Schema.Struct<{ readonly base: Schema.String; readonly ours: Schema.String; readonly theirs: Schema.String; }>>; readonly clashes: Schema.$Array<Schema.String>; readonly snapshot: Schema.String; readonly lock: Schema.String; readonly at: Schema.Number; }>

One of the author's migrations set on top of live: path the author's, target its place after live's. Its file is text, or, where the author edited what the generator wrote, the host's three-way merge of merge.theirs (the author's file) from merge.base (what the generator wrote them) onto merge.ours (what it writes on live). clashes say, in plain words, why it must stop for the author. snapshot and lock are the migrations/ files after it, and at the line's commit that brought it.

源码: packages/host-api/src/host.ts:492

cell

CellEnd type

type CellEnd = {
    /** HOST_API in its wire form; `cookie_site` is its two answers, `[insecure, secure]`. */
    readonly api: unknown;
    /** One membrane message from the kernel. */
    readonly receive: (message: unknown) => Answer;
    /** A timer the kernel fired. */
    readonly fire: (timer: number) => void;
};

What open answers: the marshalled HOST_API, and the cell's two entries.

成员

名称类型说明
apiunknown

HOST_API in its wire form; cookie_site is its two answers, [insecure, secure].

receive(message: unknown) => Answer

One membrane message from the kernel.

fire(timer: number) => void

A timer the kernel fired.

源码: packages/host-api/src/cell.ts:17

facilities

Challenge interface

interface Challenge {
    readonly site_key: string;
    verify(token: string, ip: string, signal: AbortSignal): Promise<boolean>;
}

Turnstile-style bot protection: the public site key the widget renders, and the server-side check.

成员

名称类型说明
site_keystring
verify(token: string, ip: string, signal: AbortSignal) => Promise<boolean>

源码: packages/host-api/src/facilities.ts:236

conformance

Check type

type Check = {
    readonly name: string;
    readonly run: () => Promise<void>;
};

One conformance check: its name, and the Promise that rejects with why the release fails it.

成员

名称类型说明
namestring
run() => Promise<void>

源码: packages/host-api/src/conformance.ts:18

diagnostic

CheckDiagnostic type

type CheckDiagnostic = {
    -readonly [K in keyof typeof Diagnostic.Type]: (typeof Diagnostic.Type)[K];
};

An author error as Studio shows it (Diagnostic), mutable for the checker that fills it.

源码: packages/host-api/src/diagnostic.ts:13

client

ClientPage type

type ClientPage = {
    readonly file: string;
    readonly document: boolean;
    readonly headers: {
        readonly [name: string]: string;
    };
};

What a host answers at a path of a workspace's pages: the file to send and its headers.

成员

名称类型说明
filestring
documentboolean
headers{ readonly [name: string]: string; }

源码: packages/host-api/src/client.ts:34

facilities

ConvertPort interface

interface ConvertPort {
    readonly targets: readonly ConvertTarget[];
    convert(source: ConvertSource, to: ConvertTarget, options: PreviewPdfOptions & {
        reference?: Uint8Array;
    }, signal: AbortSignal): Promise<Uint8Array>;
    /** Renders in memory without retaining source or result in a job or file store. */
    preview_pdf?(source: ConvertSource, options: PreviewPdfOptions, signal: AbortSignal): Promise<Uint8Array>;
    ingest?(file: {
        sha256: string;
        name: string;
        mime: string;
        /** Bytes the caller holds, or else `key`: a stored file the host reads, so nothing large crosses into a cell. */
        bytes?: Uint8Array | ReadableStream<Uint8Array>;
        key?: string;
        /** Whose it is: a burst of one tenant's files waits behind that tenant's own. */
        lane?: string;
    }, options: IngestOptions, signal: AbortSignal): Promise<Ingested | {
        readonly unsupported: string;
    }>;
}

The document converter behind ctx.convert.document (optional; absent → unavailable). targets is what this host serves, checked at start against workspace.convert.to. reference is the bytes of a styling document (docx, pptx, odt). ingest reads one file to Ingested for the agent's read_file and ctx.convert.ingest, or answers unsupported (the format has no parser: CAD); absent, neither ingests. A video container is heard from its audio track; a converter without a transcription model rejects audio as unavailable.

成员

名称类型说明
targetsreadonly ConvertTarget[]
convert(source: ConvertSource, to: ConvertTarget, options: PreviewPdfOptions & { reference?: Uint8Array; }, signal: AbortSignal) => Promise<Uint8Array>
preview_pdf?((source: ConvertSource, options: PreviewPdfOptions, signal: AbortSignal) => Promise<Uint8Array>) | undefined

Renders in memory without retaining source or result in a job or file store.

ingest?((file: { sha256: string; name: string; mime: string; bytes?: Uint8Array | ReadableStream<Uint8Array>; key?: string; lane?: string; }, options: IngestOptions, signal: AbortSignal) => Promise<Ingested | { readonly unsupported: string; }>) | undefined

源码: packages/host-api/src/facilities.ts:120

ConvertSource type

type ConvertSource = {
    readonly markdown: string;
} | {
    readonly html: string;
} | {
    readonly layout_html: string;
};

The source of a conversion: Markdown (pandoc's dialect, with pipe tables and front matter) or an HTML document. HTML is read for its structure (headings, tables, images, emphasis); its CSS does not carry into the output, and a PDF is typeset by Typst.

源码: packages/host-api/src/facilities.ts:95

ConvertTarget type

type ConvertTarget = (typeof CONVERT_TARGETS)[number];

A document format the converter can produce.

源码: packages/host-api/src/facilities.ts:74

host

CronEntry type

type CronEntry = {
    readonly id: string;
    readonly cron: string;
    readonly zone: string;
};

One cron the manifest declares: an automation's (id its name) or a remote sync's periodic read.

成员

名称类型说明
idstring
cronstring
zonestring

源码: packages/host-api/src/host.ts:287

CronFired type

type CronFired = {
    readonly ran: boolean;
    readonly until?: string;
};

ran: false: a repeat of (id, slot), a run that only read and wrote nothing, or a resting cron. until: the cron rests, and while the workspace is not in use the host need not fire it before this instant.

成员

名称类型说明
ranboolean
until?string

源码: packages/host-api/src/host.ts:292

integrations

DATABASE_MAX_BYTES const

const DATABASE_MAX_BYTES: number

Most JSON bytes a database result may carry (the crossing limit); more fails overflow.

源码: packages/host-api/src/integrations.ts:626

DATABASE_MAX_ROWS const

const DATABASE_MAX_ROWS: 1000

Default most rows a database result may carry; more fails overflow, never a truncation.

源码: packages/host-api/src/integrations.ts:624

system-1

DECISION_CALL_MS const

const DECISION_CALL_MS: 3000

System 1's wall: one decision call, at most 3 s (DECISION_LIMITS.call_ms).

源码: packages/host-api/src/system-1.ts:86

ai

DECISION_LIMITS const

const DECISION_LIMITS: { readonly call_ms: 3000; readonly max_images: 16; readonly max_image_bytes: number; readonly max_choices: 255; readonly min_score_levels: 1; readonly max_score_levels: 10; readonly openai_max_questions: 400; readonly openai_min_options: 2; }

Authoritative bounds for one System 1 (sys_1) decision call: wall timeout, inline image budget, question/option cardinalities, and provider-specific caps.

成员

名称类型说明
call_ms3000

Maximum wall time for one sys_1 call in milliseconds (3 s).

max_images16

Maximum number of inline PNG/JPEG images allowed inside state.

max_image_bytesnumber

Maximum combined decoded byte size of inline images inside state (20 MiB).

max_choices255

Maximum choices per choice question on the native Jev Decisions API.

min_score_levels1

Minimum criterion levels for a score question.

max_score_levels10

Maximum criterion levels for a score question.

openai_max_questions400

Maximum questions per call on the OpenAI /v1/decisions wire format.

openai_min_options2

Minimum choices/levels per question on the OpenAI /v1/decisions wire format.

源码: packages/host-api/src/ai.ts:61

media

DOWNLOAD const

const DOWNLOAD: { readonly maxBytes: number; readonly idleMs: 20000; readonly redirects: 5; readonly headBytes: 4096; }

download's limits: the body cap, the stall that ends it, the redirect hops followed, and the head its type is read from.

成员

名称类型说明
maxBytesnumber
idleMs20000
redirects5
headBytes4096

源码: packages/host-api/src/media.ts:107

integrations

DatabaseDriver interface

interface DatabaseDriver {
    query(credential: Json, request: DatabaseRequest, signal: AbortSignal): Promise<DatabaseResult>;
}

A host's database driver (a request-only link's implementation); it must not expose its connection in answers or errors.

成员

名称类型说明
query(credential: Json, request: DatabaseRequest, signal: AbortSignal) => Promise<DatabaseResult>

源码: packages/host-api/src/integrations.ts:628

DatabaseRequest const

const DatabaseRequest: Schema.Union<readonly [Schema.Struct<{ readonly max_rows: Schema.optionalKey<Schema.Int>; readonly transaction: Schema.optionalKey<Schema.Literal<"serializable">>; readonly op: Schema.Literal<"values">; readonly values: Schema.$Record<Schema.NonEmptyString, Schema.Union<readonly [Schema.String, Schema.Finite, Schema.Boolean, Schema.Null]>>; }>, Schema.Struct<{ readonly max_rows: Schema.optionalKey<Schema.Int>; readonly transaction: Schema.optionalKey<Schema.Literal<"serializable">>; readonly op: Schema.Literal<"read">; readonly table: Schema.Struct<{ readonly schema: Schema.NonEmptyString; re…

Schema of one structured database program a guest sends through a database link (today the SQL Server shape): values, read, call, CDC metadata and pages, and insert_once. The workspace names qualified tables, projected columns, filters, decimal/date formats and its delete policy; the host compiles the native SQL. CDC pages reconcile current rows and tombstones from an inclusive LSN/sequence/operation/key cursor. insert_once takes an immutable key and fingerprint, a five-second native lock and one serializable header/child/procedure batch, and answers an exact receipt; call names a procedure with typed arguments over native RPC. Cancellation, row and byte bounds, TLS identity and network admission apply to every program.

示例

yield* ctx.request(erp, { op: 'read', table: { schema: 'accounting', name: 'products' }, columns: ['code', 'name'],
	where: { active: true }, max_rows: 100 });

源码: packages/host-api/src/integrations.ts:616

DatabaseResult const

const DatabaseResult: Schema.Struct<{ readonly rows: Schema.$Array<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>; }>

Schema of a database link's answer: its rows as JSON column maps.

源码: packages/host-api/src/integrations.ts:619

db

DbBatch type

type DbBatch = {
    readonly statements: readonly Sql[];
    readonly lock?: Lock;
    /** Native dry-run: execute and answer the statements, then roll back all of their effects. */
    readonly rollback?: true;
};

Complete database work, prepared before a connection is acquired; no application callback runs inside it.

成员

名称类型说明
statementsreadonly Sql[]
lock?Lock
rollback?true

Native dry-run: execute and answer the statements, then roll back all of their effects.

源码: packages/host-api/src/db.ts:21

errors

DbError class

class DbError extends DbError_base {
    static make(...args: [sqlstate: string, message: string, constraint?: string, column?: string]): DbError;
    /** The Schema class's own form (`new DbError(props)`), which the static side keeps. */
    static make(...args: [props: DbErrorProps, options?: Schema.MakeOptions]): DbError;
}

What a Postgres adapter fails with: the SQLSTATE and constraint the write compiler maps to a refusal.

成员

名称类型说明
messagestring
sqlstateSchema.String
outcome_unknown?Schema.optionalKey<Schema.Literal<true>>
constraint?Schema.optional<Schema.String>
column?Schema.optional<Schema.String>

源码: packages/host-api/src/errors.ts:51

deadline-timer

DeadlineCompletion type

type DeadlineCompletion = {
    readonly callbackAtEpochMs: number | null | undefined;
    readonly mergeAnnouncements: boolean;
};

What a wake answers: its next deadline in epoch milliseconds (none when absent), and whether a deadline announced during the wake still counts, the earlier one winning.

成员

名称类型说明
callbackAtEpochMsnumber | null | undefined
mergeAnnouncementsboolean

源码: packages/host-api/src/deadline-timer.ts:12

DeadlineEntry type

type DeadlineEntry<Subject> = {
    readonly key: string;
    readonly subject: Subject;
    readonly at: number;
};

One armed deadline: its key, the subject it wakes and its instant in epoch milliseconds.

成员

名称类型说明
keystring
subjectSubject
atnumber

源码: packages/host-api/src/deadline-timer.ts:6

DeadlineTimer const

const DeadlineTimer: { make: <Subject, R = never>(callbacks: { readonly wake: (entry: DeadlineEntry<Subject>) => Effect.Effect<DeadlineCompletion, never, R>; readonly pulse: (entry: DeadlineEntry<Subject>) => Effect.Effect<boolean, never, R>; }) => Effect.Effect<DeadlineTimer<Subject>, never, Scope.Scope | R>; }

One clock timer; a due announcement during a wake signals its owner instead of starting another wake.

成员

名称类型说明
make<Subject, R = never>(callbacks: { readonly wake: (entry: DeadlineEntry<Subject>) => Effect.Effect<DeadlineCompletion, never, R>; /** False hands the notification back to the next wake, without spinning while the current one closes. */ readonly pulse: (entry: DeadlineEntry<Subject>) => Effect.Effect<boolean, never, R>; }) => Effect.Effect<DeadlineTimer<Subject>, never, Scope.Scope | R>

源码: packages/host-api/src/deadline-timer.ts:16

facilities

DeadlinesPort interface

interface DeadlinesPort {
    announce(scope: string, notLaterThan: string): Promise<void>;
    settle(scope: string, nextDue: string | null): Promise<void>;
    teardown(scope: string): Promise<void>;
}

One next-due instant per scope, held in host memory; no polling.

成员

名称类型说明
announce(scope: string, notLaterThan: string) => Promise<void>
settle(scope: string, nextDue: string | null) => Promise<void>
teardown(scope: string) => Promise<void>

源码: packages/host-api/src/facilities.ts:243

ai

DecisionAnswer type

type DecisionAnswer = typeof DecisionAnswerSchema.Type;

One System 1 answer to a question: a noul probability, a choice or a score, each with its probabilities.

源码: packages/host-api/src/ai.ts:160

DecisionAnswerSchema const

const DecisionAnswerSchema: Schema.Union<readonly [Schema.Struct<{ readonly type: Schema.Literal<"noul">; readonly noul: Schema.Finite; }>, Schema.Struct<{ readonly type: Schema.Literal<"choice">; readonly choice: Schema.String; readonly confidence: Schema.Finite; readonly probabilities: Schema.$Record<Schema.String, Schema.Finite>; }>, Schema.Struct<{ readonly type: Schema.Literal<"score">; readonly score: Schema.Finite; readonly level: Schema.Int; readonly confidence: Schema.Finite; readonly probabilities: Schema.$Record<Schema.String, Schema.Finite>; readonly legend: Schema.$Record<Schema.String, Schema.Union<readonl…

Schema of one System 1 answer: noul probability in [0, 1], choice with winning key and normalized distribution, or score with expected value, 0-based winning level index (mapped to the criterion value at the guest boundary), distribution, and legend.

源码: packages/host-api/src/ai.ts:142

DecisionEntrySchema const

const DecisionEntrySchema: Schema.Union<readonly [Schema.String, Schema.Null, Schema.$Array<Schema.Codec<Schema.Json, Schema.Json, never, never>>, Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>]>

Structured entry in a System 1 question or criterion: string, null, JSON array, or JSON object.

源码: packages/host-api/src/ai.ts:82

DecisionQuestionSchema const

const DecisionQuestionSchema: Schema.Union<readonly [Schema.Struct<{ readonly type: Schema.Literal<"noul">; readonly instructions: Schema.optionalKey<Schema.Union<readonly [Schema.String, Schema.Null, Schema.$Array<Schema.Codec<Schema.Json, Schema.Json, never, never>>, Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>]>>; readonly criteria: Schema.optionalKey<Schema.NullOr<Schema.Struct<{ readonly true: Schema.optionalKey<Schema.Union<readonly [Schema.String, Schema.Null, Schema.$Array<Schema.Codec<Schema.Json, Schema.Json, never, never>>, Schema.$Record<Schema.String, Schema.Codec<Schema…

One typed System 1 question: noul (binary probability), choice (categorical), or score (1–10 ordinal levels).

源码: packages/host-api/src/ai.ts:95

DecisionRequest type

type DecisionRequest = typeof DecisionRequestSchema.Type;

One System 1 call (DecisionRequestSchema): the state it reads and its questions by key.

成员

名称类型说明
stateSchema.Union<readonly [Schema.String, Schema.$Array<Schema.Codec<Schema.Json, Schema.Json, never, never>>, Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>]>
questionsSchema.$Record<Schema.String, Schema.Union<readonly [Schema.Struct<{ readonly type: Schema.Literal<"noul">; readonly instructions: Schema.optionalKey<Schema.Union<readonly [Schema.String, Schema.Null, Schema.$Array<Schema.Codec<Schema.Json, Schema.Json, never, never>>, Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>]>>; readonly criteria: Schema.optionalKey<Sch…

源码: packages/host-api/src/ai.ts:136

DecisionRequestSchema const

const DecisionRequestSchema: Schema.Struct<{ readonly state: Schema.Union<readonly [Schema.String, Schema.$Array<Schema.Codec<Schema.Json, Schema.Json, never, never>>, Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>]>; readonly questions: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.Struct<{ readonly type: Schema.Literal<"noul">; readonly instructions: Schema.optionalKey<Schema.Union<readonly [Schema.String, Schema.Null, Schema.$Array<Schema.Codec<Schema.Json, Schema.Json, never, never>>, Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>…

One System 1 decision request: shared state (JSON/text plus resolved inline PNG/JPEG images) and a non-empty map of independent questions. Intended for fixed-set classification, triage, routing, predicates, and ordinal scoring — never free-form or recursive AST generation (use sys_2.infer for that).

源码: packages/host-api/src/ai.ts:129

DecisionResult const

const DecisionResult: Schema.Struct<{ readonly answers: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.Struct<{ readonly type: Schema.Literal<"noul">; readonly noul: Schema.Finite; }>, Schema.Struct<{ readonly type: Schema.Literal<"choice">; readonly choice: Schema.String; readonly confidence: Schema.Finite; readonly probabilities: Schema.$Record<Schema.String, Schema.Finite>; }>, Schema.Struct<{ readonly type: Schema.Literal<"score">; readonly score: Schema.Finite; readonly level: Schema.Int; readonly confidence: Schema.Finite; readonly probabilities: Schema.$Record<Schema.String, Schema.Finite>; rea…

Schema of a System 1 answer set: one answer per question key, with the provider, model, cost and token usage.

源码: packages/host-api/src/ai.ts:162

DecisionStateSchema const

const DecisionStateSchema: Schema.Union<readonly [Schema.String, Schema.$Array<Schema.Codec<Schema.Json, Schema.Json, never, never>>, Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>]>

Non-null shared evidence state for one System 1 decision call (text, JSON, and resolved inline PNG/JPEG images).

源码: packages/host-api/src/ai.ts:89

system-1

DecisionsApiConfig type

type DecisionsApiConfig = {
    /** Jev/OpenRouter by default; OpenAI native `/v1/decisions` uses its own wire format. */
    format?: DecisionsApiFormat;
    url: string;
    model: string;
    api_key: string;
    timeout_ms?: number | undefined;
};

Configuration for decisions_system_1: endpoint URL, wire format, default model, bearer key, and optional timeout wall.

成员

名称类型说明
format?DecisionsApiFormat

Jev/OpenRouter by default; OpenAI native /v1/decisions uses its own wire format.

urlstring
modelstring
api_keystring
timeout_ms?number | undefined

源码: packages/host-api/src/system-1.ts:235

DecisionsApiFormat type

type DecisionsApiFormat = 'jev' | 'openai';

Wire format spoken by an HTTP Decisions API endpoint (jev native wire or OpenAI /v1/decisions).

源码: packages/host-api/src/system-1.ts:233

integrations

DeliveryReport type

type DeliveryReport = {
    kind: (typeof REPORTED_KINDS)[number];
    at: string;
    provider: string;
    code?: string;
    reason?: string;
    permanent?: boolean;
    presumed?: boolean;
    approximate?: boolean;
    /** Bounded to 4 KB by the release. */
    raw?: Json;
};

What a provider reports about one message it sent, keyed by the provider_id its send returned.

成员

名称类型说明
kind(typeof REPORTED_KINDS)[number]
atstring
providerstring
code?string
reason?string
permanent?boolean
presumed?boolean
approximate?boolean
raw?Json

Bounded to 4 KB by the release.

源码: packages/host-api/src/integrations.ts:265

diagnostic

Diagnostic const

const Diagnostic: Schema.Struct<{ readonly code: Schema.String; readonly path: Schema.String; readonly line: Schema.optionalKey<Schema.Number>; readonly message: Schema.String; readonly help: Schema.optionalKey<Schema.String>; }>

An author error; line (1-based) when the checker names one.

源码: packages/host-api/src/diagnostic.ts:5

convert

DocumentConverter type

type DocumentConverter = {
    readonly targets: readonly ConvertTarget[];
    readonly convert: (source: ConvertSource, to: ConvertTarget, options: PreviewPdfOptions & {
        reference?: Uint8Array;
    }) => Effect.Effect<Uint8Array, PortFailure>;
    readonly previewPdf: (source: ConvertSource, options: PreviewPdfOptions) => Effect.Effect<Uint8Array, PortFailure>;
};

A converter as Effects: what a host adapts to its ConvertPort (convert, preview_pdf).

成员

名称类型说明
targetsreadonly ConvertTarget[]
convert(source: ConvertSource, to: ConvertTarget, options: PreviewPdfOptions & { reference?: Uint8Array; }) => Effect.Effect<Uint8Array, PortFailure>
previewPdf(source: ConvertSource, options: PreviewPdfOptions) => Effect.Effect<Uint8Array, PortFailure>

源码: packages/host-api/src/convert.ts:17

facilities

Downloaded type

type Downloaded = Blob & {
    name: string;
};

A media file the host fetched for a tool: classified by its bytes, stored, never run.

成员

名称类型说明
keystring
bytesnumber
sha256string
mimestring
namestring

源码: packages/host-api/src/facilities.ts:54

integrations

DriverEvent type

type DriverEvent = {
    kind: 'messages';
    messages: readonly Json[];
    history?: true;
    bins?: readonly Uint8Array[];
}
/** Await registration before sending when the provider chooses its message id before I/O. */
 | ({
    kind: 'outbound_ref';
} & OutboundReference) | {
    kind: 'delivery';
    provider_id: string;
    report: DeliveryReport;
} | {
    kind: 'clear';
    thread: string;
    before: string;
}
/** The sender is typing (`typing: true`) in `thread`: a held burst waits for the rest, up to its cap. */
 | {
    kind: 'presence';
    thread: string;
    typing: boolean;
} | {
    kind: 'invalidate';
    sync: string;
    partition: string;
};

What an instance's link hands the engine (integrations.receive): inbound conversation messages (each attachment { name, mime, bytes, bin? }, its bytes in bins at bin; history is a backfill nobody waits on), a provider's report on a message it sent (provider_id is what its send answered), a chat the account cleared or deleted (clear: every message of thread sent at or before before is tombstoned), or a pushing driver's changed sync partition (sync: '<model>.<sync>').

源码: packages/host-api/src/integrations.ts:286

DriverOpen type

type DriverOpen = {
    instance: string;
    /** The instance's integration definition, including its request and credential fields. */
    definition: IntegrationDefinition;
    /** Model read syncs using this instance's definition; `name` is `'<model>.sync.<sync>'`. */
    readonly syncs: readonly {
        readonly name: string;
        /** The configuration field whose values partition this sync, otherwise one default partition. */
        readonly partitions?: string;
    }[];
    /** A personal instance (an owner's own account): it syncs and never sends a message; a command may write back to it. */
    personal: boolean;
    configuration: Json;
    /** Frozen source import boundary; absent or null retains all history. */
    import_start?: ImportStart | null;
    /** This instance's own inbound URL, shown to the operator and registered with the provider where it can. */
    webhook_url: string;
    /**
     * The host's one OAuth redirect URI (`<public URL>/hooks/oauth/callback`), the same for every instance: register it
     * with the OAuth app once. Its callback reaches this link's `webhook` by the `state` it carries, minted by `state()`.
     */
    redirect_url: string;
    /**
     * A fresh, unguessable OAuth `state` that routes its callback back to this instance; the link still checks it is its
     * own. Asynchronous, as every call into the engine: the engine may be in another isolate.
     */
    state(): Promise<string>;
    /** Aborted when the link clos…

What the links manager hands a provider to open one instance's link. Credentials stay host-side, under the opener's epoch.

成员

名称类型说明
instancestring
definitionIntegrationDefinition

The instance's integration definition, including its request and credential fields.

syncsreadonly { readonly name: string; /** The configuration field whose values partition this sync, otherwise one default partition. */ readonly partitions?: string; }[]

Model read syncs using this instance's definition; name is '<model>.sync.<sync>'.

personalboolean

A personal instance (an owner's own account): it syncs and never sends a message; a command may write back to it.

configurationJson
import_start?ImportStart | null

Frozen source import boundary; absent or null retains all history.

webhook_urlstring

This instance's own inbound URL, shown to the operator and registered with the provider where it can.

redirect_urlstring

The host's one OAuth redirect URI (<public URL>/hooks/oauth/callback), the same for every instance: register it with the OAuth app once. Its callback reaches this link's webhook by the state it carries, minted by state().

state() => Promise<string>

A fresh, unguessable OAuth state that routes its callback back to this instance; the link still checks it is its own. Asynchronous, as every call into the engine: the engine may be in another isolate.

signalAbortSignal

Aborted when the link closes or is replaced.

fetchtypeof fetch

The fetch to reach the provider with (tests pass a fake).

tcpTcpPort

Raw TCP/TLS to the provider's servers (IMAP, SMTP), under the host's egress policy.

oauth_client(vendor?: OAuthVendor) => Promise<OAuthClient | undefined>

The OAuth client to grant with for vendor: the definition's own (oauth.client, oauth.secret, both set in the workspace's secrets), else the host's (LinkHost.oauth); undefined when neither is configured. Without a vendor, only the definition's own.

credentials{ load(): Promise<ReadonlyMap<string, Json>>; write(changes: ReadonlyMap<string, Json | null>): Promise<void>; }

The instance's credentials as they were when the link opened (provider is the manager's); a write is one fenced statement retried until it lands, and rejects for good once another link opened the instance (fenced) — for a request link, once another call wrote since this one read.

emit(e: DriverEvent) => Promise<void>

Into the engine: resolves after it committed; a rejection means "do not acknowledge", so the provider redelivers.

status(s: LinkStatus) => Promise<void>

The link moved; a durable state (connected, unpaired, error) lands on the instance row when it changed.

pairing(p: Pairing | null) => void

An ephemeral QR or code (or null once it is gone), streamed to the shell and never stored.

源码: packages/host-api/src/integrations.ts:474

DriverPage type

type DriverPage = {
    items: readonly Json[];
    cursor: Json;
    more: boolean;
    snapshot?: 'begin' | 'end';
    retained?: false;
    health?: {
        state: 'ready' | 'attention';
        code?: string;
        message?: string;
    };
};

A pushing driver's page of a sync partition: its items (the sync read's items), and the page facts a read page carries.

成员

名称类型说明
itemsreadonly Json[]
cursorJson
moreboolean
snapshot?'begin' | 'end'
retained?false
health?{ state: 'ready' | 'attention'; code?: string; message?: string; }

源码: packages/host-api/src/integrations.ts:308

ai

EmbedInput type

type EmbedInput = string | {
    readonly $file: {
        readonly name: string;
        readonly mime: string;
        readonly sha256: string;
        readonly bytes: Uint8Array;
    };
} | {
    readonly $stored: {
        readonly key: string;
        readonly name: string;
        readonly mime: string;
        readonly sha256: string;
        readonly bytes: number;
    };
};

Bytes supplied by a host, or a stored file the provider reads outside the cell.

源码: packages/host-api/src/ai.ts:201

EmbeddingsPort interface

interface EmbeddingsPort {
    /** `dimensions`: the vector length the caller stores (a model that truncates, Matryoshka-style, answers at it). */
    embed(inputs: readonly EmbedInput[], model: string, signal: AbortSignal, dimensions?: number): Promise<readonly (readonly number[])[]>;
}

Embeds text and files into vectors, one per input, with the model the caller names.

成员

名称类型说明
embed(inputs: readonly EmbedInput[], model: string, signal: AbortSignal, dimensions?: number) => Promise<readonly (readonly number[])[]>

dimensions: the vector length the caller stores (a model that truncates, Matryoshka-style, answers at it).

源码: packages/host-api/src/ai.ts:244

errors

FACILITY_KINDS const

const FACILITY_KINDS: readonly ["upstream", "timeout", "rate_limited", "invalid", "too_large", "unsupported"]

A facility failure's kinds: too_large and invalid pass a provider's own limit refusal through.

源码: packages/host-api/src/errors.ts:6

first-party

FIRST_PARTY_BUNFIG const

const FIRST_PARTY_BUNFIG: string

The bunfig.toml of every bun consumer of the set: template repositories, templates, the realm and Colony's fixtures.

源码: packages/host-api/src/first-party.ts:18

FIRST_PARTY_PACKAGES const

const FIRST_PARTY_PACKAGES: readonly ["@norbital-ai/app-shell", "@norbital-ai/bolt", "@norbital-ai/bolt-cli", "@norbital-ai/bolt-server", "@norbital-ai/host-api", "@norbital-ai/providers", "@norbital-ai/store", "@norbital-ai/ui"]

Every published @norbital-ai/* package.

源码: packages/host-api/src/first-party.ts:6

facilities

Facilities type

type Facilities = {
    readonly storage: {
        /** Tenant rows (run status and chat history included): the engine's SQL over the host's driver. */
        readonly database: HostTenantDb;
        /** Uploads and blobs. */
        readonly files: FilesPort;
    };
    readonly logs: {
        /** Runtime events; the host may drop entries under load. */
        readonly runtime: LogPort;
        /** The durable audit stream, outside the tenant database, surviving a tenant restore. */
        readonly audit: AuditPort;
    };
    readonly transactional: {
        /** Emailed codes and invitations: `send('email', message, signal)`. Mandatory for every host. */
        readonly mail: TransportPort;
        /** Texted invitations: `send('sms', message, signal)`. */
        readonly sms: Optional<TransportPort>;
        /** Sends and checks a mobile number's sign-in code. */
        readonly phone: Optional<PhoneVerifier>;
        /** Web and native push for inbox notices, over the environment's database (a gone subscription is deleted there). */
        readonly push: Optional<(database: HostTenantDb) => TransportPort>;
        /** Bot protection for public sign-up; with none, the host refuses strangers (except a local host). */
        readonly challenge: Optional<Challenge>;
        /** `true` on a local host: every sign-in code is `123456`; a deployed host's are random. */
        readonly fixed_codes: boolean;
    };
    readonly intelligence: {
        /** Fast structure…

Everything a host supplies to run a bundle.

Without a host file, Colony supplies them all (tethered, the default). A workspace's norbital.host.ts, or the file bolt dev --host=<file> names, serves it untethered (bolt dev, bolt-server): its default export is this record (satisfies Facilities), and an optional serving export adds the parts served around it ({@link Serving}). The host file never enters the release's source. Every key is required: off is the only way to leave an optional member out, and mail has none. Activation refuses a bundle whose recorded needs name a member left off, naming each one. The guest runner is no facility: each host owns its own (HostPorts.guests).

成员

名称类型说明
storage{ /** Tenant rows (run status and chat history included): the engine's SQL over the host's driver. */ readonly database: HostTenantDb; /** Uploads and blobs. */ readonly files: FilesPort; }
logs{ /** Runtime events; the host may drop entries under load. */ readonly runtime: LogPort; /** The durable audit stream, outside the tenant database, surviving a tenant restore. */ readonly audit: AuditPort; }
transactional{ /** Emailed codes and invitations: `send('email', message, signal)`. Mandatory for every host. */ readonly mail: TransportPort; /** Texted invitations: `send('sms', message, signal)`. */ readonly sms: Optional<TransportPort>; /** Sends and checks a mobile number's sign-in code. */ readonly phone: Optional<PhoneVerifier>; /** Web and native push for inbox notices, over the environment's database…
intelligence{ /** Fast structured decisions (`ctx.ai.sys_1.decide`, triage). */ readonly system1: Optional<AiPort['sys_1']>; /** The LLM (`ctx.ai.sys_2.infer`, agents). */ readonly system2: Optional<AiPort['sys_2']>; /** Multimodal embeddings (`ctx.ai.embed`). */ readonly embed: Optional<EmbeddingsPort>; }
ports{ /** The public URL under which the host routes `/hooks/integration/<instance>` and OAuth callbacks into the release. */ readonly webhooks: Optional<{ readonly public_url: string; }>; /** HTTP for APIs and OAuth, TCP/TLS for IMAP and SMTP, under the host's egress policy. */ readonly outbound: Optional<{ readonly http: HttpPort; readonly tcp: TcpPort; }>; }
keysKeysPort

The tenant's secrets key, held by the host (KeysPort).

源码: packages/host-api/src/facilities.ts:378

errors

FacilityFailure class

class FacilityFailure extends FacilityFailure_base {
    /** Refuses invalid facility input without changing the shared tagged error identity. */
    static invalid(message: string): FacilityFailure;
}

A failed facility call: its kind, message, HTTP status and optional provider retry delay.

成员

名称类型说明
kindSchema.Literals<readonly ["upstream", "timeout", "rate_limited", "invalid", "too_large", "unsupported"]>
messagestring
status?Schema.optional<Schema.Number>
retry_after_ms?Schema.optional<Schema.Finite>

The provider's minimum delay before another attempt.

源码: packages/host-api/src/errors.ts:15

host

Feedback type

type Feedback = {
    readonly text: string;
    /** Stored file references of what they attached, as an agent message carries them. */
    readonly files: readonly Json[];
    readonly route: string;
};

What a person sent from the shell's Feedback dialog: their words, the files they attached and the page they were on.

成员

名称类型说明
textstring
filesreadonly Json[]

Stored file references of what they attached, as an agent message carries them.

routestring

源码: packages/host-api/src/host.ts:129

errors

Fenced class

class Fenced extends Fenced_base {
}

Another link opened the instance since this one did (its epoch moved); terminal for the fenced link.

成员

名称类型说明
instanceSchema.String
messagestring

源码: packages/host-api/src/errors.ts:68

facilities

FilesPort interface

interface FilesPort {
    put(bytes: Uint8Array, meta: {
        name: string;
        mime: string;
    }, signal: AbortSignal): Promise<Blob>;
    /** At most `max` bytes; more is `invalid`, never a truncation. */
    get(key: string, max: number, signal: AbortSignal): Promise<Uint8Array>;
    url(key: string, expiresInS: number, signal: AbortSignal): Promise<string>;
    remove(key: string, signal: AbortSignal): Promise<void>;
    /**
     * Fetches a public http(s) URL under the host's egress policy (every redirect hop re-checked, at most 5) and stores
     * its body if its first bytes are media (image, audio, video, PDF); anything else is refused, never stored. The host
     * streams it (at most 100 MiB, 20 s without bytes ends it) and names it from the response or the URL.
     */
    download(url: string, signal: AbortSignal): Promise<Downloaded>;
}

The host's blob store behind ctx.files and the sys_file rows: put, bounded get, signed URL, remove and media download.

成员

名称类型说明
put(bytes: Uint8Array, meta: { name: string; mime: string; }, signal: AbortSignal) => Promise<Blob>
get(key: string, max: number, signal: AbortSignal) => Promise<Uint8Array>

At most max bytes; more is invalid, never a truncation.

url(key: string, expiresInS: number, signal: AbortSignal) => Promise<string>
remove(key: string, signal: AbortSignal) => Promise<void>
download(url: string, signal: AbortSignal) => Promise<Downloaded>

Fetches a public http(s) URL under the host's egress policy (every redirect hop re-checked, at most 5) and stores its body if its first bytes are media (image, audio, video, PDF); anything else is refused, never stored. The host streams it (at most 100 MiB, 20 s without bytes ends it) and names it from the response or the URL.

源码: packages/host-api/src/facilities.ts:56

answers

FounderAnswer const

const FounderAnswer: Schema.Union<readonly [Schema.TaggedStruct<"Founded", { readonly user: Schema.String; }>, Schema.TaggedStruct<"FounderRefused", { readonly code: Schema.String; readonly message: Schema.String; }>]>

founder.bootstrap: the first administrator, or the identity refusal (forbidden: one exists already).

源码: packages/host-api/src/answers.ts:54

facilities

GeoHit type

type GeoHit = {
    readonly point: Point;
    readonly label: string;
    readonly address: string;
};

A geocoding result: the point, a short label and the full address.

成员

名称类型说明
pointPoint
labelstring
addressstring

源码: packages/host-api/src/facilities.ts:164

GeocoderPort interface

interface GeocoderPort {
    search(query: string, signal: AbortSignal): Promise<readonly GeoHit[]>;
    reverse(point: Point, signal: AbortSignal): Promise<GeoHit | null>;
}

Finds places by text and names the place at a point.

成员

名称类型说明
search(query: string, signal: AbortSignal) => Promise<readonly GeoHit[]>
reverse(point: Point, signal: AbortSignal) => Promise<GeoHit | null>

源码: packages/host-api/src/facilities.ts:166

guest

GuestAnswers type

type GuestAnswers = {
    readonly ids: readonly number[];
    readonly texts: readonly string[];
    readonly bins: readonly (readonly Uint8Array[])[];
};

One batch's answers (give): call ids, one JSON text per call, and each call's bytes.

成员

名称类型说明
idsreadonly number[]
textsreadonly string[]
binsreadonly (readonly Uint8Array[])[]

源码: packages/host-api/src/guest.ts:57

GuestCall type

type GuestCall = readonly [member: string, args: string, site: string, id: number];

One queued ctx call: member, JSON arguments, call site (stack frame) and call id.

源码: packages/host-api/src/guest.ts:55

GuestFinal type

type GuestFinal = typeof GuestFinalSchema.Type;

A guest invocation's end state as the prelude reports it (GuestFinalSchema).

源码: packages/host-api/src/guest.ts:14

GuestFinalSchema const

const GuestFinalSchema: Schema.Union<readonly [Schema.Tuple<readonly [Schema.Literal<"ok">, Schema.String]>, Schema.Tuple<readonly [Schema.Literal<"refused">, Schema.String, Schema.NullOr<Schema.String>, Schema.NullOr<Schema.Int>, Schema.String]>, Schema.Tuple<readonly [Schema.Literal<"missing">, Schema.String]>, Schema.Tuple<readonly [Schema.Literal<"error">, Schema.String, Schema.String, Schema.String]>, Schema.Tuple<readonly [Schema.Literal<"error">, Schema.String, Schema.String, Schema.String, Schema.String]>]>

Values produced by the tenant-controlled prelude, decoded before the host or engine consumes them.

源码: packages/host-api/src/guest.ts:6

GuestIsolatesPort interface

interface GuestIsolatesPort {
    open(program: GuestProgram, options: GuestSessionOptions, signal: AbortSignal): Promise<string>;
    start(session: string, start: GuestStart, signal: AbortSignal): Promise<GuestTurn>;
    take(session: string, signal: AbortSignal): Promise<GuestTurn>;
    give(session: string, answers: GuestAnswers, signal: AbortSignal): Promise<GuestTurn>;
    close(session: string): Promise<void>;
}

Guest isolates, made and metered by the host. open evaluates prelude as an evalClosure body with the hooks $0 say (lines buffered for the turn), $1 random (from seed), $2 digest (crypto.subtle.digest's host half) and $3 asset (program.assets by sha256), then program.source as one module bound to __boltGuest; it answers an opaque session id. start and give run their prelude hook and then take(), take only take() (after a turn whose timer ran): each call is one native slice, under a CPU slot the host takes for it. A session past its unit's CPU budget or its memory ends and rejects with an encoded HostFailure of code cpu_budget or memory; an aborted call ends its session. close disposes it (idempotent).

成员

名称类型说明
open(program: GuestProgram, options: GuestSessionOptions, signal: AbortSignal) => Promise<string>
start(session: string, start: GuestStart, signal: AbortSignal) => Promise<GuestTurn>
take(session: string, signal: AbortSignal) => Promise<GuestTurn>
give(session: string, answers: GuestAnswers, signal: AbortSignal) => Promise<GuestTurn>
close(session: string) => Promise<void>

源码: packages/host-api/src/guest.ts:71

GuestProgram type

type GuestProgram = {
    source: string;
    source_map?: string;
    assets?: Readonly<Record<string, Uint8Array>>;
};

A compiled guest bundle the runner loads: its JavaScript source, optional source map and embedded assets.

成员

名称类型说明
sourcestring
source_map?string
assets?Readonly<Record<string, Uint8Array>>

源码: packages/host-api/src/guest.ts:32

GuestSessionOptions type

type GuestSessionOptions = {
    readonly prelude: string;
    /** `$1` draws SHA-256 blocks of it (`random_stream`), so a replay with the same seed draws the same values. */
    readonly seed: string;
    readonly memory_mib: number;
    /** A program run once (a `run_js` script): no spare isolates are prepared for it. */
    readonly once?: true;
};

A guest session's options: the prelude it evaluates first (the release's PRELUDE), its entropy and its heap.

成员

名称类型说明
preludestring
seedstring

$1 draws SHA-256 blocks of it (random_stream), so a replay with the same seed draws the same values.

memory_mibnumber
once?true

A program run once (a run_js script): no spare isolates are prepared for it.

源码: packages/host-api/src/guest.ts:38

GuestStart type

type GuestStart = {
    readonly kind: string;
    readonly path: readonly string[];
    readonly input: string;
    readonly ctx: string;
    readonly invocation: string;
};

The prelude's start(kind, path, inputJson, ctxJson, invocationId), by name; kind is the release's invocation kind.

成员

名称类型说明
kindstring
pathreadonly string[]
inputstring
ctxstring
invocationstring

源码: packages/host-api/src/guest.ts:47

GuestTaken const

const GuestTaken: Schema.Tuple<readonly [Schema.NullOr<Schema.Union<readonly [Schema.Tuple<readonly [Schema.Literal<"ok">, Schema.String]>, Schema.Tuple<readonly [Schema.Literal<"refused">, Schema.String, Schema.NullOr<Schema.String>, Schema.NullOr<Schema.Int>, Schema.String]>, Schema.Tuple<readonly [Schema.Literal<"missing">, Schema.String]>, Schema.Tuple<readonly [Schema.Literal<"error">, Schema.String, Schema.String, Schema.String]>, Schema.Tuple<readonly [Schema.Literal<"error">, Schema.String, Schema.String, Schema.String, Schema.String]>]>>, Schema.$Array<Schema.Tuple<readonly [Schema.String, Schema.Stri…

The prelude's take(): end state, the calls crossing now, each call's bytes ($bin), and whether a timer ran instead.

源码: packages/host-api/src/guest.ts:16

GuestTurn type

type GuestTurn = typeof GuestTurnSchema.Type;

One guest turn (GuestTurnSchema).

成员

名称类型说明
takenSchema.Tuple<readonly [Schema.NullOr<Schema.Union<readonly [Schema.Tuple<readonly [Schema.Literal<"ok">, Schema.String]>, Schema.Tuple<readonly [Schema.Literal<"refused">, Schema.String, Schema.NullOr<Schema.String>, Schema.NullOr<Schema.Int>, Schema.String]>, Schema.Tuple<readonly [Schema.Literal<"missing">, Schema.String]>, Schema.Tuple<readonly [Schema.Literal<"error">, Schema.String, Schema.S…
linesSchema.$Array<Schema.Tuple<readonly [Schema.String, Schema.String]>>
droppedSchema.Number

源码: packages/host-api/src/guest.ts:30

GuestTurnSchema const

const GuestTurnSchema: Schema.Struct<{ readonly taken: Schema.Tuple<readonly [Schema.NullOr<Schema.Union<readonly [Schema.Tuple<readonly [Schema.Literal<"ok">, Schema.String]>, Schema.Tuple<readonly [Schema.Literal<"refused">, Schema.String, Schema.NullOr<Schema.String>, Schema.NullOr<Schema.Int>, Schema.String]>, Schema.Tuple<readonly [Schema.Literal<"missing">, Schema.String]>, Schema.Tuple<readonly [Schema.Literal<"error">, Schema.String, Schema.String, Schema.String]>, Schema.Tuple<readonly [Schema.Literal<"error">, Schema.String, Schema.String, Schema.String, Schema.String]>]>>, Schema.$Array<Schema.Tuple<read…

Schema of one guest turn: what the prelude's take() answered, the log lines it wrote and how many it dropped.

源码: packages/host-api/src/guest.ts:24

version

HOST_API_VERSION const

const HOST_API_VERSION: 1

The HOST_API this package describes.

源码: packages/host-api/src/version.ts:5

facilities

HOST_LIMITS const

const HOST_LIMITS: { readonly guestCpuMs: 3000; readonly guestMemoryMiB: 256; readonly argsBytes: number; readonly storedFileBytes: number; readonly crossingBytes: number; readonly callMs: { readonly database: 20000; readonly ai: 20000; readonly tool: 20000; readonly http: 20000; readonly web: 20000; readonly image: 20000; readonly other: 20000; readonly ingest: 600000; readonly attachment: 20000; readonly render: 60000; }; }

The walls a host enforces for a release: a unit's guest CPU and heap, the request bodies it reads and each I/O call's wall.

成员

名称类型说明
guestCpuMs3000

One unit's guest CPU: Colony's meter budget, so the kit and dev refuse what a deployed host refuses.

guestMemoryMiB256
argsBytesnumber

One call's arguments.

storedFileBytesnumber

One stored file.

crossingBytesnumber

One crossing's answer. 8 MiB fits a large jurisdiction's payroll admission while staying far below a cell's heap.

callMs{ readonly database: 20000; readonly ai: 20000; readonly tool: 20000; readonly http: 20000; readonly web: 20000; readonly image: 20000; readonly other: 20000; /** One Convert job (`ctx.convert.ingest`): a long recording's transcription takes minutes. */ readonly ingest: 600000; readonly attachment: 20000; /** One record printed by the host's browser (`ctx.convert.record`): the page loads, its rea…

Per I/O response, never per invocation. Streaming model responses reset their idle deadline on progress; a multi-step inference keeps its separate whole-call ceiling.

源码: packages/host-api/src/facilities.ts:20

host

HostApi type

type HostApi = HostApiCore & {
    /** Whether a request may run a guest body, so the host admits only these under its compute envelope. */
    needs_guest(request: Request): Promise<boolean>;
    readonly schema: {
        /** The schema state the release plans from (what a successor's plan is diffed against). */
        slice(release: Release, options: Signal): Promise<SchemaSlice>;
        /** The destructive steps planning `release` over `applied` (another release's `slice`) would take. */
        destructive(applied: SchemaSlice, release: Release, options: Signal): Promise<readonly string[]>;
        /**
         * An author's migrations set on top of live's, with this release's generator: a merged migration stays byte for
         * byte, the author's are renumbered after it and written again from live's schema. Rejects when nothing can be
         * written (an unreadable snapshot, a rename of something live dropped).
         */
        carry(input: MigrationCarry, options: Signal): Promise<readonly CarriedMigration[]>;
    };
    /**
     * Applies the artifact's verified migration files (checksummed, one transaction each under the `bolt:schema`
     * advisory lock, ledger and receipt committed with the file) and activates the release. Refuses a bundle whose
     * recorded needs name a facility left `off`, live schema drift from the verified lock (even when every applied
     * checksum matches), and a database with no migration ledger: an existing schema is never…

The versioned boundary a host drives one release through: Promise + AbortSignal calls with Schema JSON answers, so hosts and releases on different module graphs interoperate.

成员

名称类型说明
guest_execution'source'

Hosts admit only runtimes that evaluate tenant source without restoring native snapshots.

versionnumber

The HOST_API the release speaks.

contractstring

The artifact contract this release implements.

cookies{ readonly session: string; readonly preview: string; }
cookie_site(secure: boolean) => string

The session cookie's site attributes.

verify(release: Release, options: Signal) => Promise<void>

Refuses an artifact this release did not build or whose files do not match their digests.

describe(release: Release, options: Signal) => Promise<ReleaseFacts>

What the release says about itself, decoded by its own Bolt (ReleaseFacts).

frame_policy(release: Release, path: string, options: Signal) => Promise<string>

The client page's content security policy for path: frame-ancestors and img-src.

needs_guest(request: Request) => Promise<boolean>

Whether a request may run a guest body, so the host admits only these under its compute envelope.

schema{ /** The schema state the release plans from (what a successor's plan is diffed against). */ slice(release: Release, options: Signal): Promise<SchemaSlice>; /** The destructive steps planning `release` over `applied` (another release's `slice`) would take. */ destructive(applied: SchemaSlice, release: Release, options: Signal): Promise<readonly string[]>; /** * An author's migrations set on top …
activate(ports: HostPorts, options: Signal) => Promise<ActiveWorkspace>

Applies the artifact's verified migration files (checksummed, one transaction each under the bolt:schema advisory lock, ledger and receipt committed with the file) and activates the release. Refuses a bundle whose recorded needs name a facility left off, live schema drift from the verified lock (even when every applied checksum matches), and a database with no migration ledger: an existing schema is never adopted.

branch(ports: BranchPorts, options: Signal) => Promise<WorkspaceBranch>
links(host: LinkHost, options: Signal) => Promise<WorkspaceLinks>

源码: packages/host-api/src/host.ts:509

ports

HostApiCore type

type HostApiCore = {
    /** Hosts admit only runtimes that evaluate tenant source without restoring native snapshots. */
    readonly guest_execution: 'source';
    /** The HOST_API the release speaks. */
    readonly version: number;
    /** The artifact contract this release implements. */
    readonly contract: string;
    readonly cookies: {
        readonly session: string;
        readonly preview: string;
    };
    /** The session cookie's site attributes. */
    cookie_site(secure: boolean): string;
    /** Refuses an artifact this release did not build or whose files do not match their digests. */
    verify(release: Release, options: Signal): Promise<void>;
    /** What the release says about itself, decoded by its own Bolt (`ReleaseFacts`). */
    describe(release: Release, options: Signal): Promise<ReleaseFacts>;
    /** The client page's content security policy for `path`: `frame-ancestors` and `img-src`. */
    frame_policy(release: Release, path: string, options: Signal): Promise<string>;
};

What every release answers, whatever its Bolt: the version and contract a host admits it by, its cookies, and the static calls over a release. A release's full HostApi extends it.

成员

名称类型说明
guest_execution'source'

Hosts admit only runtimes that evaluate tenant source without restoring native snapshots.

versionnumber

The HOST_API the release speaks.

contractstring

The artifact contract this release implements.

cookies{ readonly session: string; readonly preview: string; }
cookie_site(secure: boolean) => string

The session cookie's site attributes.

verify(release: Release, options: Signal) => Promise<void>

Refuses an artifact this release did not build or whose files do not match their digests.

describe(release: Release, options: Signal) => Promise<ReleaseFacts>

What the release says about itself, decoded by its own Bolt (ReleaseFacts).

frame_policy(release: Release, path: string, options: Signal) => Promise<string>

The client page's content security policy for path: frame-ancestors and img-src.

源码: packages/host-api/src/ports.ts:33

failure

HostApiFailure const

const HostApiFailure: Schema.Union<readonly [Schema.TaggedStruct<"HostFailure", { readonly code: Schema.String; readonly phase: Schema.String; readonly message: Schema.String; }>, Schema.TaggedStruct<"HostDefect", { readonly message: Schema.String; }>]>

What a Host API call rejects with: an engine answer (HostFailure) or a retryable host defect (HostDefect).

源码: packages/host-api/src/failure.ts:18

host

HostCredentials type

type HostCredentials = {
    open(instance: string): Promise<{
        epoch: string;
        row: InstanceRow;
        values: ReadonlyMap<string, Json>;
    }>;
    read(instance: string): Promise<{
        epoch: string | null;
        row: InstanceRow;
        values: ReadonlyMap<string, Json>;
    }>;
    write(instance: string, epoch: string | null, changes: ReadonlyMap<string, Json | null>, rotate?: boolean): Promise<string | null>;
};

An environment's sealed integration credentials, under each instance's epoch; a failure is encoded.

成员

名称类型说明
open(instance: string) => Promise<{ epoch: string; row: InstanceRow; values: ReadonlyMap<string, Json>; }>
read(instance: string) => Promise<{ epoch: string | null; row: InstanceRow; values: ReadonlyMap<string, Json>; }>
write(instance: string, epoch: string | null, changes: ReadonlyMap<string, Json | null>, rotate?: boolean) => Promise<string | null>

源码: packages/host-api/src/host.ts:243

failure

HostDefect const

const HostDefect: Schema.TaggedStruct<"HostDefect", { readonly message: Schema.String; }>

Anything else: the database went away, a host port threw. The host may retry it elsewhere; an engine answer stands.

源码: packages/host-api/src/failure.ts:15

HostFailure const

const HostFailure: Schema.TaggedStruct<"HostFailure", { readonly code: Schema.String; readonly phase: Schema.String; readonly message: Schema.String; }>

An engine answer: a BoltError the release raised. code and phase stay strings on the wire, since two releases' sets may differ.

源码: packages/host-api/src/failure.ts:8

host

HostPorts type

type HostPorts = {
    readonly facilities: Facilities;
    /** This environment's epoch (a fork's rows are never sent). */
    readonly epoch?: string;
    /** `<tenant>/<environment>`: the deadlines scope and the log key. */
    readonly scope: string;
    readonly release: Release;
    /** The workspace's public URL with its path prefix (`https://host/acme`), no trailing slash. */
    readonly public_url: string;
    /** The host's own guest runner: isolates it makes, meters and ends for guest code (bodies, page loaders, `run_js`). */
    readonly guests: GuestIsolatesPort;
    readonly deadlines: DeadlinesPort;
    readonly images: ImagesPort;
    /** The confined bundler for the agent's file runs; `off`, `run_js` runs inline code only. */
    readonly bundler: BundlerPort | Off;
    readonly convert: ConvertPort | Off;
    /** The host's headless browser printing a record's print route (`ctx.convert.record`); `off`, that call is unavailable. */
    readonly render: RenderPort | Off;
    readonly geocoder: GeocoderPort | Off;
    readonly web: WebReadPort | Off;
    readonly browser: BrowserPort | Off;
    readonly mcp: McpPort | Off;
    /** The environment's live integration links. */
    readonly links: LinksPort | Off;
    readonly shell: ShellPorts;
    readonly agent: AgentPorts;
    /** The kernel's meter: as each run of a wake starts, the run begins the next unit, with a CPU budget of its own. */
    readonly units?: {
        next(): Promise<void>;
    };
    /*…

One serving generation of an environment: the host's facilities and what it serves around them. Every member is required; one the host may leave out takes off.

成员

名称类型说明
facilitiesFacilities
epoch?string

This environment's epoch (a fork's rows are never sent).

scopestring

<tenant>/<environment>: the deadlines scope and the log key.

releaseRelease
public_urlstring

The workspace's public URL with its path prefix (https://host/acme), no trailing slash.

guestsGuestIsolatesPort

The host's own guest runner: isolates it makes, meters and ends for guest code (bodies, page loaders, run_js).

deadlinesDeadlinesPort
imagesImagesPort
bundlerBundlerPort | Off

The confined bundler for the agent's file runs; off, run_js runs inline code only.

convertConvertPort | Off
renderRenderPort | Off

The host's headless browser printing a record's print route (ctx.convert.record); off, that call is unavailable.

geocoderGeocoderPort | Off
webWebReadPort | Off
browserBrowserPort | Off
mcpMcpPort | Off
linksLinksPort | Off

The environment's live integration links.

shellShellPorts
agentAgentPorts
units?{ next(): Promise<void>; }

The kernel's meter: as each run of a wake starts, the run begins the next unit, with a CPU budget of its own.

overran?string

Why the previous generation ended, when the kernel stopped it past a unit's CPU budget: the runs it left running fail cpu_budget with this message instead of rerunning (they would only overrun again).

源码: packages/host-api/src/host.ts:188

tools

HostSkill type

type HostSkill = {
    readonly text: string;
    readonly digest: string;
    readonly files: readonly string[];
    read(path: string): Promise<Uint8Array>;
};

A host skill (the platform authoring skill, a person's own): its text, digest, its tree's listing and each file's bytes by path.

成员

名称类型说明
textstring
digeststring
filesreadonly string[]
read(path: string) => Promise<Uint8Array>

源码: packages/host-api/src/tools.ts:120

db

HostTenantDb type

type HostTenantDb = {
    read(statements: readonly Sql[], signal?: AbortSignal): Promise<readonly Rows[]>;
    write(statement: Sql, lock?: Lock, signal?: AbortSignal): Promise<Rows>;
    transaction(batch: DbBatch, signal?: AbortSignal): Promise<readonly Rows[]>;
};

The tenant database as a release reaches it: RawDb as Promise calls, a failure an encoded DbError.

成员

名称类型说明
read(statements: readonly Sql[], signal?: AbortSignal) => Promise<readonly Rows[]>
write(statement: Sql, lock?: Lock, signal?: AbortSignal) => Promise<Rows>
transaction(batch: DbBatch, signal?: AbortSignal) => Promise<readonly Rows[]>

源码: packages/host-api/src/db.ts:37

tools

HostTool type

type HostTool = {
    /**
     * Its provider-visible name and identity: 1 to 64 of `A-Z a-z 0-9 _ -`, held by no native tool and no other host,
     * browser or MCP tool. A name that is not is offered by no list (the release logs why); it never replaces another.
     */
    name: string;
    description: string;
    input: Json;
    /** Declared once here; the release does not infer behavior from the operation's name. */
    readonly behavior: ToolBehavior;
    /** How a call reads in the panel; without it the panel names the tool and its `query`, `url`, `name`, `id` or `text`. */
    view?(input: Json): ToolView;
    read_only?: boolean;
    source?: true;
    /** Offered to every staff member in the app, whatever their policies name. */
    everyone?: true;
    studio?: StudioRole;
    /** A call's wall when it is past the usual host call's. */
    wall_ms?: number;
    /**
     * The host carries the call on past its generation and reports its end itself (`ActiveWorkspace.notify` with the
     * call's `job` as `id`): a generation closing under it writes no line for it, and holds no record of it.
     */
    reports_end?: true;
    /** The call's `files: [{ id }]` are read for it, as `run_js`'s are. */
    files?: true;
    /** Whether this call waits for the person's confirmation card (it sends, submits or saves); an envoy is refused it. */
    confirm?(input: Json): boolean;
    call(input: Json, ctx: HostToolContext, signal: AbortSignal): Promise<Json>;
};

A host capability (capabilities.tools): offered to staff members in the app only; read_only ones also while planning. An administrator holds every one, another member those their policies grant, and every staff member a read-only source tool (it reads the workspace's own source, never a secret or a host file).

成员

名称类型说明
namestring

Its provider-visible name and identity: 1 to 64 of A-Z a-z 0-9 _ -, held by no native tool and no other host, browser or MCP tool. A name that is not is offered by no list (the release logs why); it never replaces another.

descriptionstring
inputJson
behaviorToolBehavior

Declared once here; the release does not infer behavior from the operation's name.

view?((input: Json) => ToolView) | undefined

How a call reads in the panel; without it the panel names the tool and its query, url, name, id or text.

read_only?boolean
source?true
everyone?true

Offered to every staff member in the app, whatever their policies name.

studio?StudioRole
wall_ms?number

A call's wall when it is past the usual host call's.

reports_end?true

The host carries the call on past its generation and reports its end itself (ActiveWorkspace.notify with the call's job as id): a generation closing under it writes no line for it, and holds no record of it.

files?true

The call's files: [{ id }] are read for it, as run_js's are.

confirm?((input: Json) => boolean) | undefined

Whether this call waits for the person's confirmation card (it sends, submits or saves); an envoy is refused it.

call(input: Json, ctx: HostToolContext, signal: AbortSignal) => Promise<Json>

源码: packages/host-api/src/tools.ts:88

HostToolContext type

type HostToolContext = {
    actor: Actor;
    conversation: string;
    /** The agent's mark when this turn runs as one: a browser page opened for it is the agent's. */
    agent?: AgentMark;
    turn: string;
    call_id: string;
    /** The agent's job id for this call (its `[job <id> …]` lines); absent outside a turn (an automation's inference). */
    job?: string;
    /** The person's latest message, when the turn has one (a search host ranks by it). */
    question?: string;
    /** An image the model sees on its next step (a screenshot). */
    attach(file: {
        mime: string;
        bytes: Uint8Array;
    }): void;
    /** A file the host stored (a download), recorded as the person's and offered on the step; the model sees only its reference. */
    keep?(file: Downloaded): void;
    /** The conversation files the call named in `files`, by name, for a `files` tool. */
    files?: readonly (readonly [name: string, bytes: Uint8Array])[];
    /**
     * One request through the actor's active connection of `integration` (their own, else the workspace's when its
     * definition lends it (`http.lend`) or the actor is an administrator): `path` under
     * its definition's base URL, refused outside its `allow`, signed host-side and fetched under the public-network policy
     * (redirects followed, a cross-origin hop unsigned; the body at most `max_bytes`). `undefined` when nothing is
     * connected. The tool never holds the credential.
     */
    request?(integr…

What a host tool learns of its call: the person (a Studio draft is theirs), the conversation (its attachments), the key.

成员

名称类型说明
actorActor
conversationstring
agent?AgentMark

The agent's mark when this turn runs as one: a browser page opened for it is the agent's.

turnstring
call_idstring
job?string

The agent's job id for this call (its [job <id> …] lines); absent outside a turn (an automation's inference).

question?string

The person's latest message, when the turn has one (a search host ranks by it).

attach(file: { mime: string; bytes: Uint8Array; }) => void

An image the model sees on its next step (a screenshot).

keep?((file: Downloaded) => void) | undefined

A file the host stored (a download), recorded as the person's and offered on the step; the model sees only its reference.

files?readonly (readonly [name: string, bytes: Uint8Array])[]

The conversation files the call named in files, by name, for a files tool.

request?((integration: string, request: { readonly method: string; readonly path: string; readonly max_bytes: number; }, signal: AbortSignal) => Promise<HttpResponse | undefined>) | undefined

One request through the actor's active connection of integration (their own, else the workspace's when its definition lends it (http.lend) or the actor is an administrator): path under its definition's base URL, refused outside its allow, signed host-side and fetched under the public-network policy (redirects followed, a cross-origin hop unsigned; the body at most max_bytes). undefined when nothing is connected. The tool never holds the credential.

源码: packages/host-api/src/tools.ts:53

storage

HostUser const

const HostUser: Schema.Struct<{ readonly id: Schema.String; readonly name: Schema.String; readonly email: Schema.NullOr<Schema.String>; readonly phone: Schema.NullOr<Schema.String>; readonly active: Schema.Boolean; }>

A sys_user row as a host reads it from a branch database, without entering the release.

源码: packages/host-api/src/storage.ts:21

facilities

HttpFetchOptions type

type HttpFetchOptions = {
    readonly redirects: number;
    readonly max_bytes: number;
};

redirects: hops followed (each re-checked); max_bytes: the decoded body's ceiling (more fails too_large).

成员

名称类型说明
redirectsnumber
max_bytesnumber

源码: packages/host-api/src/facilities.ts:265

port

HttpOptions type

type HttpOptions = {
    http_client?: HttpClient.HttpClient;
    fetch?: typeof fetch;
};

The caller's HTTP client, else fetch (the caller's fetch when given).

成员

名称类型说明
http_client?HttpClient.HttpClient
fetch?typeof fetch

源码: packages/host-api/src/port.ts:103

facilities

HttpPort interface

interface HttpPort {
    fetch(request: HttpRequest, options: HttpFetchOptions, signal: AbortSignal): Promise<HttpResponse>;
}

Outbound HTTP under the public-network policy: HTTPS on 443 without credentials, DNS resolved once and the checked address pinned, private and reserved networks refused, every redirect hop re-checked (a cross-origin hop keeps only accept; a 301-303 of a write becomes a GET), transport headers (host, connection, content-length, transfer-encoding, upgrade, te, trailer, accept-encoding, proxy-*) refused, gzip decoded. A refusal rejects as a facility failure invalid; the wall is the caller's (Port.call).

成员

名称类型说明
fetch(request: HttpRequest, options: HttpFetchOptions, signal: AbortSignal) => Promise<HttpResponse>

源码: packages/host-api/src/facilities.ts:279

HttpRequest type

type HttpRequest = {
    readonly method: string;
    readonly url: string;
    readonly headers: readonly (readonly [name: string, value: string])[];
    readonly body?: Uint8Array;
};

An outbound request: absolute URL, headers in order, body bytes (none for GET).

成员

名称类型说明
methodstring
urlstring
headersreadonly (readonly [name: string, value: string])[]
body?Uint8Array

源码: packages/host-api/src/facilities.ts:258

HttpResponse type

type HttpResponse = {
    readonly status: number;
    readonly headers: readonly (readonly [name: string, value: string])[];
    readonly body: Uint8Array;
};

The final response: status, lowercase headers, the whole decoded body (empty for 204, 205, 304 and a redirect).

成员

名称类型说明
statusnumber
headersreadonly (readonly [name: string, value: string])[]
bodyUint8Array

源码: packages/host-api/src/facilities.ts:267

media

ImageCrop type

type ImageCrop = {
    left: number;
    top: number;
    right: number;
    bottom: number;
    /** Enlarge a small region until its longer edge reaches this many pixels, at most 4×. */
    min_edge?: number;
};

A rectangle in the oriented image, with coordinates from zero to one.

成员

名称类型说明
leftnumber
topnumber
rightnumber
bottomnumber
min_edge?number

Enlarge a small region until its longer edge reaches this many pixels, at most 4×.

源码: packages/host-api/src/media.ts:70

ImageMetadata type

type ImageMetadata = typeof ImageMetadataSchema.Type;

What ctx.files.image reads from a JPEG, PNG or HEIC: format, size, the PDQ perceptual hash and EXIF.

成员

名称类型说明
formatSchema.Literals<readonly ["jpeg", "png", "heic"]>
widthSchema.Number
heightSchema.Number
pdqSchema.String
exifSchema.Struct<{ readonly taken_at: Schema.optionalKey<Schema.String>; readonly gps: Schema.optionalKey<Schema.Struct<{ readonly lat: Schema.Number; readonly lng: Schema.Number; }>>; readonly software: Schema.optionalKey<Schema.String>; readonly make: Schema.optionalKey<Schema.String>; readonly model: Schema.optionalKey<Schema.String>; }>

源码: packages/host-api/src/media.ts:64

ImageMetadataSchema const

const ImageMetadataSchema: Schema.Struct<{ readonly format: Schema.Literals<readonly ["jpeg", "png", "heic"]>; readonly width: Schema.Number; readonly height: Schema.Number; readonly pdq: Schema.String; readonly exif: Schema.Struct<{ readonly taken_at: Schema.optionalKey<Schema.String>; readonly gps: Schema.optionalKey<Schema.Struct<{ readonly lat: Schema.Number; readonly lng: Schema.Number; }>>; readonly software: Schema.optionalKey<Schema.String>; readonly make: Schema.optionalKey<Schema.String>; readonly model: Schema.optionalKey<Schema.String>; }>; }>

Schema of what ctx.files.image reads from a JPEG, PNG or HEIC: format, size, the PDQ perceptual hash and EXIF.

源码: packages/host-api/src/media.ts:14

ImagePreview type

type ImagePreview = {
    readonly bytes: Uint8Array;
    readonly mime: string;
    readonly derived: boolean;
};

A preview at most maxEdge on its long side, EXIF-oriented; derived: false is the original (an APNG, a HEIC sequence).

成员

名称类型说明
bytesUint8Array
mimestring
derivedboolean

源码: packages/host-api/src/media.ts:79

ImagePreviewMime type

type ImagePreviewMime = typeof ImagePreviewMimeSchema.Type;

Source media the image preview decoder accepts (ImagePreviewMimeSchema).

源码: packages/host-api/src/media.ts:68

ImagePreviewMimeSchema const

const ImagePreviewMimeSchema: Schema.Literals<readonly ["image/jpeg", "image/png", "image/heic", "image/heif"]>

Source media the image preview decoder accepts. Other media are delivered unchanged.

源码: packages/host-api/src/media.ts:6

ImagePreviewSize type

type ImagePreviewSize = 64 | 512 | 1024;

The edge lengths, in pixels, an image preview is made at.

源码: packages/host-api/src/media.ts:66

ImagesPort interface

interface ImagesPort {
    facts(bytes: Uint8Array, signal: AbortSignal): Promise<ImageMetadata>;
    jpeg(bytes: Uint8Array, maxEdge: number, signal: AbortSignal): Promise<Uint8Array>;
    /** Lossless PNG of the selected oriented pixels, at most 5 MiB; the source stays unchanged. */
    crop(bytes: Uint8Array, box: ImageCrop, signal: AbortSignal): Promise<Uint8Array>;
    preview(bytes: Uint8Array, mime: ImagePreviewMime, maxEdge: ImagePreviewSize, signal: AbortSignal): Promise<ImagePreview>;
}

Image decoding off the engine (JPEG, PNG, HEIC; rasters at most 16 million pixels, input at most HOST_LIMITS.storedFileBytes): facts, a JPEG at most maxEdge on its long side, and a preview at most 5 MiB.

成员

名称类型说明
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/media.ts:88

integrations

ImportStart const

const ImportStart: Schema.Union<readonly [Schema.Struct<{ readonly kind: Schema.Literal<"all">; }>, Schema.Struct<{ readonly kind: Schema.Literal<"since">; readonly at: Schema.String; readonly zone: Schema.String; readonly origin: Schema.Literals<readonly ["now", "date"]>; }>, Schema.Struct<{ readonly kind: Schema.Literal<"native">; readonly selected_at: Schema.String; readonly provider: Schema.String; readonly values: Schema.$Record<Schema.String, Schema.String>; }>]>

A persisted source boundary. A missing boundary retains the instance's previous all-history behavior.

源码: packages/host-api/src/integrations.ts:95

ImportStartCapability const

const ImportStartCapability: Schema.Union<readonly [Schema.Struct<{ readonly kind: Schema.Literal<"timestamp">; readonly precision: Schema.optionalKey<Schema.Literal<"second">>; }>, Schema.Struct<{ readonly kind: Schema.Literal<"native">; readonly fields: Schema.$Array<Schema.Struct<{ readonly name: Schema.String; readonly label: Schema.Union<readonly [Schema.String, Schema.Struct<{ readonly en: Schema.String; readonly zh: Schema.optionalKey<Schema.middlewareDecoding<Schema.String, never>>; }>]>; readonly secret: Schema.optionalKey<Schema.middlewareDecoding<Schema.Boolean, never>>; readonly hint: Schema.optionalKey<Schem…

Where a provider can start an import from: a timestamp (optionally to the second) or its own native fields.

源码: packages/host-api/src/integrations.ts:124

ImportStartInput const

const ImportStartInput: Schema.Union<readonly [Schema.Struct<{ readonly kind: Schema.Literal<"all">; }>, Schema.Struct<{ readonly kind: Schema.Literal<"now">; readonly zone: Schema.String; }>, Schema.Struct<{ readonly kind: Schema.Literal<"since">; readonly date: Schema.String; readonly zone: Schema.String; }>, Schema.Struct<{ readonly kind: Schema.Literal<"native">; readonly provider: Schema.String; readonly values: Schema.$Record<Schema.String, Schema.String>; }>]>

The host freezes From now and resolves a selected civil day's midnight in its chosen IANA zone.

源码: packages/host-api/src/integrations.ts:112

facilities

IngestOptions type

type IngestOptions = {
    pictures?: boolean;
    page?: number;
    password?: string;
    /** A path inside an archive (zip, tar, tar.gz; on into one inside it): that file read as its own type; a folder lists its files. */
    entry?: string;
    diarize?: boolean;
    language?: string;
    speakers?: number;
    prompt?: string;
};

How an ingest reads: pictures: false reads a PDF's text alone, page one PDF page as a picture, password opens a locked PDF or Office file for this read; for audio, diarize tells speakers apart (default true), language a BCP 47 hint, speakers how many there are when known, prompt context such as names and vocabulary.

成员

名称类型说明
pictures?boolean
page?number
password?string
entry?string

A path inside an archive (zip, tar, tar.gz; on into one inside it): that file read as its own type; a folder lists its files.

diarize?boolean
language?string
speakers?number
prompt?string

源码: packages/host-api/src/facilities.ts:102

media

Ingested type

type Ingested = typeof IngestedSchema.Type;

Norbital Convert's ingest: parsing only, never OCR; a host may add a scanned page's transcript under its image in a data-read section. A document (pdf, office, html, text, images, audio) is sanitised HTML, one block element per line (audio: one <section data-speaker data-start data-end> per segment); data (a spreadsheet, CSV or JSON) is its cells as { sheets }, or a JSON file's own value. images are referenced by name.

源码: packages/host-api/src/media.ts:62

IngestedSchema const

const IngestedSchema: Schema.Union<readonly [Schema.Struct<{ readonly images: Schema.$Array<Schema.Struct<{ readonly name: Schema.String; readonly mime: Schema.String; readonly bytes: Schema.Uint8Array; }>>; readonly meta: Schema.Struct<{ readonly usage: Schema.optionalKey<Schema.Struct<{ readonly calls: Schema.$Array<Schema.String>; readonly model: Schema.String; readonly input: Schema.Number; readonly output: Schema.Number; readonly cost: Schema.Number; }>>; readonly stats: Schema.Struct<{ readonly pages: Schema.NullOr<Schema.Number>; readonly bytes: Schema.Number; readonly cpuMs: Schema.Number; readonly wallMs:…

Schema of Norbital Convert's ingest answer, its images as bytes.

源码: packages/host-api/src/media.ts:56

integrations

InstanceAdmin const

const InstanceAdmin: Schema.Struct<{ readonly instance: Schema.String; readonly active: Schema.Boolean; readonly envoy: Schema.NullOr<Schema.String>; readonly state: Schema.NullOr<Schema.Literals<readonly ["unpaired", "connecting", "pairing", "connected", "reconnecting", "error"]>>; readonly stored: Schema.Boolean; readonly revision: Schema.Int; }>

One instance as a host's operator observes it (WorkspaceBranch.integrations): never its account, pairing or values.

源码: packages/host-api/src/integrations.ts:221

host

InstanceRow type

type InstanceRow = {
    readonly integration: string;
    readonly owner: string | null;
    readonly active: boolean;
    readonly configuration: Json;
    readonly import_start: Json | null;
};

An integration instance's row, as its sealed credentials open with it.

成员

名称类型说明
integrationstring
ownerstring | null
activeboolean
configurationJson
import_startJson | null

源码: packages/host-api/src/host.ts:235

integrations

InstanceState const

const InstanceState: Schema.Literals<readonly ["unpaired", "connecting", "pairing", "connected", "reconnecting", "error"]>

Where an instance's link is. pairing is the provider asking for something; reconnecting is a retry after a drop and is progress, not failure; error is the only terminal one and names its own recovery in error.

源码: packages/host-api/src/integrations.ts:36

InstanceStatus const

const InstanceStatus: Schema.Struct<{ readonly state: Schema.Literals<readonly ["unpaired", "connecting", "pairing", "connected", "reconnecting", "error"]>; readonly account: Schema.optionalKey<Schema.middlewareDecoding<Schema.NullOr<Schema.String>, never>>; readonly detail: Schema.optionalKey<Schema.middlewareDecoding<Schema.String, never>>; readonly error: Schema.optionalKey<Schema.middlewareDecoding<Schema.String, never>>; readonly code: Schema.optionalKey<Schema.middlewareDecoding<Schema.String, never>>; readonly last_disconnect: Schema.optionalKey<Schema.Codec<Schema.Json, Schema.Json, never, never>>; readonl…

One instance as the shell shows it (GET/stream of /__bolt/integrations/<instance>): its link's status and the host's choices. A malformed member is dropped; a malformed state, instance or driver refuses the whole answer.

源码: packages/host-api/src/integrations.ts:196

IntegrationDefinition const

const IntegrationDefinition: Schema.Struct<{ readonly description: Schema.String; readonly driver: Schema.Union<readonly [Schema.String, Schema.Struct<{ readonly name: Schema.String; }>]>; readonly configuration: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Struct<{ readonly label: Schema.optionalKey<Schema.String>; readonly optional: Schema.optionalKey<Schema.Boolean>; }>>>; readonly credential: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Struct<{ readonly label: Schema.optionalKey<Schema.String>; readonly optional: Schema.optionalKey<Schema.Boolean>; }>>>; readonly oauth: Schema.optionalKey<Schem…

An integration definition as a provider reads it: its driver, its OAuth client's secret names and scopes, an http definition's base URL and auth, and its field declarations.

源码: packages/host-api/src/integrations.ts:374

cell

Kernel type

type Kernel = {
    /** A membrane message to the kernel; a call's answer when the kernel answered it at once. */
    readonly send: (message: Message) => Answer;
    /** Arms timer `id`: in `ms` the kernel enters `fire(id)`, billed to the unit that armed it. */
    readonly timer: (id: number, ms: number) => void;
    readonly clear: (id: number) => void;
    /** Fresh random bytes from the host's CSPRNG. */
    readonly random: (bytes: number) => Uint8Array<ArrayBuffer>;
    readonly log: (level: string, line: string) => void;
};

The kernel's system calls, each a synchronous host function (log is fire and forget).

成员

名称类型说明
send(message: Message) => Answer

A membrane message to the kernel; a call's answer when the kernel answered it at once.

timer(id: number, ms: number) => void

Arms timer id: in ms the kernel enters fire(id), billed to the unit that armed it.

clear(id: number) => void
random(bytes: number) => Uint8Array<ArrayBuffer>

Fresh random bytes from the host's CSPRNG.

log(level: string, line: string) => void

源码: packages/host-api/src/cell.ts:6

facilities

KeysPort interface

interface KeysPort {
    seal(plain: Uint8Array, aad: Uint8Array, signal: AbortSignal): Promise<Uint8Array>;
    open(sealed: Uint8Array, aad: Uint8Array, signal: AbortSignal): Promise<Uint8Array | null>;
}

The tenant's secrets key, held by the host: AES-256-GCM envelopes (iv ‖ tag ‖ ciphertext) bound to aad (bolt\0<owner>\0<name>), so a copied envelope never opens under another owner or name. open answers null for an envelope that does not open under this key and aad.

成员

名称类型说明
seal(plain: Uint8Array, aad: Uint8Array, signal: AbortSignal) => Promise<Uint8Array>
open(sealed: Uint8Array, aad: Uint8Array, signal: AbortSignal) => Promise<Uint8Array | null>

源码: packages/host-api/src/facilities.ts:253

integrations

type Link = {
    close(): Promise<void>;
} & Partial<{
    /** The operator's setup input (`SetupDescription`); rejects with the refusal the shell shows verbatim. */
    pair(input: Json): Promise<void>;
    /** Forgets this host at the provider; the manager destroys the credentials. */
    unpair(): Promise<void>;
    /** The provider's own test (send, then read it back); absent → the release sends a short message to the test target. */
    test(input: Json): Promise<void>;
    /**
     * Sends one queued conversation message; answers the `provider_id` its delivery reports will name. A provider that
     * picks the id before contacting the recipient (SMTP) first awaits `emit({ kind: 'outbound_ref', … })`, so a reply
     * finds the queued conversation before this resolves. Throw `SendRefused` for a refusal; any other failure after
     * handoff leaves the message `uncertain`.
     */
    send(message: Schema.Json, signal: AbortSignal, attachments?: readonly OutboundAttachment[]): Promise<SendReceipt>;
    /** The chat shows this account typing to `to` (`on`), or stops showing it. */
    typing(to: string, signal: AbortSignal, on: boolean): Promise<void>;
    /** A request driver's op (an http `{ method, path, … }` answering `{ status, body }`, a database request its rows), or a pushing driver's `call` through this link. */
    request(op: Json, signal: AbortSignal): Promise<Json>;
    /** A pushing driver's sync page from `cursor` (its `invalidate` event names the sync …

One instance's live link: whichever of these its driver supports.

成员

名称类型说明
close() => Promise<void>
pair?((input: Json) => Promise<void>) | undefined

The operator's setup input (SetupDescription); rejects with the refusal the shell shows verbatim.

unpair?(() => Promise<void>) | undefined

Forgets this host at the provider; the manager destroys the credentials.

test?((input: Json) => Promise<void>) | undefined

The provider's own test (send, then read it back); absent → the release sends a short message to the test target.

send?((message: Schema.Json, signal: AbortSignal, attachments?: readonly OutboundAttachment[]) => Promise<SendReceipt>) | undefined

Sends one queued conversation message; answers the provider_id its delivery reports will name. A provider that picks the id before contacting the recipient (SMTP) first awaits emit({ kind: 'outbound_ref', … }), so a reply finds the queued conversation before this resolves. Throw SendRefused for a refusal; any other failure after handoff leaves the message uncertain.

typing?((to: string, signal: AbortSignal, on: boolean) => Promise<void>) | undefined

The chat shows this account typing to to (on), or stops showing it.

request?((op: Json, signal: AbortSignal) => Promise<Json>) | undefined

A request driver's op (an http { method, path, … } answering { status, body }, a database request its rows), or a pushing driver's call through this link.

read?((sync: string, partition: string, cursor: Json | null, signal: AbortSignal) => Promise<DriverPage>) | undefined

A pushing driver's sync page from cursor (its invalidate event names the sync and partition).

reconcile?((thread: string, since: string, signal: AbortSignal) => Promise<ReconcilePage>) | undefined

The platform's current view of thread since the instant since. Absent where the platform keeps no history. The links manager calls it for recent threads when the link connects and once a day after, one thread at a time.

discover?(() => Promise<readonly { id: string; label: string; }[]>) | undefined

The resources a configuration may name (calendars), for the operator to pick.

renew?(() => Promise<string | null>) | undefined

Renews what the provider expires (a calendar watch); the next instant to renew at, or null.

webhook?((request: Request) => Promise<Response>) | undefined

Inbound HTTP on webhook_url and the paths under it (a pixel), and its OAuth callback on redirect_url, as the public request: the signature is checked here.

源码: packages/host-api/src/integrations.ts:530

host

LinkHost type

type LinkHost = {
    readonly release: Release;
    readonly database: HostTenantDb;
    /** As `Facilities.keys`: the sealed credentials open through it. */
    readonly keys: KeysPort;
    /** As `HostPorts.public_url`: every webhook URL and the OAuth callback are under it. */
    readonly public_url: string;
    readonly providers: readonly Provider[];
    /** The host's OAuth clients (Google), signing in every definition that names none of its own. */
    readonly oauth?: Partial<Record<OAuthVendor, OAuthClient>>;
    /** Runs `work` on the scope's current generation, outside compute admission (a link's ingest). */
    enter<T>(work: (workspace: ActiveWorkspace) => Promise<T>): Promise<T>;
    /** As `enter`, admitted under the compute envelope (a guest body: a custom conversation's webhook, a test send). */
    admit<T>(work: (workspace: ActiveWorkspace) => Promise<T>): Promise<T>;
    /** Wraps the sealed credentials the links write through, so credential I/O can survive a retirement. */
    credentials?(sealed: HostCredentials): HostCredentials;
    /** The providers' network: a cell has no `fetch` of its own. */
    readonly fetch: typeof fetch;
    /** The providers' TCP/TLS (IMAP, SMTP), as `Facilities.ports.outbound.tcp`. */
    readonly tcp: TcpPort;
    log?(line: string): void;
};

An environment's integration links: they outlive idle generations and re-enter the current one.

成员

名称类型说明
releaseRelease
databaseHostTenantDb
keysKeysPort

As Facilities.keys: the sealed credentials open through it.

public_urlstring

As HostPorts.public_url: every webhook URL and the OAuth callback are under it.

providersreadonly Provider[]
oauth?Partial<Record<OAuthVendor, OAuthClient>>

The host's OAuth clients (Google), signing in every definition that names none of its own.

enter<T>(work: (workspace: ActiveWorkspace) => Promise<T>) => Promise<T>

Runs work on the scope's current generation, outside compute admission (a link's ingest).

admit<T>(work: (workspace: ActiveWorkspace) => Promise<T>) => Promise<T>

As enter, admitted under the compute envelope (a guest body: a custom conversation's webhook, a test send).

credentials?((sealed: HostCredentials) => HostCredentials) | undefined

Wraps the sealed credentials the links write through, so credential I/O can survive a retirement.

fetchtypeof fetch

The providers' network: a cell has no fetch of its own.

tcpTcpPort

The providers' TCP/TLS (IMAP, SMTP), as Facilities.ports.outbound.tcp.

log?((line: string) => void) | undefined

源码: packages/host-api/src/host.ts:262

integrations

LinkStatus const

const LinkStatus: Schema.Struct<{ state: Schema.Literals<readonly ["unpaired", "connecting", "pairing", "connected", "reconnecting", "error"]>; account: Schema.optionalKey<Schema.middlewareDecoding<Schema.NullOr<Schema.String>, never>>; detail: Schema.optionalKey<Schema.middlewareDecoding<Schema.String, never>>; error: Schema.optionalKey<Schema.middlewareDecoding<Schema.String, never>>; code: Schema.optionalKey<Schema.middlewareDecoding<Schema.String, never>>; last_disconnect: Schema.optionalKey<Schema.Codec<Schema.Json, Schema.Json, never, never>>; about: Schema.optionalKey<Schema.Codec<Schema.Json, Schema.Js…

What a link reports of itself (DriverOpen.status): where it is, as whom, and the facts the connected view shows.

源码: packages/host-api/src/integrations.ts:190

LinksPort interface

interface LinksPort {
    send?(instance: string, message: Schema.Json, signal: AbortSignal, attachments?: readonly OutboundAttachment[]): Promise<SendReceipt>;
    typing?(instance: string, to: string, signal: AbortSignal, on: boolean): Promise<void>;
    request?(instance: string, op: Json, signal: AbortSignal): Promise<Json>;
    read?(instance: string, sync: string, partition: string, cursor: Json | null, signal: AbortSignal): Promise<DriverPage>;
    /**
     * A committed change of what an instance's session link opened with — its `configuration` or its pause — or its
     * deletion: the link closes, and opens again from the row as it is then when it is active and paired (a calendar
     * watches what it names now; a resumed instance reconnects).
     */
    changed?(instance: string): void;
}

The host's live side of integration instances, by instance id: a conversation driver sends (and shows typing), a request driver (http, sqlserver) answers request with the instance's credential host-side, a pushing driver reads a sync partition's page. A throw is a facility failure; SendRefused refuses a send (permanent or retried). An http request answers { status, body }, a database one the DatabaseResult.

成员

名称类型说明
send?((instance: string, message: Schema.Json, signal: AbortSignal, attachments?: readonly OutboundAttachment[]) => Promise<SendReceipt>) | undefined
typing?((instance: string, to: string, signal: AbortSignal, on: boolean) => Promise<void>) | undefined
request?((instance: string, op: Json, signal: AbortSignal) => Promise<Json>) | undefined
read?((instance: string, sync: string, partition: string, cursor: Json | null, signal: AbortSignal) => Promise<DriverPage>) | undefined
changed?((instance: string) => void) | undefined

A committed change of what an instance's session link opened with — its configuration or its pause — or its deletion: the link closes, and opens again from the row as it is then when it is active and paired (a calendar watches what it names now; a resumed instance reconnects).

源码: packages/host-api/src/integrations.ts:335

LocalText const

const LocalText: Schema.Union<readonly [Schema.String, Schema.Struct<{ readonly en: Schema.String; readonly zh: Schema.optionalKey<Schema.middlewareDecoding<Schema.String, never>>; }>]>

Operator-facing text a provider supplies: English, and each framework locale it is written in (the shell picks by locale).

源码: packages/host-api/src/integrations.ts:46

db

Lock type

type Lock = {
    tables?: readonly string[];
    mode?: 'SHARE ROW EXCLUSIVE';
    advisory?: readonly string[];
};

Taken before the statement, in sorted order; advisory keys are hashed by the adapter (pg_advisory_xact_lock).

成员

名称类型说明
tables?readonly string[]
mode?'SHARE ROW EXCLUSIVE'
advisory?readonly string[]

源码: packages/host-api/src/db.ts:15

logs

LogEvent type

type LogEvent = {
    readonly at: string;
    readonly severity: LogLevel;
    readonly event: string;
    readonly invocation: string;
    readonly run: string | null;
    readonly conversation: string | null;
    readonly turn: string | null;
    readonly attributes: {
        readonly [key: string]: Json;
    };
};

One runtime event as it happens: the host writes it to its log pipe, never to the workspace's database.

成员

名称类型说明
atstring
severityLogLevel
eventstring
invocationstring
runstring | null
conversationstring | null
turnstring | null
attributes{ readonly [key: string]: Json; }

源码: packages/host-api/src/logs.ts:8

LogLevel type

type LogLevel = 'info' | 'warn' | 'error';

A runtime event's severity.

源码: packages/host-api/src/logs.ts:6

LogPort interface

interface LogPort {
    write(event: LogEvent): void;
    query(query: LogQuery, signal: AbortSignal): Promise<readonly LogRow[]>;
}

The workspace's log facility, held by the host: each event written as it happens, and pages queried back newest first. The host owns identity, time, caps and scope: an event names no tenant, and a query reads only this workspace's log.

成员

名称类型说明
write(event: LogEvent) => void
query(query: LogQuery, signal: AbortSignal) => Promise<readonly LogRow[]>

源码: packages/host-api/src/logs.ts:49

LogQuery type

type LogQuery = {
    /** rows older than this id */
    readonly before?: string;
    /** rows newer than this id (the tail) */
    readonly after?: string;
    /** exactly this severity */
    readonly level?: LogLevel;
    /** this severity or worse */
    readonly min?: LogLevel;
    /** the event name or its attributes */
    readonly text?: string;
    readonly conversation?: string;
    readonly run?: string;
    /** events naming this automation */
    readonly automation?: string;
    /** instants bounding `at`: `since` inclusive, `until` exclusive */
    readonly since?: string;
    readonly until?: string;
    /** rows per page, 1 to 200 (default 200) */
    readonly limit?: number;
};

A filter over the tenant's stored log events; every given condition must hold.

成员

名称类型说明
before?string

rows older than this id

after?string

rows newer than this id (the tail)

level?LogLevel

exactly this severity

min?LogLevel

this severity or worse

text?string

the event name or its attributes

conversation?string
run?string
automation?string

events naming this automation

since?string

instants bounding at: since inclusive, until exclusive

until?string
limit?number

rows per page, 1 to 200 (default 200)

源码: packages/host-api/src/logs.ts:24

LogRow type

type LogRow = Omit<LogEvent, 'attributes'> & {
    readonly id: string;
    readonly attributes: Json;
};

A stored event as the host's log store answers it; id is the store's own cursor.

成员

名称类型说明
runstring | null
conversationstring | null
atstring
invocationstring
turnstring | null
severityLogLevel
eventstring
idstring
attributesJson

源码: packages/host-api/src/logs.ts:19

studio

MERGE_SUMMARY const

const MERGE_SUMMARY: 500

Room for a whole change set in a sentence or two.

源码: packages/host-api/src/studio.ts:243

client

MIME const

const MIME: { readonly [ext: string]: string; }

The content type of each file kind a client build and a workspace's assets carry; anything else is application/octet-stream.

源码: packages/host-api/src/client.ts:10

facilities

McpPort interface

interface McpPort {
    connect(server: McpServer, signal: AbortSignal): Promise<string>;
    tools(session: string, signal: AbortSignal): Promise<readonly McpToolInfo[]>;
    call(session: string, tool: string, input: Json, signal: AbortSignal): Promise<Json>;
    close(session: string): Promise<void>;
}

MCP over streamable HTTP on the current protocol revision: connect answers an opaque session id, call answers { content, structured?, isError? }; close ends the session (idempotent).

成员

名称类型说明
connect(server: McpServer, signal: AbortSignal) => Promise<string>
tools(session: string, signal: AbortSignal) => Promise<readonly McpToolInfo[]>
call(session: string, tool: string, input: Json, signal: AbortSignal) => Promise<Json>
close(session: string) => Promise<void>

源码: packages/host-api/src/facilities.ts:358

McpServer type

type McpServer = {
    readonly url: string;
    readonly headers: {
        readonly [name: string]: string;
    };
    readonly auth?: {
        readonly bearer: string;
    } | {
        readonly client: {
            readonly id: string;
            readonly secret: string;
            readonly scopes?: readonly string[];
        };
    };
};

An MCP server as the release resolved it from the workspace's secrets: URL, headers, and its authorization.

成员

名称类型说明
urlstring
headers{ readonly [name: string]: string; }
auth?{ readonly bearer: string; } | { readonly client: { readonly id: string; readonly secret: string; readonly scopes?: readonly string[]; }; }

源码: packages/host-api/src/facilities.ts:335

McpToolInfo type

type McpToolInfo = {
    readonly name: string;
    readonly description: string;
    readonly input_schema: Json;
};

One tool an MCP server lists: its name, description and input JSON Schema.

成员

名称类型说明
namestring
descriptionstring
input_schemaJson

源码: packages/host-api/src/facilities.ts:349

membrane

Membrane type

type Membrane = {
    /** A value in its wire form; what it hands over is this side's until the other side releases it. */
    readonly encode: (value: unknown) => unknown;
    /** A wire value with mirrors for what the other side handed over. */
    readonly decode: (value: unknown) => unknown;
    /** One message from the other side; a call answers at once when its function did. */
    readonly receive: (message: unknown) => Answer;
    /** The other side is gone: pending calls reject with `failure`, incoming streams error, nothing is handed over. */
    readonly close: (failure: unknown) => void;
};

One side of the membrane: what it sends, receives and hands over.

成员

名称类型说明
encode(value: unknown) => unknown

A value in its wire form; what it hands over is this side's until the other side releases it.

decode(value: unknown) => unknown

A wire value with mirrors for what the other side handed over.

receive(message: unknown) => Answer

One message from the other side; a call answers at once when its function did.

close(failure: unknown) => void

The other side is gone: pending calls reject with failure, incoming streams error, nothing is handed over.

源码: packages/host-api/src/membrane.ts:109

Message const

const Message: Schema.Union<readonly [Schema.Tuple<readonly [Schema.Literal<"call">, Schema.Number, Schema.$Array<Schema.Unknown>, Schema.Number]>, Schema.Tuple<readonly [Schema.Literals<readonly ["resolve", "reject", "abort", "error"]>, Schema.Number, Schema.Unknown]>, Schema.Tuple<readonly [Schema.Literal<"write">, Schema.Number, Schema.Uint8Array]>, Schema.Tuple<readonly [Schema.Literals<readonly ["pull", "end"]>, Schema.Number]>, Schema.Tuple<readonly [Schema.Literal<"release">, Schema.$Array<Schema.Number>]>]>

Every message between the two sides; each one the kernel sends into a cell is one entry.

源码: packages/host-api/src/membrane.ts:24

host

MigrationCarry const

const MigrationCarry: Schema.Struct<{ readonly base: Schema.$Record<Schema.String, Schema.String>; readonly live: Schema.$Record<Schema.String, Schema.String>; readonly line: Schema.$Array<Schema.$Record<Schema.String, Schema.String>>; }>

schema.carry's input, each side a tree's migrations/: base where an author's line left live, live live's now, and line each of the line's commits, oldest first.

源码: packages/host-api/src/host.ts:479

migration-impact

MigrationImpact const

const MigrationImpact: Schema.Struct<{ readonly duration_ms: Schema.Number; readonly steps: Schema.$Array<Schema.Struct<{ readonly id: Schema.String; readonly hazard: Schema.String; readonly rows: Schema.Number; readonly summary: Schema.String; }>>; }>

What applying pending migrations did where it ran: each step's impact and the whole migrate's duration (live's expected downtime).

源码: packages/host-api/src/migration-impact.ts:14

MigrationStepImpact const

const MigrationStepImpact: Schema.Struct<{ readonly id: Schema.String; readonly hazard: Schema.String; readonly rows: Schema.Number; readonly summary: Schema.String; }>

rows: written (INSERT/UPDATE/DELETE), held by what a destructive step drops, filled by a backfill, or checked.

源码: packages/host-api/src/migration-impact.ts:6

answers

MintedSession const

const MintedSession: Schema.Struct<{ readonly token: Schema.String; readonly user: Schema.String; readonly expires_at: Schema.String; }>

session.mint (the apex handoff): the host sets cookies.session to token until expires_at.

源码: packages/host-api/src/answers.ts:47

integrations

OAUTH_CALLBACK const

const OAUTH_CALLBACK: "/hooks/oauth/callback"

The host path an OAuth provider redirects back to after a link's consent.

源码: packages/host-api/src/integrations.ts:360

OAuthClient type

type OAuthClient = {
    readonly id: string;
    readonly secret: string;
};

A host's OAuth client: its id and secret.

成员

名称类型说明
idstring
secretstring

源码: packages/host-api/src/integrations.ts:364

OAuthVendor type

type OAuthVendor = 'google';

An OAuth provider a host holds a client for.

源码: packages/host-api/src/integrations.ts:362

off

Off type

type Off = typeof off;

The type of off.

成员

名称类型说明
_tag'Off'

源码: packages/host-api/src/off.ts:6

ai

OpenAiChat type

type OpenAiChat = (request: AiRequest) => Stream.Stream<AiEvent, PortFailure>;

A chat model call (sys_2.infer over an OpenAI-compatible endpoint): a cancellable stream whose last event carries the response.

源码: packages/host-api/src/ai.ts:289

integrations

OutboundAttachment type

type OutboundAttachment = {
    readonly id: string;
    readonly name: string;
    readonly mime: string;
    readonly bytes: Uint8Array;
    url(expiresInS: number): Promise<string>;
};

One of message.attachments (stored FileRefs, in order) as the release hands it to send: the bytes read through the host's files port, all of a message's together at most the release's attachment cap. url is a signed link a provider that fetches media itself may pass on (Twilio's MediaUrl); it throws where the host serves no file links.

成员

名称类型说明
idstring
namestring
mimestring
bytesUint8Array
url(expiresInS: number) => Promise<string>

源码: packages/host-api/src/integrations.ts:300

OutboundReference const

const OutboundReference: Schema.Struct<{ readonly message: Schema.NonEmptyString; readonly provider_id: Schema.NonEmptyString; }>

A provider-chosen id persisted before I/O; registration alone is no delivery acknowledgement. Registration refuses another account's message, a paused or personal account, a changed id or another environment epoch.

源码: packages/host-api/src/integrations.ts:239

facilities

PAPER_SIZES const

const PAPER_SIZES: readonly ["A4", "A3", "Letter"]

The paper sizes a rendered document may take.

源码: packages/host-api/src/facilities.ts:85

host

PackCapture type

type PackCapture = {
    readonly model: string;
    readonly rows: readonly {
        readonly [field: string]: Json;
    }[];
    readonly assets: readonly SeedAsset[];
    readonly next: PackCursor | null;
};

One page of a capture: rows of one model as a pack holds them, the assets their files name, and the next page.

成员

名称类型说明
modelstring
rowsreadonly { readonly [field: string]: Json; }[]
assetsreadonly SeedAsset[]
nextPackCursor | null

源码: packages/host-api/src/host.ts:359

PackCursor const

const PackCursor: Schema.Struct<{ readonly model: Schema.String; readonly after: Schema.NullOr<Schema.String>; }>

Where a capture's next page starts: a model and the last id read of it (null: its first row).

源码: packages/host-api/src/host.ts:356

PackLoad type

type PackLoad = {
    step(options: Signal): Promise<PackStep>;
};

A pack load in bounded steps ("Limits and liveness"): the host enters step once per unit of work until it answers other than more. Each step commits on its own, so a failed load leaves the steps before it: load into a branch the host drops on failure.

成员

名称类型说明
step(options: Signal) => Promise<PackStep>

源码: packages/host-api/src/host.ts:373

PackStep const

const PackStep: Schema.Literals<readonly ["more", "loaded", "hadRows"]>

One pack-load step's answer: more to enter again, loaded, or hadRows (the branch had rows; nothing changed).

源码: packages/host-api/src/host.ts:366

PageView type

type PageView = {
    readonly route: string;
    readonly dwell_ms: number;
};

One page a person had open: its route pattern (no record id, no query) and how long it stayed open.

成员

名称类型说明
routestring
dwell_msnumber

源码: packages/host-api/src/host.ts:153

integrations

Pairing const

const Pairing: Schema.Struct<{ readonly kind: Schema.Literals<readonly ["qr", "code", "credential", "form", "oauth"]>; readonly value: Schema.withDecodingDefaultKey<Schema.middlewareDecoding<Schema.NullOr<Schema.String>, never>, never>; readonly expires_at: Schema.optionalKey<Schema.middlewareDecoding<Schema.String, never>>; readonly label: Schema.optionalKey<Schema.middlewareDecoding<Schema.String, never>>; readonly fields: Schema.optionalKey<Schema.Codec<readonly { readonly name: string; readonly label: string | { readonly en: string; readonly zh?: string; }; readonly secret?: boolean; readonly hint?: str…

What the provider wants from the operator, when it wants something. value is the payload to draw (a QR, a code).

源码: packages/host-api/src/integrations.ts:152

facilities

PaperSize type

type PaperSize = (typeof PAPER_SIZES)[number];

One of PAPER_SIZES.

源码: packages/host-api/src/facilities.ts:87

studio

PhaseState type

type PhaseState = 'running' | 'done' | 'failed';

Where an authoring phase stands.

源码: packages/host-api/src/studio.ts:392

facilities

PhoneVerifier type

type PhoneVerifier = {
    via: readonly ('sms' | 'whatsapp')[];
    start(to: string, via: 'sms' | 'whatsapp', signal: AbortSignal): Promise<void>;
    check(to: string, code: string, signal: AbortSignal): Promise<boolean>;
};

Sends and checks its own six-digit codes to a mobile number, by each of via. check is false for a wrong, expired or used code; a throw is a failure to ask.

成员

名称类型说明
viareadonly ('sms' | 'whatsapp')[]
start(to: string, via: "sms" | "whatsapp", signal: AbortSignal) => Promise<void>
check(to: string, code: string, signal: AbortSignal) => Promise<boolean>

源码: packages/host-api/src/facilities.ts:200

Point type

type Point = {
    readonly lat: number;
    readonly lng: number;
};

A point on Earth: latitude and longitude in degrees.

成员

名称类型说明
latnumber
lngnumber

源码: packages/host-api/src/facilities.ts:162

port

Port const

const Port: { call: (facility: string, wallMs: number, message?: string) => <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E | FacilityFailure, R>; fromPromise: <A, RD>(f: (signal: AbortSignal) => PromiseLike<unknown>, decode: Schema.Decoder<A, RD>, facility?: string) => Effect.Effect<A, PortFailure, RD>; attempt: <A>(facility: string, f: (signal: AbortSignal) => PromiseLike<A>) => Effect.Effect<A, PortFailure>; failure: typeof failureOf; unavailable: (facility: string, reason?: string) => Effect.Effect<never, Unavailable>; }

Helpers that run host port calls under a wall and turn a port's throw or bad answer into a typed PortFailure.

成员

名称类型说明
call(facility: string, wallMs: number, message?: string) => <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E | FacilityFailure, R>

Bounds one port call by its wall: past wallMs the call is interrupted and fails timeout.

fromPromise<A, RD>(f: (signal: AbortSignal) => PromiseLike<unknown>, decode: Schema.Decoder<A, RD>, facility?: string) => Effect.Effect<A, PortFailure, RD>

A Promise port call: interruption aborts signal; a throw is the call's failure (failureOf); the answer is decoded, and one that is not decode's is upstream.

attempt<A>(facility: string, f: (signal: AbortSignal) => PromiseLike<A>) => Effect.Effect<A, PortFailure>

A typed host Promise ABI call: fromPromise without a decode, since its type is the port's.

failuretypeof failureOf

A port's throw as its failure, for a caller with its own catch (a driver's SendRefused).

unavailable(facility: string, reason?: string) => Effect.Effect<never, Unavailable>

The failure of a port the host does not provide.

源码: packages/host-api/src/port.ts:46

errors

PortFailure type

type PortFailure = FacilityFailure | Unavailable;

What a port call fails with: the facility's own failure, or the host providing none.

源码: packages/host-api/src/errors.ts:37

studio

PreviewControl type

type PreviewControl = {
    holder: 'norbius' | 'person';
    conversation?: string;
    at?: string;
};

Who is driving a change's preview: Norbius (with its conversation) or the person.

成员

名称类型说明
holder'norbius' | 'person'
conversation?string
at?string

源码: packages/host-api/src/studio.ts:181

facilities

PreviewPdfOptions type

type PreviewPdfOptions = {
    page?: PaperSize;
    landscape?: boolean;
};

A PDF's paper and orientation.

成员

名称类型说明
page?PaperSize
landscape?boolean

源码: packages/host-api/src/facilities.ts:89

integrations

Provider type

type Provider = ProviderChoice & {
    /** The driver's name: one of the release's kinds, or a driver a definition declares (`whatsapp`, `slack`, …). */
    driver: string;
    /** Required for a native boundary: validates and normalizes only this provider's declared fields. */
    validate_import_start?(values: Readonly<Record<string, string>>): Promise<Readonly<Record<string, string>>>;
    /** It imports a personal account (history and own sent messages) without sending. */
    personal?: boolean;
    /** It signs in with this vendor's OAuth client (`DriverOpen.oauth_client`); offered only where one is configured. */
    oauth?: OAuthVendor;
    /** The provider can send a test message once connected (`POST …/test`). */
    test?: TestSend;
    /**
     * `send` is idempotent by `message.id`: a repeat reaches the customer once, so a send that timed out is sent again.
     * Otherwise such a message stays `uncertain`, since the first send may have arrived.
     */
    idempotent_sends?: boolean;
    /** Provider-owned registration text for a personal or a workspace instance of `definition`; credentials and pairing keep the same runtime. */
    describe?(options: {
        readonly personal: boolean;
        readonly definition: IntegrationDefinition;
    }): Pick<ProviderChoice, 'label' | 'setup'>;
    open(ctx: DriverOpen): Promise<Link>;
};

A provider (@norbital-ai/providers, or a host's own), registered by the host for one driver by name. A release never names one. It runs in the host, outside the guest wall, with sealed credentials, raw network and direct emit, which is why a workspace cannot supply one. The contract stays Promise + AbortSignal + JSON; the engine adapts it once, aborting the signal on interruption and decoding every answer. A provider acknowledges an inbound delivery only after emit resolves, so a refused store is redelivered.

成员

名称类型说明
labelSchema.Union<readonly [Schema.String, Schema.Struct<{ readonly en: Schema.String; readonly zh: Schema.optionalKey<Schema.middlewareDecoding<Schema.String, never>>; }>]>
idSchema.String
setupSchema.Struct<{ readonly kind: Schema.Literals<readonly ["form", "qr", "code", "oauth", "none"]>; readonly steps: Schema.withDecodingDefaultKey<Schema.Codec<readonly { readonly text: string | { readonly en: string; readonly zh?: string; }; readonly href?: string; readonly copy?: "redirect_url" | "webhook_url"; }[], unknown, never, never>, never>; readonly fields: Schema.optionalKey<Schema.Codec<r…
description?Schema.optionalKey<Schema.middlewareDecoding<Schema.Union<readonly [Schema.String, Schema.Struct<{ readonly en: Schema.String; readonly zh: Schema.optionalKey<Schema.middlewareDecoding<Schema.String, never>>; }>]>, never>>

Concise catalogue description, localized by the authored surface.

icon?Schema.optionalKey<Schema.middlewareDecoding<Schema.String, never>>

Iconify provider mark, with a generic plug fallback when absent.

name?Schema.optionalKey<Schema.middlewareDecoding<Schema.Union<readonly [Schema.String, Schema.Struct<{ readonly en: Schema.String; readonly zh: Schema.optionalKey<Schema.middlewareDecoding<Schema.String, never>>; }>]>, never>>

Short catalogue name; the full registration label remains in label.

import_start?Schema.optionalKey<Schema.Union<readonly [Schema.Struct<{ readonly kind: Schema.Literal<"timestamp">; readonly precision: Schema.optionalKey<Schema.Literal<"second">>; }>, Schema.Struct<{ readonly kind: Schema.Literal<"native">; readonly fields: Schema.$Array<Schema.Struct<{ readonly name: Schema.String; readonly label: Schema.Union<readonly [Schema.String, Schema.Struct<{ readonly en: Schema.Str…
available?Schema.optionalKey<Schema.middlewareDecoding<Schema.Boolean, never>>

false: the host has no OAuth client for its sign-in (Provider.oauth), so it cannot connect here.

driverstring

The driver's name: one of the release's kinds, or a driver a definition declares (whatsapp, slack, …).

validate_import_start?((values: Readonly<Record<string, string>>) => Promise<Readonly<Record<string, string>>>) | undefined

Required for a native boundary: validates and normalizes only this provider's declared fields.

personal?boolean

It imports a personal account (history and own sent messages) without sending.

oauth?OAuthVendor

It signs in with this vendor's OAuth client (DriverOpen.oauth_client); offered only where one is configured.

test?TestSend

The provider can send a test message once connected (POST …/test).

idempotent_sends?boolean

send is idempotent by message.id: a repeat reaches the customer once, so a send that timed out is sent again. Otherwise such a message stays uncertain, since the first send may have arrived.

describe?((options: { readonly personal: boolean; readonly definition: IntegrationDefinition; }) => Pick<ProviderChoice, "label" | "setup">) | undefined

Provider-owned registration text for a personal or a workspace instance of definition; credentials and pairing keep the same runtime.

open(ctx: DriverOpen) => Promise<Link>

源码: packages/host-api/src/integrations.ts:578

ProviderChoice const

const ProviderChoice: Schema.Struct<{ readonly id: Schema.String; readonly label: Schema.Union<readonly [Schema.String, Schema.Struct<{ readonly en: Schema.String; readonly zh: Schema.optionalKey<Schema.middlewareDecoding<Schema.String, never>>; }>]>; readonly setup: Schema.Struct<{ readonly kind: Schema.Literals<readonly ["form", "qr", "code", "oauth", "none"]>; readonly steps: Schema.withDecodingDefaultKey<Schema.Codec<readonly { readonly text: string | { readonly en: string; readonly zh?: string; }; readonly href?: string; readonly copy?: "redirect_url" | "webhook_url"; }[], unknown, never, never>, never>; read…

A provider as the shell offers it: a driver with several (WhatsApp) asks which, by label, first.

源码: packages/host-api/src/integrations.ts:133

tools

REFERENCE const

const REFERENCE: { readonly mime: "application/vnd.norbital.reference+json"; readonly treeBytes: number; }

A repository reference ("Agents' files"): the host's reference tool keeps this index as the person's output file, named <repository>@<commit>, and a file run reads its tree from it. Each text file is a blob by its content address. A run reads the whole tree, so a reference over treeBytes runs no file.

成员

名称类型说明
mime'application/vnd.norbital.reference+json'
treeBytesnumber

源码: packages/host-api/src/tools.ts:182

integrations

REPORTED_KINDS const

const REPORTED_KINDS: readonly ["sent", "deferred", "delivered", "read", "opened", "bounced", "failed", "complained"]

What a provider may report about a message it sent; replies and auto-replies arrive as inbound messages instead.

源码: packages/host-api/src/integrations.ts:254

db

RawDb type

type RawDb = {
    /** Read statements share one snapshot and answer in order; rows are relayed as JSON. */
    readonly read: (statements: readonly Sql[]) => Effect.Effect<readonly Rows[], DbError>;
    /** An act's one write statement, with fixed deadlines and native locks before execution. */
    readonly write: (statement: Sql, lock?: Lock) => Effect.Effect<Rows, DbError>;
    /** Complete SQL statements atomically; answers are decoded only after commit or native dry-run rollback. */
    readonly transaction: (batch: DbBatch) => Effect.Effect<readonly Rows[], DbError>;
};

What a host's database adapter implements, as Effects failing with the driver's DbError.

成员

名称类型说明
read(statements: readonly Sql[]) => Effect.Effect<readonly Rows[], DbError>

Read statements share one snapshot and answer in order; rows are relayed as JSON.

write(statement: Sql, lock?: Lock) => Effect.Effect<Rows, DbError>

An act's one write statement, with fixed deadlines and native locks before execution.

transaction(batch: DbBatch) => Effect.Effect<readonly Rows[], DbError>

Complete SQL statements atomically; answers are decoded only after commit or native dry-run rollback.

源码: packages/host-api/src/db.ts:28

integrations

ReconcilePage type

type ReconcilePage = {
    messages: readonly Json[];
    complete: boolean;
    since?: string;
    bins?: readonly Uint8Array[];
};

The platform's current view of one thread since an instant (Link.reconcile). messages is what a messages event would carry, with bins for its bytes: what others wrote, and a personal account's own messages marked outbound. complete says it holds every message of the window, so what it lacks was deleted; a partial page repairs what it shows and deletes nothing. since narrows the window: the instant the platform's history really reaches back to, when that is later than the instant asked for.

成员

名称类型说明
messagesreadonly Json[]
completeboolean
since?string
bins?readonly Uint8Array[]

源码: packages/host-api/src/integrations.ts:323

tools

ReferenceIndex const

const ReferenceIndex: Schema.Struct<{ readonly repository: Schema.String; readonly commit: Schema.NullOr<Schema.String>; readonly digest: Schema.String; readonly files: Schema.$Array<Schema.Struct<{ readonly path: Schema.String; readonly key: Schema.String; readonly bytes: Schema.Number; }>>; }>

Schema of a repository reference file: repository, commit, tree digest and each file's path, blob key and size.

源码: packages/host-api/src/tools.ts:187

ports

Release type

type Release = {
    /** The host's release id (the artifact digest it records): authorities are compiled per release. */
    readonly id: string;
    /** The release's files (`artifact.json`, `client/…`) and its seed packs (`../seed/<pack>/…`), read-only. */
    readonly artifact: ArtifactPort;
};

A built workspace: bolt build's release, with source, format and digests verified by this release.

成员

名称类型说明
idstring

The host's release id (the artifact digest it records): authorities are compiled per release.

artifactArtifactPort

The release's files (artifact.json, client/…) and its seed packs (../seed/<pack>/…), read-only.

源码: packages/host-api/src/ports.ts:23

answers

ReleaseFacts const

const ReleaseFacts: Schema.Struct<{ readonly zone: Schema.String; readonly skills: Schema.$Array<Schema.String>; readonly pages: Schema.$Array<Schema.String>; readonly secrets: Schema.Boolean; readonly issues: Schema.$Array<Schema.String>; readonly studio: Schema.Struct<{ readonly workspace: Schema.Struct<{ readonly secrets: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Unknown>>; }>; readonly models: Schema.$Record<Schema.String, Schema.Unknown>; readonly apps: Schema.$Record<Schema.String, Schema.Struct<{ readonly shell: Schema.optionalKey<Schema.String>; readonly pages: Schema.$Record<Schema.String,…

describe: what a release says about itself, decoded by its own Bolt from its manifest.

源码: packages/host-api/src/answers.ts:31

facilities

RenderPort interface

interface RenderPort {
    pdf(page: {
        path: string;
        authorization: string;
    }, signal: AbortSignal): Promise<Uint8Array>;
}

The host's headless browser printing one workspace page to PDF (ctx.convert.record). path is under the workspace's public URL (/?record=<model>/<id>&print); every request the page makes carries the header authorization: <authorization> (a render grant, valid only while this call runs). The host loads the page with print media, waits until <html data-bolt-print="ready"> (or "failed", a refusal: answer it as an error), and answers page.pdf() with its CSS page size and backgrounds.

成员

名称类型说明
pdf(page: { path: string; authorization: string; }, signal: AbortSignal) => Promise<Uint8Array>

源码: packages/host-api/src/facilities.ts:156

db

Rows type

type Rows = {
    readonly rows: readonly {
        readonly [column: string]: Json;
    }[];
    readonly affected: number;
};

A statement's result: its rows as JSON column maps and the number of rows it affected.

成员

名称类型说明
rowsreadonly { readonly [column: string]: Json; }[]
affectednumber

源码: packages/host-api/src/db.ts:10

port

Run type

type Run = <A, E>(effect: Effect.Effect<A, E>, options?: {
    readonly signal?: AbortSignal | undefined;
}) => Promise<A>;

A host's runner (FiberSet.makeRuntimePromise): runs an Effect to a Promise, interrupted when signal aborts.

源码: packages/host-api/src/port.ts:97

authority

RunBy const

const RunBy: Schema.Union<readonly [Schema.Struct<{ readonly automation: Schema.String; }>, Schema.Struct<{ readonly platform: Schema.String; }>, Schema.Struct<{ readonly sync: Schema.String; readonly instance: Schema.String; }>]>

What a system run is: an automation's, the platform's own work (agent: a system agent's task), or a sync's.

源码: packages/host-api/src/authority.ts:6

facilities

SIGN_IN_CODE_MS const

const SIGN_IN_CODE_MS: number

How long a sign-in code stays valid.

源码: packages/host-api/src/facilities.ts:206

tools

SKILL_BYTES const

const SKILL_BYTES: number

Most bytes one skill's folder may hold (10 MiB).

源码: packages/host-api/src/tools.ts:174

SKILL_FILE const

const SKILL_FILE: "SKILL.md"

The skill's text in its tree (in a workspace's source, the folder's +skill.md).

源码: packages/host-api/src/tools.ts:176

studio

STUDIO_PHASES const

const STUDIO_PHASES: readonly ["diagnose", "copy", "preview", "merge"]

An authoring phase: diagnose (the build's checks) → copy (the preview's data) → preview → merge.

源码: packages/host-api/src/studio.ts:388

tools

STUDIO_ROLES const

const STUDIO_ROLES: readonly ["preview", "view", "logs", "merge", "rollback"]

What a host tool is to the shell's Studio surfaces, declared so a release never keys behaviour on a host's tool names: - preview: its result's preview is a preview it built; the agent may show that origin (page { preview }). - view: a look at a rendered page; the images it attaches are shown to the person too, and its result's url is a preview the panel may show. - logs: its result is { records: StudioLogLine[] }, listed in full on the step. - merge / rollback: a confirmed switch-over; its input is { summary, commit }, its card says what changes. A Studio result's caption facts (environment, release, commit, message, branch, url, viewport, capturedAt) are read at its top level.

源码: packages/host-api/src/tools.ts:18

studio

STUDIO_TABS const

const STUDIO_TABS: readonly ["workbench", "changes", "versions"]

Studio's tabs, each a stable deep link /studio/<tab>; /studio is the workbench.

源码: packages/host-api/src/studio.ts:450

host

SchemaSlice const

const SchemaSlice: Schema.Codec<Schema.Json, Schema.Json, never, never>

A release's schema state, opaque to the host: it stores one and hands it back to schema.destructive.

源码: packages/host-api/src/host.ts:471

tools

SearchAnswer type

type SearchAnswer = {
    readonly hits: readonly {
        readonly path: string;
        readonly line: number;
        readonly text: string;
    }[];
    readonly truncated: boolean;
    readonly counts?: {
        readonly lines: number;
        readonly files: number;
    };
} | {
    readonly error: string;
};

A workspace_grep answer: its hits in path order and whether the limit cut them, or why it failed.

源码: packages/host-api/src/tools.ts:140

SearchRequest type

type SearchRequest = {
    readonly pattern: string;
    readonly path?: string;
    readonly include?: string;
    /** Only the files holding a match, one hit each. */
    readonly files?: boolean;
    readonly literal?: boolean;
    readonly case_sensitive?: boolean;
    /** Count all matching lines and files without returning excerpts. */
    readonly count?: boolean;
    readonly limit?: number;
};

A workspace_grep as the host's ripgrep answers it, its hits in path order.

成员

名称类型说明
patternstring
path?string
include?string
files?boolean

Only the files holding a match, one hit each.

literal?boolean
case_sensitive?boolean
count?boolean

Count all matching lines and files without returning excerpts.

limit?number

源码: packages/host-api/src/tools.ts:127

host

SeedAsset type

type SeedAsset = {
    readonly path: string;
    readonly sha256: string;
    readonly bytes: number;
    readonly content_type: string;
};

A seed asset a restore reads: its path in the pack, digest, size and media type.

成员

名称类型说明
pathstring
sha256string
bytesnumber
content_typestring

源码: packages/host-api/src/host.ts:349

integrations

SendReceipt const

const SendReceipt: Schema.Struct<{ readonly provider_id: Schema.NonEmptyString; readonly presume_after_ms: Schema.optional<Schema.Number>; }>

A send's acknowledgement, decoded once where the provider crosses into the engine: the provider_id delivery events name, and optionally how long a quiet window lasts before the message is presumed delivered.

源码: packages/host-api/src/integrations.ts:248

errors

SendRefused class

class SendRefused extends Error {
    readonly name = "SendRefused";
    readonly code: string | undefined;
    readonly permanent: boolean;
    constructor(message: string, code?: string, permanent?: boolean);
}

A provider's refusal of a send, thrown from LinksPort.send: permanent (SMTP 5xx, an API 4xx) fails the message at once; otherwise bolt retries it with backoff and records deferred (SMTP 4xx). Recognised by name, so a copy of this class in another bundle still counts.

成员

名称类型说明
name"SendRefused"
codestring | undefined
permanentboolean

源码: packages/host-api/src/errors.ts:77

host

SentFeedback const

const SentFeedback: Schema.Struct<{ readonly id: Schema.String; readonly text: Schema.String; readonly at: Schema.String; readonly status: Schema.Literals<readonly ["received", "working", "done", "closed", "platform"]>; readonly reply: Schema.NullOr<Schema.Struct<{ readonly by: Schema.Literals<readonly ["assistant", "administrator"]>; readonly text: Schema.String; readonly at: Schema.String; }>>; }>

Something a person sent before, as its sender sees it: their words, where it stands and the last word on it.

源码: packages/host-api/src/host.ts:136

facilities

Serving type

type Serving = {
    /** The integration drivers the workspace's links open (`to_drivers` from `@norbital-ai/providers/abi`). */
    readonly providers?: readonly Provider[];
    readonly oauth?: Partial<Record<OAuthVendor, OAuthClient>>;
    /** Norbital Convert: documents for `ctx.convert.document`, and `ingest` for the agent and `ctx.convert.ingest`. */
    readonly convert?: ConvertPort;
    /** A headless browser printing a record's print route to PDF (`ctx.convert.record`). */
    readonly render?: RenderPort;
    /** Capabilities the host supplies to agent turns and `ctx.ai.sys_2.infer` (`web_search`); a policy still has to name each. */
    readonly host_tools?: AgentPorts['host_tools'];
    readonly geocoder?: GeocoderPort;
    readonly web?: WebReadPort;
    readonly browser?: BrowserPort;
    readonly shell?: Pick<ShellPorts, 'environment' | 'push'>;
    close?(): Promise<void>;
};

What a host file (norbital.host.ts) may export as serving beside its default Facilities: the parts an untethered host serves around them. Each one absent is off; close ends what the file opened when its host stops.

成员

名称类型说明
providers?readonly Provider[]

The integration drivers the workspace's links open (to_drivers from @norbital-ai/providers/abi).

oauth?Partial<Record<OAuthVendor, OAuthClient>>
convert?ConvertPort

Norbital Convert: documents for ctx.convert.document, and ingest for the agent and ctx.convert.ingest.

render?RenderPort

A headless browser printing a record's print route to PDF (ctx.convert.record).

host_tools?AgentPorts['host_tools']

Capabilities the host supplies to agent turns and ctx.ai.sys_2.infer (web_search); a policy still has to name each.

geocoder?GeocoderPort
web?WebReadPort
browser?BrowserPort
shell?Pick<ShellPorts, 'environment' | 'push'>
close?(() => Promise<void>) | undefined

源码: packages/host-api/src/facilities.ts:426

integrations

SetupDescription const

const SetupDescription: Schema.Struct<{ readonly kind: Schema.Literals<readonly ["form", "qr", "code", "oauth", "none"]>; readonly steps: Schema.withDecodingDefaultKey<Schema.Codec<readonly { readonly text: string | { readonly en: string; readonly zh?: string; }; readonly href?: string; readonly copy?: "redirect_url" | "webhook_url"; }[], unknown, never, never>, never>; readonly fields: Schema.optionalKey<Schema.Codec<readonly { readonly name: string; readonly label: string | { readonly en: string; readonly zh?: string; }; readonly secret?: boolean; readonly hint?: string | { readonly en: string; readonly zh?: strin…

How a provider is set up, as data the shell renders with no provider-named component. kind is what pair takes: form sends fields; qr/code sends the optional fields and then shows what pairing publishes; oauth sends nothing and publishes a sign-in; none needs nothing. A qr, code or oauth setup starts on Connect. webhook: the operator pastes about.webhook_url into the provider.

源码: packages/host-api/src/integrations.ts:78

SetupField const

const SetupField: Schema.Struct<{ readonly name: Schema.String; readonly label: Schema.Union<readonly [Schema.String, Schema.Struct<{ readonly en: Schema.String; readonly zh: Schema.optionalKey<Schema.middlewareDecoding<Schema.String, never>>; }>]>; readonly secret: Schema.optionalKey<Schema.middlewareDecoding<Schema.Boolean, never>>; readonly hint: Schema.optionalKey<Schema.middlewareDecoding<Schema.Union<readonly [Schema.String, Schema.Struct<{ readonly en: Schema.String; readonly zh: Schema.optionalKey<Schema.middlewareDecoding<Schema.String, never>>; }>]>, never>>; readonly optional: Schema.optionalKey<Sch…

One input a provider's setup collects. secret is drawn masked and never echoed back in about.

源码: packages/host-api/src/integrations.ts:52

SetupStep const

const SetupStep: Schema.Struct<{ readonly text: Schema.Union<readonly [Schema.String, Schema.Struct<{ readonly en: Schema.String; readonly zh: Schema.optionalKey<Schema.middlewareDecoding<Schema.String, never>>; }>]>; readonly href: Schema.optionalKey<Schema.middlewareDecoding<Schema.String, never>>; readonly copy: Schema.optionalKey<Schema.middlewareDecoding<Schema.Literals<readonly ["webhook_url", "redirect_url"]>, never>>; }>

One instruction, in order. href is where to do it (the provider's console); copy a value to paste there: the instance's webhook_url, or redirect_url (the host's one OAuth callback, to register with an OAuth app once).

源码: packages/host-api/src/integrations.ts:66

host

ShellNotice type

type ShellNotice = {
    text: string;
    tone?: 'info' | 'warning';
    href?: string;
    action?: string;
};

A host banner above every page; href is its one action.

成员

名称类型说明
textstring
tone?'info' | 'warning'
href?string
action?string

源码: packages/host-api/src/host.ts:48

ShellPorts type

type ShellPorts = {
    /** Read on every request: the host may rename or rebrand the workspace while it serves. */
    readonly workspace: () => {
        readonly name: string;
        readonly handle: string;
        readonly icons?: readonly {
            readonly src: string;
            readonly sizes: string;
            readonly type: string;
        }[];
    };
    readonly push?: {
        readonly public_key: string;
    };
    readonly studio?: StudioPort;
    /** The agent panel is offered. */
    readonly ai?: boolean;
    /** The environment badge's name (`production` shows none). */
    readonly environment?: string;
    readonly notice?: (auth: Authority) => Promise<ShellNotice | null>;
    readonly organization?: {
        write(auth: Authority, branding: {
            logo: string | null;
        }): Promise<void>;
    };
    /** The host's apex origin (sign-in hand-off, the workspace switcher). */
    readonly apex?: string;
    /** Set when this shell serves a preview environment: the live workspace's address (the preview banner's link). */
    readonly live?: string;
    /**
     * Where an administrator repairs this workspace when it will not open (the host's recovery Studio). A host with no
     * recovery of its own (a self-hosted server) sets none; the failure card then offers only a retry.
     */
    readonly recovery?: string;
    /**
     * Where an administrator sees this workspace's usage, cost, payment card and invoices (the host's billing pa…

The shell's host parts; studio and organization.write may reject with an encoded HostFailure.

成员

名称类型说明
workspace() => { readonly name: string; readonly handle: string; readonly icons?: readonly { readonly src: string; readonly sizes: string; readonly type: string; }[]; }

Read on every request: the host may rename or rebrand the workspace while it serves.

push?{ readonly public_key: string; }
studio?StudioPort
ai?boolean

The agent panel is offered.

environment?string

The environment badge's name (production shows none).

notice?(auth: Authority) => Promise<ShellNotice | null>
organization?{ write(auth: Authority, branding: { logo: string | null; }): Promise<void>; }
apex?string

The host's apex origin (sign-in hand-off, the workspace switcher).

live?string

Set when this shell serves a preview environment: the live workspace's address (the preview banner's link).

recovery?string

Where an administrator repairs this workspace when it will not open (the host's recovery Studio). A host with no recovery of its own (a self-hosted server) sets none; the failure card then offers only a retry.

billing?string

Where an administrator sees this workspace's usage, cost, payment card and invoices (the host's billing page); Settings links it. A host that bills nothing sets none.

workspaces?(auth: Authority) => Promise<readonly WorkspaceLink[]>
feedback?{ readonly send: (auth: Authority, feedback: Feedback) => Promise<void>; readonly sent: (auth: Authority) => Promise<readonly SentFeedback[]>; }

The shell's Feedback dialog: send takes what a person wrote, sent answers what that person sent before and what became of each. A host that takes no feedback sets none and the shell offers no dialog.

usage?(auth: Authority, views: readonly PageView[]) => Promise<void>

Page views as the shell saw them, in order; a host that keeps no usage sets none and the shell sends nothing.

源码: packages/host-api/src/host.ts:57

ports

Signal type

type Signal = {
    readonly signal: AbortSignal;
};

The abort signal every call takes.

成员

名称类型说明
signalAbortSignal

源码: packages/host-api/src/ports.ts:6

tools

SkillSchema const

const SkillSchema: Schema.Struct<{ readonly text: Schema.String; readonly digest: Schema.String; readonly files: Schema.$Array<Schema.String>; }>

A skill ("Running a file"): a folder of SKILL.md, its scripts and the pure-JavaScript packages it vendors, at most SKILL_BYTES. Its SKILL.md text, the digest of its tree (sha256 hex of the sorted <path>\0<sha256 hex> lines, \n-joined) and its file paths, sorted; the bytes are the artifact's skills/<name>/.

源码: packages/host-api/src/tools.ts:168

db

Sql type

type Sql = {
    readonly text: string;
    readonly params: readonly Json[];
};

One statement with positional parameters ($1…); values are JSON (numeric, timestamps and dates as strings).

成员

名称类型说明
textstring
paramsreadonly Json[]

源码: packages/host-api/src/db.ts:8

studio

StudioApproval type

type StudioApproval = {
    id: string;
    op: StudioOp;
    requestor: string;
    conversation: string;
    at: string;
    head?: string;
    destructive?: readonly string[];
};

A live-changing op (a merge, a rollback) the agent asked for, held for its requestor: it runs as them once they approve it. head: the change's head it was asked on (a moved one refuses the approval); destructive: the schema steps approving a merge accepts.

成员

名称类型说明
idstring
opStudioOp
requestorstring
conversationstring
atstring
head?string
destructive?readonly string[]

源码: packages/host-api/src/studio.ts:378

StudioBuild type

type StudioBuild = {
    commit: string;
    at: string;
    status: 'built' | 'failed';
    message: string;
    deployed: boolean;
    live: boolean;
    lines: number;
    diagnostics: number;
};

A build of a commit, newest first: deployed once a Version ran it, live while live serves it.

成员

名称类型说明
commitstring
atstring
status'built' | 'failed'
messagestring
deployedboolean
liveboolean
linesnumber
diagnosticsnumber

源码: packages/host-api/src/studio.ts:109

StudioChangeSet type

type StudioChangeSet = {
    id: string;
    title: string;
    state: 'open' | 'merged';
    opened_by: string;
    contributors: readonly string[];
    branch: string;
    base: string;
    head: string;
    /** What it holds beyond live: each commit's message, oldest first. */
    commits: readonly string[];
    /** The same commits with their ids; a merged one keeps them. */
    history?: readonly {
        commit: string;
        message: string;
    }[];
    /** What a merge changed, against `base`. */
    files?: readonly {
        path: string;
        change: 'added' | 'modified' | 'deleted';
    }[];
    behind: number;
    preview: StudioPreview | null;
    merge?: {
        /** `queued` waits its turn: `at` is when it asked, and order among the queued is by `at`. */
        state: 'scheduled' | 'queued' | 'running' | 'failed';
        at: string;
        head: string;
        error?: string;
        run_at?: string;
    };
    log: readonly StudioLogLine[];
    created_at: string;
    updated_at: string;
    /** Its head's last build's diagnosis. */
    diagnostics?: readonly StudioDiagnostic[];
};

A Change: a named set of edits on branch, from live, with its own preview. base is where it left live (the diff's other side) and behind how many live commits it lacks (a merge takes them in). merge is a merge running in the background, or the reason the last one failed; a clean merge moves live and records a Version.

成员

名称类型说明
idstring
titlestring
state'open' | 'merged'
opened_bystring
contributorsreadonly string[]
branchstring
basestring
headstring
commitsreadonly string[]

What it holds beyond live: each commit's message, oldest first.

history?readonly { commit: string; message: string; }[]

The same commits with their ids; a merged one keeps them.

files?readonly { path: string; change: 'added' | 'modified' | 'deleted'; }[]

What a merge changed, against base.

behindnumber
previewStudioPreview | null
merge?{ /** `queued` waits its turn: `at` is when it asked, and order among the queued is by `at`. */ state: 'scheduled' | 'queued' | 'running' | 'failed'; at: string; head: string; error?: string; run_at?: string; }
logreadonly StudioLogLine[]
created_atstring
updated_atstring
diagnostics?readonly StudioDiagnostic[]

Its head's last build's diagnosis.

源码: packages/host-api/src/studio.ts:142

StudioDiagnostic type

type StudioDiagnostic = CheckDiagnostic & {
    severity?: 'error' | 'warn';
};

One diagnostic of the last build (bolt build --json's errors); severity defaults to error.

成员

名称类型说明
messageSchema.String
codeSchema.String
pathSchema.String
line?Schema.optionalKey<Schema.Number>
help?Schema.optionalKey<Schema.String>
severity?'error' | 'warn'

源码: packages/host-api/src/studio.ts:88

StudioEnvironment type

type StudioEnvironment = {
    name: string;
    release: string;
    url: string | null;
};

A tenant environment the host routes (live, a change's preview, …): release is the artifact it serves, '' when unrouted.

成员

名称类型说明
namestring
releasestring
urlstring | null

源码: packages/host-api/src/studio.ts:120

StudioFile const

const StudioFile: Schema.Union<readonly [Schema.Struct<{ readonly text: Schema.String; readonly truncated: Schema.optionalKey<Schema.Struct<{ readonly limit: Schema.Number; readonly bytes: Schema.Number; }>>; }>, Schema.Struct<{ readonly binary: Schema.Literal<true>; readonly bytes: Schema.Number; }>]>

One file of a commit (StudioPort.file): its text, or binary (not UTF-8 text) with its size. A text past the host's one-file bound is cut there, and truncated says so: limit the bound, bytes the whole file (the editor is then read-only, so a save never writes the cut text back).

源码: packages/host-api/src/studio.ts:77

StudioFileChange type

type StudioFileChange = {
    path: string;
    change: 'added' | 'modified' | 'deleted';
    text?: string;
    baseline?: string;
};

A changed file and what its diff needs: the head's text (absent: deleted, or not text) and the base's baseline (absent: added, or not text), each cut at the host's one-file text bound.

成员

名称类型说明
pathstring
change'added' | 'modified' | 'deleted'
text?string
baseline?string

源码: packages/host-api/src/studio.ts:66

StudioFrame const

const StudioFrame: Schema.Decoder<StudioFrame, never>

A pushed authoring frame: a build log line, a head moved (someone else saved), a change changed, a phase or task moved.

源码: packages/host-api/src/studio.ts:394

StudioInspectInput const

const StudioInspectInput: Schema.Struct<{ readonly range: Schema.Literals<readonly ["24h", "7d", "30d"]>; readonly view: Schema.optionalKey<Schema.Literals<readonly ["bundle", "telemetry", "logs", "users", "activity", "improvements"]>>; readonly build: Schema.optionalKey<Schema.NullOr<Schema.String>>; readonly run: Schema.optionalKey<Schema.NullOr<Schema.String>>; readonly level: Schema.optionalKey<Schema.NullOr<Schema.Literals<readonly ["info", "warn", "error"]>>>; readonly text: Schema.optionalKey<Schema.NullOr<Schema.String>>; }>

The administrator's monitoring scope. No source paths, code or mutation is accepted here.

源码: packages/host-api/src/studio.ts:469

StudioInspection const

const StudioInspection: Schema.Struct<{ readonly can_inspect: Schema.Boolean; readonly as_of: Schema.String; readonly usage: Schema.$Array<Schema.Struct<{ readonly title: Schema.String; readonly unit: Schema.String; readonly lines: Schema.$Array<Schema.Struct<{ readonly label: Schema.String; readonly bound: Schema.Boolean; readonly points: Schema.$Array<Schema.Struct<{ readonly at: Schema.Number; readonly value: Schema.NullOr<Schema.Number>; }>>; }>>; readonly utilization: Schema.NullOr<Schema.Number>; }>>; readonly members: Schema.NullOr<Schema.$Array<Schema.Struct<{ readonly id: Schema.String; readonly name: Schem…

Curated host diagnostics shared by the tenant Studio and Realm; never source, manifests or credentials.

源码: packages/host-api/src/studio.ts:573

StudioLogLine type

type StudioLogLine = {
    at: string;
    level: 'info' | 'warn' | 'error';
    message: string;
};

One build log line: when, its level and its text.

成员

名称类型说明
atstring
level'info' | 'warn' | 'error'
messagestring

源码: packages/host-api/src/studio.ts:86

StudioManifest const

const StudioManifest: Schema.Struct<{ readonly workspace: Schema.Struct<{ readonly secrets: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Unknown>>; }>; readonly models: Schema.$Record<Schema.String, Schema.Unknown>; readonly apps: Schema.$Record<Schema.String, Schema.Struct<{ readonly shell: Schema.optionalKey<Schema.String>; readonly pages: Schema.$Record<Schema.String, Schema.Unknown>; }>>; readonly policies: Schema.$Record<Schema.String, Schema.Unknown>; readonly automations: Schema.$Record<Schema.String, Schema.Unknown>; }>

The parts of a build's manifest Studio reads: each declaration by name (its source path follows from it), an app's shell and pages, and the workspace's secrets.

源码: packages/host-api/src/studio.ts:51

StudioMigration type

type StudioMigration = {
    state: 'passed' | 'failed';
    error?: string;
    impact?: MigrationImpact;
    checks?: readonly {
        sql: string;
        before: Json;
        after: Json;
    }[];
};

The last run of this exact source's migrations on the author's own database: what each step did, or what refused, and each check as it read before and after. Live is never one of these: only a merge migrates live.

成员

名称类型说明
state'passed' | 'failed'
error?string
impact?MigrationImpact
checks?readonly { sql: string; before: Json; after: Json; }[]

源码: packages/host-api/src/studio.ts:190

StudioOp const

const StudioOp: Schema.Union<readonly [Schema.Struct<{ readonly op: Schema.Literal<"save">; readonly expected: Schema.String; readonly message: Schema.optionalKey<Schema.decodeTo<Schema.String, Schema.NonEmptyString, never, never>>; readonly files: Schema.$Record<Schema.String, Schema.NullOr<Schema.String>>; }>, Schema.Struct<{ readonly op: Schema.Literal<"draft">; readonly path: Schema.NonEmptyString; readonly content: Schema.String; }>, Schema.Struct<{ readonly op: Schema.Literal<"draft">; readonly path: Schema.NonEmptyString; readonly old_string: Schema.NonEmptyString; readonly new_string: Schema.String; …

change.open works on an existing change (id): a person has one active change at a time, and their first edit starts it, a branch from live and a copy-on-write fork of live's data as its preview. draft writes one path of the viewer's working tree (the whole content, an old_string replacement, a move to another path or a remove) and moves no head; with none open, it opens a change. commit makes the working tree the change's next commit, in any state. save commits edits to the viewer's change over expected (a stale head is refused; with none open, the save opens one named by its message), null deletes a file. preview is the build: it builds the head and serves it, and a merge requires the preview of the head it promotes and an empty working tree; a migration the build generates, and a squash of the change's history into a verified baseline, land in the working tree. change.merge merges a change into live in the background: git's 3-way merge (conflicts land in the change as marked files, live untouched), a build of the merged tree with its checks, then the cutover; accept names the destructive schema steps it may apply (any other refuses it); at schedules it for that instant instead, and change.unschedule drops the schedule. Its cutover is the tenant's only downtime: requests answer maintenance and in-flight work is cancelled until the new release serves. change.rebase replays the viewer's commits on top of live, and a merge needs that: merged migrations stay as they are and the viewer's are set on top, and what stops lands as marked files with conflict_notes. change.revert drops a commit and those after it, source only: data rolls back on live alone. rollback brings a Version back, source and data together, recording the state it leaves as an Undo Version first; a schema change refuses it unless discard_data_since names the instant whose later writes it discards. It is neither the operator's database restore nor a record's restore. approval.decide approves (it runs as the viewer) or rejects one of the viewer's held requests (StudioState.approvals). Every op is decoded at the shell boundary.

源码: packages/host-api/src/studio.ts:278

StudioPhase type

type StudioPhase = (typeof STUDIO_PHASES)[number];

One of STUDIO_PHASES.

源码: packages/host-api/src/studio.ts:390

StudioPort type

type StudioPort = {
    state(auth: Authority): Promise<StudioState>;
    run(auth: Authority, op: StudioOp): Promise<StudioState>;
    /** One file at a commit (`StudioState.commit`, or a change's base); `null`: no such file there. */
    file(auth: Authority, commit: string, path: string): Promise<StudioFile | null>;
    /** This workspace's frames as they happen, never another's; answers the unsubscribe. Absent → no live stream. */
    watch?(auth: Authority, send: (frame: StudioFrame) => void): () => void;
    /** Curated operational diagnostics shared with Realm across the current HOST_API contract. */
    inspect(auth: Authority, input: StudioInspectInput): Promise<StudioInspection>;
    /** Where this host serves Studio's browser bundle, under the workspace; `null`: it has none to serve. */
    bundle?(): Promise<string | null>;
};

Called for an administrator; the host decides what each may do, a refusal rejects with an encoded HostFailure.

成员

名称类型说明
state(auth: Authority) => Promise<StudioState>
run(auth: Authority, op: StudioOp) => Promise<StudioState>
file(auth: Authority, commit: string, path: string) => Promise<StudioFile | null>

One file at a commit (StudioState.commit, or a change's base); null: no such file there.

watch?((auth: Authority, send: (frame: StudioFrame) => void) => () => void) | undefined

This workspace's frames as they happen, never another's; answers the unsubscribe. Absent → no live stream.

inspect(auth: Authority, input: StudioInspectInput) => Promise<StudioInspection>

Curated operational diagnostics shared with Realm across the current HOST_API contract.

bundle?(() => Promise<string | null>) | undefined

Where this host serves Studio's browser bundle, under the workspace; null: it has none to serve.

源码: packages/host-api/src/studio.ts:454

StudioPreview type

type StudioPreview = {
    url: string | null;
    commit: string;
    artifact: string;
    stale: boolean;
    shelved?: true;
    destructive?: readonly string[];
    impact?: MigrationImpact;
};

A change's preview: its own copy-on-write fork of live's data, taken when the change was opened, serving the build of commit (stale once the head moved past it, while the newer head builds). url is null while it is shelved: idle for two hours, its fork was deleted; opening the change again re-forks live and reuses the build. destructive: the schema steps merging that build applies (a merge must accept them); impact: what applying its migrations did on the fork (each step's rows, the duration: the merge's expected downtime).

成员

名称类型说明
urlstring | null
commitstring
artifactstring
staleboolean
shelved?true
destructive?readonly string[]
impact?MigrationImpact

源码: packages/host-api/src/studio.ts:128

StudioRelease type

type StudioRelease = {
    commit: string;
    at: string;
    message: string;
    current: boolean;
    checkpoint?: string | null;
    rollback?: string;
    undo?: true;
    discards?: string;
    replaced?: true;
};

A Version: every merge or rollback live ran, newest first, restorable. rollback deploys one again as a new Version, source and data together. checkpoint: the instant whose data rolling back to it keeps (null: none to roll back to). rollback: the commit this Version rolled back to. undo: the state live was in just before a rollback, so rolling back to it undoes that rollback. discards: its schema differs from live's, so rolling back to it discards the data written after this instant (a fork at its latest point). replaced: its data point belonged to a database a reset has since replaced, so it can no longer be rolled back to (checkpoint is then null).

成员

名称类型说明
commitstring
atstring
messagestring
currentboolean
checkpoint?string | null
rollback?string
undo?true
discards?string
replaced?true

源码: packages/host-api/src/studio.ts:97

tools

StudioRole type

type StudioRole = (typeof STUDIO_ROLES)[number];

One of STUDIO_ROLES.

源码: packages/host-api/src/tools.ts:20

studio

StudioState type

type StudioState = {
    commit: string;
    /** The commit holding the viewer's uncommitted edits; `files`, `changes` and `conflicts` read it. Absent: none. */
    working?: string;
    /** The last diagnosis of this exact source; none run, absent. */
    diagnosis?: 'passed' | 'failed';
    /** The working tree's git tree: what a check and a test run are kept by. Absent on a monitoring read. */
    tree?: string;
    /** The latest test job for this exact tree; absent when it has not been tested. */
    tests?: StudioTestRun;
    migration?: StudioMigration;
    /** The head commit's description (its message's first line). */
    message?: string;
    /** The live workspace's IANA timezone. */
    zone?: string;
    /** Every path of the tree with its size; never its content, so a read stays the same size as a file grows. */
    files: {
        readonly [path: string]: {
            bytes: number;
        };
    };
    changes: readonly StudioFileChange[];
    manifest: StudioManifest | null;
    log: readonly StudioLogLine[];
    /** The viewer's change's preview URL (`null`: no change open, or its preview is shelved). */
    preview: string | null;
    releases: readonly StudioRelease[];
    environments?: readonly StudioEnvironment[];
    change?: string;
    branch?: string;
    preview_of?: StudioPreview;
    /** The open change's preview control; absent: nobody claimed it. */
    preview_control?: PreviewControl;
    base?: string;
    behind?: number;
    conflicts…

A workspace's Studio state as the host reports it: commit, working tree, checks, tests, manifest, log, preview and releases.

成员

名称类型说明
commitstring
working?string

The commit holding the viewer's uncommitted edits; files, changes and conflicts read it. Absent: none.

diagnosis?'passed' | 'failed'

The last diagnosis of this exact source; none run, absent.

tree?string

The working tree's git tree: what a check and a test run are kept by. Absent on a monitoring read.

tests?StudioTestRun

The latest test job for this exact tree; absent when it has not been tested.

migration?StudioMigration
message?string

The head commit's description (its message's first line).

zone?string

The live workspace's IANA timezone.

files{ readonly [path: string]: { bytes: number; }; }

Every path of the tree with its size; never its content, so a read stays the same size as a file grows.

changesreadonly StudioFileChange[]
manifestStudioManifest | null
logreadonly StudioLogLine[]
previewstring | null

The viewer's change's preview URL (null: no change open, or its preview is shelved).

releasesreadonly StudioRelease[]
environments?readonly StudioEnvironment[]
change?string
branch?string
preview_of?StudioPreview
preview_control?PreviewControl

The open change's preview control; absent: nobody claimed it.

base?string
behind?number
conflicts?ReadonlyArray<{ path: string; kind: 'content' | 'binary' | 'edit/delete' | 'migration'; }>
conflict_notes?readonly string[]

Why a migration among conflicts stopped, in plain words.

change_sets?readonly StudioChangeSet[]
diagnostics?readonly StudioDiagnostic[]

The viewer's change's last build's diagnosis (empty: it built clean; absent: not built, or the host reports none).

builds?readonly StudioBuild[]

The retained builds, newest first; StudioPort.build reads one's log and diagnostics.

approvals?readonly StudioApproval[]

The viewer's own held requests: what the agent asked to change on live, awaiting their approval.decide.

runtime?{ readonly current: string | null; readonly latest: string; }

The workspace's pinned @norbital-ai/bolt version beside the host's latest known release.

源码: packages/host-api/src/studio.ts:197

StudioStreamFailed class

class StudioStreamFailed extends StudioStreamFailed_base {
}

Studio's event stream ended: an undecodable event or a dropped connection.

成员

名称类型说明
messagestring

源码: packages/host-api/src/studio.ts:417

StudioTab type

type StudioTab = (typeof STUDIO_TABS)[number];

One of STUDIO_TABS.

源码: packages/host-api/src/studio.ts:452

StudioTestRun const

const StudioTestRun: Schema.Struct<{ readonly id: Schema.String; readonly commit: Schema.String; readonly state: Schema.Literals<readonly ["running", "passed", "failed", "empty"]>; readonly started_at: Schema.String; readonly finished_at: Schema.optionalKey<Schema.String>; readonly summary: Schema.optionalKey<Schema.Struct<{ readonly files: Schema.Int; readonly total: Schema.Int; readonly passed: Schema.Int; readonly failed: Schema.Int; readonly skipped: Schema.Int; readonly duration_ms: Schema.Finite; }>>; readonly files: Schema.$Array<Schema.Struct<{ readonly path: Schema.String; readonly state: Schema.Literals…

A fixed test job's parsed results, tied to the exact source it executed.

源码: packages/host-api/src/studio.ts:11

StudioView const

const StudioView: Schema.Decoder<StudioView, never>

What the browser gets: the state with the manifest cut to each Manifest chip's entries. sections is null before a build, and also when the build is stale: a declaration whose source file the workbench no longer holds fails the whole projection closed, so the pane never links into files that are gone. StudioView as the browser decodes it from the shell's Studio routes.

源码: packages/host-api/src/studio.ts:753

system-1

System1 type

type System1 = {
    readonly ask: (request: DecisionRequest, model?: string) => Effect.Effect<DecisionResult, FacilityFailure | Unavailable>;
    readonly maxChoices?: number | undefined;
};

System 1 as an Effect: one bounded decision call, failing as a facility failure or unavailable; a host adapts it to its System1Port. model is a catalogue id the workspace chose; absent, the adapter's own.

成员

名称类型说明
ask(request: DecisionRequest, model?: string) => Effect.Effect<DecisionResult, FacilityFailure | Unavailable>
maxChoices?number | undefined

源码: packages/host-api/src/system-1.ts:78

ai

System1Port interface

interface System1Port {
    /** `model`: a `catalog` id the workspace's administrator chose; absent, `catalog().default`. */
    ask(request: DecisionRequest, signal: AbortSignal, model?: string): Promise<DecisionResult>;
    readonly max_choices?: number;
    /** The models the provider can decide with, as it lists them, and the one it uses unless told otherwise. */
    catalog(): Promise<{
        models: readonly AiModel[];
        default: string;
    }>;
}

Host port for System 1 (sys_1): bounded, fail-closed, independent structured decisions over text, JSON, and resolved inline PNG/JPEG images (ctx.ai.sys_1.decide and conversation triage). Never falls back silently.

成员

名称类型说明
ask(request: DecisionRequest, signal: AbortSignal, model?: string) => Promise<DecisionResult>

model: a catalog id the workspace's administrator chose; absent, catalog().default.

max_choices?number
catalog() => Promise<{ models: readonly AiModel[]; default: string; }>

The models the provider can decide with, as it lists them, and the one it uses unless told otherwise.

源码: packages/host-api/src/ai.ts:175

host

TaskEnd type

type TaskEnd = {
    readonly run: string;
    readonly conversation: string;
    readonly state: 'completed' | 'question' | 'error' | 'cancelled';
    readonly text: string;
};

How a task ended: completed with its last words, question when they ask its starter, error or cancelled.

成员

名称类型说明
runstring
conversationstring
state'completed' | 'question' | 'error' | 'cancelled'
textstring

源码: packages/host-api/src/host.ts:122

TaskStart const

const TaskStart: Schema.Struct<{ readonly run: Schema.String; readonly description: Schema.String; readonly prompt: Schema.String; readonly files: Schema.optionalKey<Schema.$Array<Schema.Codec<Schema.Json, Schema.Json, never, never>>>; }>

A system agent's task: an agent conversation no person attends, acting as the system under policies. run names it to its starter (the automation run, or the host's own id for the work).

源码: packages/host-api/src/host.ts:112

facilities

TcpEndpoint type

type TcpEndpoint = {
    readonly host: string;
    readonly port: number;
    readonly tls: boolean;
    readonly servername?: string;
};

Where a TCP connection goes; tls opens it as TLS, verified against servername (default host).

成员

名称类型说明
hoststring
portnumber
tlsboolean
servername?string

源码: packages/host-api/src/facilities.ts:287

TcpPort interface

interface TcpPort {
    connect(endpoint: TcpEndpoint, signal: AbortSignal): Promise<TcpSocket>;
}

Outbound TCP/TLS (IMAP, SMTP) under the host's egress policy: the host resolves and checks the destination (a public host refuses private and reserved networks) and connects. signal bounds the connect; close ends the connection.

成员

名称类型说明
connect(endpoint: TcpEndpoint, signal: AbortSignal) => Promise<TcpSocket>

源码: packages/host-api/src/facilities.ts:308

TcpSocket type

type TcpSocket = {
    readonly readable: ReadableStream<Uint8Array>;
    readonly writable: WritableStream<Uint8Array>;
    close(): Promise<void>;
    /**
     * STARTTLS: TLS over this cleartext connection, verified as the endpoint says. Release both streams' locks first;
     * this socket's streams then end and the returned one carries the connection.
     */
    start_tls(signal: AbortSignal): Promise<TcpSocket>;
};

One outbound TCP connection as two byte streams.

成员

名称类型说明
readableReadableStream<Uint8Array>
writableWritableStream<Uint8Array>
close() => Promise<void>
start_tls(signal: AbortSignal) => Promise<TcpSocket>

STARTTLS: TLS over this cleartext connection, verified as the endpoint says. Release both streams' locks first; this socket's streams then end and the returned one carries the connection.

源码: packages/host-api/src/facilities.ts:294

integrations

TestSend const

const TestSend: Schema.Struct<{ readonly to: Schema.optionalKey<Schema.Struct<{ readonly name: Schema.String; readonly label: Schema.Union<readonly [Schema.String, Schema.Struct<{ readonly en: Schema.String; readonly zh: Schema.optionalKey<Schema.middlewareDecoding<Schema.String, never>>; }>]>; readonly secret: Schema.optionalKey<Schema.middlewareDecoding<Schema.Boolean, never>>; readonly hint: Schema.optionalKey<Schema.middlewareDecoding<Schema.Union<readonly [Schema.String, Schema.Struct<{ readonly en: Schema.String; readonly zh: Schema.optionalKey<Schema.middlewareDecoding<Schema.String, never>>; }>]>, ne…

A connected instance's test send: a short test message, to the handle the operator types in to (absent: to the connected account itself).

源码: packages/host-api/src/integrations.ts:149

tools

ToolBehavior const

const ToolBehavior: Schema.Struct<{ readonly pure: Schema.optionalKey<Schema.Literal<true>>; readonly progress_check: Schema.optionalKey<Schema.Literal<true>>; readonly diagnostics: Schema.optionalKey<Schema.Literal<true>>; readonly data: Schema.optionalKey<Schema.Literal<true>>; readonly page: Schema.optionalKey<Schema.Literal<true>>; readonly downloads: Schema.optionalKey<Schema.Literal<true>>; readonly source_edit: Schema.optionalKey<Schema.Literal<true>>; readonly web_results: Schema.optionalKey<Schema.Literal<true>>; readonly resume: Schema.optionalKey<Schema.Struct<{ readonly argument: Schema.String; reado…

Native tool behavior, declared by its owner and carried with its stored step: - source_edit: its input is a source edit, { path, content }, { path, oldString, newString } or { patchText }; the panel shows its diff, which never enters the model's context. - web_results: its result's results are web pages, { url, title?, site?, date?, excerpt? }, listed as links.

源码: packages/host-api/src/tools.ts:27

host

ToolSubject type

type ToolSubject = {
    readonly conversation: string;
} | {
    readonly run: string;
};

What a host tool list is for: one agent conversation, or one automation run's inference.

源码: packages/host-api/src/host.ts:105

tools

ToolView const

const ToolView: Schema.Struct<{ readonly icon: Schema.String; readonly verb: Schema.String; readonly target: Schema.String; readonly doing: Schema.optionalKey<Schema.String>; }>

How one call reads in the panel, in the person's words: its icon (lucide:<name>), what it did (verb) and to what (target, possibly empty), and what it is doing while it runs. The shell translates the words it knows.

源码: packages/host-api/src/tools.ts:45

facilities

TransportPort interface

interface TransportPort {
    /** `kind` names what it sends (`email`, `sms`, `inbox` for push); the address is the message's. Any throw is a failed send. */
    send(kind: string, message: Json, signal: AbortSignal): Promise<{
        provider_id: string;
    }>;
}

The host's transactional mail and SMS (identity codes, invitations) and web push: a send to an address.

成员

名称类型说明
send(kind: string, message: Json, signal: AbortSignal) => Promise<{ provider_id: string; }>

kind names what it sends (email, sms, inbox for push); the address is the message's. Any throw is a failed send.

源码: packages/host-api/src/facilities.ts:192

errors

Unavailable class

class Unavailable extends Unavailable_base {
    readonly message: string;
}

An optional facility with no provider bound, or an instance not paired: the facility and why.

成员

名称类型说明
messagestring
facilitySchema.String
reasonSchema.String

源码: packages/host-api/src/errors.ts:29

storage

UnknownStorage class

class UnknownStorage extends UnknownStorage_base {
}

The branch's storage is not the recovery contract's (another layout, or no applied schema).

成员

名称类型说明
messagestring

源码: packages/host-api/src/storage.ts:30

facilities

WebPage type

type WebPage = {
    readonly url: string;
    readonly title: string | null;
    readonly text: string;
    readonly content_type?: string;
    readonly sha256?: string;
    readonly pages?: number;
    readonly html?: string;
    readonly links?: readonly string[];
};

A read page: its final URL, title and readable text (a PDF's text), and, when the provider reports them, its content type, SHA-256 of the body and a document's page count; with { raw: true } also the markup and its absolute links (a crawl).

成员

名称类型说明
urlstring
titlestring | null
textstring
content_type?string
sha256?string
pages?number
html?string
links?readonly string[]

源码: packages/host-api/src/facilities.ts:174

WebReadPort interface

interface WebReadPort {
    /** Refuses private, loopback and link-local addresses. `raw`: also the markup and its links, for a page that is markup. */
    read(url: string, signal: AbortSignal, options?: {
        raw?: boolean;
    }): Promise<WebPage>;
}

Reads a public web page as text.

成员

名称类型说明
read(url: string, signal: AbortSignal, options?: { raw?: boolean; }) => Promise<WebPage>

Refuses private, loopback and link-local addresses. raw: also the markup and its links, for a page that is markup.

源码: packages/host-api/src/facilities.ts:185

host

WorkspaceBranch type

type WorkspaceBranch = {
    readonly schema: {
        /**
         * Engine tables, then the release's schema plan (destructive steps only when accepted). Answers what it
         * did: each pending step's rows and the whole duration, measured on this branch.
         */
        migrate(options: Signal & {
            readonly accept?: true | readonly string[];
        }): Promise<MigrationImpact>;
    };
    readonly packs: {
        /** The release's seed pack by name (`base`), its assets into `files` when given, ready to load in steps. */
        load(pack: string, options: Signal & {
            readonly at: string;
            readonly files?: FilesPort;
        }): Promise<PackLoad>;
        /**
         * Rows `bolt seed` sent, held only in memory, decoded here and loaded in steps like a pack; each of
         * `assets` is read through `asset` into `files`.
         */
        restore(rows: {
            readonly [model: string]: readonly {
                readonly [field: string]: Json;
            }[];
        }, options: Signal & {
            readonly at: string;
            readonly start: readonly string[];
            readonly assets: readonly SeedAsset[];
            readonly asset: (path: string, options: Signal) => Promise<Uint8Array>;
            readonly files: FilesPort;
        }): Promise<PackLoad>;
        /**
         * The branch's teams, members, integration instances and workspace rows as `restore` takes them, a page at a
         * time from `…

A branch of a workspace database the host prepared: its schema migration, seed pack loads and identity.

成员

名称类型说明
schema{ /** * Engine tables, then the release's schema plan (destructive steps only when accepted). Answers what it * did: each pending step's rows and the whole duration, measured on this branch. */ migrate(options: Signal & { readonly accept?: true | readonly string[]; }): Promise<MigrationImpact>; }
packs{ /** The release's seed pack by name (`base`), its assets into `files` when given, ready to load in steps. */ load(pack: string, options: Signal & { readonly at: string; readonly files?: FilesPort; }): Promise<PackLoad>; /** * Rows `bolt seed` sent, held only in memory, decoded here and loaded in steps like a pack; each of * `assets` is read through `asset` into `files`. */ restore(rows: { reado…
identity{ founder(address: string, options: Signal & { readonly at: string; }): Promise<FounderAnswer>; capture(options: Signal): Promise<string>; restore(snapshot: string, options: Signal): Promise<void>; }
integrations{ /** A restored branch's session instances lose their credentials and read `unpaired`. */ unpair_sessions(options: Signal): Promise<void>; /** One instance as an operator observes it; `not_found` for no such instance. */ status(instance: string, options: Signal): Promise<InstanceAdmin>; /** * Pauses or resumes an instance and deploys or detaches its envoy (an active one, on a workspace conversat…

Integration instances as the host's operator changes them, for a host whose links on this branch are stopped (it reopens them after). Each change bumps the row's revision and commits on its own; values never leave the release.

源码: packages/host-api/src/host.ts:377

type WorkspaceLink = {
    handle: string;
    name: string;
    href: string;
};

Another workspace the caller belongs to, for the shell's switcher.

成员

名称类型说明
handlestring
namestring
hrefstring

源码: packages/host-api/src/host.ts:55

type WorkspaceLinks = {
    /** Relayed, not interpreted: hand it to `activate` as `links`; its failures are the release's own. */
    readonly port: LinksPort;
    /** The sealed credentials the links write through, failures encoded (another owner's `LinkHost.credentials` may retry here). */
    readonly credentials: HostCredentials;
    /** Reopens every active, paired instance this host's providers serve. */
    resume(options: Signal): Promise<void>;
    /** How many links are open now: with none, the host may close these links until it needs them again. */
    open(): Promise<number>;
    /** Closes every link; status streams end. The host then ends its pool. */
    close(): Promise<void>;
    /** `/hooks/integration/<instance>…` and `/hooks/oauth/callback`, the request as the workspace sees it; `null` otherwise. */
    hook(request: Request): Promise<Response | null>;
    /**
     * `/__bolt/integrations/*` for a caller the current generation signs in (`LinkHost.enter`); `null` for another
     * path.
     */
    admin(request: Request): Promise<Response | null>;
};

A workspace's integration links: their port, sealed credentials, hooks and the open count the host reads to idle them.

成员

名称类型说明
portLinksPort

Relayed, not interpreted: hand it to activate as links; its failures are the release's own.

credentialsHostCredentials

The sealed credentials the links write through, failures encoded (another owner's LinkHost.credentials may retry here).

resume(options: Signal) => Promise<void>

Reopens every active, paired instance this host's providers serve.

open() => Promise<number>

How many links are open now: with none, the host may close these links until it needs them again.

close() => Promise<void>

Closes every link; status streams end. The host then ends its pool.

hook(request: Request) => Promise<Response | null>

/hooks/integration/<instance>… and /hooks/oauth/callback, the request as the workspace sees it; null otherwise.

admin(request: Request) => Promise<Response | null>

/__bolt/integrations/* for a caller the current generation signs in (LinkHost.enter); null for another path.

源码: packages/host-api/src/host.ts:451

tools

WorkspaceNote type

type WorkspaceNote = {
    readonly id: string;
    readonly at: string;
    readonly title: string;
    readonly body?: string | undefined;
};

A workspace event as the host publishes it (a change merged, maintenance scheduled, a payment due): at is ISO.

成员

名称类型说明
idstring
atstring
titlestring
body?string | undefined

源码: packages/host-api/src/tools.ts:157

WorkspacePort type

type WorkspacePort = {
    files(): Promise<readonly string[]>;
    read(path: string): Promise<string | null>;
};

A workspace's source files: the released tree, or an author's working tree.

成员

名称类型说明
files() => Promise<readonly string[]>
read(path: string) => Promise<string | null>

源码: packages/host-api/src/tools.ts:152

system-1

answer_criteria function

function answer_criteria(request: DecisionRequest): Schema.Struct<{ readonly answers: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.Struct<{ readonly type: Schema.Literal<"noul">; readonly noul: Schema.Finite; }>, Schema.Struct<{ readonly type: Schema.Literal<"choice">; readonly choice: Schema.String; readonly confidence: Schema.Finite; readonly probabilities: Schema.$Record<Schema.String, Schema.Finite>; }>, Schema.Struct<{ readonly type: Schema.Literal<"score">; readonly score: Schema.Finite; readonly level: Schema.Int; readonly confidence: Schema.Finite; readonly probabilities: Schema.$Record<Schema.String, Schema.Finite>; readonly legend: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Null, Schema.$Array<Schema.Codec<Schema.Json, Schema.Json, never, never>>, Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>]>>; }>]>>; readonly cost_usd: Schema.Finite; readonly provider: Schema.String; readonly model: Schema.optionalKey<Schema.String>; readonly call: Schema.optionalKey<Schema.String>; readonly tokens: Schema.optionalKey<Schema.Struct<{ readonly input: Schema.Number; readonly output: Schema.Number; }>>; }>

DecisionResult that answers each question of request within its offered criteria.

参数

名称类型说明
requestDecisionRequest
  • state: Schema.Union<readonly [Schema.String, Schema.$Array<Schema.Codec<Schema.Json, Schema.Json, never, never>>, Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>]>
  • questions: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.Struct<{ readonly type: Schema.Literal<"noul">; readonly instructions: Schema.optionalKey<Schema.Union<readonly [Schema.String, Schema.Null, Schema.$Array<Schema.Codec<Schema.Json, Schema.Json, never, never>>, Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>]>>; readonly criteria: Schema.optionalKey<Sch…

源码: packages/host-api/src/system-1.ts:215

storage

branch_storage function

function branch_storage(db: RawDb): { member: (person: { readonly email: string | null; readonly phone: string | null; }) => Effect.Effect<{ readonly id: string; readonly name: string; readonly email: string | null; readonly phone: string | null; readonly active: boolean; } | null, DbError | UnknownStorage, never>; user: (id: string) => Effect.Effect<{ readonly id: string; readonly name: string; readonly email: string | null; readonly phone: string | null; readonly active: boolean; } | null, DbError | UnknownStorage, never>; members: Effect.Effect<readonly { readonly id: string; readonly name: string; readonly email: string | null; readonly phone: string | null; readonly active: boolean; }[], DbError | UnknownStorage, never>; administered: (email: string) => Effect.Effect<readonly { readonly id: string; readonly name: string; readonly email: string | null; readonly phone: string | null; readonly active: boolean; }[] | null, DbError | UnknownStorage, never>; paired: Effect.Effect<boolean, DbError | UnknownStorage, never>; }

The recovery storage contract's reads of one branch database; each is one snapshot and one round trip.

参数

名称类型说明
dbRawDb
  • read: (statements: readonly Sql[]) => Effect.Effect<readonly Rows[], DbError>

    Read statements share one snapshot and answer in order; rows are relayed as JSON.

  • write: (statement: Sql, lock?: Lock) => Effect.Effect<Rows, DbError>

    An act's one write statement, with fixed deadlines and native locks before execution.

  • transaction: (batch: DbBatch) => Effect.Effect<readonly Rows[], DbError>

    Complete SQL statements atomically; answers are decoded only after commit or native dry-run rollback.

源码: packages/host-api/src/storage.ts:99

client

client_page function

function client_page(dir: string, path: string): Effect.Effect<ClientPage | undefined, import("effect/PlatformError").PlatformError, FileSystem.FileSystem | Path.Path>

path of the pages of the artifact at dir: a file of its client build, else (under /assets/) of its workspace assets, else the document; undefined when the artifact carries no client pages. /assets/* is cached for good; everything else, the document first, revalidates.

参数

名称类型说明
dirstring
pathstring

源码: packages/host-api/src/client.ts:58

code-mail

code_mail function

function code_mail(code: string, workspace?: string): { subject: string; text: string; html: string; }

The one-time code email every Norbital surface sends: workspace sign-in, signup, platform and command-center sign-in, recovery. Tables and inline styles only, so every client renders it. code is the sender's own digits.

参数

名称类型说明
codestring
workspace?string

源码: packages/host-api/src/code-mail.ts:5

conformance

conformance function

function conformance(input: { readonly api: HostApi; readonly release: Release; readonly tampered: Release; readonly branches: { readonly database: () => Promise<{ readonly port: HostTenantDb; readonly raw: RawDb; }>; readonly keys: KeysPort; readonly instance: { readonly integration: string; readonly configuration: Json; }; }; }): readonly Check[]

The checks for one release: release as built, and tampered, the same release with one of its files changed after the build (the release must refuse it with an encoded HostFailure). branches.database opens a fresh, empty database on each call, as a release reaches it (port) and through the host's own adapter (raw); keys is a working secrets key; instance names an integration the release defines and a configuration it accepts, for the unowned instance the kit seeds.

参数

名称类型说明
input{ readonly api: HostApi; readonly release: Release; readonly tampered: Release; readonly branches: { readonly database: () => Promise<{ readonly port: HostTenantDb; readonly raw: RawDb; }>; readonly keys: KeysPort; readonly instance: { readonly integration: string; readonly configuration: Json; }; }; }
  • api: HostApi
  • release: Release
  • tampered: Release
  • branches: { readonly database: () => Promise<{ readonly port: HostTenantDb; readonly raw: RawDb; }>; readonly keys: KeysPort; readonly instance: { readonly integration: string; readonly configuration: Json; }; }

源码: packages/host-api/src/conformance.ts:56

wire

copiedBatch function

function copiedBatch(batch: DbBatch): DbBatch

Snapshot a batch before acquiring a connection (copiedSql per statement), refusing one past the batch bounds.

参数

名称类型说明
batchDbBatch
  • statements: readonly Sql[]
  • lock?: Lock
  • rollback?: true

    Native dry-run: execute and answer the statements, then roll back all of their effects.

源码: packages/host-api/src/wire.ts:105

copiedSql function

function copiedSql(statement: Sql): Sql

Snapshot all caller-owned values before acquiring a connection, including nested parameter getters.

参数

名称类型说明
statementSql
  • text: string
  • params: readonly Json[]

源码: packages/host-api/src/wire.ts:99

db_error function

function db_error(e: unknown): DbError

A driver failure as a DbError: a SQLSTATE when the server gave one, else a connection failure. Call it only on what the driver threw, never on an error the caller's own code raised inside a transaction.

参数

名称类型说明
eunknown

源码: packages/host-api/src/wire.ts:163

system-1

decision_images function

function decision_images(state: DecisionRequest["state"]): Effect.Effect<{ text: Json; images: readonly { readonly type: "image_url"; readonly image_url: { readonly url: string; }; }[]; }, FacilityFailure, never>

A request's inline images, at most 16 and 20 MiB: the state's text naming each image-<n>, and the images.

参数

名称类型说明
stateDecisionRequest['state']

源码: packages/host-api/src/system-1.ts:35

decisions_system_1 function

function decisions_system_1(config: DecisionsApiConfig, options?: HttpOptions): System1

System 1 over an HTTP decisions API (the native wire or OpenAI's format), bearer-authenticated. Provider refusals and HTTP errors fail as facility failures; the call is bounded by timeout_ms (default 3 s).

参数

名称类型说明
configDecisionsApiConfig
  • format?: DecisionsApiFormat

    Jev/OpenRouter by default; OpenAI native /v1/decisions uses its own wire format.

  • url: string
  • model: string
  • api_key: string
  • timeout_ms?: number | undefined
options?HttpOptions

源码: packages/host-api/src/system-1.ts:370

convert

document_converter function

function document_converter(config: DocumentConverterConfig): DocumentConverter

A converter over a Norbital Convert server: document conversion to every target, plus in-memory PDF previews.

参数

名称类型说明
configDocumentConverterConfig
  • url: string
  • key: string
  • fetch?: typeof fetch | undefined

源码: packages/host-api/src/convert.ts:145

document_ingester function

function document_ingester(config: DocumentConverterConfig): Required<Pick<ConvertPort, "ingest">>

ConvertPort.ingest over Norbital Convert's job routes: a host constructs it from Convert's URL and key. A 415 answers { unsupported }, and a converter with no transcription model rejects audio as unavailable. A password travels as the x-ingest-password header, never the URL. The answer's meta.stats is the conversion's compute and audio's meta.usage its model calls, which the host meters once per call id. The host must resolve a stored key to bytes first.

参数

名称类型说明
configDocumentConverterConfig
  • url: string
  • key: string
  • fetch?: typeof fetch | undefined

源码: packages/host-api/src/convert.ts:322

integrations

http_allows function

function http_allows(allow: HttpSpec["allow"], base: string, method: string, url: URL): boolean

Whether a definition's allow admits method on url under base: a listed method and a path pattern matching it segment by segment ({name} one non-empty segment, a final ** any rest). No allow admits everything.

参数

名称类型说明
allowHttpSpec['allow']
basestring
methodstring
urlURL

源码: packages/host-api/src/integrations.ts:434

http_auth function

function http_auth(auth: HttpSpec["auth"], credential: unknown): Record<string, string> | undefined

The headers a definition's credential auth (bearer, basic or a named header) adds from an instance's sealed credential fields; undefined when one it names is missing. No auth adds none.

参数

名称类型说明
authHttpSpec['auth']
credentialunknown

源码: packages/host-api/src/integrations.ts:453

http_target function

function http_target(base: string, path: string): URL

path under base, never outside it: one leading / is the base itself; an absolute or //host path, ../. segments (encoded too), a \\, a query or fragment, or an encoded /, \\ or % in a segment is refused. The query (a page cursor included) goes through searchParams, so pagination stays inside the prefix.

参数

名称类型说明
basestring
pathstring

源码: packages/host-api/src/integrations.ts:415

media

imageLabel function

function imageLabel(name: string, bytes: Uint8Array): string

The words that introduce an image to the model: its pixel size, so a crop's fractions can be worked out.

参数

名称类型说明
namestring
bytesUint8Array

源码: packages/host-api/src/media.ts:187

migration-impact

impact_lines function

function impact_lines(impact: MigrationImpact, t?: (key: string) => string): readonly string[]

What a person reads before merging: every step that touches data (additions that write nothing are left out), the downtime, then what a rollback costs: the schema differs from before, so it returns live's data to this merge.

参数

名称类型说明
impactMigrationImpact
  • duration_ms: Schema.Number
  • steps: Schema.$Array<Schema.Struct<{ readonly id: Schema.String; readonly hazard: Schema.String; readonly rows: Schema.Number; readonly summary: Schema.String; }>>
t?(key: string) => string

源码: packages/host-api/src/migration-impact.ts:71

impact_text function

function impact_text(step: Pick<MigrationStepImpact, "id" | "hazard" | "rows">, t?: (key: string) => string): string

A step in plain words, read from its generated id (drop:column:contracts.bank, check:contracts.nationality).

参数

名称类型说明
stepPick<MigrationStepImpact, 'id' | 'hazard' | 'rows'>
  • id: Schema.String
  • rows: Schema.Number
  • hazard: Schema.String
t?(key: string) => string

源码: packages/host-api/src/migration-impact.ts:23

media

ingest_answer function

function ingest_answer<B extends Schema.Codec<Uint8Array, unknown>>(bytes: B): Schema.Union<readonly [Schema.Struct<{ readonly images: Schema.$Array<Schema.Struct<{ readonly name: Schema.String; readonly mime: Schema.String; readonly bytes: B; }>>; readonly meta: Schema.Struct<{ readonly usage: Schema.optionalKey<Schema.Struct<{ readonly calls: Schema.$Array<Schema.String>; readonly model: Schema.String; readonly input: Schema.Number; readonly output: Schema.Number; readonly cost: Schema.Number; }>>; readonly stats: Schema.Struct<{ readonly pages: Schema.NullOr<Schema.Number>; readonly bytes: Schema.Number; readonly cpuMs: Schema.Number; readonly wallMs: Schema.Number; }>; }>; readonly kind: Schema.Literal<"document">; readonly html: Schema.String; }>, Schema.Struct<{ readonly images: Schema.$Array<Schema.Struct<{ readonly name: Schema.String; readonly mime: Schema.String; readonly bytes: B; }>>; readonly meta: Schema.Struct<{ readonly usage: Schema.optionalKey<Schema.Struct<{ readonly calls: Schema.$Array<Schema.String>; readonly model: Schema.String; readonly input: Schema.Number; readonly output: Schema.Number; readonly cost: Schema.Number; }>>; readonly stats: Schema.Struct<{ readonly pages: Schema.NullOr<Schema.Number>; readonly bytes: Schema.Number; readonly cpuMs: Schema.Number; readonly wallMs: Schema.Number; }>; }>; readonly kind: Schema.Literal<"data">; readonly json: Schema.Codec<Schema.Json, Schema.Json, never, never>; }>]>

What an ingest answers with its image bytes decoded by bytes: Convert's wire (base64) or the port's ABI.

参数

名称类型说明
bytesB

源码: packages/host-api/src/media.ts:29

off

is_off function

function is_off(value: object): value is Off

Whether a facility member is off, by its tag (never by identity, so it holds across module graphs).

参数

名称类型说明
valueobject

源码: packages/host-api/src/off.ts:8

facilities

logged_phone function

function logged_phone(log: (line: string) => void, fixed?: boolean): PhoneVerifier

A local host's phone verifier: its own code, printed by log as (sign-in code 123456) (bolt dev, a local host, tests). fixed is 123456.

参数

名称类型说明
log(line: string) => void
fixed?boolean

源码: packages/host-api/src/facilities.ts:218

media

media_type function

function media_type(head: Uint8Array): string | undefined

The media type of a body from its first DOWNLOAD.headBytes bytes (all of a shorter body); undefined is not media.

参数

名称类型说明
headUint8Array

源码: packages/host-api/src/media.ts:119

membrane

membrane function

function membrane(send: (message: Message) => unknown): Membrane

One side of the membrane; send delivers a message to the other side and returns its answer, if it gave one.

参数

名称类型说明
send(message: Message) => unknown

源码: packages/host-api/src/membrane.ts:139

json-schema

model_schema function

function model_schema(schema: Schema.Constraint, keepEmptyDefinitions?: boolean): Json

Closed model-facing schemas share one encoder; decision responses retain their explicit empty definitions.

参数

名称类型说明
schemaSchema.Constraint
keepEmptyDefinitions?boolean

源码: packages/host-api/src/json-schema.ts:45

off

off const

const off: { readonly _tag: "Off"; }

The marker a host passes in place of a facility member it does not provide; that member then fails unavailable.

成员

名称类型说明
_tag'Off'

源码: packages/host-api/src/off.ts:4

wire

param function

function param(v: Json): string | null

A JSON parameter as Postgres text: objects and arrays as JSON text (the statement casts).

参数

名称类型说明
vJson

源码: packages/host-api/src/wire.ts:79

parse function

function parse(oid: number, s: string): Json

Postgres text → JSON: numbers and booleans as JSON, json as itself, everything else (numeric, date, uuid, ranges) as text.

参数

名称类型说明
oidnumber
sstring

源码: packages/host-api/src/wire.ts:64

browser

person_browser_profile function

function person_browser_profile(person: string, conversation: string): string

A person's browser profile for one conversation: one identity per person, a session (tab) per conversation.

参数

名称类型说明
personstring
conversationstring

源码: packages/host-api/src/browser.ts:10

media

pixelSize function

function pixelSize(b: Uint8Array): { width: number; height: number; } | undefined

An image's stored pixel size from its header: PNG, JPEG or GIF; undefined for another format. ponytail: header only, so a JPEG's EXIF rotation is not applied; the host's own tiles and crops are already oriented.

参数

名称类型说明
bUint8Array

源码: packages/host-api/src/media.ts:170

port

provide_http function

function provide_http(options: HttpOptions): <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, HttpClient.HttpClient>>

Provides an adapter's HTTP client: options.http_client, else fetch.

参数

名称类型说明
optionsHttpOptions
  • http_client?: HttpClient.HttpClient
  • fetch?: typeof fetch

源码: packages/host-api/src/port.ts:105

system-1

refusal_of function

function refusal_of(status: number, body: string): FacilityFailure | undefined

A provider's HTTP refusal as the facility failure it maps to; undefined is an ordinary failure. Hosts share it.

参数

名称类型说明
statusnumber
bodystring

源码: packages/host-api/src/system-1.ts:95

deadline-timer

scope_deadlines function

function scope_deadlines<E, R>(callbacks: { readonly wake: (scope: string) => Effect.Effect<void, E, R>; readonly pulse: (scope: string) => Effect.Effect<boolean, E, R>; }): Effect.Effect<{ announce: (scope: string, at: string) => Effect.Effect<void, never, never>; settle: (scope: string, at: string | null) => Effect.Effect<void, never, never>; teardown: (scope: string) => Effect.Effect<void, never, never>; }, never, R | Scope.Scope>

A single-process host's deadlines (bolt-server, bolt dev, a release's own port): each announced scope's earliest deadline wakes it once, a due announcement during its wake pulses it, and a failed wake retries in a minute.

参数

名称类型说明
callbacks{ readonly wake: (scope: string) => Effect.Effect<void, E, R>; readonly pulse: (scope: string) => Effect.Effect<boolean, E, R>; }
  • wake: (scope: string) => Effect.Effect<void, E, R>
  • pulse: (scope: string) => Effect.Effect<boolean, E, R>

源码: packages/host-api/src/deadline-timer.ts:182

facilities

six_digits function

function six_digits(): string

A uniformly random six-digit sign-in code.

源码: packages/host-api/src/facilities.ts:208

migration-impact

step_name function

function step_name(id: string): string

A destructive step's plain name, from its generated id (drop:column:contracts.bank).

参数

名称类型说明
idstring

源码: packages/host-api/src/migration-impact.ts:66

wire

storedInstant function

function storedInstant(value: string): string

Canonical UTC text preserves sub-millisecond digits from either database adapter.

参数

名称类型说明
valuestring

源码: packages/host-api/src/wire.ts:11

system-1

structured_system_1 function

function structured_system_1(infer: OpenAiChat, configured: string): System1

System 1 over a chat model's structured output: each question becomes a probability object in one JSON-schema answer.

参数

名称类型说明
inferOpenAiChat
configuredstring

源码: packages/host-api/src/system-1.ts:481

studio

studio_events function

function studio_events(url: string): Stream.Stream<StudioFrame, StudioStreamFailed, never>

Studio's server-sent frames at url (the shell's /__bolt/shell/studio/events under the workspace or a host's endpoint) as a stream; the event source closes with the stream. An undecodable event or a dropped connection fails it with StudioStreamFailed.

参数

名称类型说明
urlstring

源码: packages/host-api/src/studio.ts:425

studio_view function

function studio_view({ manifest: m, ...rest }: StudioState): StudioView

Projects a StudioState into the browser's StudioView, listing each section's declarations by source path.

参数

名称类型说明
__0StudioState
  • commit: string
  • working?: string

    The commit holding the viewer's uncommitted edits; files, changes and conflicts read it. Absent: none.

  • diagnosis?: 'passed' | 'failed'

    The last diagnosis of this exact source; none run, absent.

  • tree?: string

    The working tree's git tree: what a check and a test run are kept by. Absent on a monitoring read.

  • tests?: StudioTestRun

    The latest test job for this exact tree; absent when it has not been tested.

  • migration?: StudioMigration
  • message?: string

    The head commit's description (its message's first line).

  • zone?: string

    The live workspace's IANA timezone.

  • files: { readonly [path: string]: { bytes: number; }; }

    Every path of the tree with its size; never its content, so a read stays the same size as a file grows.

  • changes: readonly StudioFileChange[]
  • manifest: StudioManifest | null
  • log: readonly StudioLogLine[]
  • preview: string | null

    The viewer's change's preview URL (null: no change open, or its preview is shelved).

  • releases: readonly StudioRelease[]
  • environments?: readonly StudioEnvironment[]
  • change?: string
  • branch?: string
  • preview_of?: StudioPreview
  • preview_control?: PreviewControl

    The open change's preview control; absent: nobody claimed it.

  • base?: string
  • behind?: number
  • conflicts?: ReadonlyArray<{ path: string; kind: 'content' | 'binary' | 'edit/delete' | 'migration'; }>
  • conflict_notes?: readonly string[]

    Why a migration among conflicts stopped, in plain words.

  • change_sets?: readonly StudioChangeSet[]
  • diagnostics?: readonly StudioDiagnostic[]

    The viewer's change's last build's diagnosis (empty: it built clean; absent: not built, or the host reports none).

  • builds?: readonly StudioBuild[]

    The retained builds, newest first; StudioPort.build reads one's log and diagnostics.

  • approvals?: readonly StudioApproval[]

    The viewer's own held requests: what the agent asked to change on live, awaiting their approval.decide.

  • runtime?: { readonly current: string | null; readonly latest: string; }

    The workspace's pinned @norbital-ai/bolt version beside the host's latest known release.

源码: packages/host-api/src/studio.ts:758

suggest_message function

function suggest_message(drafts: { readonly [path: string]: unknown; }, files: { readonly [path: string]: unknown; }): string

What a save changes, in plain words, from its drafts (null: deleted) over the tree they change.

参数

名称类型说明
drafts{ readonly [path: string]: unknown; }
files{ readonly [path: string]: unknown; }

源码: packages/host-api/src/studio.ts:945

version

supports function

function supports(version: number): boolean

Hosts and releases must speak this exact protocol.

参数

名称类型说明
versionnumber

源码: packages/host-api/src/version.ts:8

ai

textOf function

function textOf(content: Json): string

Text projection shared by the producer and provider.

参数

名称类型说明
contentJson

源码: packages/host-api/src/ai.ts:26

digest

tree_digest function

function tree_digest(files: Iterable<readonly [path: string, bytes: Uint8Array]>): string

sha256 hex of a tree's sorted <path>\0<sha256 hex> lines, \n-joined: a folder's tree_hash, a skill's digest.

参数

名称类型说明
filesIterable<readonly [path: string, bytes: Uint8Array]>

源码: packages/host-api/src/digest.ts:6

tree_hash function

function tree_hash(dir: string): Effect.Effect<string, import("effect/PlatformError").PlatformError, FileSystem.FileSystem | Path.Path>

A tree's digest; *.map files are left out: the bundler writes random names into them, so they are not byte-stable.

参数

名称类型说明
dirstring

源码: packages/host-api/src/digest.ts:13

uuid

uuidv7 function

function uuidv7(nowMs?: number): string

A fresh uuidv7 (RFC 9562): 48 bits of Unix milliseconds, version 7, monotonic 12-bit sub-ms counter, variant 10, 62 bits random.

参数

名称类型说明
nowMs?number

源码: packages/host-api/src/uuid.ts:14

uuidv7_within function

function uuidv7_within(id: string, nowMs: number): boolean

A caller-minted id is a uuidv7 whose timestamp is within 24 h of the host clock, either side.

参数

名称类型说明
idstring
nowMsnumber

源码: packages/host-api/src/uuid.ts:5