跳到主要内容

bolt

bolt

导入自 @norbital-ai/bolt

@norbital-ai/bolt: the declaration functions and their types. Nothing else is a runtime value (P29).

Act interface

interface Act {
    /** A held write is a success. */
    <const N extends string>(callable: Is<N, Callable>, input: NoInfer<ActInput<N>>, ...options: NoInfer<OptionsOf<N>>): Eff<Committed<ActOutput<N>, N> | PendingApproval<N>, ActRefused | ActConflict | ActUnknown>;
    /**
     * Generated verbs (`create`, `update`, `upsert`, `delete`) over several collections as ONE act: planned together (their
     * reads one round trip per step), committed as one statement; the first that does not commit fails it. The acts are
     * independent: none names a row another creates. Answers each act's output, in order.
     * @example
     * yield* ctx.act.many([{ callable: 'task.create', input: rows }, { callable: 'slip.update', input: holds }]);
     */
    many(acts: readonly {
        readonly callable: Callable;
        readonly input: Json;
    }[]): Eff<Committed<readonly unknown[]>, ActRefused | ActConflict | ActUnknown>;
}

ctx.act in an action or automation: runs a callable with its typed input. It succeeds with a committed or held write and fails with ActRefused, ActConflict or ActUnknown; Effect.catchTag recovers the one a body handles.

成员

名称类型说明
many(acts: readonly { readonly callable: Callable; readonly input: Json; }[]) => Eff<Committed<readonly unknown[]>, ActRefused | ActConflict | ActUnknown>

Generated verbs (create, update, upsert, delete) over several collections as ONE act: planned together (their reads one round trip per step), committed as one statement; the first that does not commit fails it. The acts are independent: none names a row another creates. Answers each act's output, in order.

示例

const { records } = yield* ctx.act('orders.create', { customer, lines: { create: [{ sku, qty: 1 }] } });

源码: packages/bolt/src/decl/ctx.ts:491

ActInput type

type ActInput<N> = N extends `${infer C}.${infer V}` ? V extends 'create' ? Insert<C> | readonly Insert<C>[] : V extends 'upsert' ? Insert<C> | ({
    id: Id<C>;
} & Patch<C>) | readonly (Insert<C> | ({
    id: Id<C>;
} & Patch<C>))[] : V extends 'import' ? readonly Insert<C>[] : V extends 'update' ? {
    target: Targets<C>;
    set: Patch<C>;
} | readonly {
    target: Id<C>;
    set: Patch<C>;
}[] : V extends 'delete' ? {
    target: Targets<C>;
} : V extends ActionName<C> ? ActionArg<C, ActionsOfC<C>[V]> : never : never;

The input a callable takes ('<c>.create', '<c>.update', '<c>.<action>', …): an insert, { target, set }, { target } or the action's declared input.

源码: packages/bolt/src/decl/ctx.ts:367

ActOutput type

type ActOutput<N> = N extends `${infer C}.${infer V}` ? V extends 'upsert' ? readonly (Id<C> | null)[] : V extends 'import' ? ImportReport<C> : V extends ActionName<C> ? ActionsOfC<C>[V] extends {
    target: 'record';
} ? OutputOf<ActionsOfC<C>[V]> | readonly OutputOf<ActionsOfC<C>[V]>[] : OutputOf<ActionsOfC<C>[V]> : undefined : never;

The output actually returned by a callable; record actions may target several records.

源码: packages/bolt/src/decl/ctx.ts:391

ActionCtx interface

interface ActionCtx<in out C, in out X = {}> extends QueryCtx {
    readonly policies: readonly string[];
    readonly admin: boolean;
    act: Act;
    schedule: Schedule;
    notify: Notify;
    refuse(message: string, at?: {
        field?: InputField<X>;
    }): Eff<never, Refusal>;
    /** The row a `target: 'record'` action runs on; `never` on any other action. */
    target: X extends {
        target: 'record';
    } ? Row<C> : never;
}

Every ctx.act is recorded into the action's one statement (rule 20), so nothing it writes is in the database until the action returns: a later ctx.read/ctx.get, and a later act's transform, see the rows as they were before the action. A later act may name a row an earlier one created (its id from records, rule 36). To read what you wrote, keep the values you passed, or write the dependents in the same act (relation with, or one batch through the transform, which sees the whole batch and db.after).

成员

名称类型说明
policiesreadonly string[]
adminboolean
actAct
scheduleSchedule
notifyNotify
refuse(message: string, at?: { field?: InputField<X>; }) => Eff<never, Refusal>

Ends the body with an authored refusal (rule 32), return yield* ctx.refuse(…); field names an input field.

targetX extends { target: 'record'; } ? Row<C> : never

The row a target: 'record' action runs on; never on any other action.

invocationIdstring
actorActor
nowInstant
todayPlainDate
tzIanaZone
todayIn(zone: IanaZone) => PlainDate
read{ <C extends string>(collection: Is<C, ReadableName>, query: DeclaredQuery): Eff<Page<DeclaredRow<C>>, ReadFailed>; <C extends string, const S extends Select<C> = {}>(collection: Is<C, ReadableName>, q: { where?: NoInfer<Where<C>> | undefined; select?: S | undefined; orderBy?: NoInfer<OrderBy<C>> | undefined; search?: string; } & Paged): Eff<Page<ListResult<C, S>>, never>; <const M extends ReadSe…

Dynamic declarations use the same native caller policies, exposure and masked values as literal reads. A keyed set of reads in one crossing and ONE statement: each member is a read (or, with id, a get) under the caller's read policies, answered under its key. Every member states its page (rule 9); the row and byte caps hold per member and name the member that breaks them.

get<C extends string, const S extends Select<C> = {}>(collection: Is<C, ReadableName>, id: NoInfer<Id<C>>, q?: { select?: S | undefined; revision?: number; } | undefined) => Eff<ReadResult<C, S> | null, never>

{ revision } (L-BOLT-181): the record as of that revision, folded from its history; null once pruned past its create.

similar{ <C extends string, N extends SimilarityName<C>, const S extends Select<C> = {}>(collection: Is<C, ReadableName>, search: N, input: NoInfer<In<SimilaritiesOfC<C>[N]>>, q: { where?: NoInfer<Where<C>> | undefined; select?: S | undefined; limit: number; }): Eff<readonly (ListResult<C, S> & { readonly $distance: number; })[], never>; <C extends string, const S extends Select<C> = {}>(collection: Is<…

A named similarity search (§3.3.4): nearest first, each row with its $distance. Over search.semantic (L-BOLT-123): nearest by meaning to a text, or to a record's own embedding (the record itself left out).

query<C extends string, Q extends QueryName<C>>(collection: Is<C, CollectionName>, query: Q, input: NoInfer<In<QueriesOfC<C>[Q]>>) => Eff<OutputOf<QueriesOfC<C>[Q]>, never>

源码: packages/bolt/src/decl/ctx.ts:532

ActionName type

type ActionName<C> = keyof ActionsOfC<C> & string;

The names of C's declared actions.

源码: packages/bolt/src/decl/ctx.ts:139

ActionSpec type

type ActionSpec = {
    description: string;
    input: InputFields;
    output?: InputKind;
    target?: 'record';
    internal?: true;
    agent?: AgentUse;
};

A collection action: typed input, optional output, target: 'record' to run on chosen rows, internal to hide it from callers, and agent use. Its body attaches with c.action(name, fn).

成员

名称类型说明
descriptionstring
inputInputFields
output?InputKind
target?'record'
internal?true
agent?AgentUse

源码: packages/bolt/src/decl/collection.ts:148

Actor type

type Actor = {
    kind: 'member';
    id: Id<'sys_user'>;
    email: string | null;
    phone: string | null;
    external: boolean;
    teams: readonly TeamName[];
    teamPath: readonly string[];
    admin: boolean;
    party: RecordRef | null;
} | {
    kind: 'envoy';
    envoy: EnvoyName;
    instance: Id<'sys_integration'>;
    sender: Handle;
    member: Id<'sys_user'> | null;
} | {
    kind: 'visitor';
    app: AppName;
    visitor: string;
} | {
    kind: 'apiKey';
    key: Id<'sys_api_key'>;
} | {
    kind: 'system';
    run: Id<'sys_run'>;
    by: {
        automation: AutomationName;
    } | {
        platform: PlatformAutomation;
    } | {
        integration: IntegrationName;
        instance: Id<'sys_integration'>;
        feed: string;
    } | {
        integration: IntegrationName;
        instance: Id<'sys_integration'>;
        outbound: string;
    };
};

Who a request runs as (§3.9), discriminated by kind: a member (with teams and admin), an envoy answering a sender on the instance it is deployed on, a public visitor of an app, an apiKey, or the system running an automation, a feed or outbound run of an instance, or a platform run.

源码: packages/bolt/src/decl/access/actor.ts:18

AgentUse type

type AgentUse = 'direct' | 'confirm' | 'never';

How the in-app agent may call a query or action: direct (default), confirm (an in-app confirmation card first) or never.

源码: packages/bolt/src/decl/collection.ts:45

AggRow type

type AggRow = {
    readonly key?: {
        readonly [field: string]: unknown;
    };
    readonly count?: number;
    readonly sum?: {
        readonly [field: string]: Decimal | null;
    };
    readonly avg?: {
        readonly [field: string]: Decimal | null;
    };
    readonly min?: {
        readonly [field: string]: unknown;
    };
    readonly max?: {
        readonly [field: string]: unknown;
    };
};

An aggregate row: the bucket values under key, then each measure asked for (a sum or average is a Decimal).

成员

名称类型说明
key?{ readonly [field: string]: unknown; }
count?number
sum?{ readonly [field: string]: Decimal | null; }
avg?{ readonly [field: string]: Decimal | null; }
min?{ readonly [field: string]: unknown; }
max?{ readonly [field: string]: unknown; }

源码: packages/bolt/src/decl/ctx.ts:637

AiModelClass type

type AiModelClass = 'default' | 'fast' | 'strong';

A sys_2 model class an agent or ctx.ai.sys_2.infer asks for; the host maps each to a model.

源码: packages/bolt/src/decl/runtime/names.ts:32

AppName type

type AppName = keyof NamesPart<'apps'> & string;

The app names (src/app/<a>/+app.ts).

源码: packages/bolt/src/decl/names.ts:108

Approval type

type Approval<C extends CollectionName, O = Op, R = unknown> = {
    match?: ApprovalMatch<C, O>;
    where?: Where<C>;
    fields?: O extends 'delete' ? never : readonly WriteField<C, O>[];
    steps: unknown extends R ? NonEmpty<NonEmpty<TeamName>> : Steps<R extends {
        steps: infer S;
    } ? S : never>;
    superseded_by?: readonly TeamName[];
} & (O extends 'update' ? {
    previous?: Where<C>;
} : {});

One route: the first route whose match matches supplies the steps (sequential; teams in one step are alternatives).

源码: packages/bolt/src/decl/access/policy.ts:80

ApprovalMatch type

type ApprovalMatch<C extends CollectionName, O = Op> = {
    record?: Where<C>;
    changed?: readonly FieldName<C>[];
    requestor?: 'in_team' | 'no_team' | {
        team: readonly TeamName[];
    };
    and?: readonly ApprovalMatch<C, O>[];
    or?: readonly ApprovalMatch<C, O>[];
    not?: ApprovalMatch<C, O>;
} & (O extends 'update' ? {
    previous?: Where<C>;
} : {});

When an approval route applies: the record matches record, the write changes one of changed, the requestor is in a team (or none, or one of team), combined with and/or/not; an update may also test the previous row.

源码: packages/bolt/src/decl/access/policy.ts:64

AssetPath type

type AssetPath = string;

A path under the workspace assets/ directory (an app banner).

源码: packages/bolt/src/decl/values.ts:50

Attachment type

type Attachment = {
    readonly id?: Id<'sys_file'>;
    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?Id<'sys_file'>
namestring
mimestring
bytesnumber

源码: packages/bolt/src/decl/runtime/integration.ts:67

AutomationCtx type

type AutomationCtx<S = AutomationSpec> = Omit<QueryCtx, 'actor' | 'refuse'> & {
    actor: S extends {
        runAs: 'trigger';
    } ? Actor : Extract<Actor, {
        kind: 'system';
    }>;
    /** 1 on the first attempt. */
    attempt: number;
    cause: RunCause;
    progress(update: {
        ratio?: number | null;
        text?: string | null;
    }): Eff<void>;
    act: Act;
    schedule: Schedule;
    notify: Notify;
    send: Send;
    request: Request;
    web: Web;
    files: Files;
    /** Markdown or HTML to a declared document format (optional host capability; absent → `unavailable`). */
    convert: Convert;
    ai: Ai<S extends {
        runAs: 'trigger';
    } ? false : true>;
    geo: Geo;
};

a.run's ctx (§3.4): reads, writes and schedules as its runAs policies; the only place for I/O.

成员

名称类型说明
read{ <C extends string>(collection: Is<C, ReadableName>, query: DeclaredQuery): Eff<Page<DeclaredRow<C>>, ReadFailed>; <C extends string, const S extends Select<C> = {}>(collection: Is<C, ReadableName>, q: { where?: NoInfer<Where<C>> | undefined; select?: S | undefined; orderBy?: NoInfer<OrderBy<C>> | undefined; search?: string; } & Paged): Eff<Page<ListResult<C, S>>, never>; <const M extends ReadSe…

Dynamic declarations use the same native caller policies, exposure and masked values as literal reads. A keyed set of reads in one crossing and ONE statement: each member is a read (or, with id, a get) under the caller's read policies, answered under its key. Every member states its page (rule 9); the row and byte caps hold per member and name the member that breaks them.

nowInstant
todayPlainDate
tzIanaZone
todayIn(zone: IanaZone) => PlainDate
invocationIdstring
get<C extends string, const S extends Select<C> = {}>(collection: Is<C, ReadableName>, id: NoInfer<Id<C>>, q?: { select?: S | undefined; revision?: number; } | undefined) => Eff<ReadResult<C, S> | null, never>

{ revision } (L-BOLT-181): the record as of that revision, folded from its history; null once pruned past its create.

similar{ <C extends string, N extends SimilarityName<C>, const S extends Select<C> = {}>(collection: Is<C, ReadableName>, search: N, input: NoInfer<In<SimilaritiesOfC<C>[N]>>, q: { where?: NoInfer<Where<C>> | undefined; select?: S | undefined; limit: number; }): Eff<readonly (ListResult<C, S> & { readonly $distance: number; })[], never>; <C extends string, const S extends Select<C> = {}>(collection: Is<…

A named similarity search (§3.3.4): nearest first, each row with its $distance. Over search.semantic (L-BOLT-123): nearest by meaning to a text, or to a record's own embedding (the record itself left out).

query<C extends string, Q extends QueryName<C>>(collection: Is<C, CollectionName>, query: Q, input: NoInfer<In<QueriesOfC<C>[Q]>>) => Eff<OutputOf<QueriesOfC<C>[Q]>, never>
actorS extends { runAs: 'trigger'; } ? Actor : Extract<Actor, { kind: 'system'; }>
attemptnumber

1 on the first attempt.

causeRunCause
progress(update: { ratio?: number | null; text?: string | null; }) => Eff<void>
actAct
scheduleSchedule
notifyNotify
sendSend
requestRequest
webWeb
filesFiles
convertConvert

Markdown or HTML to a declared document format (optional host capability; absent → unavailable).

aiAi<S extends { runAs: 'trigger'; } ? false : true>
geoGeo

源码: packages/bolt/src/decl/runtime/automation.ts:154

AutomationName type

type AutomationName = keyof NamesPart<'automations'> & string;

The automation names (src/automation/+<a>.automation.ts).

源码: packages/bolt/src/decl/names.ts:112

BankReader type

type BankReader = {
    readonly tree: string;
    has(path: string): boolean;
    json<T = unknown>(path: string): T;
    bytes(path: string): Uint8Array;
    /** Every file under `dir` (default the tree), relative to the tree, sorted. */
    files(dir?: string): string[];
};

One bank tree, read-only. Paths are relative to the tree.

成员

名称类型说明
treestring
has(path: string) => boolean
json<T = unknown>(path: string) => T
bytes(path: string) => Uint8Array
files(dir?: string) => string[]

Every file under dir (default the tree), relative to the tree, sorted.

源码: packages/bolt/src/compiler/artifact/seed.ts:29

BodyError type

type BodyError = {
    readonly _tag: string;
};

A body's failure: every failure is tagged (D3), and a body requires no service.

成员

名称类型说明
_tagstring

源码: packages/bolt/src/decl/ctx.ts:57

BtreeField type

type BtreeField<M> = Exclude<FieldName<M>, OfKind<M, NotBtree>>;

A field a btree index, key or unique may name: scalar fields and FKs.

源码: packages/bolt/src/decl/names.ts:326

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 feed pushes; ctx.partition is its calendar.

成员

名称类型说明
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/bolt/src/decl/runtime/integration.ts:199

CalendarTime type

type CalendarTime = {
    readonly date: PlainDate;
} | {
    readonly at: Instant;
    readonly zone: IanaZone | null;
};

When a calendar event starts or ends: a whole day, or an instant with the zone it was set in.

源码: packages/bolt/src/decl/runtime/integration.ts:196

Callable type

type Callable = {
    [C in CollectionName]: `${C}.${Verbs<C> | ActionName<C>}`;
}[CollectionName];

Every callable: a collection's generated verb or declared action (X-1, X-24).

源码: packages/bolt/src/decl/ctx.ts:357

CallerReads interface

interface CallerReads<E = never> {
    /** Dynamic declarations use the same native caller policies, exposure and masked values as literal reads. */
    read<C extends string>(collection: Is<C, ReadableName>, query: DeclaredQuery): Eff<Page<DeclaredRow<C>>, ReadFailed>;
    read<C extends string, const S extends Select<C> = {}>(collection: Is<C, ReadableName>, q: {
        where?: NoInfer<Where<C>>;
        select?: S;
        orderBy?: NoInfer<OrderBy<C>>;
        search?: string;
    } & Paged): Eff<Page<ListResult<C, S>>, E>;
    /**
     * A keyed set of reads in one crossing and ONE statement: each member is a read (or, with `id`, a `get`) under the
     * caller's read policies, answered under its key. Every member states its page (rule 9); the row and byte caps hold
     * per member and name the member that breaks them.
     * @example
     * const { contracts, entity } = yield* ctx.read({
     *   contracts: { collection: 'contract', where: { company_id: { eq: id } }, all: true },
     *   entity: { collection: 'entity', id },
     *   versions: { collection: 'settings', where: { code: { in: { member: 'entity', field: 'settings_code' } } }, all: true },
     * });
     */
    read<const M extends ReadSet>(set: M & {
        readonly [K in keyof M]: ReadMember<M[K]['collection']>;
    }): Eff<ReadSetAnswer<M>, E>;
    /** `{ revision }` (L-BOLT-181): the record as of that revision, folded from its history; `null` once pruned past its create. */
    get<C extends stri…

Reads as the caller (queries, actions): exposed fields only. Only the collection name (and select) infers: NoInfer keeps TS from inferring back through Where and ActInput, which walked their conditional branches on every call.

成员

名称类型说明
read{ <C extends string>(collection: Is<C, ReadableName>, query: DeclaredQuery): Eff<Page<DeclaredRow<C>>, ReadFailed>; <C extends string, const S extends Select<C> = {}>(collection: Is<C, ReadableName>, q: { where?: NoInfer<Where<C>>; select?: S; orderBy?: NoInfer<OrderBy<C>>; search?: string; } & Paged): Eff<Page<ListResult<C, S>>, E>; <const M extends ReadSet>(set: M & { readonly [K in keyof M]: R…

Dynamic declarations use the same native caller policies, exposure and masked values as literal reads. A keyed set of reads in one crossing and ONE statement: each member is a read (or, with id, a get) under the caller's read policies, answered under its key. Every member states its page (rule 9); the row and byte caps hold per member and name the member that breaks them.

get<C extends string, const S extends Select<C> = {}>(collection: Is<C, ReadableName>, id: NoInfer<Id<C>>, q?: { select?: S; revision?: number; }) => Eff<ReadResult<C, S> | null, E>

{ revision } (L-BOLT-181): the record as of that revision, folded from its history; null once pruned past its create.

similar{ <C extends string, N extends SimilarityName<C>, const S extends Select<C> = {}>(collection: Is<C, ReadableName>, search: N, input: NoInfer<In<SimilaritiesOfC<C>[N]>>, q: { where?: NoInfer<Where<C>>; select?: S; limit: number; }): Eff<readonly (ListResult<C, S> & { readonly $distance: number; })[], E>; <C extends string, const S extends Select<C> = {}>(collection: Is<C, ReadableName>, q: { to: s…

A named similarity search (§3.3.4): nearest first, each row with its $distance. Over search.semantic (L-BOLT-123): nearest by meaning to a text, or to a record's own embedding (the record itself left out).

query<C extends string, Q extends QueryName<C>>(collection: Is<C, CollectionName>, query: Q, input: NoInfer<In<QueriesOfC<C>[Q]>>) => Eff<OutputOf<QueriesOfC<C>[Q]>, E>

源码: packages/bolt/src/decl/ctx.ts:191

Change type

type Change<R, K = R> = {
    readonly upsert: R;
} | {
    readonly delete: K;
};

One change a feed commits: a row upserted by its key, or a key removed (the feed's removed decides what that does).

源码: packages/bolt/src/decl/runtime/integration.ts:319

Check type

type Check<E> = [E] extends [never] ? true : {
    [K in E & string]: K;
}[E & string];

true when E is never; otherwise an object type whose keys are the error messages, so tsc prints them. The generated Check<Verify> gate.

源码: packages/bolt/src/decl/verify.ts:124

ChildName type

type ChildName<G> = G extends keyof NamesPart<'groups'> ? NamesPart<'groups'>[G] & string : never;

The app and group folders directly in group G.

源码: packages/bolt/src/decl/runtime/names.ts:43

CollectionName type

type CollectionName = (keyof Colls & string) | SystemName;

Every surface addresses collections (P9): authored ones, plus the system collections.

源码: packages/bolt/src/decl/names.ts:94

CollectionSpec type

type CollectionSpec = {
    description?: string;
    /** The fields and relations callers read (grants narrow them further). */
    read: {
        fields: 'all' | readonly string[];
        relations?: 'all' | readonly string[];
        projection?: ReadProjection;
    };
    /** The generated `create`: its input allowlist (`columns`, `filled`, and relation actions under `with`). */
    create?: {
        input: SelectionBase;
    };
    /** The generated `update`: its input allowlist. */
    update?: {
        input: SelectionBase;
    };
    /** The generated `delete`; `{ transform: true }` runs the transform on it. */
    delete?: {} | {
        transform: true;
    };
    /** Named read operations; bodies attach with `c.query`. */
    queries?: {
        readonly [q: string]: QuerySpec;
    };
    /** Named write operations; bodies attach with `c.action`. */
    actions?: {
        readonly [a: string]: ActionSpec;
    };
    /** Named similarity searches; bodies attach with `c.similarity`. */
    similarity?: {
        readonly [s: string]: SimilarSpec;
    };
    /** Notification rules per write or approval event. */
    notifications?: {
        readonly [E in NotificationEvent]?: readonly NotificationSpec[];
    };
};

A collection's spec: its read exposure, write allowlists and named queries, actions and similarities.

成员

名称类型说明
description?string
read{ fields: 'all' | readonly string[]; relations?: 'all' | readonly string[]; projection?: ReadProjection; }

The fields and relations callers read (grants narrow them further).

create?{ input: SelectionBase; }

The generated create: its input allowlist (columns, filled, and relation actions under with).

update?{ input: SelectionBase; }

The generated update: its input allowlist.

delete?{} | { transform: true; }

The generated delete; { transform: true } runs the transform on it.

queries?{ readonly [q: string]: QuerySpec; }

Named read operations; bodies attach with c.query.

actions?{ readonly [a: string]: ActionSpec; }

Named write operations; bodies attach with c.action.

similarity?{ readonly [s: string]: SimilarSpec; }

Named similarity searches; bodies attach with c.similarity.

notifications?{ readonly [E in NotificationEvent]?: readonly NotificationSpec[]; }

Notification rules per write or approval event.

源码: packages/bolt/src/decl/collection.ts:178

Committed type

type Committed<O, N = string> = {
    kind: 'committed';
    output: O;
    records: WrittenOf<N>;
};

The write is in the database: output is the action's result, records every row written with its new revision.

成员

名称类型说明
kind'committed'
outputO
recordsWrittenOf<N>

源码: packages/bolt/src/decl/ctx.ts:452

ComputedKind type

type ComputedKind = 'text' | 'int' | 'decimal' | 'money' | 'bool' | 'date' | 'instant';

The kinds a computed field's expression may produce.

源码: packages/bolt/src/decl/model.ts:8

ConfigurationOf type

type ConfigurationOf<D> = ConfigurationIn<IntegrationSpecOf<D>>;

An instance's decoded configuration for definition D: every defaulted field present, an optional one without a default absent or null.

源码: packages/bolt/src/decl/runtime/integration.ts:286

Conflict type

type Conflict = {
    kind: 'conflict';
    records: readonly {
        collection: CollectionName;
        id: string;
        fields: readonly string[];
    }[];
};

The write lost a race: another write changed the named fields of these records since they were read.

成员

名称类型说明
kind'conflict'
recordsreadonly { collection: CollectionName; id: string; fields: readonly string[]; }[]

源码: packages/bolt/src/decl/ctx.ts:474

ConnectionName type

type ConnectionName = keyof Connections & string;

The named instances +workspace.ts declares under connections.

源码: packages/bolt/src/decl/runtime/names.ts:7

ConversationOf type

type ConversationOf<D> = KindIn<IntegrationSpecOf<D>>;

The message kind definition D carries (chat | email); never for a definition with no conversation.

源码: packages/bolt/src/decl/runtime/integration.ts:270

ConvertOptions type

type ConvertOptions = {
    [T in DeclaredConvertTarget]: {
        to: T;
        name: string;
        for: FileOwner;
    } & ConvertTargets[T];
}[DeclaredConvertTarget];

One declared target's options, discriminated by to: reference only where the format takes one, page only for PDF.

源码: packages/bolt/src/decl/runtime/facilities.ts:215

ConvertSource type

type ConvertSource = {
    readonly markdown: string;
} | {
    readonly 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/bolt/src/decl/runtime/facilities.ts:213

ConvertTarget type

type ConvertTarget = keyof ConvertTargets;

A document format ctx.convert.document can produce.

源码: packages/bolt/src/decl/runtime/facilities.ts:207

ConvertTargets type

type ConvertTargets = {
    pdf: {
        page?: 'A4' | 'A3' | 'Letter';
        landscape?: boolean;
    };
    docx: {
        reference?: FileRef;
    };
    pptx: {
        reference?: FileRef;
    };
    odt: {
        reference?: FileRef;
    };
    epub: {};
    html: {};
};

What each conversion target takes beyond to, name and for: a reference document styles a Word, PowerPoint or OpenDocument output (its fonts, headers, footers and page setup, as pandoc's reference-doc); a PDF sets its paper.

成员

名称类型说明
pdf{ page?: 'A4' | 'A3' | 'Letter'; landscape?: boolean; }
docx{ reference?: FileRef; }
pptx{ reference?: FileRef; }
odt{ reference?: FileRef; }
epub{}
html{}

源码: packages/bolt/src/decl/runtime/facilities.ts:198

CurrencyCode type

type CurrencyCode = Iso4217 | Uppercase<string>;

An ISO 4217 currency code (SGD, USD): a literal or std's branded currency().

源码: packages/bolt/src/decl/values.ts:40

Cursor type

type Cursor = string & {
    readonly [cursor]: true;
};

An opaque page cursor: pass a page's next back as after to read on.

源码: packages/bolt/src/decl/ctx.ts:64

CustomFieldName type

type CustomFieldName = keyof CustomFields & string;

A custom field name a model may store as { kind: 'custom', of }: a built-in's or the workspace's own.

源码: packages/bolt/src/decl/names.ts:102

CustomFieldView type

type CustomFieldView<F extends string = string, V = F extends CustomFieldName ? ValueOf<CustomShape<F>> : Json> = (ViewCommon<F, V> & {
    mode: 'show';
    dense?: true;
}) | (ViewCommon<F, V> & {
    mode: 'edit';
    disabled: boolean;
    error?: string;
    onChange(next: V | null): void;
});

§3.2 role 5: what +renderer.svelte receives, { view: CustomFieldView<'<f>'> }, a workspace's and a built-in's (money, file, point, phone) alike. row is the record's other field values (the form's draft in edit mode), absent when a page embeds the renderer; kind the field's literal (a custom reference's shape); dense asks for one compact line (a table cell, a card); address is a point field's address sibling.

源码: packages/bolt/src/shell/runtime.ts:453

DatabaseRequester interface

interface DatabaseRequester {
    (op: DatabaseRequest): Eff<DatabaseResult, FacilityFailure | Unavailable>;
}

A database instance's live request: one bounded statement, journalled, its connection string host-side.

源码: packages/bolt/src/decl/runtime/integration.ts:228

DatePeriod type

type DatePeriod = {
    readonly from: PlainDate;
    readonly to: PlainDate | null;
};

A period of dates: from and to inclusive; to: null is open-ended.

成员

名称类型说明
fromPlainDate
toPlainDate | null

源码: packages/bolt/src/decl/values.ts:23

Decimal class

class Decimal {
    #private;
    private constructor();
    /** `x instanceof Decimal` holds for a decimal from any std copy; its methods are its own copy's, and `of` re-reads it. */
    static [Symbol.hasInstance](v: unknown): boolean;
    get [BRAND](): true;
    /** Refuses NaN, exponents, blanks and non-numeric text; a JS number must be an integer. */
    static of(v: DecimalLike): Decimal;
    /** The only door from a float: its shortest round-trip digits, rounded to `scale`. */
    static fromNumber(v: number, scale: number, mode?: Rounding): Decimal;
    plus(o: DecimalLike): Decimal;
    minus(o: DecimalLike): Decimal;
    times(o: DecimalLike): Decimal;
    /** Division needs a scale: the result is rounded to it. */
    div(o: DecimalLike, scale: number, mode?: Rounding): Decimal;
    round(scale: number, mode?: Rounding): Decimal;
    /** Rounded to the currency's minor unit (JPY 0, SGD 2, KWD 3). */
    roundTo(c: CurrencyCode | string, mode?: Rounding): Decimal;
    neg(): Decimal;
    abs(): Decimal;
    sign(): -1 | 0 | 1;
    isZero(): boolean;
    /** The number of digits after the point, as stored (`1.20` → 2). */
    get scale(): number;
    cmp(o: DecimalLike): -1 | 0 | 1;
    eq(o: DecimalLike): boolean;
    lt(o: DecimalLike): boolean;
    lte(o: DecimalLike): boolean;
    gt(o: DecimalLike): boolean;
    gte(o: DecimalLike): boolean;
    toString(): string;
    /** The wire form (D6): `{ $dec: '1.20' }`, the one tag the wire carries, in both directions…

An exact decimal: a bigint coefficient and a scale, so no amount passes through a float. Build one with Decimal.of (or dec); arithmetic is plus, minus, times, div with a rounding mode, comparison is cmp. valueOf throws, so a + b on decimals fails loudly.

成员

名称类型说明
#privateany
plus(o: DecimalLike) => Decimal
minus(o: DecimalLike) => Decimal
times(o: DecimalLike) => Decimal
div(o: DecimalLike, scale: number, mode?: Rounding) => Decimal

Division needs a scale: the result is rounded to it.

round(scale: number, mode?: Rounding) => Decimal
roundTo(c: CurrencyCode | string, mode?: Rounding) => Decimal

Rounded to the currency's minor unit (JPY 0, SGD 2, KWD 3).

neg() => Decimal
abs() => Decimal
sign() => -1 | 0 | 1
isZero() => boolean
scalenumber

The number of digits after the point, as stored (1.20 → 2).

cmp(o: DecimalLike) => -1 | 0 | 1
eq(o: DecimalLike) => boolean
lt(o: DecimalLike) => boolean
lte(o: DecimalLike) => boolean
gt(o: DecimalLike) => boolean
gte(o: DecimalLike) => boolean
toString() => string
toJSON() => { readonly $dec: string; }

The wire form (D6): { $dec: '1.20' }, the one tag the wire carries, in both directions.

toNumber() => number

Lossy, and named so.

valueOf() => never

示例

dec('19.90').times(3).round(2, 'halfUp').toString() // '59.70'

源码: packages/std/src/decimal.ts:52

DecisionAnswers type

type DecisionAnswers<Q extends {
    readonly [id: string]: DecisionQuestion;
}> = {
    [K in keyof Q]: Q[K] extends {
        type: 'choice';
        criteria: infer O;
    } ? {
        type: 'choice';
        choice: keyof O & string;
        confidence: number;
        probabilities: Record<keyof O & string, number>;
    } : Q[K] extends {
        type: 'score';
        criteria: readonly (infer L)[];
    } ? {
        type: 'score';
        score: number;
        level: L;
        confidence: number;
        probabilities: Record<`${number}`, number>;
        legend: Record<`${number}`, L>;
    } : {
        type: 'noul';
        noul: number;
    };
};

ctx.ai.sys_1.decide's answers, each typed from its question literal (P36, P37): a choice's option key; a score's continuous score, its most probable level (the level itself), and probabilities/legend keyed by level index.

源码: packages/bolt/src/decl/runtime/facilities.ts:329

DecisionQuestion type

type DecisionQuestion = {
    readonly type: 'noul';
    readonly instructions: string;
    readonly criteria: {
        readonly true: string;
        readonly false: string;
    };
} | {
    readonly type: 'choice';
    readonly instructions: string;
    readonly criteria: {
        readonly [option: string]: string;
    };
} | {
    readonly type: 'score';
    readonly instructions: string;
    readonly criteria: readonly string[];
};

One typed question in the provider's shape (P37): a noul's criteria say what true and false mean; score levels run lowest first.

源码: packages/bolt/src/decl/runtime/facilities.ts:313

DecisionState type

type DecisionState = {
    readonly [key: string]: DecisionValue;
};

A System 1 state: structured text keyed by name (P37); never a file.

源码: packages/bolt/src/decl/runtime/facilities.ts:311

DeclaredConvertTarget type

type DeclaredConvertTarget = ConvertDecl & ConvertTarget;

A document target +workspace.ts declares under convert.to; ctx.convert.document takes only these.

源码: packages/bolt/src/decl/runtime/names.ts:30

DeclaredQuery type

type DeclaredQuery = {
    readonly mode: 'declared';
    readonly where?: Json | undefined;
    readonly select?: readonly string[] | undefined;
    readonly all: true;
};

Evaluated predicates and scalar field names, checked by the host against the actual model and reader.

成员

名称类型说明
mode'declared'
where?Json | undefined
select?readonly string[] | undefined
alltrue

源码: packages/bolt/src/decl/ctx.ts:75

DeclaredRow type

type DeclaredRow<C extends string> = {
    readonly id: Id<C>;
} & Readonly<Record<string, unknown>>;

A manifest-checked dynamic read keeps the native identity; its selected values require domain decoding.

成员

名称类型说明
idId<C>

源码: packages/bolt/src/decl/ctx.ts:71

DeliveryEvent type

type DeliveryEvent<E extends DeliveryKind = DeliveryKind, K = 'email'> = {
    readonly kind: E;
    readonly at: Instant;
    readonly message: Id<'sys_message'>;
    /** The provider that reported it (`bolt` for bolt's own `queued`, `failed` and presumed events). */
    readonly provider: string;
    /** The server's or provider's code: SMTP basic + enhanced (`550 5.1.1`), a provider error code (`63016`). */
    readonly code?: string;
    /** The reason as the server or provider gave it. */
    readonly reason?: string;
    /** bounced / failed / deferred: whether retrying can never help (a hard bounce). */
    readonly permanent?: boolean;
    /** delivered by inference, not confirmation. */
    readonly presumed?: boolean;
    /** opened: a pixel is prefetched or blocked, so an open is a hint. */
    readonly approximate?: boolean;
    /** The provider's own payload, bounded (≤ 4 KB), for support. */
    readonly raw?: Json;
} & (E extends 'replied' | 'auto_replied' ? {
    readonly reply: Inbound<K>;
} : E extends 'bounced' | 'failed' ? {
    readonly reason: string;
} : {});

What an outbound rule's events.<E> receives: the report as the provider gave it, the message it is about, and the reply.

源码: packages/bolt/src/decl/runtime/integration.ts:169

DeliveryKind type

type DeliveryKind = 'queued' | 'sent' | 'deferred' | 'delivered' | 'read' | 'opened' | 'bounced' | 'failed' | 'complained' | 'auto_replied' | 'replied';

Where an outbound message stands. Every provider maps its own reports to these; bolt keeps every report on the message's timeline, mapped or not.

源码: packages/bolt/src/decl/runtime/integration.ts:156

DriverName type

type DriverName = keyof typeof DRIVERS;

A driver kind: what a definition's driver names.

源码: packages/bolt/src/decl/runtime/integration.ts:60

DriverOf type

type DriverOf<D> = DriverIn<IntegrationSpecOf<D>>;

The driver definition D names.

源码: packages/bolt/src/decl/runtime/integration.ts:268

Duration type

type Duration = `${bigint}${'s' | 'min' | 'h' | 'd'}`;

A duration literal: whole seconds, minutes, hours or days ('30s', '15min', '2h', '7d').

源码: packages/bolt/src/decl/values.ts:59

Edge type

type Edge<C, F> = Columns<C>[F & keyof Columns<C>] extends {
    states: infer S;
} ? EdgeStates<S> : never;

A declared edge of state field F, written '<from>-><to>'.

源码: packages/bolt/src/decl/access/policy.ts:43

EmbeddingModelName type

type EmbeddingModelName = Ai extends {
    embeddings: readonly (infer E)[];
} ? E & string : never;

A name +workspace.ts declares under ai.embeddings.

源码: packages/bolt/src/decl/runtime/names.ts:24

EnvoyLimit type

type EnvoyLimit = Rate | {
    rate: Rate;
    per: 'sender' | 'subject';
} | readonly {
    rate: Rate;
    per: 'sender' | 'subject';
}[];

A rate limit on an envoy's inbound traffic, counted per sender or per subject.

源码: packages/bolt/src/decl/access/policy.ts:155

EnvoyName type

type EnvoyName = keyof NamesPart<'envoys'> & string;

The envoy names (src/agent/envoy/+<id>.envoy.ts).

源码: packages/bolt/src/decl/names.ts:114

EnvoySpec type

type EnvoySpec = {
    /** What people call it: a message that says this name is addressed to it, mention or not. */
    name: string;
    /** `private`: only a sender whose handle is a member's; `public`: anyone, an unknown sender under `policies` alone. */
    audience: 'public' | 'private';
    /** Every group turn's whole authority, joined in a DM by a linked member's own (`dm`); the source of every envoy limit. */
    policies: NonEmpty<string>;
    /** Which group messages it answers; default `mention_or_reply`. Email is always addressed. */
    groupMessages?: 'disabled' | 'mention_or_reply' | 'all';
    /** Whether it may delegate to sub-agents. */
    delegation: 'enabled' | 'disabled';
    /** System 1 triage of inbound messages (where the host binds it); `false` answers every addressed message at once. */
    triage?: false | {
        scope?: 'dm' | 'group' | 'all';
    };
    /**
     * A linked member's DM: `union` (default) holds the envoy's policies and the member's own; `envoy` holds the envoy's
     * alone, its operands bound to the member (never admin, no member routes), and `history`'s 'mine' to this instance.
     */
    dm?: 'union' | 'envoy';
    /** A standing directive on top of `+agent.md`; never who may do what. */
    task: string;
};

An envoy literal's general shape.

成员

名称类型说明
namestring

What people call it: a message that says this name is addressed to it, mention or not.

audience'public' | 'private'

private: only a sender whose handle is a member's; public: anyone, an unknown sender under policies alone.

policiesNonEmpty<string>

Every group turn's whole authority, joined in a DM by a linked member's own (dm); the source of every envoy limit.

groupMessages?'disabled' | 'mention_or_reply' | 'all'

Which group messages it answers; default mention_or_reply. Email is always addressed.

delegation'enabled' | 'disabled'

Whether it may delegate to sub-agents.

triage?false | { scope?: 'dm' | 'group' | 'all'; }

System 1 triage of inbound messages (where the host binds it); false answers every addressed message at once.

dm?'union' | 'envoy'

A linked member's DM: union (default) holds the envoy's policies and the member's own; envoy holds the envoy's alone, its operands bound to the member (never admin, no member routes), and history's 'mine' to this instance.

taskstring

A standing directive on top of +agent.md; never who may do what.

源码: packages/bolt/src/decl/runtime/agent.ts:10

Expr type

type Expr = {
    field: string;
} | number | string | boolean | {
    plus: readonly [E, E];
} | {
    minus: readonly [E, E];
} | {
    times: readonly [E, E];
} | {
    div: readonly [E, E];
} | {
    round: readonly [E, number];
} | {
    concat: readonly E[];
} | {
    plusDays: readonly [E, E];
} | {
    startOf: readonly [E, Unit];
} | {
    text: E;
} | {
    lower: E;
} | {
    upper: E;
} | {
    trim: E;
} | {
    substring: readonly [E, E] | readonly [E, E, E];
} | {
    regexReplace: readonly [E, string, string];
}
/** A json field's member as text (`party->>'id'`). */
 | {
    jsonText: readonly [E, string];
} | {
    eq: readonly [E, E];
} | {
    ne: readonly [E, E];
} | {
    gt: readonly [E, E];
} | {
    gte: readonly [E, E];
} | {
    lt: readonly [E, E];
} | {
    lte: readonly [E, E];
} | {
    and: readonly E[];
} | {
    or: readonly E[];
} | {
    not: E;
} | {
    when: readonly [E, E, E];
} | {
    coalesce: readonly E[];
};

A computed expression: an operator tree over the model's own fields (§3.3.2, rule 3).

源码: packages/bolt/src/decl/model.ts:12

FeedCtx interface

interface FeedCtx<N extends string, S> extends IntegrationReads, Pick<QueryCtx, 'now' | 'today' | 'tz'> {
    readonly instance: InstanceId<N>;
    /** The partition value (a calendar id) for a partitioned feed, else `null`. */
    readonly partition: string | null;
    readonly configuration: ConfigurationIn<S>;
}

A feed body's ctx: the instance and partition it runs for, its configuration and trusted reads; writes are only its changes.

成员

名称类型说明
instanceInstanceId<N>
partitionstring | null

The partition value (a calendar id) for a partitioned feed, else null.

configurationConfigurationIn<S>
read{ <C extends string>(collection: Is<C, ReadableName>, query: DeclaredQuery): Eff<Page<DeclaredRow<C>>, ReadFailed>; <C extends string, const S extends { readonly [P in WorkspaceReadField<C>]?: true; } = {}>(collection: Is<C, ReadableName>, q: { where?: NoInfer<ModelWhere<C>>; select?: S; } & Paged): Eff<Page<[keyof S] extends [never] ? StoredRow<C> : WorkspaceSelection<C, S, { [K in keyof ColumnV…

Dynamic declarations read actual stored values; selected names and operands are manifest-checked. select names stored fields or existing native sequence labels (rule 72); id always comes. Defaults remain stored rows without sequences, roll-ups or computed fields. A keyed set of stored reads in one crossing and one statement (as the caller's read({ … }), unmasked).

get<C extends string>(collection: Is<C, ReadableName>, id: NoInfer<Id<C>>, q?: { revision?: number; }) => Eff<StoredRow<C> | null>
nowInstant
todayPlainDate
tzIanaZone

源码: packages/bolt/src/decl/runtime/integration.ts:509

FeedField type

type FeedField<C> = Exclude<WritableField<C>, InstanceFkIn<C> | LocalField<C>>;

The fields a feed writes into C: writable, less its instance FK (the engine stamps it) and its local fields.

源码: packages/bolt/src/decl/runtime/integration.ts:305

FeedPage type

type FeedPage<R, K = R> = {
    readonly changes: readonly Change<R, K>[];
    readonly cursor: Json;
    readonly more: boolean;
    readonly snapshot?: 'begin' | 'end';
    readonly retained?: false;
    readonly health?: Health;
};

One page a read returns. The engine commits its changes, the cursor and the row markers in one statement. more reads on in the same run; retained: false (the source lost its history) starts a fresh snapshot, and after the page marked snapshot: 'end' the rows the snapshot did not see are reconciled through removed.

成员

名称类型说明
changesreadonly Change<R, K>[]
cursorJson
moreboolean
snapshot?'begin' | 'end'
retained?false
health?Health

源码: packages/bolt/src/decl/runtime/integration.ts:331

FeedRow type

type FeedRow<C> = FeedRowOf<C>;

One row a feed upserts into C: its feed fields, required as an insert requires them.

源码: packages/bolt/src/decl/runtime/integration.ts:307

FeedSpec type

type FeedSpec = {
    /** The collection it writes; its model key is the instance FK (pinned to this definition) and `key`. */
    into: string;
    /** The remote identity: the model key's fields beside the instance FK. */
    key: readonly string[];
    /** `read` (default): pulled on `cron`; `driver`: pushed by the driver; `messages`: this definition's conversation messages. */
    from?: 'read' | 'driver' | 'messages';
    cron?: string;
    /** A text-many configuration field: one cursor per value (calendar ids); a dropped value releases its cursor and markers, and its rows stay. */
    partitions?: string;
    /** What a remote delete, or a row a snapshot no longer has, does: a patch of feed fields, or `'delete'` (default). */
    removed?: object | 'delete';
};

One feed: rows of one collection from the account.

成员

名称类型说明
intostring

The collection it writes; its model key is the instance FK (pinned to this definition) and key.

keyreadonly string[]

The remote identity: the model key's fields beside the instance FK.

from?'read' | 'driver' | 'messages'

read (default): pulled on cron; driver: pushed by the driver; messages: this definition's conversation messages.

cron?string
partitions?string

A text-many configuration field: one cursor per value (calendar ids); a dropped value releases its cursor and markers, and its rows stay.

removed?object | 'delete'

What a remote delete, or a row a snapshot no longer has, does: a patch of feed fields, or 'delete' (default).

源码: packages/bolt/src/decl/runtime/integration.ts:344

FieldCommon type

type FieldCommon = {
    optional?: true;
    default?: unknown;
    unique?: true;
    label?: Msg;
    help?: Msg;
    hidden?: true;
};

Options every field kind takes: optional, default, unique, a label and help message, and hidden.

成员

名称类型说明
optional?true
default?unknown
unique?true
label?Msg
help?Msg
hidden?true

源码: packages/bolt/src/decl/fields.ts:49

FieldKind type

type FieldKind = Flat<FieldCommon & StoredArm>;

A stored field's kind literal in a model ({ kind: 'text' }, { kind: 'money' }, { kind: 'state', … }, …) with its options.

源码: packages/bolt/src/decl/fields.ts:102

FieldName type

type FieldName<M> = (keyof OwnColumns<M> | keyof OneRels<M>) & string;

A field name of M as author positions use it: own fields, computed values and FKs.

源码: packages/bolt/src/decl/names.ts:318

FileField type

type FileField<M> = OfKind<M, {
    kind: 'file';
}>;

The file fields of model M: what $bolt.upload names as '<c>.<field>'.

源码: packages/bolt/src/decl/names.ts:340

FileMeta type

type FileMeta = FileRef & {
    readonly bytes: number;
    readonly sha256: string;
};

A file reference with its size in bytes and SHA-256.

成员

名称类型说明
idId<'sys_file'>
namestring
mimestring
bytesnumber
sha256string

源码: packages/bolt/src/decl/runtime/facilities.ts:152

FileRef type

type FileRef = {
    readonly [brand]: 'FileRef';
    readonly id: Id<'sys_file'>;
    readonly name: string;
    readonly mime: string;
};

A file field's value: a handle to a stored file (id, name, MIME type), never its bytes.

成员

名称类型说明
idId<'sys_file'>
namestring
mimestring

源码: packages/bolt/src/decl/values.ts:31

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/bolt/src/decl/runtime/facilities.ts:408

Grant type

type Grant<C extends CollectionName, G = unknown> = G extends {
    via: unknown;
} ? {
    via: OneRel<C>;
} : unknown extends G ? Scoped<C, {
    read: true;
}> | {
    via: OneRel<C>;
} : Scoped<C, G>;

A collection grant: scoped operations, or via alone, which inherits the parent's grant.

源码: packages/bolt/src/decl/access/policy.ts:136

Handle type

type Handle = string;

A transport address of an outside sender (a phone number, a Telegram id, an email address).

源码: packages/bolt/src/decl/access/actor.ts:6

Health type

type Health = {
    readonly state: 'ready' | 'attention';
    readonly code?: string;
    readonly message?: string;
};

A feed's sync health: attention raises the instance's status (and any automation watching it).

成员

名称类型说明
state'ready' | 'attention'
code?string
message?string

源码: packages/bolt/src/decl/runtime/integration.ts:321

HostToolName type

type HostToolName = keyof NamesPart<'hostTools'> & string;

The host tools a policy's capabilities.tools may name (the host's Studio and browser tools).

源码: packages/bolt/src/decl/names.ts:136

HttpOp type

type HttpOp<O> = {
    method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
    path: string;
    query?: {
        readonly [name: string]: string | number | boolean;
    };
    headers?: {
        readonly [name: string]: string;
    };
    body?: Json;
    output: O & Checked<InputKind, O, Exact<O, ValidInput<O>>>;
};

An HTTP request through an http instance: path resolves under the definition's base URL (never another host).

成员

名称类型说明
method'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE'
pathstring
query?{ readonly [name: string]: string | number | boolean; }
headers?{ readonly [name: string]: string; }
body?Json
outputO & Checked<InputKind, O, Exact<O, ValidInput<O>>>

源码: packages/bolt/src/decl/runtime/integration.ts:215

HttpRequester interface

interface HttpRequester {
    <const O extends InputKind>(op: HttpOp<O>): Eff<ValueOf<O>, FacilityFailure | Unavailable>;
}

An instance's live request: journalled, credential host-side; it fails with a FacilityFailure or Unavailable.

源码: packages/bolt/src/decl/runtime/integration.ts:224

IanaZone type

type IanaZone = string;

An IANA time zone name (Asia/Singapore).

源码: packages/bolt/src/decl/values.ts:46

IconName type

type IconName = string;

An icon name as the ui's Icon takes it (an Iconify name such as lucide:users).

源码: packages/bolt/src/decl/values.ts:44

Id type

type Id<C extends string> = string & {
    readonly [brand]: C;
};

A row id, branded by its collection so an id of one collection never passes for another's.

源码: packages/bolt/src/decl/values.ts:16

IdentityGrant type

type IdentityGrant<C extends CollectionName> = {
    read: true | Scope<C>;
    fields?: readonly ReadField<C>[];
};

Rule 38c: identity collections are read-only to every policy.

成员

名称类型说明
readtrue | Scope<C>
fields?readonly ReadField<C>[]

源码: packages/bolt/src/decl/access/policy.ts:142

ImageFacts type

type ImageFacts = {
    readonly format: string;
    readonly width: number;
    readonly height: number;
    readonly sha256: string;
    readonly pdq: string;
    readonly exif: {
        readonly takenAt?: Instant;
        readonly gps?: Point;
        readonly software?: string;
        readonly make?: string;
        readonly model?: string;
    };
};

What ctx.files.image reads from an image: format, size, SHA-256, the PDQ perceptual hash and EXIF (time taken, GPS, camera).

成员

名称类型说明
formatstring
widthnumber
heightnumber
sha256string
pdqstring
exif{ readonly takenAt?: Instant; readonly gps?: Point; readonly software?: string; readonly make?: string; readonly model?: string; }

源码: packages/bolt/src/decl/runtime/facilities.ts:156

ImportFinding type

type ImportFinding = {
    readonly row: number | null;
    readonly column: string;
    readonly message: string;
    readonly severity: 'warn' | 'refuse';
};

A problem an import found with one sheet row (row null: the whole file or a stored row): refuse blocks the file, warn waits for acceptance.

成员

名称类型说明
rownumber | null
columnstring
messagestring
severity'warn' | 'refuse'

源码: packages/bolt/src/decl/runtime/pipeline.ts:22

InboundChat type

type InboundChat = {
    readonly id: string;
    readonly thread: string;
    readonly sentAt: Instant;
    readonly from: {
        readonly handle: Handle;
        readonly name: string | null;
    };
    readonly replyTo: string | null;
    readonly text: string;
    readonly attachments: readonly Attachment[];
    readonly group?: boolean;
    readonly participants?: readonly {
        readonly handle: string;
        readonly name: string | null;
    }[];
};

An inbound chat message. thread is the chat; replyTo the message it answers.

成员

名称类型说明
idstring
threadstring
sentAtInstant
from{ readonly handle: Handle; readonly name: string | null; }
replyTostring | null
textstring
attachmentsreadonly Attachment[]
group?boolean
participants?readonly { readonly handle: string; readonly name: string | null; }[]

源码: packages/bolt/src/decl/runtime/integration.ts:90

InboundMail type

type InboundMail = {
    readonly id: string;
    readonly thread: string | null;
    readonly sentAt: Instant;
    readonly from: Address;
    readonly replyTo: Address | null;
    readonly to: readonly Address[];
    readonly cc: readonly Address[];
    readonly subject: string;
    readonly text: string;
    readonly html: string | null;
    readonly headers: {
        readonly [name: string]: string;
    };
    readonly attachments: readonly Attachment[];
};

An inbound email: the full text and headers.

成员

名称类型说明
idstring
threadstring | null
sentAtInstant
fromAddress
replyToAddress | null
toreadonly Address[]
ccreadonly Address[]
subjectstring
textstring
htmlstring | null
headers{ readonly [name: string]: string; }
attachmentsreadonly Attachment[]

源码: packages/bolt/src/decl/runtime/integration.ts:75

InputFields type

type InputFields = {
    readonly [name: string]: InputKind;
};

A record of named input fields: a query's, action's, automation's or custom field's input shape.

源码: packages/bolt/src/decl/fields.ts:108

InputKind type

type InputKind = Flat<FieldCommon & (StoredArm | InputArm)>;

An input field's kind: every stored kind plus the input-only number, id, union and record.

源码: packages/bolt/src/decl/fields.ts:106

InputName type

type InputName = string;

The name of a declared input field, as a { param } operand names it.

源码: packages/bolt/src/decl/values.ts:52

InputOf type

type InputOf<F> = InputOfFields<F>;

An object of kinds as a value: absent-or-null for optional, absent for a default.

源码: packages/bolt/src/decl/fields.ts:214

Insert type

type Insert<C> = InsertValues<C, InputSel<C, 'create'>>;

A create input of C: its create allowlist, required fields required.

源码: packages/bolt/src/decl/ctx.ts:337

InstanceId type

type InstanceId<D extends string = IntegrationName> = Id<'sys_integration'> & {
    readonly [definition]: D;
};

A sys_integration id known to be an instance of definition D: what an FK pinned to D holds.

源码: packages/bolt/src/decl/names.ts:126

InstanceTarget type

type InstanceTarget = ConnectionName | InstanceId;

Where a send or request goes: a connection, or an instance id pinned to a definition.

源码: packages/bolt/src/decl/runtime/facilities.ts:101

Instant type

function Instant(v: string | Date): Instant;

An ISO instant with Z or an offset (or a Date), as canonical UTC …Z.

源码: packages/std/src/date.ts:7

InstantPeriod type

type InstantPeriod = {
    readonly start: Instant;
    readonly end: Instant | null;
};

A period of instants: start inclusive, end exclusive; end: null is open-ended.

成员

名称类型说明
startInstant
endInstant | null

源码: packages/bolt/src/decl/values.ts:25

Integration type

type Integration<N extends string, S> = {
    readonly name: N;
    readonly spec: S;
    readonly bodies: IntegrationBodies;
    /** Checks a freshly paired instance (the host's `test` verb). */
    test(body: (ctx: TestCtx<S>) => BodyReturn<void>): void;
    /** A declared feed's body: `read` for a pulled feed, `map` for a pushed or message feed. */
    feed<F extends keyof Feeds<S> & string, P = unknown>(name: F, body: FeedBody<N, S, Feeds<S>[F], P>): void;
    /** A declared outbound rule's body. */
    outbound: Outbound<N, S>;
    /** A custom conversation's inbound: the verified webhook body → the messages it carries (committed before the 200). */
    receive(body: Custom<S, ReceiveBody<S>>): void;
    /** A custom conversation's outbound: envoy replies, rules and `ctx.send` through an instance. */
    send(body: Custom<S, SendBody<N, S>>): void;
};

What integration() returns: the literal, and the bodies it attaches by name.

成员

名称类型说明
nameN
specS
bodiesIntegrationBodies
test(body: (ctx: TestCtx<S>) => BodyReturn<void>) => void

Checks a freshly paired instance (the host's test verb).

feed<F extends keyof Feeds<S> & string, P = unknown>(name: F, body: FeedBody<N, S, Feeds<S>[F], P>) => void

A declared feed's body: read for a pulled feed, map for a pushed or message feed.

outboundOutbound<N, S>

A declared outbound rule's body.

receive(body: Custom<S, ReceiveBody<S>>) => void

A custom conversation's inbound: the verified webhook body → the messages it carries (committed before the 200).

send(body: Custom<S, SendBody<N, S>>) => void

A custom conversation's outbound: envoy replies, rules and ctx.send through an instance.

源码: packages/bolt/src/decl/runtime/integration.ts:606

IntegrationName type

type IntegrationName = keyof Definitions & string;

The integration definitions: the workspace's (src/integration/<name>/) and bolt's conversation definitions.

源码: packages/bolt/src/decl/names.ts:117

IntegrationOf type

type IntegrationOf<N> = N extends ConnectionName ? Connections[N] extends {
    integration: infer D;
} ? D : never : N extends InstanceId<infer D> ? D : never;

The definition a connection, or an instance id pinned to a definition, is an instance of.

源码: packages/bolt/src/decl/runtime/names.ts:9

IntegrationSpec type

type IntegrationSpec = {
    description: string;
    driver: DriverName;
    /** Safe settings each instance edits at run time (with history), decoded against these fields. */
    configuration?: InputFields;
    /** The secret each instance pairs with, sealed host-side and never readable (`http` and `sqlserver` only). */
    credential?: InputFields;
    /**
     * The OAuth client an `oauth` driver (http, calendar) grants with, by secret name; tokens are per instance. An http
     * definition names its `authorize` and `token` endpoints too, and its requests carry the instance's token as a bearer.
     */
    oauth?: {
        client: string;
        secret: string;
        authorize?: string;
        token?: string;
        scopes?: readonly string[];
    };
    /** `http` only: the base URL (a literal or a text configuration field) and how requests authenticate. */
    http?: {
        baseUrl: string;
        auth?: HttpAuth<string>;
    };
    /** `http` with a conversation: the signed webhook messages arrive by, verified with a credential field. */
    webhook?: {
        scheme: WebhookScheme;
        secret: string;
    };
    /** `http` only: a custom conversation (`receive` and `send` bodies) and the member handle its senders carry. */
    conversation?: {
        kind: 'chat' | 'email';
        handle: HandleKind;
    };
    feeds?: {
        readonly [feed: string]: FeedSpec;
    };
    outbound?: {
        readonly [rule: string]: OutboundSpec;
    };
};

A definition literal's general shape.

成员

名称类型说明
descriptionstring
driverDriverName
configuration?InputFields

Safe settings each instance edits at run time (with history), decoded against these fields.

credential?InputFields

The secret each instance pairs with, sealed host-side and never readable (http and sqlserver only).

oauth?{ client: string; secret: string; authorize?: string; token?: string; scopes?: readonly string[]; }

The OAuth client an oauth driver (http, calendar) grants with, by secret name; tokens are per instance. An http definition names its authorize and token endpoints too, and its requests carry the instance's token as a bearer.

http?{ baseUrl: string; auth?: HttpAuth<string>; }

http only: the base URL (a literal or a text configuration field) and how requests authenticate.

webhook?{ scheme: WebhookScheme; secret: string; }

http with a conversation: the signed webhook messages arrive by, verified with a credential field.

conversation?{ kind: 'chat' | 'email'; handle: HandleKind; }

http only: a custom conversation (receive and send bodies) and the member handle its senders carry.

feeds?{ readonly [feed: string]: FeedSpec; }
outbound?{ readonly [rule: string]: OutboundSpec; }

源码: packages/bolt/src/decl/runtime/integration.ts:369

JsonChange type

type JsonChange = {
    readonly path: string;
    readonly kind: 'added' | 'removed' | 'changed';
    readonly before?: Json;
    readonly after?: Json;
};

One difference between two JSON values, at a keyed pointer.

成员

名称类型说明
pathstring
kind'added' | 'removed' | 'changed'
before?Json
after?Json

源码: packages/bolt/src/engine/agent/draft.ts:9

KeyValues type

type KeyValues<C> = NamesPart<'models'> extends {
    [P in C & string]: {
        key: readonly (infer K)[];
    };
} ? {
    readonly [P in K & string]: ColumnValue<C, P>;
} : never;

A model's natural key as values; exists only where the model declares key (§3.3.9).

源码: packages/bolt/src/decl/ctx.ts:105

KioskName type

type KioskName = keyof NamesPart<'kiosks'> & string;

The kiosk names (src/kiosk/<k>/+kiosk.ts).

源码: packages/bolt/src/decl/names.ts:110

KioskPageName type

type KioskPageName<K> = K extends keyof NamesPart<'kioskPages'> ? NamesPart<'kioskPages'>[K] & string : never;

The +<page>.page.svelte files in kiosk K's folder.

源码: packages/bolt/src/decl/runtime/names.ts:35

Limit type

type Limit = Rate | {
    rate: Rate;
    per: 'actor' | 'ip';
} | readonly {
    rate: Rate;
    per: 'actor' | 'ip';
}[];

A rate limit (rule 38): '<n>/<unit>', optionally per actor or IP; a list applies every rule.

源码: packages/bolt/src/decl/access/policy.ts:152

LimitKey type

type LimitKey = 'act' | 'read' | 'agent' | 'register' | 'upload' | EnvoyKey | {
    [C in CollectionName]: `${C}.${QueryName<C> | ActionName<C>}`;
}[CollectionName];

What a limits entry throttles: acts, reads, agent turns, registration, uploads, envoy traffic, or one '<c>.<query|action>'.

源码: packages/bolt/src/decl/access/policy.ts:163

ListRow type

type ListRow<C> = Omit<Row<C>, HeavyField<C>>;

A read's row without a select: the caller row less its heavy fields, which only a select or a get returns.

源码: packages/bolt/src/decl/ctx.ts:128

LocalField type

type LocalField<C> = SelectionColumns<InputSel<C, 'update'>>;

A feed target's local fields: its collection's update columns, which the feed never writes and only they may change.

源码: packages/bolt/src/decl/runtime/integration.ts:302

LocaleTag type

type LocaleTag = string;

A BCP 47 locale tag (en, zh-CN).

源码: packages/bolt/src/decl/values.ts:48

Masked interface

interface Masked {
    readonly [masked]: true;
}

A value the reading caller's grants do not admit (rules 10, 14).

源码: packages/bolt/src/decl/names.ts:413

McpName type

type McpName = keyof NamesPart<'mcp'> & string;

The MCP server names (src/agent/mcp/+<n>.mcp.ts).

源码: packages/bolt/src/decl/names.ts:132

MemberIn type

type MemberIn = {
    readonly in: {
        readonly member: string;
        readonly field: string;
    };
} | {
    readonly nin: {
        readonly member: string;
        readonly field: string;
    };
};

An earlier keyed member's values of one of its fields: { in: { member: 'entity', field: 'settings_code' } }.

源码: packages/bolt/src/decl/ctx.ts:157

MemberWhere type

type MemberWhere<C> = {
    readonly [P in ReadField<C>]?: MemberIn | NonNullable<Where<C>[P & keyof Where<C>]>;
};

A keyed member's where that names an earlier member's values (each other clause as Where takes it).

源码: packages/bolt/src/decl/ctx.ts:161

MessageItem type

type MessageItem<K> = Inbound<K> & {
    readonly version: string;
    readonly deleted: boolean;
};

A message a from: 'messages' feed maps: the message as stored, its version (an edit is a new one) and whether it was deleted or recalled.

源码: packages/bolt/src/decl/runtime/integration.ts:104

MessageKey type

type MessageKey = keyof NamesPart<'messages'> & string;

A key of src/i18n/+messages.ts.

源码: packages/bolt/src/decl/ctx.ts:635

MimePattern type

type MimePattern = `${string}/${string}`;

A MIME type or wildcard a file field accepts (image/*, application/pdf).

源码: packages/bolt/src/decl/values.ts:56

ModelName type

type ModelName = keyof Models & string;

An authored model (src/data/model/+<m>.model.ts).

源码: packages/bolt/src/decl/names.ts:90

Msg type

type Msg = string;

A key of src/i18n/+messages.ts or, outside catalog mode, a literal string.

源码: packages/bolt/src/decl/values.ts:42

Names interface

interface Names {
}

Augmented by the generated .norbital/names.ts: declare module '@norbital-ai/bolt' { interface Names { … } }.

源码: packages/bolt/src/decl/names.ts:9

Notice type

type Notice = {
    to: NoticeRecipient | readonly NoticeRecipient[];
    title: Msg;
    body?: Msg;
    link?: RecordRef;
    once?: string;
};

A notice sent with ctx.notify: recipients (team, member or policy holders), a title and body message, an optional record link and a once key.

成员

名称类型说明
toNoticeRecipient | readonly NoticeRecipient[]
titleMsg
body?Msg
link?RecordRef
once?string

源码: packages/bolt/src/decl/runtime/facilities.ts:82

NotificationEvent type

type NotificationEvent = 'committed' | 'rejected' | 'approvalStarted' | 'approvalStepRequested' | 'approvalStepApproved' | 'approvalChangesRequested' | 'approvalWithdrawn' | 'approvalSuperseded' | 'approvalResubmitted' | 'approvalCommented' | 'approvalCompleted';

The write and approval events a collection's notifications rules react to.

源码: packages/bolt/src/decl/collection.ts:47

NotificationInput type

type NotificationInput = {
    readonly event: NotificationEvent;
    readonly action: string;
    readonly collection: string;
    readonly records: readonly {
        readonly id: string;
        readonly values: Readonly<Record<string, Json>>;
    }[];
    readonly requestor: string | null;
    readonly approvers: readonly TeamName[];
};

Data available to a pure recipient callback: native write images or caller-readable action targets, expressed as JSON.

成员

名称类型说明
eventNotificationEvent
actionstring
collectionstring
recordsreadonly { readonly id: string; readonly values: Readonly<Record<string, Json>>; }[]
requestorstring | null
approversreadonly TeamName[]

源码: packages/bolt/src/decl/collection.ts:75

NotificationRecipient type

type NotificationRecipient = {
    readonly user: string;
} | {
    readonly team: TeamName;
} | {
    readonly policy: PolicyName;
};

A member ID, an authored team, or a policy's holders: the members whose source team (+team.ts) or sign-up lists it.

源码: packages/bolt/src/decl/collection.ts:87

NotificationRecipients type

type NotificationRecipients = (event: NotificationInput) => readonly NotificationRecipient[];

Pure: runs in a fresh bounded isolate with no host I/O. IDs and policy names are validated before the guarded write.

示例

event => event.requestor === null ? [] : [{ user: event.requestor }]

源码: packages/bolt/src/decl/collection.ts:92

NotificationRule type

type NotificationRule<C, A extends string = never> = {
    channel?: 'inbox' | ConnectionName;
    to: readonly Recipient<C>[] | NotificationRecipients;
    on?: {
        action?: readonly ('create' | 'update' | 'delete' | A)[];
    };
    title: Title;
    body?: Title;
};

One notification rule: a pure recipient callback or descriptors, triggering writes and title/body. Every resolved member gets an in-app notice; channel (a conversation connection, bolt check refuses any other) also sends it to their handle there.

成员

名称类型说明
channel?'inbox' | ConnectionName
toreadonly Recipient<C>[] | NotificationRecipients
on?{ action?: readonly ('create' | 'update' | 'delete' | A)[]; }
titleTitle
body?Title

源码: packages/bolt/src/decl/collection.ts:98

Offset type

type Offset = `${'+' | '-'}${Duration}` | '';

A signed duration from now or today ('-7d', '+1h'); '' is none.

源码: packages/bolt/src/decl/values.ts:61

OneRel type

type OneRel<C> = keyof OneRels<C> & string;

A one-relation of C (an FK), as a via grant names the parent whose grant it inherits.

源码: packages/bolt/src/decl/access/policy.ts:50

Operand type

type Operand = {
    field: string;
} | {
    param: string;
} | {
    now: Offset;
} | {
    today: Offset;
} | StartOf | {
    actor: 'id' | 'email' | 'phone' | 'teams' | 'teamTree' | 'party' | 'visitor' | 'instance' | {
        scopes: PolicyName;
    };
};

A typed operand literal; which ones a position admits depends on the value's kind.

源码: packages/bolt/src/decl/where.ts:23

OrderBy type

type OrderBy<C> = SortKey<C> | readonly SortKey<C>[];

Up to ORDER_MAX_KEYS keys, each once, then id (rule 11); nulls last ascending, first descending.

源码: packages/bolt/src/decl/where.ts:271

OutboundSpec type

type OutboundSpec = {
    from: string;
    /** Default `'create'`; queued in the row's own commit, once the write is effective (after approval). */
    on?: 'create' | 'update' | readonly ('create' | 'update')[];
    when?: object;
    /** The instance it goes through: a connection of this definition, or an FK of `from` pinned to it. */
    via: string;
    /** The field whose value keys the send (one per record and value); default the record id (one per record). */
    version?: string;
};

One outbound rule: a send or command for each committed row of from matching on and when.

成员

名称类型说明
fromstring
on?'create' | 'update' | readonly ('create' | 'update')[]

Default 'create'; queued in the row's own commit, once the write is effective (after approval).

when?object
viastring

The instance it goes through: a connection of this definition, or an FK of from pinned to it.

version?string

The field whose value keys the send (one per record and value); default the record id (one per record).

源码: packages/bolt/src/decl/runtime/integration.ts:358

OutboundState type

type OutboundState = {
    readonly status: 'queued' | 'sending' | 'sent' | 'skipped' | 'failed' | 'uncertain';
    readonly error: string | null;
};

Where the latest send of an outbound rule (<definition>.<rule>) for a row stands.

成员

名称类型说明
status'queued' | 'sending' | 'sent' | 'skipped' | 'failed' | 'uncertain'
errorstring | null

源码: packages/bolt/src/decl/names.ts:465

Outcome type

type Outcome<O, N = string> = Committed<O, N> | PendingApproval<N> | Refused | Conflict | Unknown;

Every result of a write (rule 32): committed, pendingApproval, refused, conflict or unknown, told apart by kind.

源码: packages/bolt/src/decl/ctx.ts:483

Outgoing type

type Outgoing<K> = K extends 'email' ? Common & {
    to: readonly string[];
    cc?: readonly string[];
    subject: string;
    html?: string;
    text?: string;
    /** The correlation id replies are matched back to. */ thread?: string;
    /** Stored files only: a message row keeps references, never bytes. */
    attachments?: readonly FileRef[];
} : K extends 'chat' ? Common & {
    to: Handle | Id<'sys_conversation'>;
    text: string;
    attachments?: readonly FileRef[];
} : never;

What a conversation sends, by its kind: an outbound rule's build, ctx.send and an envoy's reply.

源码: packages/bolt/src/decl/runtime/integration.ts:107

OutputOf type

type OutputOf<X> = X extends {
    output: infer O;
} ? ValueOf<O> : undefined;

The value a query, action or automation literal declares as its output (undefined when it declares none).

源码: packages/bolt/src/decl/collection.ts:159

Page type

type Page<T> = {
    readonly rows: readonly T[];
    readonly next: Cursor | null;
};

One page of a read: its rows, and the next cursor, null on the last page.

成员

名称类型说明
rowsreadonly T[]
nextCursor | null

源码: packages/bolt/src/decl/ctx.ts:69

PageData type

type PageData<P extends {
    readonly data: Schema.Top;
}> = P['data']['Type'];

The decoded data passed to a page's Svelte component during server rendering and hydration.

源码: packages/bolt/src/decl/runtime/page.ts:22

PageLoad type

type PageLoad<D> = (request: PageLoadRequest, ctx: PageReadContext) => BodyReturn<D>;

A public page reads as its admitted caller and returns data described by its shared codec.

源码: packages/bolt/src/decl/runtime/page.ts:13

PageLoadRequest interface

interface PageLoadRequest {
    readonly pathname: string;
    readonly search: string;
}

The requested URL within this workspace; transport headers and credentials stay with the host.

成员

名称类型说明
pathnamestring
searchstring

源码: packages/bolt/src/decl/runtime/page.ts:7

PageName type

type PageName<A> = A extends keyof NamesPart<'pages'> ? NamesPart<'pages'>[A] & string : never;

The +<page>.page.svelte files in app A's folder.

源码: packages/bolt/src/decl/runtime/names.ts:39

PageReadContext interface

interface PageReadContext extends Readonly<Clock>, CallerReads<ReadFailed> {
}

Server-rendered page loaders receive caller-scoped reads and a clock, with no write or facility authority.

成员

名称类型说明
actorActor
nowInstant
todayPlainDate
tzIanaZone
todayIn(zone: IanaZone) => PlainDate
read{ <C extends string>(collection: Is<C, ReadableName>, query: DeclaredQuery): Eff<Page<DeclaredRow<C>>, ReadFailed>; <C extends string, const S extends Select<C> = {}>(collection: Is<C, ReadableName>, q: { where?: NoInfer<Where<C>> | undefined; select?: S | undefined; orderBy?: NoInfer<OrderBy<C>> | undefined; search?: string; } & Paged): Eff<Page<ListResult<C, S>>, ReadFailed>; <const M extends R…

Dynamic declarations use the same native caller policies, exposure and masked values as literal reads. A keyed set of reads in one crossing and ONE statement: each member is a read (or, with id, a get) under the caller's read policies, answered under its key. Every member states its page (rule 9); the row and byte caps hold per member and name the member that breaks them.

get<C extends string, const S extends Select<C> = {}>(collection: Is<C, ReadableName>, id: NoInfer<Id<C>>, q?: { select?: S | undefined; revision?: number; } | undefined) => Eff<ReadResult<C, S> | null, ReadFailed>

{ revision } (L-BOLT-181): the record as of that revision, folded from its history; null once pruned past its create.

similar{ <C extends string, N extends SimilarityName<C>, const S extends Select<C> = {}>(collection: Is<C, ReadableName>, search: N, input: NoInfer<In<SimilaritiesOfC<C>[N]>>, q: { where?: NoInfer<Where<C>> | undefined; select?: S | undefined; limit: number; }): Eff<readonly (ListResult<C, S> & { readonly $distance: number; })[], ReadFailed>; <C extends string, const S extends Select<C> = {}>(collection…

A named similarity search (§3.3.4): nearest first, each row with its $distance. Over search.semantic (L-BOLT-123): nearest by meaning to a text, or to a record's own embedding (the record itself left out).

query<C extends string, Q extends QueryName<C>>(collection: Is<C, CollectionName>, query: Q, input: NoInfer<In<QueriesOfC<C>[Q]>>) => Eff<OutputOf<QueriesOfC<C>[Q]>, ReadFailed>

源码: packages/bolt/src/decl/ctx.ts:514

PageServer interface

interface PageServer<out D> {
    readonly data: Schema.Codec<D, Json>;
    readonly load: PageLoad<D>;
}

A public page's shared data codec and caller-scoped server loader.

成员

名称类型说明
dataSchema.Codec<D, Json>
loadPageLoad<D>

源码: packages/bolt/src/decl/runtime/page.ts:16

Paged type

type Paged = {
    limit: number;
    after?: Cursor;
    all?: never;
} | {
    all: true;
    limit?: never;
    after?: never;
};

Rule 9: every read states a limit or asks for everything.

源码: packages/bolt/src/decl/ctx.ts:66

Patch type

type Patch<C> = PatchValues<C, InputSel<C, 'update'>>;

An update set of C: its update allowlist, every field optional.

源码: packages/bolt/src/decl/ctx.ts:339

PendingApproval type

type PendingApproval<N = string> = {
    kind: 'pendingApproval';
    requestId: RequestId;
    records: WrittenOf<N>;
};

The write is held for approval (§3.8): requestId names the approval request, records the held rows.

成员

名称类型说明
kind'pendingApproval'
requestIdRequestId
recordsWrittenOf<N>

源码: packages/bolt/src/decl/ctx.ts:454

PeriodField type

type PeriodField<M> = OfKind<M, {
    kind: 'period';
}>;

The period fields of model M.

源码: packages/bolt/src/decl/names.ts:338

PipelineCtx type

type PipelineCtx = Pick<QueryCtx, 'now' | 'today' | 'tz'> & Pick<CallerReads, 'read' | 'get'>;

What a pipeline's known, check and template bodies see: the clock and the caller's reads; no I/O.

成员

名称类型说明
nowInstant
todayPlainDate
tzIanaZone
read{ <C extends string>(collection: Is<C, ReadableName>, query: DeclaredQuery): Eff<Page<DeclaredRow<C>>, ReadFailed>; <C extends string, const S extends Select<C> = {}>(collection: Is<C, ReadableName>, q: { where?: NoInfer<Where<C>> | undefined; select?: S | undefined; orderBy?: NoInfer<OrderBy<C>> | undefined; search?: string; } & Paged): Eff<Page<ListResult<C, S>>, never>; <const M extends ReadSe…

Dynamic declarations use the same native caller policies, exposure and masked values as literal reads. A keyed set of reads in one crossing and ONE statement: each member is a read (or, with id, a get) under the caller's read policies, answered under its key. Every member states its page (rule 9); the row and byte caps hold per member and name the member that breaks them.

get<C extends string, const S extends Select<C> = {}>(collection: Is<C, ReadableName>, id: NoInfer<Id<C>>, q?: { select?: S | undefined; revision?: number; } | undefined) => Eff<ReadResult<C, S> | null, never>

{ revision } (L-BOLT-181): the record as of that revision, folded from its history; null once pruned past its create.

源码: packages/bolt/src/decl/runtime/pipeline.ts:18

PlainDate type

function PlainDate(s: string): PlainDate;

A calendar day YYYY-MM-DD; anything else throws.

源码: packages/std/src/date.ts:6

PlainTime interface

interface PlainTime {
    readonly [brand]: 'PlainTime';
}

A time field's value: a time of day.

源码: packages/bolt/src/decl/values.ts:10

PlatformAutomation type

type PlatformAutomation = 'notifications.deliver' | 'bolt.membership' | 'bolt.embed';

A platform automation a system actor can run as: resuming and discarding held writes, notification delivery, membership sync and embedding.

源码: packages/bolt/src/decl/access/actor.ts:11

PlatformRefusal type

type PlatformRefusal = 'locked' | 'sourceChanged' | 'readBudgetExceeded' | 'forbidden' | 'notFound' | 'invalidInput' | 'unique' | 'check' | 'overlap' | 'missingRef' | 'restricted' | 'required' | 'overflow' | 'rateLimited' | 'keyReuse' | 'approvalSplit'
/** L-BOLT-171: the act names a schema (`Bolt-Contract`) this workspace no longer runs; reload the page. */
 | 'releaseChanged'
/** Rule 31: an `issuedAt` older than 23 h or more than 5 min ahead. */
 | 'expired'
/** Rule 42: a throw from tenant code (its message reaches members only); the guest budgets (rule 72). */
 | 'internal' | 'cpuBudget' | 'crossingBudget' | 'memory' | 'tooLarge';

The engine's own refusal codes (rule 32), beside an authored refused: grants, constraints, budgets, rate limits and stale requests.

源码: packages/bolt/src/decl/ctx.ts:422

Point type

type Point = {
    readonly lat: number;
    readonly lng: number;
};

A point field's value: latitude and longitude in degrees.

成员

名称类型说明
latnumber
lngnumber

源码: packages/bolt/src/decl/values.ts:27

PolicyName type

type PolicyName = keyof NamesPart<'policies'> & string;

The policy names (src/access_control/policy/+<name>.policy.ts).

源码: packages/bolt/src/decl/names.ts:106

ProjectReadCtx interface

interface ProjectReadCtx extends QueryCtx {
    readonly admin: boolean;
    readonly policies: readonly string[];
    readonly fields: readonly string[];
}

The general shape of collection()'s spec: what callers read, the create/update input allowlists, delete, and the named queries, actions, similarity searches and notifications.

成员

名称类型说明
adminboolean
policiesreadonly string[]
fieldsreadonly string[]
invocationIdstring
refuse(message: string, at?: { field?: string; }) => Eff<never, Refusal>

Ends the body with an authored refusal (rule 32), return yield* ctx.refuse(…); field names an input field.

actorActor
nowInstant
todayPlainDate
tzIanaZone
todayIn(zone: IanaZone) => PlainDate
read{ <C extends string>(collection: Is<C, ReadableName>, query: DeclaredQuery): Eff<Page<DeclaredRow<C>>, ReadFailed>; <C extends string, const S extends Select<C> = {}>(collection: Is<C, ReadableName>, q: { where?: NoInfer<Where<C>> | undefined; select?: S | undefined; orderBy?: NoInfer<OrderBy<C>> | undefined; search?: string; } & Paged): Eff<Page<ListResult<C, S>>, never>; <const M extends ReadSe…

Dynamic declarations use the same native caller policies, exposure and masked values as literal reads. A keyed set of reads in one crossing and ONE statement: each member is a read (or, with id, a get) under the caller's read policies, answered under its key. Every member states its page (rule 9); the row and byte caps hold per member and name the member that breaks them.

get<C extends string, const S extends Select<C> = {}>(collection: Is<C, ReadableName>, id: NoInfer<Id<C>>, q?: { select?: S | undefined; revision?: number; } | undefined) => Eff<ReadResult<C, S> | null, never>

{ revision } (L-BOLT-181): the record as of that revision, folded from its history; null once pruned past its create.

similar{ <C extends string, N extends SimilarityName<C>, const S extends Select<C> = {}>(collection: Is<C, ReadableName>, search: N, input: NoInfer<In<SimilaritiesOfC<C>[N]>>, q: { where?: NoInfer<Where<C>> | undefined; select?: S | undefined; limit: number; }): Eff<readonly (ListResult<C, S> & { readonly $distance: number; })[], never>; <C extends string, const S extends Select<C> = {}>(collection: Is<…

A named similarity search (§3.3.4): nearest first, each row with its $distance. Over search.semantic (L-BOLT-123): nearest by meaning to a text, or to a record's own embedding (the record itself left out).

query<C extends string, Q extends QueryName<C>>(collection: Is<C, CollectionName>, query: Q, input: NoInfer<In<QueriesOfC<C>[Q]>>) => Eff<OutputOf<QueriesOfC<C>[Q]>, never>

源码: packages/bolt/src/decl/collection.ts:169

QueryCtx interface

interface QueryCtx extends Clock, CallerReads {
    invocationId: string;
    /** Ends the body with an authored refusal (rule 32), `return yield* ctx.refuse(…)`; `field` names an input field. */
    refuse(message: string, at?: {
        field?: string;
    }): Eff<never, Refusal>;
}

What a query body sees: the actor, clock and timezone, caller reads (read, get, similar, query) and refuse.

成员

名称类型说明
invocationIdstring
refuse(message: string, at?: { field?: string; }) => Eff<never, Refusal>

Ends the body with an authored refusal (rule 32), return yield* ctx.refuse(…); field names an input field.

actorActor
nowInstant
todayPlainDate
tzIanaZone
todayIn(zone: IanaZone) => PlainDate
read{ <C extends string>(collection: Is<C, ReadableName>, query: DeclaredQuery): Eff<Page<DeclaredRow<C>>, ReadFailed>; <C extends string, const S extends Select<C> = {}>(collection: Is<C, ReadableName>, q: { where?: NoInfer<Where<C>> | undefined; select?: S | undefined; orderBy?: NoInfer<OrderBy<C>> | undefined; search?: string; } & Paged): Eff<Page<ListResult<C, S>>, never>; <const M extends ReadSe…

Dynamic declarations use the same native caller policies, exposure and masked values as literal reads. A keyed set of reads in one crossing and ONE statement: each member is a read (or, with id, a get) under the caller's read policies, answered under its key. Every member states its page (rule 9); the row and byte caps hold per member and name the member that breaks them.

get<C extends string, const S extends Select<C> = {}>(collection: Is<C, ReadableName>, id: NoInfer<Id<C>>, q?: { select?: S | undefined; revision?: number; } | undefined) => Eff<ReadResult<C, S> | null, never>

{ revision } (L-BOLT-181): the record as of that revision, folded from its history; null once pruned past its create.

similar{ <C extends string, N extends SimilarityName<C>, const S extends Select<C> = {}>(collection: Is<C, ReadableName>, search: N, input: NoInfer<In<SimilaritiesOfC<C>[N]>>, q: { where?: NoInfer<Where<C>> | undefined; select?: S | undefined; limit: number; }): Eff<readonly (ListResult<C, S> & { readonly $distance: number; })[], never>; <C extends string, const S extends Select<C> = {}>(collection: Is<…

A named similarity search (§3.3.4): nearest first, each row with its $distance. Over search.semantic (L-BOLT-123): nearest by meaning to a text, or to a record's own embedding (the record itself left out).

query<C extends string, Q extends QueryName<C>>(collection: Is<C, CollectionName>, query: Q, input: NoInfer<In<QueriesOfC<C>[Q]>>) => Eff<OutputOf<QueriesOfC<C>[Q]>, never>

源码: packages/bolt/src/decl/ctx.ts:519

QueryInput type

type QueryInput<N> = In<QueryOf<N>>;

A query callable's input and output ('<c>.<q>').

源码: packages/bolt/src/decl/ctx.ts:631

QueryName type

type QueryName<C> = keyof QueriesOfC<C> & string;

The names of C's declared queries.

源码: packages/bolt/src/decl/ctx.ts:137

QueryOutput type

type QueryOutput<N> = OutputOf<QueryOf<N>>;

A query callable's output ('<c>.<q>'): the query's declared output value.

源码: packages/bolt/src/decl/ctx.ts:633

QuerySpec type

type QuerySpec = {
    description: string;
    input: InputFields;
    output: InputKind;
    agent?: AgentUse;
};

A collection query: a description, the typed input fields, the output kind and how the agent may call it. Its body attaches with c.query(name, fn).

成员

名称类型说明
descriptionstring
inputInputFields
outputInputKind
agent?AgentUse

源码: packages/bolt/src/decl/collection.ts:139

Rate type

type Rate = `${bigint}/${'s' | 'min' | 'h' | 'd' | Duration}`;

A rate literal: a count per unit or per duration ('60/min', '5/10min').

源码: packages/bolt/src/decl/values.ts:65

ReadCtx interface

interface ReadCtx<N extends string, S> extends FeedCtx<N, S> {
    request: Requester<S>;
}

A read body's ctx: a feed's, with the instance's live request.

成员

名称类型说明
requestRequester<S>
instanceInstanceId<N>
partitionstring | null

The partition value (a calendar id) for a partitioned feed, else null.

configurationConfigurationIn<S>
read{ <C extends string>(collection: Is<C, ReadableName>, query: DeclaredQuery): Eff<Page<DeclaredRow<C>>, ReadFailed>; <C extends string, const S extends { readonly [P in WorkspaceReadField<C>]?: true; } = {}>(collection: Is<C, ReadableName>, q: { where?: NoInfer<ModelWhere<C>>; select?: S; } & Paged): Eff<Page<[keyof S] extends [never] ? StoredRow<C> : WorkspaceSelection<C, S, { [K in keyof ColumnV…

Dynamic declarations read actual stored values; selected names and operands are manifest-checked. select names stored fields or existing native sequence labels (rule 72); id always comes. Defaults remain stored rows without sequences, roll-ups or computed fields. A keyed set of stored reads in one crossing and one statement (as the caller's read({ … }), unmasked).

get<C extends string>(collection: Is<C, ReadableName>, id: NoInfer<Id<C>>, q?: { revision?: number; }) => Eff<StoredRow<C> | null>
nowInstant
todayPlainDate
tzIanaZone

源码: packages/bolt/src/decl/runtime/integration.ts:517

ReadField type

type ReadField<C> = (ReadSpec<C> extends {
    fields: 'all';
} ? FieldName<C> : ReadSpec<C> extends {
    fields: readonly (infer F)[];
} ? F & string : never) | keyof SystemColumns<C>;

Fields of C any grant can ever see (system columns always).

源码: packages/bolt/src/decl/names.ts:373

ReadMember type

type ReadMember<C extends string> = ({
    readonly collection: Is<C, ReadableName>;
    readonly where?: Where<C> | MemberWhere<C>;
    readonly select?: Select<C>;
    readonly orderBy?: OrderBy<C>;
} & Paged) | {
    readonly collection: Is<C, ReadableName>;
    readonly id: Id<C>;
    readonly select?: Select<C>;
};

One member of a keyed read (ctx.read({ key: member })): a read of collection (its where, select, orderBy and page, as read takes them), or with an id that row (get). A field's { in: { member, field } } takes the values of field across the rows an EARLIER member of the same read answered, inside the same statement: a dependent read (an entity, then the versions its settings_code names) is still one read.

源码: packages/bolt/src/decl/ctx.ts:148

ReadProjection type

type ReadProjection = {
    fields: readonly string[];
    context: readonly string[];
};

A read projection: the JSON fields computed by the attached body over the trusted context columns.

成员

名称类型说明
fieldsreadonly string[]
contextreadonly string[]

源码: packages/bolt/src/decl/collection.ts:175

ReadSet type

type ReadSet = {
    readonly [key: string]: {
        readonly collection: string;
    };
};

A keyed read's members by key.

源码: packages/bolt/src/decl/ctx.ts:165

ReadSetAnswer type

type ReadSetAnswer<M> = {
    readonly [K in keyof M]: MemberAnswer<M[K]>;
};

A keyed read's answer: each member's page (or row, for an id member) under its key.

源码: packages/bolt/src/decl/ctx.ts:172

ReadableName type

type ReadableName = Exclude<CollectionName, Ledger>;

A collection a trigger or a read may name: every collection but the ledgers.

源码: packages/bolt/src/decl/names.ts:98

ReceivedChat type

type ReceivedChat = {
    id: string;
    thread: string;
    sentAt: Instant;
    from: {
        handle: string;
        name?: string | null;
    };
    text: string;
    replyTo?: string | null;
    group?: boolean;
    /** Why a group message is addressed to the envoy. */
    invocation?: 'mention' | 'reply';
    participants?: readonly {
        handle: string;
        name?: string | null;
    }[];
};

One chat message a custom conversation's receive maps a verified webhook body to; id deduplicates.

成员

名称类型说明
idstring
threadstring
sentAtInstant
from{ handle: string; name?: string | null; }
textstring
replyTo?string | null
group?boolean
invocation?'mention' | 'reply'

Why a group message is addressed to the envoy.

participants?readonly { handle: string; name?: string | null; }[]

源码: packages/bolt/src/decl/runtime/integration.ts:127

ReceivedMail type

type ReceivedMail = {
    id: string;
    thread?: string | null;
    sentAt: Instant;
    from: {
        address: string;
        name?: string | null;
    };
    to?: readonly string[];
    subject: string;
    text: string;
    html?: string | null;
};

One email a custom conversation's receive maps a verified webhook body to; id deduplicates.

成员

名称类型说明
idstring
thread?string | null
sentAtInstant
from{ address: string; name?: string | null; }
to?readonly string[]
subjectstring
textstring
html?string | null

源码: packages/bolt/src/decl/runtime/integration.ts:140

Recipient type

type Recipient<C> = 'requestor' | 'step_approvers' | {
    team: TeamName;
} | {
    user: UserField<C>;
} | {
    policy: PolicyName;
};

Whom a notification goes to: the requestor, the current step's approvers, a team, a member named by a field of the row, or a policy's holders.

源码: packages/bolt/src/decl/collection.ts:68

RecordRef type

type RecordRef<C extends string = string> = {
    [K in C]: {
        readonly collection: K;
        readonly id: Id<K>;
    };
}[C];

A typed reference to one record: its collection and id.

源码: packages/bolt/src/decl/values.ts:18

RecordView type

type RecordView<C extends string = string> = {
    collection: C;
    mode: 'update';
    record: RowFor<C>;
} | {
    collection: C;
    mode: 'create';
    values: Partial<RowFor<C>>;
};

X-20: what +representation.svelte receives, { view: RecordView<'<collection>'> } (ui's views pass the same shape).

源码: packages/bolt/src/shell/runtime.ts:436

Refused type

type Refused = {
    kind: 'refused';
    code: 'refused' | PlatformRefusal;
    message: string;
    field?: string;
    row?: number;
    rows?: readonly number[];
    /** A.2 L-BOLT-043: the tenant code that refused — `'<collection>.transform'` or `'<collection>.<action>'`. */
    rule?: string;
    data?: {
        readonly requestId: RequestId;
    };
};

The write was refused: code is refused for an authored refusal or a platform code, with the message and the field or rows it names.

成员

名称类型说明
kind'refused'
code'refused' | PlatformRefusal
messagestring
field?string
row?number
rows?readonly number[]
rule?string

A.2 L-BOLT-043: the tenant code that refused — '<collection>.transform' or '<collection>.<action>'.

data?{ readonly requestId: RequestId; }

源码: packages/bolt/src/decl/ctx.ts:462

RelName type

type RelName<M> = RelNameOf<M>;

The relation names of model M: its FKs and the inverse many-relations.

源码: packages/bolt/src/decl/names.ts:348

RelPath type

type RelPath<M> = {
    [R in keyof ManyRels<M> & string]: `${R}.${FieldName<ManyRels<M>[R]>}`;
}[keyof ManyRels<M> & string];

A roll-up path: <many-relation>.<child field>.

源码: packages/bolt/src/decl/names.ts:350

RelationshipSpec type

type RelationshipSpec = {
    to: string | readonly string[];
    inverse?: string;
    optional?: true;
    default?: {
        actor: 'id' | 'party';
    };
    onDelete?: 'restrict' | 'cascade' | 'setNull';
    owned?: true;
    where?: object;
};

One relationship in +relationship.ts: its target (to), the inverse many-relation name, optional, a default from the actor, onDelete, owned children and a where on the target.

成员

名称类型说明
tostring | readonly string[]
inverse?string
optional?true
default?{ actor: 'id' | 'party'; }
onDelete?'restrict' | 'cascade' | 'setNull'
owned?true
where?object

源码: packages/bolt/src/decl/names.ts:67

Request interface

interface Request {
    <const N extends string, const O extends InputKind = {
        kind: 'json';
    }>(to: Is<N, InstanceTarget>, op: RequestPayload<N, O>): Eff<RequestResult<IntegrationOf<N>, O>, Failure>;
}

A live request through one http or sqlserver instance: an HTTP op (its path under the definition's base URL) or a database statement, journalled, with the credential host-side; it fails with a FacilityFailure, or Unavailable while the instance is unpaired.

源码: packages/bolt/src/decl/runtime/facilities.ts:127

RequestId type

type RequestId = string;

An approval request's id (PendingApproval.requestId, ApprovalHeld).

源码: packages/bolt/src/decl/values.ts:54

RequestOf type

type RequestOf<D, O = InputKind, R = RequestIn<IntegrationSpecOf<D>>> = R extends 'http' ? HttpOp<O> : R extends 'database' ? DatabaseRequest : never;

What ctx.request takes through an instance of definition D: an HTTP op or a database statement.

源码: packages/bolt/src/decl/runtime/integration.ts:274

RequestResult type

type RequestResult<D, O = InputKind, R = RequestIn<IntegrationSpecOf<D>>> = R extends 'http' ? ValueOf<O> : R extends 'database' ? DatabaseResult : never;

What ctx.request answers through an instance of definition D.

源码: packages/bolt/src/decl/runtime/integration.ts:280

RequiredBtreeField type

type RequiredBtreeField<M> = Exclude<BtreeField<M>, OfKind<M, {
    optional: true;
}> | {
    [F in keyof OneRels<M>]: OneRels<M>[F] extends {
        optional: true;
    } ? F : never;
}[keyof OneRels<M>]>;

A btree field that is never null (key).

源码: packages/bolt/src/decl/names.ts:328

Revision type

type Revision<C> = {
    readonly revision: number;
    readonly at: Instant;
    readonly actor: {
        readonly kind: Actor['kind'];
        readonly id: string;
    } | null;
    readonly cause: 'direct' | 'cascade' | 'derived' | 'seed' | 'erased';
    readonly changed: Partial<Row<C>>;
};

One history entry of a row of C (rule 17).

成员

名称类型说明
revisionnumber
atInstant
actor{ readonly kind: Actor['kind']; readonly id: string; } | null
cause'direct' | 'cascade' | 'derived' | 'seed' | 'erased'
changedPartial<Row<C>>

源码: packages/bolt/src/decl/ctx.ts:110

Row type

type Row<C> = RowOf<C> & RowState;

A caller's row of collection C: its exposed fields (maskable ones | Masked), FK ids and system columns (rule 10).

成员

名称类型说明
$outbound?{ readonly [rule: string]: OutboundState; }
$approval?RowApproval

源码: packages/bolt/src/decl/names.ts:446

RowApproval type

type RowApproval = {
    readonly requestId: string;
    readonly state: 'Pending' | 'ChangesRequested';
    readonly step: number;
    readonly steps: number;
    readonly requestedBy: string;
    readonly waitingOn: readonly string[];
};

A record an open approval request holds (rule 46b): its request, Pending at step (from 0) of steps or ChangesRequested, who asked and whom it waits on. Absent once the request closes.

成员

名称类型说明
requestIdstring
state'Pending' | 'ChangesRequested'
stepnumber
stepsnumber
requestedBystring
waitingOnreadonly string[]

源码: packages/bolt/src/decl/names.ts:456

RowState type

type RowState = {
    readonly $outbound?: {
        readonly [rule: string]: OutboundState;
    };
    readonly $approval?: RowApproval;
};

What a caller's read attaches to each root row beside its fields, whatever it selects (§4.2, rule 46b).

成员

名称类型说明
$outbound?{ readonly [rule: string]: OutboundState; }
$approval?RowApproval

源码: packages/bolt/src/decl/names.ts:448

RunCtx interface

interface RunCtx<N extends string, S> extends IntegrationReads {
    readonly instance: InstanceId<N>;
    readonly key: string;
    readonly configuration: ConfigurationIn<S>;
    request: Requester<S>;
}

An outbound run and a custom send's ctx: key is the send's immutable idempotency key, for the remote side.

成员

名称类型说明
instanceInstanceId<N>
keystring
configurationConfigurationIn<S>
requestRequester<S>
read{ <C extends string>(collection: Is<C, ReadableName>, query: DeclaredQuery): Eff<Page<DeclaredRow<C>>, ReadFailed>; <C extends string, const S extends { readonly [P in WorkspaceReadField<C>]?: true; } = {}>(collection: Is<C, ReadableName>, q: { where?: NoInfer<ModelWhere<C>>; select?: S; } & Paged): Eff<Page<[keyof S] extends [never] ? StoredRow<C> : WorkspaceSelection<C, S, { [K in keyof ColumnV…

Dynamic declarations read actual stored values; selected names and operands are manifest-checked. select names stored fields or existing native sequence labels (rule 72); id always comes. Defaults remain stored rows without sequences, roll-ups or computed fields. A keyed set of stored reads in one crossing and one statement (as the caller's read({ … }), unmasked).

get<C extends string>(collection: Is<C, ReadableName>, id: NoInfer<Id<C>>, q?: { revision?: number; }) => Eff<StoredRow<C> | null>

源码: packages/bolt/src/decl/runtime/integration.ts:521

RunHandle type

type RunHandle<A = StartableName> = {
    readonly id: Id<'sys_run'>;
    readonly automation: A;
};

A started run: its id and the automation it runs.

成员

名称类型说明
idId<'sys_run'>
automationA

源码: packages/bolt/src/decl/runtime/facilities.ts:43

RunRow type

type RunRow<O = unknown> = {
    readonly id: Id<'sys_run'>;
    readonly automation: StartableName;
    readonly cause: RunCause;
    readonly status: RunStatus;
    readonly due_at: Instant;
    readonly started: Instant | null;
    readonly progress: {
        readonly ratio: number | null;
        readonly text: string | null;
    } | null;
    readonly result?: O;
    readonly error: {
        readonly code: string;
        readonly message: string;
    } | null;
    readonly attempt_count: number;
};

A run as $bolt.runs and the run ledger show it: cause, status, due and start time, progress, result and error.

成员

名称类型说明
idId<'sys_run'>
automationStartableName
causeRunCause
statusRunStatus
due_atInstant
startedInstant | null
progress{ readonly ratio: number | null; readonly text: string | null; } | null
result?O
error{ readonly code: string; readonly message: string; } | null
attempt_countnumber

源码: packages/bolt/src/decl/runtime/facilities.ts:50

SearchableField type

type SearchableField<M> = OfKind<M, {
    kind: 'text' | 'enum';
}>;

The fields of M a text search reads: text and enum.

源码: packages/bolt/src/decl/names.ts:344

Seconds type

type Seconds = number & {
    readonly [brand]: 'Seconds';
};

A duration field's value: whole seconds.

源码: packages/bolt/src/decl/values.ts:14

SecretName type

type SecretName = keyof NamesPart<'secrets'> & string;

A name declared in src/+secrets.ts.

源码: packages/bolt/src/decl/runtime/names.ts:21

SeedSource type

type SeedSource = {
    bank: string;
    rows(bank: BankReader): SeedRows | Promise<SeedRows>;
    /** Rule 70's first-admission start: one run of each on the first admission of an environment built from the pack. */
    start?: readonly AutomationName[];
};

seed/seed.ts's default export (§3.3.10, X-15): runs only at build; imports no runtime value from bolt.

成员

名称类型说明
bankstring
rows(bank: BankReader) => SeedRows | Promise<SeedRows>
start?readonly AutomationName[]

Rule 70's first-admission start: one run of each on the first admission of an environment built from the pack.

源码: packages/bolt/src/compiler/artifact/seed.ts:38

Select type

type Select<in out C> = {
    readonly [P in ReadField<C> | ReadRelation<C>]?: P extends ReadRelation<C> ? RelSelect<C, P> | (P extends ReadField<C> ? true : never) : true;
};

A select literal: exposed fields as true, exposed relations as nested selects (an FK may be either).

源码: packages/bolt/src/decl/ctx.ts:87

Selection type

type Selection<M, Op = 'create'> = {
    columns: readonly (Op extends 'update' ? Exclude<WritableField<M>, OwnedFk<M>> : WritableField<M>)[];
    filled?: Op extends 'update' ? never : readonly WritableField<M>[];
    with?: {
        [R in keyof ManyRels<M>]?: {
            create?: Selection<ManyRels<M>[R]>;
            update?: Selection<ManyRels<M>[R], 'update'>;
            upsert?: Selection<ManyRels<M>[R]>;
            link?: {};
            unlink?: {};
            delete?: {};
        };
    };
};

An update never lists an owned child's parent key (rule 41). A create's filled names the fields its transform fills when the input omits them (GAP-6): optional in Insert, still required after the transform (rule 23).

成员

名称类型说明
columnsreadonly (Op extends 'update' ? Exclude<WritableField<M>, OwnedFk<M>> : WritableField<M>)[]
filled?Op extends 'update' ? never : readonly WritableField<M>[]
with?{ [R in keyof ManyRels<M>]?: { create?: Selection<ManyRels<M>[R]>; update?: Selection<ManyRels<M>[R], 'update'>; upsert?: Selection<ManyRels<M>[R]>; link?: {}; unlink?: {}; delete?: {}; }; }

源码: packages/bolt/src/decl/collection.ts:117

Send type

type Send = <const N extends string>(to: Is<N, InstanceTarget>, payload: SendPayload<N>) => Eff<Id<'sys_message'>>;

Queues a message through one conversation instance (the outbox delivers it after the run's write commits); a union-typed target is a type error (§3.3.9), and a member's personal instance refuses at run time.

源码: packages/bolt/src/decl/runtime/facilities.ts:112

SendInput type

type SendInput<D> = Outgoing<ConversationOf<D>>;

What a send through an instance of definition D takes.

源码: packages/bolt/src/decl/runtime/integration.ts:272

Shape type

type Shape = {
    readonly polygon: readonly Point[];
} | {
    readonly bbox: readonly [Point, Point];
};

A geographic area a point filter tests: a polygon, or a bounding box of two corners.

源码: packages/bolt/src/decl/where.ts:46

SimilarSpec type

type SimilarSpec = {
    description: string;
    input: InputFields;
    candidates?: Candidates;
};

A named similarity search: its typed input and how many candidates the body returns per call (1–16).

成员

名称类型说明
descriptionstring
inputInputFields
candidates?Candidates

源码: packages/bolt/src/decl/collection.ts:157

Size type

type Size = `${bigint}${'KiB' | 'MiB'}`;

A byte size literal in KiB or MiB ('512KiB', '10MiB').

源码: packages/bolt/src/decl/values.ts:63

SkillName type

type SkillName = keyof NamesPart<'skills'> & string;

The agent skill names (src/agent/skill/+<n>.skill.md).

源码: packages/bolt/src/decl/names.ts:134

SpeakOptions type

type SpeakOptions = {
    for: FileOwner;
    name?: string;
    voice?: string;
    format?: SpeechFormat;
    language?: string;
};

ctx.ai.speak's options: the owner for and file name (default speech.<format>), a provider voice, the format (default mp3) and a language hint that providers reading the language from the text ignore.

成员

名称类型说明
forFileOwner
name?string
voice?string
format?SpeechFormat
language?string

源码: packages/bolt/src/decl/runtime/facilities.ts:400

SpeechFormat type

type SpeechFormat = 'mp3' | 'wav' | 'ogg';

An audio format ctx.ai.speak writes.

源码: packages/bolt/src/decl/runtime/facilities.ts:395

State type

type State<C, F = StateField<C>> = Columns<C>[F & keyof Columns<C>] extends {
    states: infer S;
} ? keyof S & string : never;

The states of state field F of C.

源码: packages/bolt/src/decl/access/policy.ts:37

StateField type

type StateField<C> = StateFieldOf<C>;

The names of C's state fields: what a policy's moves grant is keyed by.

源码: packages/bolt/src/decl/access/policy.ts:32

StaticWhere type

type StaticWhere<M, Fk = true> = {
    [P in keyof Columns<M> & string]?: Ops<M, Columns<M>[P], true>;
} & (Fk extends true ? {
    [R in keyof OneRels<M> & string]?: IdOps<OneTarget<M, R>, true>;
} : {}) & {
    and?: readonly StaticWhere<M, Fk>[];
    or?: readonly StaticWhere<M, Fk>[];
    not?: StaticWhere<M, Fk>;
};

An own-row predicate with static operands only (check, unique.where, noOverlap.where, relationship where). Fk = false leaves FK columns out: a relationship's own where cannot read the relationships it is declaring.

源码: packages/bolt/src/decl/where.ts:205

StoredAnswer type

type StoredAnswer<M> = M extends {
    collection: infer C extends string;
    id: unknown;
} ? StoredRow<C> | null : M extends {
    collection: infer C extends string;
} ? Page<[keyof SelectOf<M>] extends [never] ? StoredRow<C> : WorkspaceSelection<C, SelectOf<M>>> : never;

The unmasked stored result of one native workspace read member, with its exact selected fields.

源码: packages/bolt/src/decl/ctx.ts:183

StoredMember type

type StoredMember<C extends string> = ({
    readonly collection: Is<C, ReadableName>;
    readonly where?: ModelWhere<C> | MemberWhere<C>;
    readonly select?: {
        readonly [P in WorkspaceReadField<C>]?: true;
    };
} & Paged) | {
    readonly collection: Is<C, ReadableName>;
    readonly id: Id<C>;
};

A workspace keyed read's member (ctx.db.read({ key: member })): stored rows, or with an id that row.

源码: packages/bolt/src/decl/ctx.ts:174

TeamEntry type

type TeamEntry = readonly PolicyName[] | TeamSpec;

A source team entry: a policy list, or a structured team definition.

源码: packages/bolt/src/decl/access/team.ts:12

TeamName type

type TeamName = keyof NamesPart<'teams'> & string;

The team names +team.ts declares.

源码: packages/bolt/src/decl/names.ts:104

TeamSpec type

type TeamSpec = {
    readonly name?: string;
    readonly parent?: string | null;
    readonly policies: readonly PolicyName[];
};

A source team with optional display label and parent, holding only its explicitly listed policies.

成员

名称类型说明
name?string
parent?string | null
policiesreadonly PolicyName[]

源码: packages/bolt/src/decl/access/team.ts:6

TestCtx interface

interface TestCtx<S> {
    readonly configuration: ConfigurationIn<S>;
    request: Requester<S>;
}

i.test's ctx: the instance's configuration and its live request.

成员

名称类型说明
configurationConfigurationIn<S>
requestRequester<S>

源码: packages/bolt/src/decl/runtime/integration.ts:504

TextField type

type TextField<M> = OfKind<M, {
    kind: 'text';
}>;

The text fields of model M.

源码: packages/bolt/src/decl/names.ts:336

TranscribeOptions type

type TranscribeOptions = {
    diarize?: boolean;
    language?: string;
    speakers?: number;
    prompt?: string;
};

How ctx.ai.transcribe listens: 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.

成员

名称类型说明
diarize?boolean
language?string
speakers?number
prompt?string

源码: packages/bolt/src/decl/runtime/facilities.ts:375

Transcript type

type Transcript = {
    readonly segments: readonly TranscriptSegment[];
    readonly language: string | null;
    readonly durationMs: number;
};

ctx.ai.transcribe's answer: segments in order, the language heard (BCP 47, or null) and the audio's length.

成员

名称类型说明
segmentsreadonly TranscriptSegment[]
languagestring | null
durationMsnumber

源码: packages/bolt/src/decl/runtime/facilities.ts:389

TranscriptSegment type

type TranscriptSegment = {
    readonly speaker: string;
    readonly start: number;
    readonly end: number;
    readonly text: string;
};

One stretch of speech: its speaker (S1, S2, … across the whole file), start and end in seconds, and the words.

成员

名称类型说明
speakerstring
startnumber
endnumber
textstring

源码: packages/bolt/src/decl/runtime/facilities.ts:382

TransformCtx interface

interface TransformCtx<in out M> extends Clock {
    /** The act's invocation: what a prepared create's receipts carry as `invocation_id`. */
    readonly invocationId: string;
    readonly policies: readonly string[];
    readonly admin: boolean;
    refuse(message: string, at?: {
        field?: WritableField<M>;
    }): Eff<never, Refusal>;
    /** `existing[i]` is the stored row of `inputs[i]`, `undefined` for a create. */
    existing: readonly (StoredRow<M> | undefined)[];
    /** Engine-assigned identities for submitted roots and native relation children; never caller fields. */
    readonly staged: readonly {
        readonly collection: string;
        readonly id: string;
        readonly path: readonly (string | number)[];
        readonly operation: string;
        readonly parent?: {
            readonly collection: string;
            readonly id: string;
            readonly relation: string;
            readonly field: string;
        };
    }[];
    db: WorkspaceReads & {
        /** Reserve an engine identity for a generated owned child path. No write or approval occurs here. */
        prepareCreate(collection: CollectionName, values: Readonly<Record<string, Json>>, options: {
            readonly path: readonly (string | number)[];
        }): Eff<PreparedCreateReceipt>;
    };
}

What the collection transform sees: the clock, existing[i] (the stored row of inputs[i], undefined on create), the workspace reads in db (unmasked, including db.after) and refuse.

成员

名称类型说明
invocationIdstring

The act's invocation: what a prepared create's receipts carry as invocation_id.

policiesreadonly string[]
adminboolean
refuse(message: string, at?: { field?: WritableField<M>; }) => Eff<never, Refusal>
existingreadonly (StoredRow<M> | undefined)[]

existing[i] is the stored row of inputs[i], undefined for a create.

stagedreadonly { readonly collection: string; readonly id: string; readonly path: readonly (string | number)[]; readonly operation: string; readonly parent?: { readonly collection: string; readonly id: string; readonly relation: string; readonly field: string; }; }[]

Engine-assigned identities for submitted roots and native relation children; never caller fields.

dbWorkspaceReads & { /** Reserve an engine identity for a generated owned child path. No write or approval occurs here. */ prepareCreate(collection: CollectionName, values: Readonly<Record<string, Json>>, options: { readonly path: readonly (string | number)[]; }): Eff<PreparedCreateReceipt>; }
actorActor
nowInstant
todayPlainDate
tzIanaZone
todayIn(zone: IanaZone) => PlainDate

源码: packages/bolt/src/decl/ctx.ts:593

TransformRow type

type TransformRow<M> = TransformRowOf<M>;

One element of a transform batch: the submitted input, which the transform returns with derived values set.

源码: packages/bolt/src/decl/ctx.ts:544

Trigger type

type Trigger = {
    cron: string;
    tz?: IanaZone;
} | {
    webhook: `/${string}`;
    verify: {
        scheme: WebhookScheme;
        secret: string;
    };
} | {
    created: string;
    where?: object;
    delay?: Duration;
} | {
    updated: string;
    where?: object;
    fields?: readonly string[];
    delay?: Duration;
} | {
    deleted: string;
    where?: object;
    delay?: Duration;
};

When an automation runs (its on): a cron schedule, a webhook path, or a row created, updated or deleted in a collection (optionally filtered by where, fields, and delayed).

源码: packages/bolt/src/decl/runtime/automation.ts:61

Unavailable class

class Unavailable extends Unavailable_base {
    readonly message: string;
}

An optional facility with no provider bound (P19), or an instance not paired: the facility and why.

成员

名称类型说明
messagestring
facilitySchema.String
reasonSchema.String

源码: packages/bolt/src/decl/errors/facility.ts:21

Unknown type

type Unknown = {
    kind: 'unknown';
    invocation: string;
};

The outcome could not be confirmed (a lost connection); invocation is the id to look the write up by.

成员

名称类型说明
kind'unknown'
invocationstring

源码: packages/bolt/src/decl/ctx.ts:479

UserField type

type UserField<C> = ({
    [R in keyof OneRels<C>]: OneTarget<C, R> extends 'sys_user' ? R : never;
}[keyof OneRels<C>] & string) | 'created_by' | 'updated_by';

A column of C holding a member: an FK to sys_user, or created_by/updated_by.

源码: packages/bolt/src/decl/collection.ts:60

Value type

type Value<K> = Literal<K>;

A plain value literal of kind K (defaults, Where values).

源码: packages/bolt/src/decl/fields.ts:120

ValueOf type

type ValueOf<K> = K extends {
    optional: true;
} ? Base<K> | null : Base<K>;

The TypeScript type of a value of kind K; optional: true admits null.

源码: packages/bolt/src/decl/fields.ts:205

Vector type

type Vector = readonly number[];

A vector field's value: its numbers.

源码: packages/bolt/src/decl/values.ts:29

VectorField type

type VectorField<M> = OfKind<M, {
    kind: 'vector';
}>;

The vector fields of model M.

源码: packages/bolt/src/decl/names.ts:342

Verify type

type Verify = {
    [M in keyof Models & string]: ModelErrors<M>;
}[keyof Models & string] | LocaleErrors | ConnectionErrors;

Every cross-file declaration error in the workspace, as messages; never when there is none.

源码: packages/bolt/src/decl/verify.ts:117

Where type

type Where<C> = C extends CollectionName ? WhereOver<C, C> : never;

A predicate over collection C: only its exposed fields and relations exist (rule 10).

源码: packages/bolt/src/decl/where.ts:200

WorkspaceReads interface

interface WorkspaceReads {
    /** Dynamic declarations read actual stored values; selected names and operands are manifest-checked. */
    read<C extends string>(collection: Is<C, ReadableName>, query: DeclaredQuery): Eff<Page<DeclaredRow<C>>, ReadFailed>;
    /** `select` names stored fields or existing native sequence labels (rule 72); `id` always comes. Defaults remain stored rows without sequences, roll-ups or computed fields. */
    read<C extends string, const S extends {
        readonly [P in WorkspaceReadField<C>]?: true;
    } = {}>(collection: Is<C, ReadableName>, q: {
        where?: NoInfer<ModelWhere<C>>;
        select?: S;
    } & Paged): Eff<Page<[keyof S] extends [never] ? StoredRow<C> : WorkspaceSelection<C, S>>>;
    /** A keyed set of stored reads in one crossing and one statement (as the caller's `read({ … })`, unmasked). */
    read<const M extends ReadSet>(set: M & {
        readonly [K in keyof M]: StoredMember<M[K]['collection']>;
    }): Eff<{
        readonly [K in keyof M]: StoredAnswer<M[K]>;
    }>;
    get<C extends string>(collection: Is<C, ReadableName>, id: NoInfer<Id<C>>, q?: {
        revision?: number;
    }): Eff<StoredRow<C> | null>;
    /** Stored rows overlaid with this batch's inputs (PH GAP-5). */
    after<C extends string>(collection: Is<C, ReadableName>, where: NoInfer<ModelWhere<C>>): Eff<readonly StoredRow<C>[]>;
    after<C extends string, const S extends {
        readonly [P in keyof StoredRow<C>]?: true;
    } = {}>(colle…

Reads as the workspace (the transform, rule 15): unmasked stored rows.

成员

名称类型说明
read{ <C extends string>(collection: Is<C, ReadableName>, query: DeclaredQuery): Eff<Page<DeclaredRow<C>>, ReadFailed>; <C extends string, const S extends { readonly [P in WorkspaceReadField<C>]?: true; } = {}>(collection: Is<C, ReadableName>, q: { where?: NoInfer<ModelWhere<C>>; select?: S; } & Paged): Eff<Page<[keyof S] extends [never] ? StoredRow<C> : WorkspaceSelection<C, S>>>; <const M extends R…

Dynamic declarations read actual stored values; selected names and operands are manifest-checked. select names stored fields or existing native sequence labels (rule 72); id always comes. Defaults remain stored rows without sequences, roll-ups or computed fields. A keyed set of stored reads in one crossing and one statement (as the caller's read({ … }), unmasked).

get<C extends string>(collection: Is<C, ReadableName>, id: NoInfer<Id<C>>, q?: { revision?: number; }) => Eff<StoredRow<C> | null>
after{ <C extends string>(collection: Is<C, ReadableName>, where: NoInfer<ModelWhere<C>>): Eff<readonly StoredRow<C>[]>; <C extends string, const S extends { readonly [P in keyof StoredRow<C>]?: true; } = {}>(collection: Is<C, ReadableName>, where: NoInfer<ModelWhere<C>>, query: { select?: S; orderBy?: NoInfer<OrderBy<C>>; } & Paged): Eff<Page<[keyof S] extends [never] ? StoredRow<C> : Pick<StoredRow<…

Stored rows overlaid with this batch's inputs (PH GAP-5).

源码: packages/bolt/src/decl/ctx.ts:250

WriteField type

type WriteField<C, O = 'create' | 'update'> = InputSel<C, O> extends infer S ? S extends {
    columns: readonly (infer P)[];
} ? (P | (S extends {
    with: infer W;
} ? keyof W : never)) & string : never : never;

What an op's grant may admit field by field: the collection's allowlist for that op, relation actions included.

源码: packages/bolt/src/decl/access/policy.ts:52

WriteGrant type

type WriteGrant<C extends CollectionName, O extends 'create' | 'update' = 'create' | 'update', G = {
    read: true;
}> = (G extends {
    read: unknown;
} ? 'read' : never) extends infer Rd ? true | Rd | Scope<C> | ({
    where?: Scope<C> | Rd;
    fields?: readonly WriteField<C, O>[];
} & (O extends 'update' ? {
    previous?: Scope<C> | true;
} : {}) & object) : never;

A create or update grant; G is the whole grant literal, so 'read' exists only beside a read grant (rule 35).

源码: packages/bolt/src/decl/access/policy.ts:106

app function

function app<const A extends AppName, const S extends AppSpec>(name: A, spec: S & Checked<AppSpec, S, Exact<S, AppFor<A>>>): { readonly name: A; readonly spec: S; }

src/app/<a>/+app.ts: an app's title, description, icon and banner, its audience, and its pages in nav order (each +<page>.page.svelte in the folder needs an entry).

参数

名称类型说明
nameA
specS & Checked<AppSpec, S, Exact<S, AppFor<A>>>
  • title: Msg
  • description: Msg
  • icon: IconName
  • banner?: string

    The app card image, an asset path.

  • audience?: Audience

    Who sees the app: members (default), external, all, or { public } for signed-out visitors.

  • requires?: readonly DeviceRequirement[]

    Device access every page of the app needs; the shell walls the app until it is granted.

  • pages: { readonly [page: string]: Page; }

    The app's pages by file name, in nav order: a title, icon and optional section each.

示例

export default app('crm', {
	title: 'app.crm.title',
	description: 'app.crm.description',
	icon: 'lucide:handshake',
	pages: { desk: { title: 'app.crm.title', icon: 'lucide:handshake' } }
});

源码: packages/bolt/src/decl/runtime/app.ts:161

automation function

function automation<const S extends AutomationSpec>(spec: S & NoInfer<Checked<AutomationSpec, S, Exact<S, AutomationFor<S>>>>): Automation<S>

src/automation/+<a>.automation.ts: work that runs on a trigger (on: cron, webhook, a row created, updated or deleted) or when started, as the policies in runAs, with typed input and output, retries and concurrency. The body attaches with a.run(function* (input, ctx) { … }); ctx carries reads, act, files, AI and the other facilities.

参数

名称类型说明
specS & NoInfer<Checked<AutomationSpec, S, Exact<S, AutomationFor<S>>>>
  • description: string
  • input?: InputFields

    The typed input a start or schedule passes.

  • output?: InputKind

    The typed result recorded on the run.

  • on?: Trigger | readonly Trigger[]

    What runs it: cron, webhook, or a row created, updated or deleted; absent means started only.

  • runAs: NonEmpty<string> | 'trigger'

    The policies the run holds, or 'trigger' (the starter's authority) for an automation with no on.

  • delegations?: readonly { verb: `${string}.${'create' | 'update' | 'delete'}`; policy: string; }[]

    Native generated verbs delegated to this authenticated run and its child action lineage only.

  • retry?: { attempts: Attempts; backoff?: Duration; }

    Retries of a failed run, with backoff.

  • concurrency?: { max: Max; }

    At most max runs at once.

  • agent?: AgentUse

    How the agent may start it (direct, confirm, never).

示例

const a = automation({ description: 'Daily sweep of lapsed quotes.', on: { cron: '0 6 * * *' }, runAs: ['quote_watch'] });
export default a;
a.run(function* (_, ctx) {
	const lapsed = yield* ctx.read('quotes', { where: { valid_until: { lt: { today: '' } } }, limit: 50 });
	yield* ctx.progress({ text: `${lapsed.rows.length} lapsed` });
});

源码: packages/bolt/src/decl/runtime/automation.ts:193

collection function

function collection<const K extends ModelName | SystemName, const S extends CollectionSpec>(name: K, spec: S & NoInfer<Checked<CollectionSpec, S, Exact<S, SpecFor<K, S>>>>): Collection<K, S>

src/data/collection/<m>/+collection.ts: what callers may do with model <m>: the fields they read, the create and update input allowlists, delete, and named queries, actions and similarity searches. Bodies attach after the literal with c.transform, c.query, c.action and c.similarity.

参数

名称类型说明
nameK
specS & NoInfer<Checked<CollectionSpec, S, Exact<S, SpecFor<K, S>>>>
  • description?: string
  • read: { fields: 'all' | readonly string[]; relations?: 'all' | readonly string[]; projection?: ReadProjection; }

    The fields and relations callers read (grants narrow them further).

  • create?: { input: SelectionBase; }

    The generated create: its input allowlist (columns, filled, and relation actions under with).

  • update?: { input: SelectionBase; }

    The generated update: its input allowlist.

  • delete?: {} | { transform: true; }

    The generated delete; { transform: true } runs the transform on it.

  • queries?: { readonly [q: string]: QuerySpec; }

    Named read operations; bodies attach with c.query.

  • actions?: { readonly [a: string]: ActionSpec; }

    Named write operations; bodies attach with c.action.

  • similarity?: { readonly [s: string]: SimilarSpec; }

    Named similarity searches; bodies attach with c.similarity.

  • notifications?: { readonly [E in NotificationEvent]?: readonly NotificationSpec[]; }

    Notification rules per write or approval event.

示例

const c = collection('products', {
	read: { fields: 'all' },
	create: { input: { columns: ['code', 'name', 'unit_price'] } },
	queries: { active_count: { description: 'Active products', input: {}, output: { kind: 'int' } } }
});
export default c;
c.query('active_count', function* (_, ctx) {
	return (yield* ctx.read('products', { where: { active: { eq: true } }, all: true })).rows.length;
});

源码: packages/bolt/src/decl/collection.ts:358

customField function

function customField<const S extends CustomFieldBase>(spec: S & Checked<CustomFieldBase, S, Exact<S, { description: string; shape: ValidInput<S["shape"]>; label?: Msg; search?: true; }>>): CustomField<S>

src/data/custom_field/<f>/+definition.ts: a reusable structured value (shape, an input kind literal) that model fields store as { kind: 'custom', of: '<f>' }, with an optional f.validate check and a +renderer.svelte.

参数

名称类型说明
specS & Checked<CustomFieldBase, S, Exact<S, { description: string; shape: ValidInput<S['shape']>; label?: Msg; search?: true; }>>
  • description: string
  • shape: InputKind

    The value's shape: an input kind literal (usually an object, list or union).

  • label?: Msg
  • search?: true

    Include the value's text in the record's text search.

示例

const address = customField({
	description: 'A postal address.',
	shape: { kind: 'object', fields: { line1: { kind: 'text' }, postcode: { kind: 'text' } } }
});
export default address;
address.validate((v) => (/^\d{6}$/.test(v.postcode) ? undefined : 'A postcode has six digits.'));

源码: packages/bolt/src/decl/custom-field.ts:32

envoy function

function envoy<const S extends EnvoySpec>(spec: S & Checked<EnvoySpec, S, Exact<S, EnvoyFor>>): S

src/agent/envoy/+<id>.envoy.ts: the workspace agent as it answers outside senders on a conversation instance: who may reach it (audience), the policies its turns hold, group messages, delegation, triage, DM authority and its task.

参数

名称类型说明
specS & Checked<EnvoySpec, S, Exact<S, EnvoyFor>>
  • name: string

    What people call it: a message that says this name is addressed to it, mention or not.

  • audience: 'public' | 'private'

    private: only a sender whose handle is a member's; public: anyone, an unknown sender under policies alone.

  • policies: NonEmpty<string>

    Every group turn's whole authority, joined in a DM by a linked member's own (dm); the source of every envoy limit.

  • groupMessages?: 'disabled' | 'mention_or_reply' | 'all'

    Which group messages it answers; default mention_or_reply. Email is always addressed.

  • delegation: 'enabled' | 'disabled'

    Whether it may delegate to sub-agents.

  • triage?: false | { scope?: 'dm' | 'group' | 'all'; }

    System 1 triage of inbound messages (where the host binds it); false answers every addressed message at once.

  • dm?: 'union' | 'envoy'

    A linked member's DM: union (default) holds the envoy's policies and the member's own; envoy holds the envoy's alone, its operands bound to the member (never admin, no member routes), and history's 'mine' to this instance.

  • task: string

    A standing directive on top of +agent.md; never who may do what.

示例

export default envoy({
	name: 'Norbital',
	audience: 'private',
	policies: ['field_ops_whatsapp'],
	delegation: 'disabled',
	task: 'Answer questions about job assignments and keep them up to date from what people report.'
});

源码: packages/bolt/src/decl/runtime/agent.ts:45

group function

function group<const G extends GroupName, const S extends GroupSpec>(name: G, spec: S & Checked<GroupSpec, S, Exact<S, { label: Msg; description?: Msg; icon: IconName; defaultChild: ChildName<G>; }>>): { readonly name: G; readonly spec: S; }

src/app/<g>/+group.ts: a folder of apps shown as one entry in the nav, opening defaultChild; a policy's capabilities.apps naming the group reaches every app under it.

参数

名称类型说明
nameG
specS & Checked<GroupSpec, S, Exact<S, { label: Msg; description?: Msg; icon: IconName; defaultChild: ChildName<G>; }>>
  • label: Msg
  • description?: Msg
  • icon: IconName
  • defaultChild: string

示例

export default group('hr', { label: 'HR', icon: 'lucide:briefcase-business', defaultChild: 'people' });

源码: packages/bolt/src/decl/runtime/app.ts:175

integration function

function integration<const N extends IntegrationName, const S extends IntegrationSpec>(name: N, spec: S & NoInfer<Checked<IntegrationSpec, S, Exact<S, IntegrationFor<N, S>>>>): Integration<N, S>

src/integration/<name>/+integration.ts: one external system's definition. Its instances are sys_integration rows (a +workspace.ts connection names one); feeds write collections from each instance and outbound rules send for records.

参数

名称类型说明
nameN
specS & NoInfer<Checked<IntegrationSpec, S, Exact<S, IntegrationFor<N, S>>>>
  • description: string
  • driver: DriverName
  • configuration?: InputFields

    Safe settings each instance edits at run time (with history), decoded against these fields.

  • credential?: InputFields

    The secret each instance pairs with, sealed host-side and never readable (http and sqlserver only).

  • oauth?: { client: string; secret: string; authorize?: string; token?: string; scopes?: readonly string[]; }

    The OAuth client an oauth driver (http, calendar) grants with, by secret name; tokens are per instance. An http definition names its authorize and token endpoints too, and its requests carry the instance's token as a bearer.

  • http?: { baseUrl: string; auth?: HttpAuth<string>; }

    http only: the base URL (a literal or a text configuration field) and how requests authenticate.

  • webhook?: { scheme: WebhookScheme; secret: string; }

    http with a conversation: the signed webhook messages arrive by, verified with a credential field.

  • conversation?: { kind: 'chat' | 'email'; handle: HandleKind; }

    http only: a custom conversation (receive and send bodies) and the member handle its senders carry.

  • feeds?: { readonly [feed: string]: FeedSpec; }
  • outbound?: { readonly [rule: string]: OutboundSpec; }

示例

const routes = integration('google_routes', {
	description: 'Drive times for matching and the ETA watch.',
	driver: 'http',
	credential: { apiKey: { kind: 'text', label: 'Routes API key' } },
	http: { baseUrl: 'https://routes.googleapis.com/', auth: { header: { name: 'X-Goog-Api-Key', value: 'apiKey' } } }
});
export default routes;
routes.test(function* (ctx) { yield* ctx.request({ method: 'GET', path: 'healthz', output: { kind: 'json' } }); });

源码: packages/bolt/src/decl/runtime/integration.ts:638

isMasked function

function isMasked(value: unknown): value is Masked

The canonical wire marker for a field omitted by the reading caller's grants.

参数

名称类型说明
valueunknown

源码: packages/bolt/src/decl/names.ts:417

jsonDiff function

function jsonDiff(before: Json, after: Json, output?: InputKind): readonly JsonChange[]

What changed from before to after, each change at a JSON Pointer: added, removed or changed (leaves only; an added or removed object or item is one change). With output, items of its keyed lists are matched and addressed by key, so a removal is one change rather than a shift of every later item; other lists are compared by index.

参数

名称类型说明
beforeJson
afterJson
output?InputKind

源码: packages/bolt/src/engine/agent/draft.ts:212

kiosk function

function kiosk<const K extends KioskName, const S extends KioskSpec>(name: K, spec: S & Checked<KioskSpec, S, Exact<S, KioskFor<K>>>): { readonly name: K; readonly spec: S; }

src/kiosk/<k>/+kiosk.ts: a standalone kiosk's title, description, icon and banner, who may open it (auth), the policies it runs as inside (policies), and its pages in nav order (each +<page>.page.svelte in the folder needs an entry).

参数

名称类型说明
nameK
specS & Checked<KioskSpec, S, Exact<S, KioskFor<K>>>
  • title: Msg
  • description: Msg
  • icon: IconName
  • banner?: string

    The kiosk card image, an asset path.

  • auth?: KioskAuth

    Who may open it: a signed-in audience, or 'none' for no authentication (default 'members').

  • policies: NonEmpty<string>

    The assigned policies it runs as inside (envoy-style override, never an admin bypass).

  • pages: { readonly [page: string]: KioskPage; }

    The kiosk's pages by file name, in nav order: a title and icon each.

示例

export default kiosk('clock', {
	title: 'app.kiosk.title',
	description: 'app.kiosk.description',
	icon: 'lucide:clock',
	auth: 'none',
	policies: ['kiosk_clock'],
	pages: { clock: { title: 'app.kiosk.clock', icon: 'lucide:clock' } }
});

源码: packages/bolt/src/decl/runtime/kiosk.ts:56

mcp function

function mcp<const S extends McpBase>(spec: S & Checked<McpBase, S, Exact<S, McpSpec>>): S

src/agent/mcp/+<n>.mcp.ts: an MCP server the agent may call, its url and credentials named from +secrets.ts, and an optional tool allowlist. Reachable only through a policy's capabilities.mcp.

参数

名称类型说明
specS & Checked<McpBase, S, Exact<S, McpSpec>>
  • description: string
  • url: string

    The secret name holding the server's streamable-HTTP URL.

  • auth?: { bearer: string; } | { oauth: { clientId: string; clientSecret?: string; scopes?: readonly string[]; }; }

    A bearer token or OAuth client, by secret name.

  • tools?: readonly string[]

    An allowlist of the server's tools; absent = every tool it lists.

示例

export default mcp({ description: 'HQ tools', url: 'HQ_URL', auth: { bearer: 'HQ_TOKEN' } });

源码: packages/bolt/src/decl/runtime/agent.ts:79

messages function

function messages<const M extends { readonly [key: string]: string; }>(spec: M): M

src/i18n/+messages.ts (the base catalogue) and src/i18n/+<locale>.messages.ts: message keys to text with {name} placeholders. A locale's keys must be the base's (checked by Verify). Pages read them with bolt.t.

参数

名称类型说明
specM

示例

export default messages({ 'app.crm.title': 'CRM', 'jobs.assigned': 'Assigned to {name}' });

源码: packages/bolt/src/decl/runtime/app.ts:193

model function

function model<const M extends ModelSpec>(spec: M & NoInfer<Checked<ModelSpec, M, Exact<M, ModelSpecFor<M>>>>): M

src/data/model/+<m>.model.ts: a model's storage: its fields (each a kind literal), the label paths that name a record, keys, uniqueness, indexes, checks, computed fields and search. Returns the literal: declarations are data.

参数

名称类型说明
specM & NoInfer<Checked<ModelSpec, M, Exact<M, ModelSpecFor<M>>>>
  • description: string

    What a record is, for people and the agent.

  • icon?: IconName

    The model's icon (an Iconify name).

  • label: string | readonly string[]

    The field path (or paths, joined) that names a record: 'name', ['code', 'name'].

  • fields: { readonly [name: string]: FieldKind; }

    The stored fields. Every row also carries the system columns id revision created_at created_by updated_at updated_by, which are not field names: revision is the row version every update checks (rule 25), so a document's own revision mark is a field such as document_revision (bolt check: load/reserved-field).

  • key?: readonly string[]

    The natural key (never null): what imports match rows by. Upsert matches by id.

  • unique?: readonly { fields: readonly string[]; where?: object; name?: string; }[]

    Unique field sets, optionally partial (where).

  • index?: readonly (string | readonly string[])[]

    Extra indexes: a field or a field list each.

  • check?: { readonly [name: string]: object; }

    Named row checks: a Where every row must match.

  • noOverlap?: readonly { key: readonly string[]; period: string; where?: object; name?: string; }[]

    Rows with equal key fields may not have overlapping periods.

  • computed?: { readonly [name: string]: { kind: ComputedKind; scale?: number; expr: Expr; }; }

    Computed fields: an expression over the row's own fields, stored and kept current.

  • search?: { text: readonly string[]; semantic?: { fields: readonly string[]; model: EmbeddingModelName; /** The embedding column's width: the model class is asked for exactly this many numbers, stored or probed. Required — a * workspace states it, so the host's binding is a conformance question, not a guess bolt makes for it. */ dim: number; }; }

    Text search over text fields, and semantic (embedding) search over semantic.fields.

  • table?: TableSpec

    A system table's physical row (the built-in layer only).

示例

export default model({
	description: 'Products in the catalogue.',
	icon: 'lucide:package',
	label: 'name',
	fields: { code: { kind: 'text', unique: true }, name: { kind: 'text' }, unit_price: { kind: 'decimal', scale: 4, optional: true } },
	search: { text: ['name'] }
});

源码: packages/bolt/src/decl/model.ts:597

pageServer function

function pageServer<D>(spec: { readonly data: Schema.Codec<D, Json>; readonly load: PageLoad<NoInfer<D>>; }): PageServer<D>

+<page>.page.server.ts: a read-only server loader beside +<page>.page.svelte. Import the default codec from the ordinary <page>.page.data.ts helper in both files; the browser never imports this server declaration. Evaluation attaches the loader without running it.

参数

名称类型说明
spec{ readonly data: Schema.Codec<D, Json>; readonly load: PageLoad<NoInfer<D>>; }
  • data: Schema.Codec<D, Json>
  • load: PageLoad<NoInfer<D>>

源码: packages/bolt/src/decl/runtime/page.ts:29

pipeline function

function pipeline<const C extends ModelName, const I extends InputFields = {}, Rec = never, M = { [K in keyof ({ readonly [P in Exclude<Cols<InputSel<C, "create">>, OptionalCols<C, InputSel<C, "create">>>]: Loose<ColumnValue<C, P>>; } & { readonly [P in Cols<InputSel<C, "create">> & OptionalCols<C, InputSel<C, "create">>]?: Loose<ColumnValue<C, P>> | undefined; } & WithValues<C, InputSel<C, "create">>)]: ({ readonly [P in Exclude<Cols<InputSel<C, "create">>, OptionalCols<C, InputSel<C, "create">>>]: Loose<ColumnValue<C, P>>; } & { readonly [P in Cols<InputSel<C, "create">> & OptionalCols<C, InputSel<C, "create">>]?: Loose<ColumnValue<C, P>> | undefined; } & WithValues<C, InputSel<C, "create">>)[K]; }, K = undefined, const X extends InputFields = {}>(name: C, spec: PipelineSpec<C, I, Rec, M, K, X>): { readonly name: C; readonly spec: PipelineSpec<C, I, Rec, M, K, X>; }

src/data/collection/<c>/+pipeline.ts: file import and export of collection <c>: an import maps a sheet's or file's records onto inserts that enter through the collection's write pipeline as the caller (a JSON or xlsx upload, a downloadable xlsx template, an optional scope set with deletes, check findings); an export writes the selected fields as CSV, XLSX or JSON. The view toolbar's ⚡ menu wires every pipeline by itself.

参数

名称类型说明
nameC
specPipelineSpec<C, I, Rec, M, K, X>
  • import?: ImportSpec<C, I, Rec, M, K, X>
  • export?: { description: string; select: readonly ReadField<C>[]; where?: Where<C>; format: 'csv' | 'xlsx' | 'json'; }

源码: packages/bolt/src/decl/runtime/pipeline.ts:113

policy function

function policy<const P extends PolicyBase>(spec: P & NoInfer<Checked<PolicyBase, P, Exact<P, PolicyFor<P, keyof Grants<P> & Grantable>>>>): P

src/access_control/policy/+<name>.policy.ts: what holders may do: per-collection grants (read, create, update, delete, queries, actions, state moves, approvals), the automations they may start, capabilities (apps, host tools, MCP servers, skills) and rate limits. Teams hold policies in src/access_control/team/+team.ts. Returns the literal.

参数

名称类型说明
specP & NoInfer<Checked<PolicyBase, P, Exact<P, PolicyFor<P, keyof Grants<P> & Grantable>>>>
  • description: string

    What holding the policy is for, for people and the agent.

  • grants: { readonly [collection: string]: object; }

    Per collection: read, history, create, update, delete (each true, a scope or fields), queries, actions, state moves, approvals, or via a parent.

  • automations?: readonly string[]

    The automations (and <definition>.<feed> runs) holders may start.

  • capabilities?: { readonly [k: string]: readonly string[]; }

    The apps (or groups), host tools, MCP servers and agent skills holders may use.

  • limits?: { readonly [key: string]: unknown; }

    Rate limits per limit key.

示例

export default policy({
	description: 'Reads the product catalogue.',
	grants: { products: { read: true } },
	capabilities: { apps: ['crm'] }
});

源码: packages/bolt/src/decl/access/policy.ts:217

relationship function

function relationship<const R extends Relationships>(spec: R & NoInfer<Checked<Relationships, R, Exact<R, RelationshipsFor<R>>>>): R

src/data/+relationship.ts: every relation, keyed '<model>.<fk field>'. Each entry adds an FK field to that model pointing to a target model, with an optional inverse many-relation on the target; owned children are written and deleted with their parent. Returns the literal.

参数

名称类型说明
specR & NoInfer<Checked<Relationships, R, Exact<R, RelationshipsFor<R>>>>

示例

export default relationship({ 'lines.order': { to: 'orders', inverse: 'lines', owned: true } });

源码: packages/bolt/src/decl/relationship.ts:64

secrets function

function secrets<const E extends Record<string, SecretDecl>>(spec: E & Exact<E, { [N in keyof E]: N extends Uppercase<N & string> ? SecretDecl : "error: secret names are UPPER_SNAKE"; }>): E

src/+secrets.ts: the workspace's secret names; values stay in the encrypted tenant store.

参数

名称类型说明
specE & Exact<E, { [N in keyof E]: N extends Uppercase<N & string> ? SecretDecl : 'error: secret names are UPPER_SNAKE'; }>

源码: packages/bolt/src/decl/runtime/app.ts:14

team function

function team<const T extends TeamBase>(spec: T & Checked<TeamBase, T, TeamsFor<T>>): T

src/access_control/team/+team.ts: stable team handles, optional display labels/parents and source policies.

参数

名称类型说明
specT & Checked<TeamBase, T, TeamsFor<T>>

源码: packages/bolt/src/decl/access/team.ts:36

workspace function

function workspace<const S extends WorkspaceBase>(spec: S & Checked<WorkspaceBase, S, Exact<S, WorkspaceFor<S>>>): S

src/+workspace.ts, exactly one: the workspace's timezone and locale, the app order in the nav, AI settings, and connections (named integration instances).

参数

名称类型说明
specS & Checked<WorkspaceBase, S, Exact<S, WorkspaceFor<S>>>
  • tz: IanaZone

    The workspace's IANA zone: today, date defaults and document numbers are read in it.

  • locale: string

    The default locale tag.

  • currency?: CurrencyCode

    The default currency of money fields that name none.

  • apps?: readonly string[]

    App order in the launcher.

  • ai?: { models: readonly AiModelClass[]; default: AiModelClass; embeddings?: readonly string[]; }

    The model classes agents may use, the default one, and the embedding models.

  • convert?: { to: readonly ConvertTarget[]; }

    The document formats automations convert Markdown or HTML to (ctx.convert.document); the host must serve each.

  • csp?: { connect?: readonly `https://${string}`[]; }

    Origins pages may connect to beyond the workspace.

  • agent?: { triage?: false; }

    triage: false turns off System 1 triage of the in-app agent.

  • signup?: Signup

    Who may join without an invitation (§5.11.2); absent, only invited members join.

  • connections?: { readonly [slot: string]: { integration: string; envoy?: string; }; }

    Named instances source addresses: each slot is a sys_integration row of integration, its id the slot name.

示例

export default workspace({ tz: 'Asia/Singapore', locale: 'en-SG', apps: ['crm'] });

源码: packages/bolt/src/decl/runtime/app.ts:102