@segmentstream/ontology · A–D
242 public exports from @segmentstream/ontology.
Public exports
ACT_AS_HEADER
The header in which a runtime caller names the member it acts for: the member's user id. The service honours it only with a verified runtime token, so nobody else can claim a member with it.
const ACT_AS_HEADER = "x-segmentstream-act-as"
ACT_AS_PROVIDER_HEADER
How a request may authenticate as the runtime: the verifier and the member it names, if any.
const ACT_AS_PROVIDER_HEADER = "x-segmentstream-identity-provider"
AGENT_DRAFT_FILES_LIMIT
The most files a draft holds, as many as `attachments_send` sends at once.
const AGENT_DRAFT_FILES_LIMIT = 10
AGENT_DRAFT_MODES
const AGENT_DRAFT_MODES: readonly [
{
readonly value: "always";
readonly description: "Every reply in the chat waits for a member.";
},
{
readonly value: "whenUnsure";
readonly description: "The decision model was not sure enough that staff would send it as written.";
},
{
readonly value: "requested";
readonly description: string;
}
]AGENT_DRAFT_NEWER_LIMIT
The most drafts one `newer` call answers for.
const AGENT_DRAFT_NEWER_LIMIT = 50
AGENT_DRAFT_STATUSES
The agent's draft reply awaiting a staff decision. `agent/segmentstream.json` says, per role of the person the agent replies to, whether a member reviews its replies (`chats.*.review`); the agent records each reply it keeps for review here as a draft, and only the actions below change it. Approving sends the draft, or the member's edit of it, to the person's chat as the agent, without the sender attribution a chat post carries, at most once; rejecting discards it. Reading, approving and rejecting each need a permission that names `agent_draft`: an entity wildcard does not cover it, since its records hold the workspace's chats with the people it serves.
const AGENT_DRAFT_STATUSES: readonly [
{
readonly value: "pending";
readonly description: "Waiting for a member to approve, edit or reject it.";
},
{
readonly value: "sent";
readonly description: "Approved and delivered to the person.";
},
{
readonly value: "uncertain";
readonly description: "Approved; the provider may have delivered it, and it is never sent again.";
},
{
readonly value: "failed";
readonly description: "Approved; the provider refused it, and nothing was sent.";
},
{
readonly value: "rejected";
readonly description: "Rejected: the person never sees it.";
},
{
readonly value: "superseded";
readonly description: "Redrafted at a member's request: the draft that revises it replaces it.";
},
{
readonly value: "dismissed";
readonly description: string;
}
]AGENT_DRAFT_TEXT_LIMIT
The longest reply a draft holds; a provider may accept less in one message.
const AGENT_DRAFT_TEXT_LIMIT = 20000
AGENT_EVAL_CLIENT_ID
The first-party client of the grants with which a builder's evals reach the agent of an app preview, as a test member that exists only in the preview's branch: `POST /api/ontology/agent/eval-tokens` issues them, for the platform only. Its tokens are agent tokens like `agent-web`'s, which introspection marks `eval: true`. Outside a preview that runs the agent the client is refused outright, and a production ontology holds none of its grants.
const AGENT_EVAL_CLIENT_ID = "agent-eval"
AGENT_EVAL_TOKENS_PATH
Where the platform issues an eval session's agent token, in a preview that runs the agent.
const AGENT_EVAL_TOKENS_PATH = "/api/ontology/agent/eval-tokens"
AGENT_GRANT_HEADER
The OAuth grant behind the agent token a member's browser showed the agent, when the agent acts for a member who wrote on the web (`X-SegmentStream-Identity-Provider: web`) instead of a paired account.
const AGENT_GRANT_HEADER = "x-segmentstream-agent-grant"
AGENT_INSTRUCTIONS_NAME_PATTERN
A published instruction's name: lowercase letters, digits, `-` and `_`, from a letter.
const AGENT_INSTRUCTIONS_NAME_PATTERN: RegExp
AGENT_INSTRUCTIONS_TEXT_LIMIT
The longest text one published instruction holds: about two thousand words, a share of the model's context the agent can spend on every turn. Longer text is refused, never cut; split it into several names.
const AGENT_INSTRUCTIONS_TEXT_LIMIT = 8000
AGENT_PATH
The agent's endpoints, under the ontology service's path.
const AGENT_PATH = "/api/ontology/agent"
AGENT_REVIEW_MODES
const AGENT_REVIEW_MODES: readonly [
{
readonly value: "always";
readonly description: "Every reply in the chat waits for a member.";
},
{
readonly value: "whenUnsure";
readonly description: "The decision model was not sure enough that staff would send it as written.";
},
{
readonly value: "requested";
readonly description: string;
}
]AGENT_REVIEW_STATUSES
const AGENT_REVIEW_STATUSES: readonly [
{
readonly value: "pending";
readonly description: "Waiting for a member to approve, edit or reject it.";
},
{
readonly value: "sent";
readonly description: "Approved and delivered to the person.";
},
{
readonly value: "uncertain";
readonly description: "Approved; the provider may have delivered it, and it is never sent again.";
},
{
readonly value: "failed";
readonly description: "Approved; the provider refused it, and nothing was sent.";
},
{
readonly value: "rejected";
readonly description: "Rejected: the person never sees it.";
},
{
readonly value: "superseded";
readonly description: "Redrafted at a member's request: the draft that revises it replaces it.";
},
{
readonly value: "dismissed";
readonly description: string;
}
]AGENT_REVIEW_TEXT_LIMIT
const AGENT_REVIEW_TEXT_LIMIT = 20000
AGENT_TASK_HEADER
The header in which the app's agent, running a task a workflow handed it, presents the task's secret instead of naming a member. With a verified runtime token it authenticates as the task's workflow user, on `/mcp` and the task routes only; every other route refuses it.
const AGENT_TASK_HEADER = "x-segmentstream-agent-task"
AGENT_TASK_PATH
The task the agent runs, as its secret names it.
const AGENT_TASK_PATH = "/api/ontology/agent/tasks/current"
AGENT_TASK_RESULT_PATH
Where the agent reports the task's outcome.
const AGENT_TASK_RESULT_PATH = "/api/ontology/agent/tasks/current/result"
AGENT_TOKENS_PATH
Where a signed-in member gets an agent token, and where the agent asks whom one stands for.
const AGENT_TOKENS_PATH = "/api/ontology/agent/tokens"
AGENT_TOKEN_INTROSPECTION_PATH
const AGENT_TOKEN_INTROSPECTION_PATH = "/api/ontology/agent/tokens/introspect"
AGENT_TOOL_VERBS
The agent's own tools a role may grant. `sandbox`: the shell and file tools in the agent's sandbox, copying a file the caller may read into it, and calling an ontology tool with arguments from a file in it. `web`: fetching pages from the domains the agent's configuration lists. `browser`: driving the agent's own platform browser, signed in as the agent, with scripts that run in its sandbox, so the agent also needs the sandbox for it. `web_search`: searching the web, each search billed to the workspace. The agent's configuration says which of them the agent has; the roles say which caller gets them.
const AGENT_TOOL_VERBS: readonly [
"sandbox",
"web",
"browser",
"web_search"
]AGENT_VISITORS_PATH
Where a browser on a declared website signs its visitor up on `web`.
const AGENT_VISITORS_PATH = "/api/ontology/agent/visitors"
AGENT_WEB_CLIENT_ID
A member's browser reaches the app's agent with an ordinary access token of the ontology's OAuth server (`sso_…`): the token of the member's grant to the first-party client `agent-web`, for the agent's resource on the app's origin. Like every access token, it works only for the resource of its grant, so it is no app session and no MCP token. The agent asks the ontology who a token stands for, and names the token's grant whenever it then acts for the member.
const AGENT_WEB_CLIENT_ID = "agent-web"
API_KEY_ITERATIONS
PBKDF2-SHA256 iterations for a key's secret: about 5 ms per verification on Node. The secret already carries 256 bits of entropy, so the KDF is not what protects it; it exists so that stored secrets are handled like any password storage, and it must stay cheap because it runs on every request authenticated with an API key.
const API_KEY_ITERATIONS = 10000
API_KEY_PREFIX
API keys are `ssk_<key id>.<secret>`.
const API_KEY_PREFIX = "ssk_"
APP_FEEDBACK_ENTITIES
The entities `feedback: true` adds, in the order their tables are created.
const APP_FEEDBACK_ENTITIES: readonly [
import("./entity.js").Entity<"app_feedback", {
readonly title: import("./property.js").Property<string, false, false>;
readonly body: import("./property.js").Property<string, false, false>;
readonly status: import("./property.js").Property<"open" | "done" | "declined", false, false>;
readonly response: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
readonly respondedAt: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
readonly seenAt: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
readonly claimedBy: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
readonly claimedUntil: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
}, {
readonly reporter: import("./relationship.js").OneRelationship<false, false, "user">;
}, import("./entity.js").InvocableActions<{
readonly submit: import("./action.js").Action<Schema.Struct<{
readonly title: import("./property.js").Property<string, false, false>;
readonly body: import("./property.js").Property<string, false, false>;
}>, {
feedback: string;
}>;
readonly respond: import("./action.js").Action<Schema.Struct<{
readonly feedback: Schema.Codec<string, string, never, never>;
readonly status: import("./property.js").Property<"done" | "declined", false, false>;
readonly response: import("./property.js").Property<string, false, false>;
}>, {
feedback: string;
}>;
readonly claim: import("./action.js").Action<Schema.Struct<{
readonly feedback: Schema.Codec<string, string, never, never>;
readonly by: import("./property.js").Property<string, false, false>;
readonly minutes: Schema.optional<import("./property.js").Property<number, false, false>>;
}>, {
feedback: string;
claimedBy: string;
claimedUntil: string;
renewed: boolean;
}>;
readonly release: import("./action.js").Action<Schema.Struct<{
readonly feedback: Schema.Codec<string, string, never, never>;
readonly by: import("./property.js").Property<string, false, false>;
}>, {
feedback: string;
released: boolean;
}>;
readonly acknowledge: import("./action.js").Action<Schema.Struct<{
readonly feedback: Schema.Codec<string, string, never, never>;
readonly respondedAt: import("./property.js").Property<string, false, false>;
}>, {
feedback: string;
acknowledged: boolean;
}>;
}, "app_feedback", {
readonly id: string;
readonly createdAt: string;
readonly updatedAt: string;
readonly createdBy: string | null;
readonly updatedBy: string | null;
readonly title: string;
readonly body: string;
readonly status: "open" | "done" | "declined";
readonly response: string | null;
readonly respondedAt: string | null;
readonly seenAt: string | null;
readonly claimedBy: string | null;
readonly claimedUntil: string | null;
readonly reporterId: string;
}>, Readonly<Record<never, never>>, "generated">,
import("./entity.js").Entity<"app_feedback_file", {
readonly file: import("./property.js").Property<{
readonly id: string;
readonly filename: string;
readonly contentType: string;
readonly size: number;
readonly createdAt: string;
}, false, false>;
}, {
readonly feedback: import("./relationship.js").OneRelationship<false, false, "app_feedback">;
}, import("./entity.js").InvocableActions<{
readonly attach: import("./action.js").Action<Schema.Struct<{
readonly feedback: Schema.Codec<string, string, never, never>;
readonly file: Schema.Struct<{
readonly uploadId: Schema.String;
}>;
}>, {
file: string;
}>;
}, "app_feedback_file", {
readonly id: string;
readonly createdAt: string;
readonly updatedAt: string;
readonly createdBy: string | null;
readonly updatedBy: string | null;
readonly file: {
readonly id: string;
readonly filename: string;
readonly contentType: string;
readonly size: number;
readonly createdAt: string;
};
readonly feedbackId: string;
}>, Readonly<Record<never, never>>, "generated">
]APP_FEEDBACK_FILE_MAX_BYTES
A feedback file's limit: screenshots, logs and documents, not archives of a whole project.
const APP_FEEDBACK_FILE_MAX_BYTES: number
ATTACHABLE_IDENTITY_PROVIDERS
The chat providers whose accounts an administrator may attach to a member with `user_identity.attach`: the providers the app's agent talks on. An `email` account is the address a member writes to the agent's mailbox from, which the agent never links to a member by itself.
const ATTACHABLE_IDENTITY_PROVIDERS: readonly [
"telegram",
"whatsapp",
"slack",
"email"
]Action
A described, typed, permissioned Effect function: the only way to change records.
interface Action<Input extends Schema.Top = Schema.Top, Result = unknown> {
readonly [ActionTypeId]: typeof ActionTypeId;
readonly description: string;
readonly input: Input;
readonly permission: string | ReadonlyArray<string> | undefined;
readonly openToMembers?: boolean;
readonly hints: ActionHints | undefined;
readonly retryOnDeadlock?: boolean;
readonly writes?: ReadonlyArray<ActionWriteTarget>;
readonly connections: ReadonlyArray<AnyConnectionHandle>;
readonly files?: ReadonlyArray<FileTarget>;
confirm?(context: ConfirmContext<Input["Type"]>): Effect.Effect<ActionConfirmation, ActionError, OntologyReads>;
prepare?(context: PrepareContext<Input["Type"]>): Effect.Effect<unknown, PrepareError, OntologyReads | Connection<string> | Files>;
handler(context: ActionContext<Input["Type"], unknown>): Effect.Effect<Result, ActionError, OntologyRuntime>;
readonly transactional: boolean;
}ActionCommitted
A committed action, as an after-commit hook receives it.
interface ActionCommitted {
readonly entity: string;
readonly action: string;
readonly principal: Principal;
readonly input: unknown;
readonly result: unknown;
readonly edits: ReadonlyArray<unknown>;
readonly requestId: string;
readonly run?: (input: {
readonly entity: string;
readonly action: string;
readonly input: unknown;
readonly as: "service";
}) => Promise<unknown>;
}ActionConfig
interface ActionConfig<Input extends Schema.Top, Result> extends ActionOptions<Input> {
readonly handler: (context: ActionContext<Input["Type"]>) => Effect.Effect<Result, ActionError, OntologyRuntime>;
readonly connections?: undefined;
readonly prepare?: undefined;
readonly files?: undefined;
}ActionConfigWithConnections
An action that calls connections. `prepare` runs after the permission check and before the transaction, with reads and the declared connections but no writes, so a provider's latency never holds a database connection or a lock. `handler` then runs in the transaction with what `prepare` returned, and cannot call connections. `prepare` sees committed data without locks: a handler whose write depends on what `prepare` read re-reads it with `forUpdate` and checks it again. A provider write in `prepare` happens even when the transaction later fails, so derive its idempotency key from the record, never from the request.
interface ActionConfigWithConnections<Input extends Schema.Top, C extends ReadonlyArray<AnyConnectionHandle>, Prepared, Result> extends ActionOptions<Input> {
readonly connections: C;
readonly files?: ReadonlyArray<FileTarget>;
readonly prepare: (context: PrepareContext<Input["Type"]>) => Effect.Effect<Prepared, PrepareError, OntologyReads | ConnectionsOf<C> | Files>;
readonly handler?: (context: ActionContext<Input["Type"], Prepared>) => Effect.Effect<Result, ActionError, OntologyRuntime>;
}ActionConfirmation
What a person confirms before an agent runs an action, in the language of the chat the agent asks in. The agent shows it as its confirmation card, with the confirm and cancel buttons and the outcome below it. Every text is plain: no markup, ids, codes or links in the text itself.
const ActionConfirmation: Schema.Struct<{
readonly title: Schema.String;
readonly icon: Schema.optionalKey<Schema.String>;
readonly facts: Schema.$Array<Schema.Struct<{
readonly icon: Schema.optionalKey<Schema.String>;
readonly text: Schema.String;
readonly url: Schema.optionalKey<Schema.String>;
}>>;
readonly details: Schema.optionalKey<Schema.$Array<Schema.String>>;
readonly link: Schema.optionalKey<Schema.Struct<{
readonly text: Schema.String;
readonly url: Schema.String;
}>>;
}>type ActionConfirmation = typeof ActionConfirmation.Type;
ActionContext
interface ActionContext<Input, Prepared = undefined> extends PrepareContext<Input> {
readonly principal: Principal & {
readonly identities: ReadonlyArray<ActionIdentity>;
readonly createdVia: string;
readonly authenticatedVia: string;
};
readonly prepared: Prepared;
}ActionEncodedInput
The input of an action as a caller sends it: the encoded form of its input schema.
type ActionEncodedInput<A> = A extends Action<infer Input extends Schema.Top, unknown> ? Input["Encoded"] : never;
ActionError
The failures an action handler may produce.
type ActionError = ActionRejected | PermissionDenied | DeploymentSwitching | DeploymentInterrupted | Conflict | NotFound | ScopeViolated;
ActionEvent
One committed run of an action, as an action trigger's `when` and `input` receive it: the facts history stores, as one value. `input` and `result` are typed from the action handle; for a trigger on an entity they are `unknown`.
interface ActionEvent<Input = unknown, Result = unknown> {
readonly action: string;
readonly actionId: string;
readonly at: string;
readonly principal: Principal;
readonly input: Input;
readonly result: Result;
readonly edits: ReadonlyArray<Edit>;
}ActionHandle
What an authored action handle names besides its definition: the entity it belongs to and its key in `.actions(…)`, as declared, so `after(name, Lead.actions.changeStatus, …)` can name the action in the manifest, and type-level only, the entity's record type for the trigger's record.
interface ActionHandle<EntityName extends string = string, Key extends string = string, EntityType = unknown> {
readonly entity: EntityName;
readonly name: Key;
readonly "~ontology.record": EntityType;
}ActionHints
How an action behaves. Agents confirm destructive, irreversible or external actions before preparation. Actions with connections are external even when both safety hints are false, except for enforced read-only prepare actions declared with `readOnly: true`. Permitted, routine reversible actions can run without confirmation. Custom actions without safety labels require confirmation for backwards compatibility. Idempotence does not decide whether confirmation is needed.
interface ActionHints {
readonly readOnly?: boolean;
readonly connectionsReadOnly?: boolean;
readonly destructive?: boolean;
readonly irreversible?: boolean;
readonly idempotent?: boolean;
}ActionIdentity
A live channel account of the member invoking the action.
const ActionIdentity: Schema.Struct<{
readonly provider: Schema.String;
readonly subject: Schema.String;
readonly username: Schema.optionalKey<Schema.String>;
readonly verified: Schema.Literal<true>;
}>type ActionIdentity = typeof ActionIdentity.Type;
ActionInput
The input of an action as its handler receives it: the decoded form of its input schema.
type ActionInput<A> = A extends Action<infer Input extends Schema.Top, unknown> ? Input["Type"] : never;
ActionInvoker
An authored action as an entity handle exposes it: its definition, its {@link ActionHandle} names, and callable as an Effect that runs it as the current caller, through the same path as its HTTP route, with its permission check and history. Calling it requires {@link OntologyActions}, which a workflow step's `run` provides; inside an action handler the call does not type-check.
type ActionInvoker<A, EntityName extends string = string, Key extends string = string, EntityType = unknown> = A extends Action<infer Input, infer Result> ? A & ActionHandle<EntityName, Key, EntityType> & ((input: Input["Type"], options?: ActionRunOptions) => Effect.Effect<Result, ActionError | ConnectionError, OntologyActions>) : A;
ActionManifest
const ActionManifest: Schema.Struct<{
readonly name: Schema.String;
readonly description: Schema.String;
readonly permission: Schema.optionalKey<Schema.String>;
readonly anyOf: Schema.optionalKey<Schema.$Array<Schema.String>>;
readonly input: Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>;
readonly retryOnDeadlock: Schema.optionalKey<Schema.Boolean>;
readonly writes: Schema.optionalKey<Schema.$Array<Schema.String>>;
readonly connections: Schema.optionalKey<Schema.$Array<Schema.String>>;
readonly files: Schema.optionalKey<Schema.$Array<Schema.Struct<{
readonly entity: Schema.String;
readonly property: Schema.String;
}>>>;
readonly hints: Schema.optionalKey<Schema.Struct<{
readonly readOnly: Schema.optionalKey<Schema.Boolean>;
readonly connectionsReadOnly: Schema.optionalKey<Schema.Boolean>;
readonly destructive: Schema.optionalKey<Schema.Boolean>;
readonly irreversible: Schema.optionalKey<Schema.Boolean>;
readonly idempotent: Schema.optionalKey<Schema.Boolean>;
}>>;
}>type ActionManifest = typeof ActionManifest.Type;
ActionOutcome
The response of an action: its result, the input's validation, and the records it changed.
const ActionOutcome: Schema.Struct<{
readonly result: Schema.Codec<Schema.Json, Schema.Json, never, never>;
readonly validation: Schema.Struct<{
readonly ok: Schema.Boolean;
readonly issues: Schema.$Array<Schema.Struct<{
readonly path: Schema.$Array<Schema.Union<readonly [
Schema.String,
Schema.Number
]>>;
readonly message: Schema.String;
}>>;
}>;
readonly edits: Schema.$Array<Schema.Struct<{
readonly entity: Schema.String;
readonly id: Schema.String;
readonly kind: Schema.Literals<readonly [
"create",
"update",
"delete",
"link",
"unlink"
]>;
readonly changes: Schema.$Record<Schema.String, Schema.Struct<{
readonly before: Schema.Codec<Schema.Json, Schema.Json, never, never>;
readonly after: Schema.Codec<Schema.Json, Schema.Json, never, never>;
}>>;
}>>;
}>interface ActionOutcome<Result = unknown> {
readonly result: Result | null;
readonly validation: ActionValidation;
readonly edits: ReadonlyArray<Edit>;
}ActionRejected
An action refused the request for a business reason. The message is written for the caller and is returned to them.
class ActionRejected extends ActionRejected_base {
}ActionRequest
interface ActionRequest<R = never> {
readonly runtime?: ActionRuntime;
readonly entity: string;
readonly action: string;
readonly input: unknown;
readonly principal: Principal;
readonly options?: {
readonly validateOnly?: boolean;
readonly idempotencyKey?: string;
readonly createIntent?: string;
readonly newUserHook?: true;
readonly signUpHook?: true;
readonly confirm?: {
readonly locale: string;
};
};
readonly branchId?: string;
readonly afterCommit?: ReadonlyArray<AfterCommit<R>>;
readonly requestId?: string;
readonly connections?: ConnectionTransport["Service"];
}ActionResult
What an action's handler succeeds with: the `result` of an action response.
type ActionResult<A> = A extends Action<Schema.Top, infer Result> ? Result : never;
ActionRunOptions
Stable invocation and creation identities for actions that attach upload tickets.
interface ActionRunOptions {
readonly idempotencyKey?: string;
readonly createIntent?: string;
}ActionRuntime
interface ActionRuntime {
readonly source: RuntimeSource;
}ActionTrigger
An action trigger, `after(name, target, { description, when, input })`: starts the workflow after an action of `entity` commits, `action` or any of them. `when` and `input` are code: the manifest records the kind, the name, the description, the entity and the action, never the functions.
interface ActionTrigger<Name extends string = string, Input = unknown> {
readonly [WorkflowTriggerTypeId]: typeof WorkflowTriggerTypeId;
readonly kind: "action";
readonly name: Name;
readonly description: string;
readonly entity: string;
readonly action: string | undefined;
readonly target: unknown;
readonly when: TriggerFunction<ActionEvent, unknown, boolean> | undefined;
readonly input: TriggerFunction<ActionEvent, unknown, Input> | undefined;
readonly runs?: AnyActionHandle | undefined;
readonly role?: string | undefined;
}ActionTriggerManifest
An action trigger of a workflow: the ontology service starts the workflow after an action of `entity` commits, `action` or, when it is absent, any of them. Wire names; the trigger's predicate and input mapping are code and never in the manifest.
const ActionTriggerManifest: Schema.Struct<{
readonly kind: Schema.Literal<"action">;
readonly name: Schema.String;
readonly description: Schema.String;
readonly entity: Schema.String;
readonly action: Schema.optionalKey<Schema.String>;
}>type ActionTriggerManifest = typeof ActionTriggerManifest.Type;
ActionValidation
const ActionValidation: Schema.Struct<{
readonly ok: Schema.Boolean;
readonly issues: Schema.$Array<Schema.Struct<{
readonly path: Schema.$Array<Schema.Union<readonly [
Schema.String,
Schema.Number
]>>;
readonly message: Schema.String;
}>>;
}>type ActionValidation = typeof ActionValidation.Type;
ActionWriteTarget
An entity an action writes: its handle, a thunk returning it for a circular import, or its name as `entity(name, …)` declares it, in its authored or snake_case spelling (`"staffMember"` or `"staff_member"`). A name is any string here, since an action is declared before the ontology that lists its entities; `check` refuses one that names no stored entity of the ontology.
type ActionWriteTarget = AnyEntity | (() => AnyEntity) | string;
Actions
An entity's authored actions by name, as `.actions(…)` returns them.
type Actions = {
readonly [name: string]: AnyAction;
};ActionsBuilder
`entity(…).actions((self) => ({ … }))`: declares the entity's actions next to its definition and returns the entity with `actions` typed as the returned object, so `typeof Lead.actions` carries every action's input and result types. Inside the callback, refer to the entity being defined as `self`, never as the constant it is being assigned to: `self` is the entity without actions, with the same `ref`, `properties` and data access. Naming the constant (`Lead.ref` inside `Lead`'s own actions) is a TypeScript self-reference error, because the constant's type depends on the callback's result. Other entities may be named as usual inside handlers. The callback runs once, when `.actions` is called.
interface ActionsBuilder<Name extends string, P extends Properties, R extends Relationships, M extends Metrics = Metrics, W extends EntityWrites = EntityWrites> {
<const A extends Actions>(define: (self: Entity<Name, P, R, NoActions, M, W>) => A): Entity<Name, P, R, InvocableActions<A, Name, EntityRecord<P, R>>, M, W>;
}AfterCommit
Runs after the transaction commits, never inside it: starting a workflow that notifies the team or calls a webhook. A failure is logged; the action has committed and still succeeds.
type AfterCommit<R = never> = (committed: CommittedAction) => Effect.Effect<void, unknown, R>;
AfterCommitHook
Runs after an action commits, outside its transaction: start a Vercel Workflow that notifies the team or calls a webhook. The response waits for the hook, so keep it to starting the work. A failed hook is logged; the action stays committed and the caller still gets its result.
type AfterCommitHook = (event: ActionCommitted) => void | Promise<void>;
AfterOptions
interface AfterOptions<Event, T, Input> extends TriggerRuns {
readonly description: string;
readonly when?: TriggerFunction<Event, T, boolean>;
readonly input?: TriggerFunction<Event, T, Input>;
}AgentChat
Existing chat registry and membership storage; delivery lives in the ontology service.
const AgentChat: import("./entity.js").Entity<"agent_chat", {
readonly provider: import("./property.js").Property<string, false, false>;
readonly kind: import("./property.js").Property<"private" | "group", true, false>;
readonly externalId: import("./property.js").Property<string, false, false>;
readonly key: Schema.optionalKey<import("./property.js").Property<string, false, true>>;
readonly title: import("./property.js").Property<string, false, false>;
readonly recipient: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
readonly threadId: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
readonly lastMessageAt: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
readonly handoffAt: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
readonly handoffReason: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
readonly groupAccess: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
readonly personaNoticeAt: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
readonly personaChangedAt: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
readonly agentPersona: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
readonly description: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
}, {
readonly members: import("./relationship.js").ManyRelationship;
readonly handledBy: import("./relationship.js").OneRelationship<true, false, "user">;
}, import("./entity.js").InvocableActions<{
readonly setAccess: import("./action.js").Action<Schema.Struct<{
readonly chat: Schema.Codec<string, string, never, never>;
readonly access: Schema.Literals<readonly [
"members",
"public"
]>;
readonly expected: Schema.optional<Schema.NullOr<Schema.String>>;
}>, {
groupAccess: "members" | "public";
}>;
readonly setPersona: import("./action.js").Action<Schema.Struct<{
readonly chat: Schema.Codec<string, string, never, never>;
readonly persona: Schema.NullOr<Schema.String>;
readonly expected: Schema.optional<Schema.NullOr<Schema.String>>;
}>, {
agentPersona: string | null;
}>;
readonly takeOver: import("./action.js").Action<Schema.Struct<{
readonly chat: Schema.Codec<string, string, never, never>;
}>, {
chat: string;
handled_by: string;
}>;
readonly handBack: import("./action.js").Action<Schema.Struct<{
readonly chat: Schema.Codec<string, string, never, never>;
}>, {
chat: string;
handled_by: null;
}>;
readonly draft: import("./action.js").Action<Schema.Struct<{
readonly chat: Schema.Codec<string, string, never, never>;
readonly message: Schema.optionalKey<Schema.String>;
readonly note: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
}>, {
chat: string;
request: string;
key: string;
message: string;
status: "requested";
}>;
readonly previewMessage: import("./action.js").Action<Schema.Struct<{
readonly chat: Schema.String;
readonly text: Schema.String;
readonly replyTo: Schema.optionalKey<Schema.String>;
readonly files: Schema.optionalKey<Schema.$Array<Schema.Struct<{
readonly entity: Schema.String;
readonly id: Schema.String;
readonly property: Schema.optionalKey<Schema.String>;
}>>>;
readonly idempotencyKey: Schema.String;
}>, import("./chat.js").ChatPreview>;
readonly recipients: import("./action.js").Action<Schema.Struct<{
readonly chat: Schema.Codec<string, string, never, never>;
}>, {
readonly to: readonly string[];
readonly cc: readonly string[];
}>;
readonly messages: import("./action.js").Action<Schema.Struct<{
readonly chat: Schema.String;
readonly before: Schema.optionalKey<Schema.String>;
readonly after: Schema.optionalKey<Schema.String>;
readonly limit: Schema.optionalKey<Schema.Int>;
readonly internal: Schema.optionalKey<Schema.Boolean>;
}>, {
readonly events: readonly {
readonly [x: string]: unknown;
}[];
readonly nextCursor: string | null;
}>;
readonly searchMessages: import("./action.js").Action<Schema.Struct<{
readonly q: Schema.optionalKey<Schema.String>;
readonly provider: Schema.optionalKey<Schema.String>;
readonly chatId: Schema.optionalKey<Schema.String>;
readonly threadId: Schema.optionalKey<Schema.String>;
readonly senderId: Schema.optionalKey<Schema.String>;
readonly from: Schema.optionalKey<Schema.String>;
readonly to: Schema.optionalKey<Schema.String>;
readonly before: Schema.optionalKey<Schema.String>;
readonly limit: Schema.optionalKey<Schema.Int>;
}>, {
readonly events: readonly {
readonly [x: string]: unknown;
}[];
readonly nextCursor: string | null;
}>;
readonly registerGroup: import("./action.js").Action<Schema.Struct<{
readonly channel: Schema.String;
readonly chatId: Schema.String;
readonly botId: Schema.String;
}>, {
readonly id: string;
readonly title: string;
}>;
readonly importHistory: import("./action.js").Action<Schema.Struct<{
readonly chat: Schema.optionalKey<Schema.String>;
readonly channel: Schema.optionalKey<Schema.String>;
readonly chatId: Schema.optionalKey<Schema.String>;
readonly kind: Schema.optionalKey<Schema.Literals<readonly [
"private",
"group"
]>>;
readonly thread: Schema.optionalKey<Schema.String>;
readonly person: Schema.optionalKey<Schema.String>;
readonly messages: Schema.$Array<Schema.Struct<{
readonly id: Schema.String;
readonly at: Schema.String;
readonly direction: Schema.Literals<readonly [
"inbound",
"outbound"
]>;
readonly by: Schema.optionalKey<Schema.Literals<readonly [
"human",
"agent",
"bot"
]>>;
readonly name: Schema.optionalKey<Schema.String>;
readonly text: Schema.optionalKey<Schema.String>;
readonly replyTo: Schema.optionalKey<Schema.String>;
readonly files: Schema.optionalKey<Schema.$Array<Schema.Struct<{
readonly upload: Schema.Struct<{
readonly uploadId: Schema.String;
}>;
}>>>;
}>>;
}>, {
readonly imported: number;
readonly duplicates: number;
readonly skipped: number;
readonly expired: number;
}>;
readonly editMessage: import("./action.js").Action<Schema.Struct<{
readonly chat: Schema.String;
readonly messageId: Schema.String;
readonly idempotencyKey: Schema.String;
readonly text: Schema.String;
readonly telegramHtml: Schema.String;
readonly buttons: Schema.optionalKey<Schema.$Array<Schema.$Array<Schema.Union<readonly [
Schema.Struct<{
readonly url: Schema.String;
readonly text: Schema.String;
readonly style: Schema.optionalKey<Schema.Literals<readonly [
"primary",
"success",
"danger"
]>>;
}>,
Schema.Struct<{
readonly token: Schema.String;
readonly text: Schema.String;
readonly style: Schema.optionalKey<Schema.Literals<readonly [
"primary",
"success",
"danger"
]>>;
}>,
Schema.Struct<{
readonly copyText: Schema.String;
readonly text: Schema.String;
readonly style: Schema.optionalKey<Schema.Literals<readonly [
"primary",
"success",
"danger"
]>>;
}>
]>>>>;
}>, {
readonly status: "sent" | "uncertain";
readonly message_id: string | null;
readonly url: string | null;
readonly duplicate: boolean;
readonly history_recorded: boolean;
}>;
readonly send: import("./action.js").Action<Schema.Struct<{
readonly telegramHtml: Schema.optionalKey<Schema.String>;
readonly chat: Schema.String;
readonly text: Schema.optionalKey<Schema.String>;
readonly template: Schema.optionalKey<Schema.Struct<{
readonly name: Schema.String;
readonly language: Schema.String;
readonly parameters: Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>;
readonly header: Schema.optionalKey<Schema.Struct<{
readonly parameters: Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>;
readonly media: Schema.optionalKey<Schema.Struct<{
readonly url: Schema.optionalKey<Schema.String>;
readonly file: Schema.optionalKey<Schema.Struct<{
readonly entity: Schema.String;
readonly id: Schema.String;
readonly property: Schema.optionalKey<Schema.String>;
}>>;
readonly filename: Schema.optionalKey<Schema.String>;
}>>;
}>>;
readonly buttons: Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>;
}>>;
readonly replyTo: Schema.optionalKey<Schema.String>;
readonly buttons: Schema.optionalKey<Schema.$Array<Schema.$Array<Schema.Union<readonly [
Schema.Struct<{
readonly url: Schema.String;
readonly text: Schema.String;
readonly style: Schema.optionalKey<Schema.Literals<readonly [
"primary",
"success",
"danger"
]>>;
}>,
Schema.Struct<{
readonly token: Schema.String;
readonly text: Schema.String;
readonly style: Schema.optionalKey<Schema.Literals<readonly [
"primary",
"success",
"danger"
]>>;
}>,
Schema.Struct<{
readonly copyText: Schema.String;
readonly text: Schema.String;
readonly style: Schema.optionalKey<Schema.Literals<readonly [
"primary",
"success",
"danger"
]>>;
}>
]>>>>;
readonly files: Schema.optionalKey<Schema.$Array<Schema.Struct<{
readonly entity: Schema.String;
readonly id: Schema.String;
readonly property: Schema.optionalKey<Schema.String>;
}>>>;
readonly to: Schema.optionalKey<Schema.$Array<Schema.String>>;
readonly cc: Schema.optionalKey<Schema.$Array<Schema.String>>;
readonly as: Schema.optionalKey<Schema.Literals<readonly [
"agent",
"me"
]>>;
readonly idempotencyKey: Schema.String;
}>, {
readonly status: "sent" | "uncertain";
readonly message_id: string | null;
readonly url: string | null;
readonly duplicate: boolean;
readonly history_recorded: boolean;
}>;
readonly postMessage: import("./action.js").Action<Schema.Struct<{
readonly chat: Schema.String;
readonly text: Schema.String;
readonly replyTo: Schema.optionalKey<Schema.String>;
readonly files: Schema.optionalKey<Schema.$Array<Schema.Struct<{
readonly entity: Schema.String;
readonly id: Schema.String;
readonly property: Schema.optionalKey<Schema.String>;
}>>>;
readonly idempotencyKey: Schema.String;
}>, {
readonly status: "sent" | "uncertain";
readonly message_id: string | null;
readonly url: string | null;
readonly duplicate: boolean;
readonly history_recorded: boolean;
}>;
}, "agent_chat", {
readonly id: string;
readonly createdAt: string;
readonly updatedAt: string;
readonly createdBy: string | null;
readonly updatedBy: string | null;
readonly provider: string;
readonly kind: "private" | "group";
readonly externalId: string;
readonly key: string | null;
readonly title: string;
readonly recipient: string | null;
readonly threadId: string | null;
readonly lastMessageAt: string | null;
readonly handoffAt: string | null;
readonly handoffReason: string | null;
readonly groupAccess: string | null;
readonly personaNoticeAt: string | null;
readonly personaChangedAt: string | null;
readonly agentPersona: string | null;
readonly description: string | null;
readonly handledById: string | null;
}>, Readonly<Record<never, never>>, "generated">type AgentChat = typeof AgentChat.Type;
AgentDraft
const AgentDraft: import("./entity.js").Entity<"agent_draft", {
readonly key: import("./property.js").Property<string, false, true>;
readonly channelKind: import("./property.js").Property<string, false, false>;
readonly channel: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
readonly chatId: import("./property.js").Property<string, false, false>;
readonly recipient: import("./property.js").Property<string, false, false>;
readonly to: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
readonly cc: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
readonly participants: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
readonly chatKind: import("./property.js").Property<"private" | "group", false, false>;
readonly threadId: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
readonly replyTo: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
readonly sessionId: import("./property.js").Property<string, false, false>;
readonly turnId: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
readonly basis: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
readonly message: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
readonly draft: import("./property.js").Property<string, false, false>;
readonly files: Schema.optionalKey<import("./property.js").Property<Schema.Json, false, false>>;
readonly text: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
readonly status: import("./property.js").Property<"pending" | "sent" | "failed" | "uncertain" | "rejected" | "dismissed" | "superseded", false, false>;
readonly mode: import("./property.js").Property<"requested" | "always" | "whenUnsure", false, false>;
readonly confidence: Schema.optionalKey<import("./property.js").Property<number, false, false>>;
readonly messageId: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
readonly decidedAt: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
readonly reason: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
readonly note: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
readonly revision: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
readonly revisionState: Schema.optionalKey<import("./property.js").Property<"failed" | "requested", false, false>>;
}, {
readonly person: import("./relationship.js").OneRelationship<false, false, "user">;
readonly decidedBy: import("./relationship.js").OneRelationship<true, false, "user">;
readonly notedBy: import("./relationship.js").OneRelationship<true, false, "user">;
readonly revises: import("./relationship.js").OneRelationship<true, false, "agent_draft">;
readonly agentChat: import("./relationship.js").OneRelationship<true, false, "agent_chat">;
}, import("./entity.js").InvocableActions<{
readonly approve: import("./action.js").Action<Schema.Struct<{
readonly draft: Schema.Codec<string, string, never, never>;
readonly text: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
readonly to: Schema.optionalKey<Schema.$Array<Schema.String>>;
readonly cc: Schema.optionalKey<Schema.$Array<Schema.String>>;
readonly files: Schema.optionalKey<Schema.$Array<Schema.Struct<{
readonly entity: Schema.String;
readonly id: Schema.String;
readonly property: Schema.String;
readonly revisionId: Schema.String;
}>>>;
readonly unlessNewer: Schema.optionalKey<Schema.Boolean>;
}>, {
to?: readonly string[] | undefined;
cc?: readonly string[] | undefined;
draft: string;
review: string;
status: "sent" | "failed" | "uncertain";
message_id: string | null;
duplicate: boolean;
}>;
readonly reject: import("./action.js").Action<Schema.Struct<{
readonly draft: Schema.Codec<string, string, never, never>;
readonly reason: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
}>, {
draft: string;
review: string;
status: "rejected";
}>;
readonly dismiss: import("./action.js").Action<Schema.Struct<{
readonly draft: Schema.Codec<string, string, never, never>;
readonly reason: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
}>, {
draft: string;
status: "dismissed";
}>;
readonly newer: import("./action.js").Action<Schema.Struct<{
readonly drafts: Schema.$Array<Schema.Codec<string, string, never, never>>;
}>, {
drafts: readonly import("./chat.js").DraftNewer[];
}>;
readonly revise: import("./action.js").Action<Schema.Struct<{
readonly draft: Schema.Codec<string, string, never, never>;
readonly note: import("./property.js").Property<string, false, false>;
}>, {
draft: string;
review: string;
revision: string;
status: "requested";
}>;
}, "agent_draft", {
readonly id: string;
readonly createdAt: string;
readonly updatedAt: string;
readonly createdBy: string | null;
readonly updatedBy: string | null;
readonly key: string;
readonly channelKind: string;
readonly channel: string | null;
readonly chatId: string;
readonly recipient: string;
readonly to: string | null;
readonly cc: string | null;
readonly participants: string | null;
readonly chatKind: "private" | "group";
readonly threadId: string | null;
readonly replyTo: string | null;
readonly sessionId: string;
readonly turnId: string | null;
readonly basis: string | null;
readonly message: string | null;
readonly draft: string;
readonly files: Schema.Json;
readonly text: string | null;
readonly status: "pending" | "sent" | "failed" | "uncertain" | "rejected" | "dismissed" | "superseded";
readonly mode: "requested" | "always" | "whenUnsure";
readonly confidence: number | null;
readonly messageId: string | null;
readonly decidedAt: string | null;
readonly reason: string | null;
readonly note: string | null;
readonly revision: string | null;
readonly revisionState: "failed" | "requested" | null;
readonly personId: string;
readonly decidedById: string | null;
readonly notedById: string | null;
readonly revisesId: string | null;
readonly agentChatId: string | null;
}>, Readonly<Record<never, never>>, "actions">type AgentDraft = typeof AgentDraft.Type;
AgentDraftFile
A record file a draft holds, snapshotted when the reply was held: the revision the person may read, which approval sends whatever the record holds by then, with what the inbox shows of it.
interface AgentDraftFile {
readonly entity: string;
readonly id: string;
readonly property: string;
readonly revisionId: string;
readonly filename: string;
readonly contentType: string;
readonly size: number;
}AgentIdentity
A channel account paired with a member: the app's agent acts as the member for its messages.
interface AgentIdentity {
readonly id: string;
readonly provider: string;
readonly externalId: string;
readonly userId: string;
readonly display: string | null;
readonly username?: string;
readonly createdAt: Date;
readonly revokedAt: Date | null;
readonly origin: "paired" | "provisioned";
readonly noticedAt: Date | null;
readonly noticeSha256: string | null;
readonly noticeVersion: string | null;
}AgentInstructions
Instructions the workspace's members publish for its agent without a deploy, such as a playbook staff refine as they learn. The agent's code declares which name it reads and for whose turns, by role; the text then reaches those turns as the agent's own instructions. Only the actions below change it, and reading or publishing needs a permission that names `agent_instructions`: an entity wildcard does not cover it, since the text steers what the agent says to everyone it serves.
const AgentInstructions: import("./entity.js").Entity<"agent_instructions", {
readonly name: import("./property.js").Property<string, false, true>;
readonly text: import("./property.js").Property<string, false, false>;
}, Readonly<Record<never, never>>, import("./entity.js").InvocableActions<{
readonly publish: import("./action.js").Action<Schema.Struct<{
readonly name: Schema.String;
readonly text: import("./property.js").Property<string, false, false>;
}>, {
instructions: string;
name: string;
}>;
readonly withdraw: import("./action.js").Action<Schema.Struct<{
readonly name: Schema.String;
}>, {
withdrawn: boolean;
}>;
}, "agent_instructions", {
readonly id: string;
readonly createdAt: string;
readonly updatedAt: string;
readonly createdBy: string | null;
readonly updatedBy: string | null;
readonly name: string;
readonly text: string;
}>, Readonly<Record<never, never>>, "actions">type AgentInstructions = typeof AgentInstructions.Type;
AgentLimitScope
type AgentLimitScope = "turnsPerMinute" | "turnsPerDay" | "newUsersPerHour" | "workspaceTurnsPerDay" | "guestTurnsPerDay" | "guestWorkspaceTurnsPerDay" | "guestUsdPerDay" | "guestWorkspaceUsdPerDay" | "newGuestsPerHour" | "guestEmailCodesPerHour" | "guestSignUpAttemptsPerHour";
AgentLimits
Limits supplied only by the trusted runtime; fixed windows use the database clock.
interface AgentLimits {
readonly perSender: {
readonly turnsPerMinute: number;
readonly turnsPerDay: number;
};
readonly newUsersPerHour: number;
readonly workspaceTurnsPerDay: number;
readonly guest: {
readonly turnsPerDay: number;
readonly workspaceTurnsPerDay: number;
readonly usdPerDay?: number;
readonly workspaceUsdPerDay?: number;
};
}AgentMember
A member as the agent names them: their user's name and the roles they hold now.
interface AgentMember {
readonly name: string;
readonly principal: Principal;
}AgentPairing
A channel account waiting, for ten minutes, for a member to claim it with its pairing code.
interface AgentPairing {
readonly id: string;
readonly provider: string;
readonly externalId: string;
readonly display: string | null;
readonly expiresAt: Date;
}AgentResolution
type AgentResolution = {
readonly status: "existing" | "created";
readonly member: AgentMember;
readonly provisioned: boolean;
readonly counted: boolean;
readonly noticeDue: boolean;
readonly onNewUserPending: boolean;
readonly inbox?: true;
readonly takeover?: true;
} | {
readonly status: "pairing_required";
readonly telegramMiniApp?: true;
} | {
readonly status: "refused";
readonly reason: "blocked" | "inactive";
} | {
readonly status: "limited";
readonly scope: AgentLimitScope;
readonly retryAfterSeconds: number;
readonly notify: boolean;
readonly notificationId?: string;
};AgentReview
const AgentReview: import("./entity.js").Entity<"agent_draft", {
readonly key: import("./property.js").Property<string, false, true>;
readonly channelKind: import("./property.js").Property<string, false, false>;
readonly channel: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
readonly chatId: import("./property.js").Property<string, false, false>;
readonly recipient: import("./property.js").Property<string, false, false>;
readonly to: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
readonly cc: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
readonly participants: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
readonly chatKind: import("./property.js").Property<"private" | "group", false, false>;
readonly threadId: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
readonly replyTo: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
readonly sessionId: import("./property.js").Property<string, false, false>;
readonly turnId: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
readonly basis: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
readonly message: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
readonly draft: import("./property.js").Property<string, false, false>;
readonly files: Schema.optionalKey<import("./property.js").Property<Schema.Json, false, false>>;
readonly text: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
readonly status: import("./property.js").Property<"pending" | "sent" | "failed" | "uncertain" | "rejected" | "dismissed" | "superseded", false, false>;
readonly mode: import("./property.js").Property<"requested" | "always" | "whenUnsure", false, false>;
readonly confidence: Schema.optionalKey<import("./property.js").Property<number, false, false>>;
readonly messageId: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
readonly decidedAt: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
readonly reason: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
readonly note: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
readonly revision: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
readonly revisionState: Schema.optionalKey<import("./property.js").Property<"failed" | "requested", false, false>>;
}, {
readonly person: import("./relationship.js").OneRelationship<false, false, "user">;
readonly decidedBy: import("./relationship.js").OneRelationship<true, false, "user">;
readonly notedBy: import("./relationship.js").OneRelationship<true, false, "user">;
readonly revises: import("./relationship.js").OneRelationship<true, false, "agent_draft">;
readonly agentChat: import("./relationship.js").OneRelationship<true, false, "agent_chat">;
}, import("./entity.js").InvocableActions<{
readonly approve: import("./action.js").Action<Schema.Struct<{
readonly draft: Schema.Codec<string, string, never, never>;
readonly text: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
readonly to: Schema.optionalKey<Schema.$Array<Schema.String>>;
readonly cc: Schema.optionalKey<Schema.$Array<Schema.String>>;
readonly files: Schema.optionalKey<Schema.$Array<Schema.Struct<{
readonly entity: Schema.String;
readonly id: Schema.String;
readonly property: Schema.String;
readonly revisionId: Schema.String;
}>>>;
readonly unlessNewer: Schema.optionalKey<Schema.Boolean>;
}>, {
to?: readonly string[] | undefined;
cc?: readonly string[] | undefined;
draft: string;
review: string;
status: "sent" | "failed" | "uncertain";
message_id: string | null;
duplicate: boolean;
}>;
readonly reject: import("./action.js").Action<Schema.Struct<{
readonly draft: Schema.Codec<string, string, never, never>;
readonly reason: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
}>, {
draft: string;
review: string;
status: "rejected";
}>;
readonly dismiss: import("./action.js").Action<Schema.Struct<{
readonly draft: Schema.Codec<string, string, never, never>;
readonly reason: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
}>, {
draft: string;
status: "dismissed";
}>;
readonly newer: import("./action.js").Action<Schema.Struct<{
readonly drafts: Schema.$Array<Schema.Codec<string, string, never, never>>;
}>, {
drafts: readonly import("./chat.js").DraftNewer[];
}>;
readonly revise: import("./action.js").Action<Schema.Struct<{
readonly draft: Schema.Codec<string, string, never, never>;
readonly note: import("./property.js").Property<string, false, false>;
}>, {
draft: string;
review: string;
revision: string;
status: "requested";
}>;
}, "agent_draft", {
readonly id: string;
readonly createdAt: string;
readonly updatedAt: string;
readonly createdBy: string | null;
readonly updatedBy: string | null;
readonly key: string;
readonly channelKind: string;
readonly channel: string | null;
readonly chatId: string;
readonly recipient: string;
readonly to: string | null;
readonly cc: string | null;
readonly participants: string | null;
readonly chatKind: "private" | "group";
readonly threadId: string | null;
readonly replyTo: string | null;
readonly sessionId: string;
readonly turnId: string | null;
readonly basis: string | null;
readonly message: string | null;
readonly draft: string;
readonly files: Schema.Json;
readonly text: string | null;
readonly status: "pending" | "sent" | "failed" | "uncertain" | "rejected" | "dismissed" | "superseded";
readonly mode: "requested" | "always" | "whenUnsure";
readonly confidence: number | null;
readonly messageId: string | null;
readonly decidedAt: string | null;
readonly reason: string | null;
readonly note: string | null;
readonly revision: string | null;
readonly revisionState: "failed" | "requested" | null;
readonly personId: string;
readonly decidedById: string | null;
readonly notedById: string | null;
readonly revisesId: string | null;
readonly agentChatId: string | null;
}>, Readonly<Record<never, never>>, "actions">type AgentReview = AgentDraft;
AgentStore
Where the app's agent keeps pairing codes and the identities they create: the runtime's agent tables in the workspace database. Codes are stored only as SHA-256 hashes. Expiry is checked against the database's clock; failures are defects.
interface AgentStore {
readonly confirmations?: ConfirmationStore;
readonly savePairing: (pairing: AgentPairing & {
readonly codeHash: string;
}) => Effect.Effect<boolean>;
readonly telegramLaunchPairing?: (id: string, sender: string) => Effect.Effect<{
readonly codeHash: string;
} | undefined>;
readonly findPairing: (codeHash: string) => Effect.Effect<AgentPairing | undefined>;
readonly approvePairing: (input: {
readonly codeHash: string;
readonly userId: string;
readonly identityId: string;
}) => Effect.Effect<AgentIdentity | undefined, IdentityInUse>;
readonly resolveIdentity: (input: ResolveIdentityInput) => Effect.Effect<AgentResolution>;
readonly inboundIdentity?: ReadonlyMap<string, AgentStore["resolveIdentity"]>;
readonly completeLimitNotice: (input: {
readonly notificationId: string;
readonly delivered: boolean;
}) => Effect.Effect<boolean>;
readonly setMemberBlocked: (input: {
readonly id: string;
readonly blocked: boolean;
}) => Effect.Effect<boolean>;
readonly recordNotice: (input: {
readonly provider: string;
readonly externalId: string;
readonly sha256: string;
readonly version?: string;
}) => Effect.Effect<boolean>;
readonly findIdentity: (input: {
readonly provider: string;
readonly externalId: string;
}) => Effect.Effect<AgentIdentity | undefined>;
readonly segmentStreamSubject?: (userId: string, issuer: string) => Effect.Effect<string | undefined>;
readonly listIdentities: (userId: string) => Effect.Effect<ReadonlyArray<AgentIdentity>>;
readonly revokeIdentity: (input: {
readonly id: string;
readonly userId: string;
}) => Effect.Effect<boolean>;
readonly member: (userId: string, provider?: string) => Effect.Effect<AgentMember | undefined>;
readonly actingMember: (userId: string, provider?: string) => Effect.Effect<Principal | undefined>;
readonly channelKind?: (name: string) => string | undefined;
readonly claimChatPersonaNotice?: (id: string, memberId: string) => Effect.Effect<boolean>;
readonly channelGuest?: (channel: string, chat: string, sender: string) => Effect.Effect<Principal | undefined>;
readonly readGroupAccess?: (key: string) => Effect.Effect<string | null>;
readonly readAgentInstructions?: (name: string) => Effect.Effect<{
readonly text: string | null;
readonly publishedAt: string | null;
}>;
readonly readChatPersona?: (key: string) => Effect.Effect<{
readonly persona: string | null;
readonly changedAt: string | null;
readonly registeredAt?: string | null;
}>;
readonly seeChat: (input: {
readonly provider: string;
readonly externalId: string;
readonly title: string;
readonly memberId?: string;
readonly leftMemberId?: string;
readonly agentLeft?: true;
readonly migratedFrom?: string;
readonly registeredBy?: string;
}) => Effect.Effect<SeenChat>;
readonly seeInboxChat?: (input: InboxChatInput) => Effect.Effect<SeenChat | undefined>;
readonly handOffChat: (input: HandoffInput) => Effect.Effect<Handoff | undefined>;
readonly seeGuestChat?: (guestId: string) => Effect.Effect<SeenChat | undefined>;
readonly holdReply?: (input: HeldReplyInput) => Effect.Effect<HeldReview | undefined>;
readonly holdProposal?: (input: HeldReplyInput, delivered: Effect.Effect<boolean>) => Effect.Effect<HeldReview | "delivered" | undefined>;
readonly reserveProposal?: <A, E>(input: {
readonly key: string;
readonly reserve: Effect.Effect<A, E>;
}) => Effect.Effect<{
readonly kind: "reserved";
readonly value: A;
} | {
readonly kind: "held";
readonly review: HeldReview;
}, E>;
readonly holdRevision?: (input: RevisedReplyInput) => Effect.Effect<HeldReview | "discarded" | undefined>;
readonly requestRevision?: (input: {
readonly review: string;
readonly revision: string;
readonly note: string;
readonly notedBy: string;
readonly principal?: Principal;
readonly owner?: ConnectionOwner | undefined;
}) => Effect.Effect<boolean>;
readonly cancelRevision?: (input: {
readonly review: string;
}) => Effect.Effect<boolean>;
readonly reserveDraft?: <A, E>(input: {
readonly review: string;
readonly principalId: string;
readonly unlessNewer: boolean;
readonly reserve: Effect.Effect<A, E>;
readonly claimOf: (reserved: A) => string | undefined;
}) => Effect.Effect<DraftReservation<A>, E>;
readonly draftsNewer?: (drafts: ReadonlyArray<string>) => Effect.Effect<ReadonlyArray<{
readonly draft: string;
readonly newer: boolean | null;
}>>;
readonly failRevision?: (input: {
readonly review: string;
readonly revision: string;
}) => Effect.Effect<boolean>;
readonly purgeDrafts?: (input: {
readonly retentionDays: number;
}) => Effect.Effect<{
readonly deleted: number;
readonly more: boolean;
}>;
readonly sessionReviews?: (sessionId: string) => Effect.Effect<ReadonlyArray<SessionReview>>;
readonly web?: AgentWebStore;
readonly chatMessages?: import("../runtime/chat-messages.js").ChatMessageStore;
}AgentToolVerb
type AgentToolVerb = (typeof AGENT_TOOL_VERBS)[number];
AgentWebStore
The grants through which members reach the app's agent from a browser: ordinary OAuth grants of the first-party client `agent-web`, with ordinary access tokens.
interface AgentWebStore {
readonly issue: (input: {
readonly userId: string;
readonly resource: string;
readonly expiresAt: Date;
}) => Effect.Effect<string | undefined>;
readonly grantMember: (input: {
readonly grantId: string;
readonly userId: string;
readonly evalGrants?: boolean;
}) => Effect.Effect<Principal | undefined>;
readonly issueEval?: (input: {
readonly email: string;
readonly resource: string;
readonly expiresAt: Date;
}) => Effect.Effect<EvalIssue>;
readonly countTurn: (userId: string, limits?: ResolveIdentityInput["limits"]) => Effect.Effect<WebTurnLimit | undefined>;
readonly grantGuest?: (grantId: string) => Effect.Effect<Principal | undefined>;
readonly countGuestTurn?: (guestId: string, limits?: ResolveIdentityInput["limits"], delivery?: string) => Effect.Effect<WebTurnLimit | undefined>;
readonly recordGuestUsage?: (input: {
readonly guestId: string;
readonly costUsd: number;
readonly key: string;
}) => Effect.Effect<void>;
readonly countGuestAttempt?: (input: {
readonly scope: "guestEmailCodesPerHour" | "guestSignUpAttemptsPerHour";
readonly subject: string;
readonly limit: number;
}) => Effect.Effect<number | undefined>;
readonly upgradeGuest?: (input: {
readonly guestId: string;
readonly identity: SignInIdentity;
readonly expiresAt: Date;
}) => Effect.Effect<GuestUpgrade>;
readonly guestEmailMethod?: (email: string) => Effect.Effect<"code" | "link">;
readonly requestGuestLink?: (input: {
readonly guestId: string;
readonly email: string;
readonly returnTo: string | undefined;
readonly nonceHash: string;
readonly expiresAt: Date;
}) => Effect.Effect<void>;
readonly openGuestLink?: (input: {
readonly nonceHash: string;
readonly identity: SignInIdentity;
readonly handoffHash: string;
readonly handoffExpiresAt: Date;
}) => Effect.Effect<GuestLinkOpening>;
readonly takeGuestHandoff?: (input: {
readonly handoffHash: string;
readonly guestId: string;
readonly expiresAt: Date;
}) => Effect.Effect<GuestHandoff>;
readonly guest?: (input: {
readonly resource: string;
readonly client: string;
}) => Effect.Effect<GuestIssue>;
readonly visitor: (input: {
readonly visitorId: string;
readonly resource: string;
readonly client: string;
}) => Effect.Effect<VisitorSignUp>;
}AggregateDeclarations
What an aggregate declares about the rows it reads, beside a metric's options.
interface AggregateDeclarations {
readonly where?: ReadonlyArray<MetricCondition>;
readonly balanceOver?: string;
}AggregateGroupKey
type AggregateGroupKey<P, R> = MetricQueryGroupKey<P, R>;
AggregateOptions
The options of `count`, `sum`, `countDistinct`, `avg`, `min` and `max`: a metric's options with the aggregate's declarations, or the declarations alone for an aggregate that is an argument of arithmetic.
type AggregateOptions = (MetricOptions & AggregateDeclarations) | AggregateDeclarations;
AggregateValue
type AggregateValue = MetricQueryValue;
AlignmentGroup
One group of a model metric's alignment: every entity the metric reads, by its TypeScript name, with its property that stands for the others', or `null` when the entity has no counterpart, as a current snapshot has no date.
type AlignmentGroup = Readonly<Record<string, string | null>>;
AnyAction
Any action, whatever its input and result.
type AnyAction = Action<any, any>;
AnyActionHandle
An authored action handle, `Lead.actions.changeStatus`.
type AnyActionHandle = AnyAction & ActionHandle;
AnyConnectionHandle
Any connection handle. Its context key is invariant in the key, so the key is `any` here.
type AnyConnectionHandle = ConnectionHandle<any>;
AnyEntity
type AnyEntity = AnyStoredEntity | WarehouseBackedEntity<string, any, any, Metrics>;
AnyProperty
Any property, required or optional, as entity `properties` accept it.
type AnyProperty = Property<unknown, boolean, boolean> | Schema.optionalKey<Property<unknown, boolean, boolean>>;
AnyRelationship
type AnyRelationship = OneRelationship | ManyRelationship;
AnyStoredEntity
Any entity, whatever its properties, relationships and actions. The built-in `User` is listed on its own: its member writes make it more than an {@link Entity}, which TypeScript then compares member by member.
type AnyStoredEntity = Entity<string, any, any, any> | UserHandle<any>;
AnyWorkflow
Any workflow, whatever its input.
type AnyWorkflow = Workflow<string, any>;
ApiKeyCredential
An API key, verified: its user's principal, and whether it acts with `delegation`, only for the member each request names, instead of with that principal's roles.
interface ApiKeyCredential {
readonly connection?: {
readonly id: string;
readonly name: string;
};
readonly principal: Principal;
readonly delegation: boolean;
}ApiKeyParts
interface ApiKeyParts {
readonly keyId: string;
readonly secret: string;
}ApiKeySummary
An API key as the platform lists it: everything but the secret.
interface ApiKeySummary {
readonly id: string;
readonly keyId: string;
readonly label: string;
readonly createdAt: string;
readonly revokedAt: string | undefined;
readonly user: {
readonly id: string;
readonly name: string;
readonly active: boolean;
};
readonly roles: ReadonlyArray<string>;
readonly delegation: boolean;
}AppFeedback
Feedback the app's members send its builders through their clients, enabled by default unless `defineOntology({ feedback: false })` disables it. Only the actions below change it; submit always captures the caller the client acts for, including a service with deliberately authored named grants.
const AppFeedback: import("./entity.js").Entity<"app_feedback", {
readonly title: import("./property.js").Property<string, false, false>;
readonly body: import("./property.js").Property<string, false, false>;
readonly status: import("./property.js").Property<"open" | "done" | "declined", false, false>;
readonly response: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
readonly respondedAt: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
readonly seenAt: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
readonly claimedBy: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
readonly claimedUntil: Schema.optionalKey<import("./property.js").Property<string, false, false>>;
}, {
readonly reporter: import("./relationship.js").OneRelationship<false, false, "user">;
}, import("./entity.js").InvocableActions<{
readonly submit: import("./action.js").Action<Schema.Struct<{
readonly title: import("./property.js").Property<string, false, false>;
readonly body: import("./property.js").Property<string, false, false>;
}>, {
feedback: string;
}>;
readonly respond: import("./action.js").Action<Schema.Struct<{
readonly feedback: Schema.Codec<string, string, never, never>;
readonly status: import("./property.js").Property<"done" | "declined", false, false>;
readonly response: import("./property.js").Property<string, false, false>;
}>, {
feedback: string;
}>;
readonly claim: import("./action.js").Action<Schema.Struct<{
readonly feedback: Schema.Codec<string, string, never, never>;
readonly by: import("./property.js").Property<string, false, false>;
readonly minutes: Schema.optional<import("./property.js").Property<number, false, false>>;
}>, {
feedback: string;
claimedBy: string;
claimedUntil: string;
renewed: boolean;
}>;
readonly release: import("./action.js").Action<Schema.Struct<{
readonly feedback: Schema.Codec<string, string, never, never>;
readonly by: import("./property.js").Property<string, false, false>;
}>, {
feedback: string;
released: boolean;
}>;
readonly acknowledge: import("./action.js").Action<Schema.Struct<{
readonly feedback: Schema.Codec<string, string, never, never>;
readonly respondedAt: import("./property.js").Property<string, false, false>;
}>, {
feedback: string;
acknowledged: boolean;
}>;
}, "app_feedback", {
readonly id: string;
readonly createdAt: string;
readonly updatedAt: string;
readonly createdBy: string | null;
readonly updatedBy: string | null;
readonly title: string;
readonly body: string;
readonly status: "open" | "done" | "declined";
readonly response: string | null;
readonly respondedAt: string | null;
readonly seenAt: string | null;
readonly claimedBy: string | null;
readonly claimedUntil: string | null;
readonly reporterId: string;
}>, Readonly<Record<never, never>>, "generated">type AppFeedback = typeof AppFeedback.Type;
AppFeedbackFile
A screenshot, log or document attached to feedback; an item has any number of them.
const AppFeedbackFile: import("./entity.js").Entity<"app_feedback_file", {
readonly file: import("./property.js").Property<{
readonly id: string;
readonly filename: string;
readonly contentType: string;
readonly size: number;
readonly createdAt: string;
}, false, false>;
}, {
readonly feedback: import("./relationship.js").OneRelationship<false, false, "app_feedback">;
}, import("./entity.js").InvocableActions<{
readonly attach: import("./action.js").Action<Schema.Struct<{
readonly feedback: Schema.Codec<string, string, never, never>;
readonly file: Schema.Struct<{
readonly uploadId: Schema.String;
}>;
}>, {
file: string;
}>;
}, "app_feedback_file", {
readonly id: string;
readonly createdAt: string;
readonly updatedAt: string;
readonly createdBy: string | null;
readonly updatedBy: string | null;
readonly file: {
readonly id: string;
readonly filename: string;
readonly contentType: string;
readonly size: number;
readonly createdAt: string;
};
readonly feedbackId: string;
}>, Readonly<Record<never, never>>, "generated">type AppFeedbackFile = typeof AppFeedbackFile.Type;
ApplyMigrationError
type ApplyMigrationError = MigrationRefused | CatalogMismatch | CatalogInvalid | MigrationFailed | SqlError;
ApplyMigrationOptions
interface ApplyMigrationOptions extends CatalogInput {
readonly sql: SqlClient.SqlClient;
readonly statementTimeout?: Duration.Input;
readonly lockTimeout?: Duration.Input;
readonly workspaceId?: string;
}AttachableIdentityProvider
type AttachableIdentityProvider = (typeof ATTACHABLE_IDENTITY_PROVIDERS)[number];
BASE_PATH
The path every ontology route lives under.
const BASE_PATH = "/api/ontology"
BLOB_CONTENT_TYPES
Common content types for file properties; any valid MIME type may be declared.
const BLOB_CONTENT_TYPES: readonly [
"application/pdf",
"image/jpeg",
"image/png",
"text/plain",
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"application/vnd.ms-excel",
"text/csv",
"text/tab-separated-values",
"application/json",
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"application/zip",
"application/octet-stream"
]BatchCreateValues
Create values for a batch: ordinary properties and stored `rel.one` assignments only.
type BatchCreateValues<P, R> = Simplify<Omit<CreateValues<P, R>, UnsupportedBatchKeys<P, R>> & {
readonly [K in UnsupportedBatchKeys<P, R>]?: never;
}>;BatchErrorDetails
Safe batch failure locations: zero-based input indices and wire field names.
const BatchErrorDetails: Schema.Struct<{
readonly indices: Schema.$Array<Schema.Int>;
readonly fields: Schema.optionalKey<Schema.$Array<Schema.String>>;
}>type BatchErrorDetails = typeof BatchErrorDetails.Type;
BatchKey
Ordinary declared properties accepted as upsert keys; unique declarations are checked at runtime.
type BatchKey<P> = Exclude<keyof P & string, BlobKeys<P>>;
BatchOptions
interface BatchOptions {
readonly returning?: BatchReturning;
}BatchRecordResult
One result per input, in input order, including records whose values did not change.
interface BatchRecordResult<R = StoredRecord> extends BatchSummaryResult {
readonly items: ReadonlyArray<{
readonly index: number;
readonly status: "created" | "updated" | "unchanged";
readonly record: R;
}>;
}BatchResult
type BatchResult<R = StoredRecord> = BatchRecordResult<R> | BatchSummaryResult;
BatchReturning
Whether a batch returns its records or only outcome counts. Defaults to `records`.
type BatchReturning = "records" | "summary";
BatchSummaryResult
Outcome counts, which together equal the number of inputs in a successful batch.
interface BatchSummaryResult {
readonly created: number;
readonly updated: number;
readonly unchanged: number;
}BatchUpdateRecord
interface BatchUpdateRecord<P, R> {
readonly id: string;
readonly values: BatchUpdateValues<P, R>;
}BatchUpdateValues
Patch values for a batch. Blob and collection assignments use single-record methods.
type BatchUpdateValues<P, R> = Simplify<Omit<UpdateValues<P, R>, UnsupportedBatchKeys<P, R>> & {
readonly [K in UnsupportedBatchKeys<P, R>]?: never;
}>;BatchUpsertValues
Upsert inputs must explicitly supply non-null values for every selected conflict key.
type BatchUpsertValues<P, R, K extends BatchKey<P>> = Simplify<Omit<BatchCreateValues<P, R>, K> & {
readonly [Key in K]: NonNullable<WriteValueOf<P[Key]>>;
}>;BlobOptions
Property constructors.
interface BlobOptions extends Omit<PropertyOptions<BlobValue>, "default" | "unique"> {
readonly accept?: ReadonlyArray<string>;
readonly maxBytes?: number;
}BlobStorageBinding
Validated deployment binding, independent of the action and browser contracts.
const BlobStorageBinding: Schema.Struct<{
readonly projectId: Schema.String;
readonly branchId: Schema.String;
readonly deploymentId: Schema.optionalKey<Schema.String>;
readonly productionBranchId: Schema.optionalKey<Schema.String>;
readonly endpoint: Schema.String;
readonly region: Schema.String;
readonly bucket: Schema.Literal<"ontology-files">;
readonly accessKeyId: Schema.String;
readonly secretAccessKey: Schema.String;
readonly quotaBytes: Schema.Int;
}>type BlobStorageBinding = typeof BlobStorageBinding.Type;
BlobUpload
const BlobUpload: Schema.Struct<{
readonly uploadId: Schema.String;
}>type BlobUpload = typeof BlobUpload.Type;
BlobValue
Metadata of an immutable file revision. Provider keys and grants never appear in records.
const BlobValue: Schema.Struct<{
readonly id: Schema.String;
readonly filename: Schema.String;
readonly contentType: Schema.String;
readonly size: Schema.Int;
readonly createdAt: Schema.String;
}>type BlobValue = typeof BlobValue.Type;
BrowserSignInMethod
type BrowserSignInMethod = "email" | "segmentstream";
BrowserSignInOptions
Workspace-owned browser authentication policy; omission keeps legacy behavior.
interface BrowserSignInOptions {
readonly methods: ReadonlyArray<BrowserSignInMethod>;
readonly primary: BrowserSignInMethod;
readonly autoRedirect: boolean;
readonly local?: {
readonly port: number;
};
}CHANNEL_PROVIDERS
Channels `signIn.channels` can open; `signUp` replaces it.
const CHANNEL_PROVIDERS: readonly [
"telegram"
]CHAT_CHANNEL_KINDS
The kinds of channel the platform provides, each with a channel named after it.
const CHAT_CHANNEL_KINDS: readonly [
"telegram",
"slack",
"whatsapp",
"email"
]CHAT_CHANNEL_NAME
A channel's name: a lower-case letter, then up to 31 lower-case letters, digits or `_`.
const CHAT_CHANNEL_NAME: RegExp
CHAT_KINDS
Every kind a channel of another name may say: the platform's, and the workspace's own.
const CHAT_KINDS: readonly [
"telegram",
"slack",
"whatsapp",
"email",
"custom"
]CHAT_RETENTION_DAYS
`chat.retentionDays` of `defineOntology`: how many days the workspace keeps its chats' messages, a whole number in this range; 365 when the ontology declares none.
const CHAT_RETENTION_DAYS: {
readonly default: 365;
readonly minimum: 1;
readonly maximum: 3650;
}CONNECTION_ERROR_REASONS
Why a connection call failed, as {@link ConnectionError} carries it: - `authorization_required`: the connection is declared but not configured or authorized yet; - `not_deployed`: the workspace's connection declarations are not deployed; - `not_granted`: the platform refused this service the connection, a platform fault; - `unavailable`: the proxy or the provider could not be reached; retrying may succeed; - `refused`: the provider refused the request in a way retrying will not fix; - `timeout`: the call exceeded its deadline; - `invalid_request`: the proxy refused the request itself, such as a forbidden header or path; - `invalid_response`: the response did not match the schema given to `json`; - `owner_required`: the connection is owned (`owner: "user"`) and the code runs as nobody whose credential it may use, such as a workflow run with no owner, a service or a guest, or a key the run's workflow does not list; - `background_consent_required`: the owner has not allowed their credential to be used while nobody is asking for the work.
const CONNECTION_ERROR_REASONS: readonly [
"authorization_required",
"not_deployed",
"not_granted",
"unavailable",
"refused",
"timeout",
"invalid_request",
"invalid_response",
"owner_required",
"background_consent_required"
]CONNECTION_KEY
A connection key, as `connections/connections.py` declares it.
const CONNECTION_KEY: RegExp
CONNECTION_METHODS
const CONNECTION_METHODS: readonly [
"GET",
"POST",
"PUT",
"PATCH",
"DELETE",
"HEAD",
"OPTIONS"
]CatalogInput
interface CatalogInput {
readonly sql: SqlClient.SqlClient;
}CatalogInvalid
The `_ontology` row cannot be read as a manifest.
class CatalogInvalid extends CatalogInvalid_base {
}CatalogMismatch
The applied manifest is not the one the plan was made from: another migration ran in between, or the plan was made against another database. Nothing was applied.
class CatalogMismatch extends CatalogMismatch_base {
}Change
One property's change. A relationship's change carries record ids.
const Change: Schema.Struct<{
readonly before: Schema.Codec<Schema.Json, Schema.Json, never, never>;
readonly after: Schema.Codec<Schema.Json, Schema.Json, never, never>;
}>type Change = typeof Change.Type;
ChangedBounds
The bounds of {@link changed}: the value before, the value after, or both.
interface ChangedBounds<V> {
readonly from?: V | null;
readonly to?: V | null;
}ChannelAppProvider
Verified provider facts only; admission and session issuance remain provider-independent.
interface ChannelAppProvider {
readonly provider: string;
readonly verify: (assertion: string, ctx: {
readonly connections: ConnectionTransport["Service"];
}) => Effect.Effect<Omit<ChannelSignInInput, "provider"> | undefined>;
}ChannelProvider
type ChannelProvider = (typeof CHANNEL_PROVIDERS)[number];
ChannelSignInInput
Verified provider facts only; channel-app callers cannot submit policy or bot-turn fields.
type ChannelSignInInput = Pick<ResolveIdentityInput, "provider" | "externalId" | "display" | "username">;
ChatChannelConfig
One channel of `chat`, by name: the channel named after its kind, or one that says its kind. A channel the workspace defines in its own code says `kind: "custom"` and takes no connection: the agent sends through it, with the connection `agent/segmentstream.json` gives it.
interface ChatChannelConfig {
readonly kind?: ChatKind;
readonly connection?: AnyConnectionHandle;
readonly files?: ChatFilesConfig;
readonly signature?: boolean;
}ChatChannelKind
type ChatChannelKind = (typeof CHAT_CHANNEL_KINDS)[number];
ChatConfig
`chat` of {@link OntologyConfig}: the agent's channels by name, the post attribution, and how long the workspace keeps its chats' messages.
interface ChatConfig {
readonly telegram?: {
readonly connection: AnyConnectionHandle;
readonly files?: ChatFilesConfig;
};
readonly slack?: {
readonly connection: AnyConnectionHandle;
readonly files?: ChatFilesConfig;
};
readonly whatsapp?: {
readonly connection: AnyConnectionHandle;
readonly files?: ChatFilesConfig;
};
readonly email?: {
readonly connection: AnyConnectionHandle;
readonly files?: ChatFilesConfig;
readonly signature?: boolean;
};
readonly attribution?: ChatAttributionSettings;
readonly retentionDays?: number;
readonly [name: string]: ChatChannelConfig | ChatAttributionSettings | number | undefined;
}ChatDelivery
Deliver the exact Markdown source through the channel renderer, without invoking an agent; and hand a reply the agent held for review back to the agent to redraft.
class ChatDelivery extends ChatDelivery_base {
}ChatDraftInput
A request that the agent draft a reply in a person's private chat, held for a member.
interface ChatDraftInput {
readonly chat: string;
readonly message?: string;
readonly note?: string;
}ChatDraftResult
The draft the agent started: it is held as an `agent_draft` keyed `key` once written.
interface ChatDraftResult {
readonly request: string;
readonly key: string;
readonly message: string;
}ChatFilesConfig
`files` of a chat channel: whether its chats keep their files with their messages.
interface ChatFilesConfig {
readonly keep?: boolean;
}ChatHistoryImportInput
const ChatHistoryImportInput: Schema.Struct<{
readonly chat: Schema.optionalKey<Schema.String>;
readonly channel: Schema.optionalKey<Schema.String>;
readonly chatId: Schema.optionalKey<Schema.String>;
readonly kind: Schema.optionalKey<Schema.Literals<readonly [
"private",
"group"
]>>;
readonly thread: Schema.optionalKey<Schema.String>;
readonly person: Schema.optionalKey<Schema.String>;
readonly messages: Schema.$Array<Schema.Struct<{
readonly id: Schema.String;
readonly at: Schema.String;
readonly direction: Schema.Literals<readonly [
"inbound",
"outbound"
]>;
readonly by: Schema.optionalKey<Schema.Literals<readonly [
"human",
"agent",
"bot"
]>>;
readonly name: Schema.optionalKey<Schema.String>;
readonly text: Schema.optionalKey<Schema.String>;
readonly replyTo: Schema.optionalKey<Schema.String>;
readonly files: Schema.optionalKey<Schema.$Array<Schema.Struct<{
readonly upload: Schema.Struct<{
readonly uploadId: Schema.String;
}>;
}>>>;
}>>;
}>type ChatHistoryImportInput = typeof ChatHistoryImportInput.Type;
ChatHistoryImportResult
const ChatHistoryImportResult: Schema.Struct<{
readonly imported: Schema.Number;
readonly duplicates: Schema.Number;
readonly skipped: Schema.Number;
readonly expired: Schema.Number;
}>type ChatHistoryImportResult = typeof ChatHistoryImportResult.Type;
ChatHistoryMessage
One message of a chat from before the agent's archive recorded it, as the workspace kept it.
const ChatHistoryMessage: Schema.Struct<{
readonly id: Schema.String;
readonly at: Schema.String;
readonly direction: Schema.Literals<readonly [
"inbound",
"outbound"
]>;
readonly by: Schema.optionalKey<Schema.Literals<readonly [
"human",
"agent",
"bot"
]>>;
readonly name: Schema.optionalKey<Schema.String>;
readonly text: Schema.optionalKey<Schema.String>;
readonly replyTo: Schema.optionalKey<Schema.String>;
readonly files: Schema.optionalKey<Schema.$Array<Schema.Struct<{
readonly upload: Schema.Struct<{
readonly uploadId: Schema.String;
}>;
}>>>;
}>type ChatHistoryMessage = typeof ChatHistoryMessage.Type;
ChatKind
type ChatKind = (typeof CHAT_KINDS)[number];
ChatMessagesInput
`agent_chat.messages`: one chat's messages, in order, a page at a time.
const ChatMessagesInput: Schema.Struct<{
readonly chat: Schema.String;
readonly before: Schema.optionalKey<Schema.String>;
readonly after: Schema.optionalKey<Schema.String>;
readonly limit: Schema.optionalKey<Schema.Int>;
readonly internal: Schema.optionalKey<Schema.Boolean>;
}>type ChatMessagesInput = typeof ChatMessagesInput.Type;
ChatMessagesPage
A page of a chat's messages, newest first unless read `after` a revision: each event carries the message's id, author, sender and text as the chat store or the archive keeps them, provider and imported ids as opaque strings; `nextCursor` continues it, `null` at its end.
const ChatMessagesPage: Schema.Struct<{
readonly events: Schema.$Array<Schema.$Record<Schema.String, Schema.Unknown>>;
readonly nextCursor: Schema.NullOr<Schema.String>;
}>type ChatMessagesPage = typeof ChatMessagesPage.Type;
ChatPostInput
A text post in the caller's own voice, signed with their name, as `agent_chat.previewMessage` renders it: what `agent_chat.send` takes with `as: "me"`, without a template or buttons.
const ChatPostInput: Schema.Struct<{
readonly chat: Schema.String;
readonly text: Schema.String;
readonly replyTo: Schema.optionalKey<Schema.String>;
readonly files: Schema.optionalKey<Schema.$Array<Schema.Struct<{
readonly entity: Schema.String;
readonly id: Schema.String;
readonly property: Schema.optionalKey<Schema.String>;
}>>>;
readonly idempotencyKey: Schema.String;
}>type ChatPostInput = typeof ChatPostInput.Type;
ChatPostResult
const ChatPostResult: Schema.Struct<{
readonly status: Schema.Literals<readonly [
"sent",
"uncertain"
]>;
readonly message_id: Schema.NullOr<Schema.String>;
readonly url: Schema.NullOr<Schema.String>;
readonly duplicate: Schema.Boolean;
readonly history_recorded: Schema.Boolean;
}>type ChatPostResult = typeof ChatPostResult.Type;
ChatProvenance
The chat the app's agent acted in, as the chat archive names it, and the agent's session there. Only the deployment's own agent runtime reports it; a web chat is checked against the member or guest it acts for.
interface ChatProvenance {
readonly provider: string;
readonly chatId: string;
readonly sessionId?: string;
}ChatSearchMessagesInput
`agent_chat.searchMessages`: the chats' messages that match, across chats or within one.
const ChatSearchMessagesInput: Schema.Struct<{
readonly q: Schema.optionalKey<Schema.String>;
readonly provider: Schema.optionalKey<Schema.String>;
readonly chatId: Schema.optionalKey<Schema.String>;
readonly threadId: Schema.optionalKey<Schema.String>;
readonly senderId: Schema.optionalKey<Schema.String>;
readonly from: Schema.optionalKey<Schema.String>;
readonly to: Schema.optionalKey<Schema.String>;
readonly before: Schema.optionalKey<Schema.String>;
readonly limit: Schema.optionalKey<Schema.Int>;
}>type ChatSearchMessagesInput = typeof ChatSearchMessagesInput.Type;
ChatSendInput
What `agent_chat.send` takes: a message's text, or on WhatsApp an approved template instead, in the voice `as` names.
const ChatSendInput: Schema.Struct<{
readonly telegramHtml: Schema.optionalKey<Schema.String>;
readonly chat: Schema.String;
readonly text: Schema.optionalKey<Schema.String>;
readonly template: Schema.optionalKey<Schema.Struct<{
readonly name: Schema.String;
readonly language: Schema.String;
readonly parameters: Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>;
readonly header: Schema.optionalKey<Schema.Struct<{
readonly parameters: Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>;
readonly media: Schema.optionalKey<Schema.Struct<{
readonly url: Schema.optionalKey<Schema.String>;
readonly file: Schema.optionalKey<Schema.Struct<{
readonly entity: Schema.String;
readonly id: Schema.String;
readonly property: Schema.optionalKey<Schema.String>;
}>>;
readonly filename: Schema.optionalKey<Schema.String>;
}>>;
}>>;
readonly buttons: Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>;
}>>;
readonly replyTo: Schema.optionalKey<Schema.String>;
readonly buttons: Schema.optionalKey<Schema.$Array<Schema.$Array<Schema.Union<readonly [
Schema.Struct<{
readonly url: Schema.String;
readonly text: Schema.String;
readonly style: Schema.optionalKey<Schema.Literals<readonly [
"primary",
"success",
"danger"
]>>;
}>,
Schema.Struct<{
readonly token: Schema.String;
readonly text: Schema.String;
readonly style: Schema.optionalKey<Schema.Literals<readonly [
"primary",
"success",
"danger"
]>>;
}>,
Schema.Struct<{
readonly copyText: Schema.String;
readonly text: Schema.String;
readonly style: Schema.optionalKey<Schema.Literals<readonly [
"primary",
"success",
"danger"
]>>;
}>
]>>>>;
readonly files: Schema.optionalKey<Schema.$Array<Schema.Struct<{
readonly entity: Schema.String;
readonly id: Schema.String;
readonly property: Schema.optionalKey<Schema.String>;
}>>>;
readonly to: Schema.optionalKey<Schema.$Array<Schema.String>>;
readonly cc: Schema.optionalKey<Schema.$Array<Schema.String>>;
readonly as: Schema.optionalKey<Schema.Literals<readonly [
"agent",
"me"
]>>;
readonly idempotencyKey: Schema.String;
}>type ChatSendInput = typeof ChatSendInput.Type;
ChatTemplate
A WhatsApp template message: an approved template by name and language, with its values.
const ChatTemplate: Schema.Struct<{
readonly name: Schema.String;
readonly language: Schema.String;
readonly parameters: Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>;
readonly header: Schema.optionalKey<Schema.Struct<{
readonly parameters: Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>;
readonly media: Schema.optionalKey<Schema.Struct<{
readonly url: Schema.optionalKey<Schema.String>;
readonly file: Schema.optionalKey<Schema.Struct<{
readonly entity: Schema.String;
readonly id: Schema.String;
readonly property: Schema.optionalKey<Schema.String>;
}>>;
readonly filename: Schema.optionalKey<Schema.String>;
}>>;
}>>;
readonly buttons: Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>;
}>type ChatTemplate = typeof ChatTemplate.Type;
ChatTemplateMedia
The file of a template's image, video or document header, where it is stored or served.
const ChatTemplateMedia: Schema.Struct<{
readonly url: Schema.optionalKey<Schema.String>;
readonly file: Schema.optionalKey<Schema.Struct<{
readonly entity: Schema.String;
readonly id: Schema.String;
readonly property: Schema.optionalKey<Schema.String>;
}>>;
readonly filename: Schema.optionalKey<Schema.String>;
}>type ChatTemplateMedia = typeof ChatTemplateMedia.Type;
CommittedAction
An action that committed, as after-commit effects receive it.
interface CommittedAction {
readonly entity: string;
readonly action: string;
readonly actionId: string;
readonly principal: Principal;
readonly input: unknown;
readonly result: unknown;
readonly edits: ReadonlyArray<Edit>;
}ConfirmContext
What an action's `confirm` runs with.
interface ConfirmContext<Input> {
readonly input: Input;
readonly principal: Principal;
readonly locale: string;
readonly requestId: string;
}ConfirmationFact
One thing a person checks before they confirm, such as the document, a signer or an amount.
const ConfirmationFact: Schema.Struct<{
readonly icon: Schema.optionalKey<Schema.String>;
readonly text: Schema.String;
readonly url: Schema.optionalKey<Schema.String>;
}>type ConfirmationFact = typeof ConfirmationFact.Type;
Conflict
The write conflicts with existing data, for example a duplicate value of a unique property.
class Conflict extends Conflict_base {
}Connection
The requirement of a connection handle's calls. `prepare` has exactly the connections its action declares, so calling an undeclared one does not type-check.
interface Connection<Key extends string> {
readonly "~connection": Key;
}ConnectionAudit
Who a connection call is made for. SegmentStream logs these; it never trusts them.
interface ConnectionAudit {
readonly action: string;
readonly principalId: string;
readonly requestId: string;
}ConnectionCall
One HTTP request through the connection proxy, before it is bound to a connection key.
interface ConnectionCall {
readonly api?: string;
readonly method: ConnectionMethod;
readonly path: string;
readonly headers: ReadonlyArray<readonly [
string,
string
]>;
readonly body: Uint8Array;
readonly file?: FileRange;
readonly source?: FileSource;
}ConnectionCallKind
`interactive` when a person asked for the work, such as an action they called; `background` when nobody did.
type ConnectionCallKind = "interactive" | "background";
ConnectionClient
The service behind {@link Connection}: the transport, bound to one connection key.
interface ConnectionClient {
readonly request: (call: ConnectionCall) => Effect.Effect<ConnectionReply, ConnectionError>;
readonly stream?: (call: ConnectionCall) => Effect.Effect<ConnectionStreamReply, ConnectionError, Scope.Scope>;
}ConnectionError
A connection call failed. A provider's non-2xx status is a response, not this error. `prepare` may catch it; if it escapes, the action responds with the matching status and writes nothing.
class ConnectionError extends ConnectionError_base {
}ConnectionErrorReason
type ConnectionErrorReason = (typeof CONNECTION_ERROR_REASONS)[number];
ConnectionHandle
A workspace connection an action may call, declared once in `ontology/` with `connection(key, { description })` and listed in the actions that use it. Calls go through SegmentStream's connection proxy, so the provider's credentials never reach the deployment.
interface ConnectionHandle<Key extends string = string> {
readonly [ConnectionTypeId]: typeof ConnectionTypeId;
readonly key: Key;
readonly description: string;
readonly delivers: boolean;
readonly owner?: "user";
readonly service: Context.Service<Connection<Key>, ConnectionClient>;
request(request: ConnectionRequest): Call<Key>;
stream(request: ConnectionRequest): Effect.Effect<ConnectionStreamResponse, ConnectionError, Connection<Key> | Scope.Scope>;
get(path: string, options?: ConnectionRequestOptions): Call<Key>;
post(path: string, options?: ConnectionRequestOptions): Call<Key>;
put(path: string, options?: ConnectionRequestOptions): Call<Key>;
patch(path: string, options?: ConnectionRequestOptions): Call<Key>;
delete(path: string, options?: ConnectionRequestOptions): Call<Key>;
}ConnectionHeaders
type ConnectionHeaders = Readonly<Record<string, string>> | ReadonlyArray<readonly [
string,
string
]>;ConnectionManifest
A workspace connection the ontology's actions call, by its key in `connections/connections.py`.
const ConnectionManifest: Schema.Struct<{
readonly key: Schema.String;
readonly description: Schema.String;
readonly delivers: Schema.optionalKey<Schema.Literal<true>>;
readonly owner: Schema.optionalKey<Schema.Literal<"user">>;
}>type ConnectionManifest = typeof ConnectionManifest.Type;
ConnectionMethod
type ConnectionMethod = (typeof CONNECTION_METHODS)[number];
ConnectionOptions
interface ConnectionOptions {
readonly description: string;
readonly delivers?: boolean;
readonly owner?: "user";
}ConnectionReply
What the proxy answered: the provider's status, headers and buffered body.
interface ConnectionReply {
readonly status: number;
readonly headers: ReadonlyArray<readonly [
string,
string
]>;
readonly body: Uint8Array;
}ConnectionRequest
interface ConnectionRequest extends ConnectionRequestOptions {
readonly method: ConnectionMethod;
readonly path: string;
}ConnectionRequestOptions
The options of `request` and the method helpers.
interface ConnectionRequestOptions {
readonly api?: string;
readonly query?: Readonly<Record<string, QueryValue | undefined>>;
readonly headers?: ConnectionHeaders;
readonly json?: unknown;
readonly form?: Readonly<Record<string, string>>;
readonly body?: string | Uint8Array;
readonly file?: FileRange;
}ConnectionResponse
A buffered provider response.
interface ConnectionResponse {
readonly status: number;
readonly ok: boolean;
readonly headers: ReadonlyArray<readonly [
string,
string
]>;
readonly body: Uint8Array;
readonly text: string;
header(name: string): string | undefined;
json<S extends Schema.Top>(schema: S): Effect.Effect<S["Type"], ConnectionError, S["DecodingServices"]>;
}ConnectionStreamReply
A provider response whose body is consumed within the caller's scope.
interface ConnectionStreamReply {
readonly status: number;
readonly headers: ReadonlyArray<readonly [
string,
string
]>;
readonly body: Stream.Stream<Uint8Array, ConnectionError>;
}ConnectionStreamResponse
interface ConnectionStreamResponse extends ConnectionStreamReply {
readonly ok: boolean;
header(name: string): string | undefined;
}ConnectionStub
type ConnectionStub = (request: StubRequest, selection?: StubSelection) => Effect.Effect<StubResponse | ConnectionReply, ConnectionError>;
ConnectionTransport
Sends connection calls: to backend-next from a deployed service, to the local route with a CLI grant in development, or to stubs in tests. The ontology service provides it to actions; tests provide {@link Connections.test}.
class ConnectionTransport extends ConnectionTransport_base {
}ConnectionTransportFactory
Builds the transport of one action request.
type ConnectionTransportFactory = ((input: {
readonly identityToken: string | undefined;
readonly audit: ConnectionAudit;
}) => ConnectionTransport["Service"]) & {
readonly retirement?: (identityToken: string | undefined) => OwnedConnectionRetirement["Service"];
};Connections
const Connections: {
test: (stubs: Readonly<Record<string, ConnectionStub>>, options?: TestConnectionsOptions) => Layer.Layer<ConnectionTransport>;
}ConnectionsOf
The requirements of the handles in a list: `Connection<"apollo"> | Connection<"stripe">`.
type ConnectionsOf<C extends ReadonlyArray<AnyConnectionHandle>> = C[number] extends infer H ? H extends ConnectionHandle<infer Key> ? Connection<Key> : never : never;
CreateManyInput
Raw batch inputs use wire entity and field names.
interface CreateManyInput extends BatchOptions {
readonly entity: string;
readonly records: ReadonlyArray<StoredValues>;
}CreateValues
Values for `create` and `upsertBy`. Properties without a default are required unless optional; relationships take ids by relationship name (`{ lead: lead.id }`), `rel.many` a list of ids.
type CreateValues<P, R> = Simplify<{
readonly [K in RequiredPropertyKeys<P>]: WriteValueOf<P[K]>;
} & {
readonly [K in Exclude<keyof P, RequiredPropertyKeys<P>>]?: WriteValueOf<P[K]>;
} & {
readonly [K in RequiredOneKeys<R>]: string;
} & {
readonly [K in Exclude<OneKeys<R>, RequiredOneKeys<R>>]?: string | null;
} & {
readonly [K in ManyKeys<R>]?: ReadonlyArray<string>;
}>;CreatedApiKey
interface CreatedApiKey {
readonly id: string;
readonly key: string;
}CronOptions
interface CronOptions<Input = unknown> extends TriggerRuns {
readonly description: string;
readonly input?: Input;
}CronProblem
Which field of a cron expression does not parse.
type CronProblem = "fields" | "minute" | "hour" | "day_of_month" | "month" | "day_of_week" | "both_days";
CronTrigger
A cron trigger, `cron(name, expression, { description, input })`: the platform writes it into the workspace deployment's crons, and each invocation starts the workflow with `input`. Five fields, read in UTC.
interface CronTrigger<Name extends string = string, Input = unknown> {
readonly [WorkflowTriggerTypeId]: typeof WorkflowTriggerTypeId;
readonly kind: "cron";
readonly name: Name;
readonly description: string;
readonly cron: string;
readonly input: Input | undefined;
readonly runs?: AnyActionHandle | undefined;
readonly role?: string | undefined;
}CronTriggerManifest
A cron trigger of a workflow: the platform writes a Vercel cron for it, whose invocation starts the workflow with `input`, the wire form of the workflow's input, sent as it is.
const CronTriggerManifest: Schema.Struct<{
readonly kind: Schema.Literal<"cron">;
readonly name: Schema.String;
readonly description: Schema.String;
readonly cron: Schema.String;
readonly input: Schema.Codec<Schema.Json, Schema.Json, never, never>;
}>type CronTriggerManifest = typeof CronTriggerManifest.Type;
CurrentPrincipal
The principal the request runs as, provided by {@link Authentication}.
class CurrentPrincipal extends CurrentPrincipal_base {
}DEFAULT_AGENT_LIMITS
The limits that apply where the agent sets none, shared by bot resolution and other trusted channel admission boundaries. `newUsersPerHour` is the agent's `signUpsPerHour`, under the name the protocol keeps.
const DEFAULT_AGENT_LIMITS: AgentLimits
DEFAULT_MEMBER_PERMISSIONS
What the deprecated `member` export grants: reading everything.
const DEFAULT_MEMBER_PERMISSIONS: ReadonlyArray<string>
DEFAULT_QUERY_LIMIT
The query language of `find` and of the HTTP API's list and query endpoints. ```json { "where": { "status": { "in": ["new", "contacted"] }, "owner": { "email": { "eq": "ada@example.com" } }, "tags": { "some": { "name": { "eq": "priority" } } }, "or": [{ "fitScore": { "gte": 80 } }, { "source": "pilot_request" }] }, "orderBy": [{ "field": "created_at", "direction": "desc" }], "include": ["owner"], "limit": 50 } ``` {@link Query} checks the structure for any entity; {@link entityQuerySchema} builds the precise schema of one entity from the manifest, with its fields, their operators and its relationships. The runtime validates every query with the precise schema. `include` also takes the object form `{ "owner": true }`, which a list of names decodes into.
const DEFAULT_QUERY_LIMIT = 50
DEFAULT_SIGN_IN_POLICY
An internal app is closed by default: a person enters by invitation.
const DEFAULT_SIGN_IN_POLICY: SignInPolicy
DIAGNOSTIC_CODES
const DIAGNOSTIC_CODES: readonly [
"invalid-source",
"missing-column",
"invalid-column",
"invalid-scope",
"invalid-scope-path",
"scope-reads-all",
"scope-unused",
"scope-member-overlap",
"source-with-actions",
"source-with-index",
"invalid-metric",
"unknown-metric",
"circular-metric",
"invalid-join",
"missing-join",
"invalid-entity",
"invalid-property",
"invalid-relationship",
"invalid-actions",
"invalid-action",
"invalid-action-input",
"invalid-role",
"invalid-name",
"reserved-name",
"duplicate-name",
"invalid-entity-id",
"duplicate-entity-id",
"missing-label",
"missing-description",
"invalid-title",
"invalid-options",
"invalid-default",
"invalid-constraint",
"unknown-relationship-target",
"inverse-collision",
"invalid-on-delete",
"invalid-phrase",
"invalid-index",
"unknown-reference",
"invalid-renamed-from",
"earlier-name",
"invalid-guide",
"invalid-writes",
"invalid-erasure",
"generated-update-empty",
"managed-without-effect",
"missing-permissions",
"invalid-permission",
"unknown-permission",
"removed-allow",
"unreachable-action",
"wildcard-permission",
"invalid-sign-in",
"invalid-inbox",
"invalid-chat",
"invalid-connection",
"invalid-feedback",
"invalid-discovery",
"invalid-email",
"feedback-unanswerable",
"feedback-unreportable",
"agent-tools-implicit",
"named-secret-deprecated",
"unknown-connection",
"unused-connection",
"invalid-prepare",
"invalid-tool-name",
"invalid-toolset",
"toolset-lock-mismatch",
"toolset_connection_owned",
"invalid-alignment",
"single-entity-model-metric",
"invalid-workflow",
"workflow_role_unknown",
"workflow_role_is_member",
"workflow_role_grants_nothing",
"workflow_role_wildcard",
"workflow_role_scoped",
"workflow_cron_never_fires",
"workflow_input_invalid",
"workflow_cron_invalid",
"workflow_run_missing",
"invalid-trigger",
"trigger_action_unknown",
"trigger_function_async",
"trigger_runs_invalid",
"workflow_trigger_limit_exceeded",
"workflow_webhook_duplicate",
"workflow_webhook_input_invalid",
"workflow_webhook_mixed_triggers",
"workflow_webhook_signature_invalid",
"workflow_webhook_verification_invalid",
"workflow_webhook_headers_invalid",
"workflow_webhook_limit_exceeded",
"workflow_owned_connection_webhook",
"platform_event_unknown",
"platform_trigger_owned"
]Decide
The probability of "yes" by question id, for every question asked.
type Decide = (request: DecisionRequest) => Promise<Readonly<Record<string, number>>>;
DecisionRequest
Yes-or-no questions about one shared state, answered by a decision model on AI Gateway, such as TypeSafe's Jev: each answer is the probability of "yes". The SDK asks them to rank `discover`'s entities by meaning, when the ontology opts in with `discovery: { model }`.
interface DecisionRequest {
readonly model: string;
readonly state: string;
readonly questions: Readonly<Record<string, string>>;
readonly signal?: AbortSignal;
}DeploymentAdmissionCode
type DeploymentAdmissionCode = "preview_configuration_invalid" | "preview_expired" | "preview_capability_unavailable" | "preview_authentication_unavailable" | "preview_deployment_mismatch" | "preview_storage_binding_invalid";
DeploymentAdmissionError
Stable codes only: workspace code owns explanations and presentation.
class DeploymentAdmissionError extends Error {
readonly code: DeploymentAdmissionCode;
readonly capability?: keyof DeploymentCapabilities | undefined;
readonly _tag = "DeploymentAdmissionError";
constructor(code: DeploymentAdmissionCode, capability?: keyof DeploymentCapabilities | undefined);
get status(): number;
}DeploymentCapabilities
Runtime observations; authorization of the machine credential remains platform-owned.
interface DeploymentCapabilities {
readonly warehouseRead: boolean;
readonly pipelineRuns: boolean;
readonly connections: boolean;
readonly agents: boolean;
readonly workflows: boolean;
}DeploymentInterrupted
This deployment cannot safely execute against the applied catalog. Retrying cannot repair it.
class DeploymentInterrupted extends DeploymentInterrupted_base {
}DeploymentObservation
type DeploymentObservation = {
readonly target: "production";
readonly deploymentId?: string;
readonly capabilities: DeploymentCapabilities;
} | {
readonly target: "preview";
readonly deploymentId: string;
readonly expiresAt: string;
readonly host?: "local";
readonly agent?: true;
readonly capabilities: DeploymentCapabilities;
};DeploymentSwitching
A bounded deployment transition, which ontology SDKs 0.86.0 to 0.88.0 raised while their deploy guard paused workflow starts. Nothing raises it now; it is kept to read their recorded failures.
class DeploymentSwitching extends DeploymentSwitching_base {
}DeriveApiOptions
interface DeriveApiOptions {
readonly generatedActions?: GeneratedActionsProvider;
}DevicePoll
type DevicePoll = {
readonly status: "approved";
readonly device: OAuthDevice;
} | {
readonly status: "authorization_pending" | "slow_down" | "access_denied" | "expired_token" | "invalid_grant";
};Diagnostic
A problem `check` found in an ontology definition.
const Diagnostic: Schema.Struct<{
readonly severity: Schema.Literals<readonly [
"error",
"warning",
"info"
]>;
readonly code: Schema.Literals<readonly [
"invalid-source",
"missing-column",
"invalid-column",
"invalid-scope",
"invalid-scope-path",
"scope-reads-all",
"scope-unused",
"scope-member-overlap",
"source-with-actions",
"source-with-index",
"invalid-metric",
"unknown-metric",
"circular-metric",
"invalid-join",
"missing-join",
"invalid-entity",
"invalid-property",
"invalid-relationship",
"invalid-actions",
"invalid-action",
"invalid-action-input",
"invalid-role",
"invalid-name",
"reserved-name",
"duplicate-name",
"invalid-entity-id",
"duplicate-entity-id",
"missing-label",
"missing-description",
"invalid-title",
"invalid-options",
"invalid-default",
"invalid-constraint",
"unknown-relationship-target",
"inverse-collision",
"invalid-on-delete",
"invalid-phrase",
"invalid-index",
"unknown-reference",
"invalid-renamed-from",
"earlier-name",
"invalid-guide",
"invalid-writes",
"invalid-erasure",
"generated-update-empty",
"managed-without-effect",
"missing-permissions",
"invalid-permission",
"unknown-permission",
"removed-allow",
"unreachable-action",
"wildcard-permission",
"invalid-sign-in",
"invalid-inbox",
"invalid-chat",
"invalid-connection",
"invalid-feedback",
"invalid-discovery",
"invalid-email",
"feedback-unanswerable",
"feedback-unreportable",
"agent-tools-implicit",
"named-secret-deprecated",
"unknown-connection",
"unused-connection",
"invalid-prepare",
"invalid-tool-name",
"invalid-toolset",
"toolset-lock-mismatch",
"toolset_connection_owned",
"invalid-alignment",
"single-entity-model-metric",
"invalid-workflow",
"workflow_role_unknown",
"workflow_role_is_member",
"workflow_role_grants_nothing",
"workflow_role_wildcard",
"workflow_role_scoped",
"workflow_cron_never_fires",
"workflow_input_invalid",
"workflow_cron_invalid",
"workflow_run_missing",
"invalid-trigger",
"trigger_action_unknown",
"trigger_function_async",
"trigger_runs_invalid",
"workflow_trigger_limit_exceeded",
"workflow_webhook_duplicate",
"workflow_webhook_input_invalid",
"workflow_webhook_mixed_triggers",
"workflow_webhook_signature_invalid",
"workflow_webhook_verification_invalid",
"workflow_webhook_headers_invalid",
"workflow_webhook_limit_exceeded",
"workflow_owned_connection_webhook",
"platform_event_unknown",
"platform_trigger_owned"
]>;
readonly path: Schema.String;
readonly message: Schema.String;
}>type Diagnostic = typeof Diagnostic.Type;
DiagnosticCode
type DiagnosticCode = (typeof DIAGNOSTIC_CODES)[number];
DiscoveryOptions
How `discover` ranks entities: see {@link OntologyConfig.discovery}.
interface DiscoveryOptions {
readonly model: string;
}DraftEntity
An entity as `entity()` returns it: no actions yet, and `actions` is the builder that adds them. It has no keys, so it reads as an empty set of actions.
type DraftEntity<Name extends string, P extends Properties, R extends Relationships, M extends Metrics = Metrics, W extends EntityWrites = EntityWrites> = Entity<Name, P, R, ActionsBuilder<Name, P, R, M, W>, M, W>;
DraftNewer
Whether the person wrote after a draft's turn; `null` when it cannot be told.
interface DraftNewer {
readonly draft: string;
readonly newer: boolean | null;
}acceptingEarlierManifestNames
A manifest schema that reads documents of every version: each is renamed with {@link withCurrentManifestNames} before the schema decodes it. Being a declaration, it keeps doing so on its type side, so `Schema.toType` of it accepts the earlier names too.
function acceptingEarlierManifestNames<S extends Schema.Top>(schema: S): Schema.declareConstructor<S["Type"], S["Encoded"], readonly [
S
]>;acceptingEarlierMetricQueryNames
A metric query schema that also reads the earlier names older app SDKs send, through {@link withCurrentMetricQueryNames}, and refuses a request that uses both names for one field. Its type side is `schema` itself, which documents the current names only.
function acceptingEarlierMetricQueryNames<S extends Schema.Top>(schema: S): Schema.decodeTo<S, Schema.Unknown, never, never>;
action
function action<Input extends Schema.Top, Result>(config: ActionConfig<Input, Result>): Action<Input, Result>;
function action<Input extends Schema.Top, const C extends ReadonlyArray<AnyConnectionHandle>, Prepared>(config: ActionConfigWithConnections<Input, C, Prepared, never> & {
readonly handler?: undefined;
}): Action<Input, Prepared>;function action<Input extends Schema.Top, const C extends ReadonlyArray<AnyConnectionHandle>, Prepared, Result>(config: ActionConfigWithConnections<Input, C, Prepared, Result>): Action<Input, Result>;
actionConnectionKeys
The keys of every connection the manifest's actions and toolsets call, without duplicates.
function actionConnectionKeys(manifest: Pick<OntologyManifest, "entities" | "toolsets">): Array<string>;
after
Declares an action trigger; list it in `workflow(name, { triggers })`. The target is an action handle, `Lead.actions.changeStatus`, or an entity handle, `Lead`, for any of its actions, authored or generated. A trigger does not fire for an action the workflow's own user ran.
function after<const Name extends string, A extends AnyActionHandle, Input = unknown>(name: Name, target: A, options: AfterOptions<ActionEvent<ActionInput<A>, ActionResult<A>>, HandleRecord<A>, Input>): ActionTrigger<Name, Input>;
function after<const Name extends string, E extends AnyStoredEntity, Input = unknown>(name: Name, target: E, options: AfterOptions<ActionEvent, E["Type"], Input>): ActionTrigger<Name, Input>;
agentResource
The resource agent tokens are issued for: the agent's routes on the origin the member used.
function agentResource(origin: string): string;
agentToolPermission
`agent_tool:sandbox`.
function agentToolPermission(tool: AgentToolVerb): string;
agentToolsOf
The agent's own tools a caller holds, as the ontology tells the agent whom it acts for: each of {@link AGENT_TOOL_VERBS} whose `agent_tool:<tool>` the caller's current permissions grant, in that order. `roles` are the ontology's roles.
function agentToolsOf(roles: ReadonlyArray<RolePermissions>, holder: PermissionHolder): ReadonlyArray<AgentToolVerb>;
applyMigration
Applies a plan. Non-transactional steps run first, each statement on its own; they only add enum values and build indexes concurrently, and are safe to run again after a failure. Every other step then runs in one transaction with `statement_timeout` and `lock_timeout` set, which also verifies that the catalog still records the manifest the plan starts from and finally records the target. A failure rolls the transaction back and leaves the applied version in place. With `workspaceId`, the same transaction then reconciles the workflow users with the target's workflows. A no-op plan writes nothing else when the runtime schema is also current; with `workspaceId` it still reconciles the workflow users, under the migration lock while the catalog records its target.
const applyMigration: (plan: MigrationPlan, options: ApplyMigrationOptions) => Effect.Effect<MigrationResult, ApplyMigrationError>
backendLayer
The service's backend on the runtime, over the SQL client in context. `blobStorage` is the deployment's file storage, or a test's `memoryFileStorage().blobStorage`; without it, actions that upload, stage or open files are refused.
function backendLayer(ontology: Ontology, blobStorage?: Redacted.Redacted<BlobStorageBinding>, workflowStarter?: WorkflowStarter["Service"], deployment?: DeploymentObservation, signInLinks?: SignInLinks["Service"]): Layer.Layer<OntologyBackend, never, SqlClient.SqlClient>;
browserAuthenticationCompatible
Whether two manifests differ only in presentation metadata: labels, descriptions, guides, display hints and relationship phrases. Pages and forwarded reads of one keep working against the other, because its schema, permissions and sign-in policy are the same. It is not permission evidence: live users, exact roles and revocations still apply.
function browserAuthenticationCompatible(left: OntologyManifest, right: OntologyManifest): boolean;
callbackIdentityToken
The OIDC token of the callback request whose step is running, if it carried one.
function callbackIdentityToken(): string | undefined;
canonicalJson
JSON with object keys sorted at every level and no whitespace: the input of the manifest hash.
function canonicalJson(value: unknown): string;
changed
A `when` predicate: true when the record's `field` differs before and after the action and matches the bounds given. A missing record or value counts as no value, so a create that sets `status` changed it, and `{ to: "qualified" }` does not fire when it was already qualified.
function changed<T extends object, K extends keyof T & string>(field: K, bounds?: ChangedBounds<NoInfer<T[K]>>): TriggerFunction<unknown, T, boolean>;
channelIdentityProvider
The provider of the accounts people write from on the channel `name` of `kind`: the kind for the platform's channels, whose accounts are the same on every channel of the kind, and `channel:<name>` for a workspace channel, whose accounts are its own, so it can claim no Telegram, WhatsApp or email account, nor another workspace channel's.
function channelIdentityProvider(kind: string, name: string): string;
channelPolicyOf
Unsupported providers and missing or unknown channel policies require invitation.
function channelPolicyOf(manifest: Pick<OntologyManifest, "signIn">, provider: string): SignInPolicy;
chatRetentionDaysOf
How many days the workspace keeps its chats' messages: `chat.retentionDays` where it is a whole number in range, else the default.
function chatRetentionDaysOf(manifest: Pick<OntologyManifest, "chat">): number;
check
Checks an ontology definition and returns every problem found, without throwing. Accepts the input of `defineOntology` or its result.
function check(input: OntologyConfig | Ontology, options?: AnalyzeOptions): ReadonlyArray<Diagnostic>;
checkSignIn
Whether a person may sign in with this address, and how; it reads and changes nothing else. Under `invited`, an active member who signed in with Neon Auth before gets `code`, an active member who has not gets `link`, and anyone else is not allowed: a deactivated member is answered like an unknown address. Under `open`, unblocked addresses get `link`.
function checkSignIn(ontology: Ontology, email: string): Effect.Effect<SignInCheck, never, SqlClient.SqlClient>;
clampChannelLimits
The agent's limits within the platform's ceilings; the default for each it leaves out.
function clampChannelLimits(input: ResolveIdentityInput["limits"]): AgentLimits;
compatibleWarehouseColumn
function compatibleWarehouseColumn(propertyType: string, field: {
readonly type?: unknown;
readonly mode?: unknown;
readonly fields?: unknown;
}): boolean;compiledWorkflowId
The Workflow SDK's id of a compiled `"use workflow"` function; `undefined` before compilation.
function compiledWorkflowId(run: unknown): string | undefined;
configFromEnv
Reads the service's configuration from the environment. It fails closed: a missing or invalid variable throws {@link OntologyServiceConfigError} naming every missing variable, and never the value of the database URL. The Neon Auth and runtime identity variables are optional, but only as pairs. The app credential is optional and kept redacted.
function configFromEnv(environment?: Readonly<Record<string, string | undefined>>): OntologyEnvironment;
connection
Declares a connection the ontology's actions may call. `key` names a connection in the workspace's `connections/connections.py`. List the handle once in `defineOntology({ connections })` and in the `connections` of each action that calls it.
function connection<const Key extends string>(key: Key, options: ConnectionOptions): ConnectionHandle<Key>;
countUsersWithoutEmailIdentity
Active admitted OIDC members who would lose browser access if email were their only method.
function countUsersWithoutEmailIdentity(): Effect.Effect<number, SqlError, SqlClient.SqlClient>;
countUsersWithoutSegmentStreamIdentity
Established email members who would lose access if SegmentStream became their only method.
function countUsersWithoutSegmentStreamIdentity(issuer?: string): Effect.Effect<number, SqlError, SqlClient.SqlClient>;
createApiKey
Issues an API key for a user. With `delegation` the key acts only for the member each request names; the column is written only then, so that keys without it can still be issued on a database an earlier SDK migrated.
function createApiKey(input: {
readonly userId: string;
readonly label: string;
readonly delegation?: boolean;
}): Effect.Effect<CreatedApiKey, never, SqlClient.SqlClient>;createOntologyService
The ontology service: the derived HttpApi, the MCP server at `/mcp` and the agent's pairing routes, wired to the runtime, behind Neon Auth, app-token, API-key and runtime-token authentication. Every response carries `x-ontology-hash` and `x-request-id`; failures answer with a JSON error and never a stack or SQL.
function createOntologyService(ontology: Ontology, config: OntologyServiceConfig): OntologyService;
createServiceUser
Creates a service user with roles and a first API key, as the app or the CLI does for the website's intake key. With `delegation` the service holds no role and its key acts only for the member each request names, as an external agent the workspace trusts does: roles and delegation never come together, so that such a key has no authority of its own.
function createServiceUser(ontology: Ontology, input: {
readonly name: string;
readonly roles: ReadonlyArray<string>;
readonly keyLabel: string;
readonly delegation?: boolean;
}): Effect.Effect<{
readonly user: StoredRecord;
readonly apiKey: CreatedApiKey;
}, UnknownRole, SqlClient.SqlClient>;cron
Declares a cron trigger; list it in `workflow(name, { triggers })`. UTC, five fields.
function cron<const Name extends string, Input = unknown>(name: Name, expression: string, options: CronOptions<Input>): CronTrigger<Name, Input>;
cronNeverFires
Whether a valid expression names no day that exists: a day of the month no listed month has, such as `0 0 31 4 *` or `0 0 30 2 *`. The 29th of February counts: it exists in leap years.
function cronNeverFires(expression: string): boolean;
cronProblem
Checks a cron expression by the syntax Vercel crons accept: five fields, read in UTC, each `*`, numbers, ranges, steps and lists, without month or day names, and with at most one of the day fields restricted. It validates syntax only. `undefined` when it parses.
function cronProblem(expression: string): CronProblem | undefined;
decodeManifestDocument
Retain the complete document when decoding a persisted or published manifest: encoding the decoded manifest returns it untouched, earlier names included, so its hash still verifies.
const decodeManifestDocument: (value: unknown) => Effect.Effect<{
readonly roles: readonly {
readonly description: string;
readonly name: string;
readonly builtIn: boolean;
readonly scopes?: readonly {
readonly permission: string;
readonly where: {
readonly [x: string]: Schema.Json;
};
}[] | undefined;
readonly permissions?: readonly string[] | undefined;
}[];
readonly version: number;
readonly hash: string;
readonly entities: readonly {
readonly id: string;
readonly description: string;
readonly name: string;
readonly label: string;
readonly title: string;
readonly properties: readonly {
readonly optional: boolean;
readonly name: string;
readonly label: string;
readonly unique: boolean;
readonly managed: boolean;
readonly type: "number" | "boolean" | "email" | "text" | "list" | "date" | "timestamp" | "url" | "select" | "integer" | "json" | "blob";
readonly max?: number | undefined;
readonly description?: string | undefined;
readonly options?: readonly {
readonly value: string;
readonly label: string;
readonly description: string;
}[] | undefined;
readonly min?: number | undefined;
readonly column?: string | undefined;
readonly maxLength?: number | undefined;
readonly scope?: readonly string[] | undefined;
readonly default?: Schema.Json | undefined;
readonly renamedFrom?: string | undefined;
readonly excludeFromReplication?: boolean | undefined;
readonly display?: string | undefined;
readonly accept?: readonly string[] | undefined;
readonly maxBytes?: number | undefined;
readonly items?: "number" | "boolean" | "email" | "text" | "list" | "date" | "timestamp" | "url" | "select" | "integer" | "json" | "blob" | undefined;
}[];
readonly actions: readonly {
readonly description: string;
readonly name: string;
readonly input: {
readonly [x: string]: Schema.Json;
};
readonly permission?: string | undefined;
readonly files?: readonly {
readonly entity: string;
readonly property: string;
}[] | undefined;
readonly connections?: readonly string[] | undefined;
readonly anyOf?: readonly string[] | undefined;
readonly retryOnDeadlock?: boolean | undefined;
readonly writes?: readonly string[] | undefined;
readonly hints?: {
readonly readOnly?: boolean | undefined;
readonly connectionsReadOnly?: boolean | undefined;
readonly destructive?: boolean | undefined;
readonly irreversible?: boolean | undefined;
readonly idempotent?: boolean | undefined;
} | undefined;
}[];
readonly relationships: readonly {
readonly description: string;
readonly name: string;
readonly to: string;
readonly phrase: readonly [
string,
string
];
readonly cardinality: "one" | "many";
readonly inverse: string;
readonly optional?: boolean | undefined;
readonly onDelete?: "setNull" | "cascade" | "restrict" | undefined;
readonly on?: {
readonly property: string;
readonly targetProperty: string;
} | undefined;
readonly ordered?: boolean | undefined;
}[];
readonly indexes: readonly {
readonly properties: readonly string[];
readonly unique: boolean;
}[];
readonly plural: string;
readonly builtIn: boolean;
readonly permissions?: {
readonly read: string;
readonly create?: string | undefined;
readonly update?: string | undefined;
readonly delete?: string | undefined;
readonly link?: string | undefined;
readonly unlink?: string | undefined;
} | undefined;
readonly renamedFrom?: string | undefined;
readonly source?: {
readonly key: readonly string[];
readonly asset: string;
readonly currency?: string | undefined;
} | undefined;
readonly metrics?: readonly {
readonly description: string;
readonly name: string;
readonly label: string;
readonly unit: "number" | "currency" | "ratio" | "percent";
readonly format: "decimal" | "currency" | "percent";
readonly expression: Schema.Json;
readonly balanceOver?: string | undefined;
}[] | undefined;
readonly guide?: string | undefined;
readonly writes?: "actions" | undefined;
readonly eraseFromWarehouseOnDelete?: true | undefined;
}[];
readonly chat?: {
readonly telegram?: {
readonly connection: string;
readonly files?: {
readonly keep: boolean;
} | undefined;
readonly signature?: boolean | undefined;
} | undefined;
readonly slack?: {
readonly connection: string;
readonly files?: {
readonly keep: boolean;
} | undefined;
readonly signature?: boolean | undefined;
} | undefined;
readonly whatsapp?: {
readonly connection: string;
readonly files?: {
readonly keep: boolean;
} | undefined;
readonly signature?: boolean | undefined;
} | undefined;
readonly email?: {
readonly connection: string;
readonly files?: {
readonly keep: boolean;
} | undefined;
readonly signature?: boolean | undefined;
} | undefined;
readonly channels?: {
readonly [x: string]: {
readonly kind: "telegram" | "slack" | "whatsapp" | "email" | "custom";
readonly files?: {
readonly keep: boolean;
} | undefined;
readonly connection?: string | undefined;
readonly signature?: boolean | undefined;
};
} | undefined;
readonly attribution?: {
readonly separator?: string | undefined;
readonly template?: string | undefined;
} | undefined;
readonly retentionDays?: number | undefined;
} | undefined;
readonly workflows?: readonly {
readonly description: string;
readonly name: string;
readonly connections: readonly string[];
readonly input: {
readonly [x: string]: Schema.Json;
};
readonly triggers: readonly ({
readonly [x: string]: Schema.Json;
} | {
readonly kind: "cron";
readonly name: string;
readonly description: string;
readonly cron: string;
readonly input: Schema.Json;
} | {
readonly kind: "action";
readonly entity: string;
readonly description: string;
readonly name: string;
readonly action?: string | undefined;
} | {
readonly kind: "webhook";
readonly description: string;
readonly name: string;
readonly connection?: string | undefined;
readonly headers?: readonly string[] | undefined;
readonly signature?: {
readonly scheme: string;
readonly message?: readonly (string | {
readonly body: true | "sorted-json";
} | {
readonly header: string;
} | {
readonly timestamp: true;
})[] | undefined;
readonly key?: {
readonly decode: string;
readonly prefix?: string | undefined;
} | undefined;
readonly timestamp?: {
readonly unit?: string | undefined;
readonly entry?: string | undefined;
readonly tolerance?: number | undefined;
readonly header?: string | undefined;
} | undefined;
readonly generated?: true | undefined;
readonly input?: string | undefined;
readonly algorithm?: string | undefined;
readonly encoding?: string | undefined;
readonly signatures?: {
readonly header: string;
readonly entries?: {
readonly separator: string;
readonly assign: string;
readonly name: string;
} | undefined;
readonly prefix?: string | undefined;
} | undefined;
readonly secret?: string | undefined;
} | undefined;
readonly verification?: {
readonly scheme: string;
readonly input?: string | undefined;
readonly verifyToken?: string | undefined;
} | undefined;
} | {
readonly kind: "platform";
readonly name: string;
readonly description: string;
readonly events: readonly string[];
})[];
readonly role: string;
readonly action?: {
readonly entity: string;
readonly action: string;
} | undefined;
}[] | undefined;
readonly feedback?: {
readonly files: boolean;
readonly builders: readonly string[];
readonly enabled: boolean;
readonly automaticFailureReports?: boolean | undefined;
} | undefined;
readonly connections?: readonly {
readonly description: string;
readonly key: string;
readonly owner?: "user" | undefined;
readonly delivers?: true | undefined;
}[] | undefined;
readonly metrics?: readonly {
readonly name: string;
readonly label: string;
readonly description: string;
readonly unit: "number" | "currency" | "ratio" | "percent";
readonly format: "decimal" | "currency" | "percent";
readonly expression: Schema.Json;
readonly inputs: readonly string[];
readonly align: readonly {
readonly [x: string]: string | null;
}[];
}[] | undefined;
readonly runtimeCapabilities?: readonly string[] | undefined;
readonly executionCompatibility?: {
readonly version: number;
readonly hash: string;
} | undefined;
readonly signIn?: {
readonly policy: string;
readonly guest?: {
readonly channels: readonly string[];
readonly origins: readonly string[];
readonly openOnInvite?: readonly string[] | undefined;
readonly byChannel?: {
readonly [x: string]: readonly string[];
} | undefined;
readonly botCheck?: {
readonly scheme: string;
readonly connection?: string | undefined;
readonly input?: string | undefined;
readonly secret?: string | undefined;
} | undefined;
readonly confirmations?: boolean | undefined;
} | undefined;
readonly browser?: {
readonly methods: readonly string[];
readonly primary: string;
readonly autoRedirect: boolean;
readonly local?: {
readonly port: number;
} | undefined;
} | undefined;
readonly channels?: {
readonly [x: string]: unknown;
} | undefined;
readonly onNewUser?: string | undefined;
readonly codeLink?: boolean | undefined;
readonly cli?: boolean | undefined;
readonly signUp?: {
readonly channels: {
readonly [x: string]: unknown;
};
readonly origins?: readonly string[] | undefined;
} | undefined;
readonly onSignUp?: string | undefined;
readonly invitationEmail?: string | undefined;
readonly linkEmail?: string | undefined;
readonly codeEmail?: string | undefined;
} | undefined;
readonly emails?: {
readonly [x: string]: {
readonly subject: string;
readonly text: string;
readonly html: string;
readonly replyTo?: string | undefined;
} | {
readonly subject: string;
readonly heading: string;
readonly action: string;
readonly replyTo?: string | undefined;
readonly eyebrow?: string | undefined;
readonly card?: {
readonly title: string;
readonly detail?: string | undefined;
} | undefined;
readonly note?: string | undefined;
readonly paragraphs?: readonly string[] | undefined;
readonly sections?: readonly {
readonly title: string;
readonly text?: string | undefined;
readonly items?: readonly {
readonly label: string;
readonly code?: string | undefined;
readonly text?: string | undefined;
}[] | undefined;
readonly note?: string | undefined;
readonly copy?: {
readonly value: string;
readonly label?: string | undefined;
} | undefined;
}[] | undefined;
readonly footer?: string | undefined;
};
} | undefined;
readonly inbox?: {
readonly roles: readonly string[];
readonly channels?: readonly string[] | undefined;
readonly attribution?: "name" | "none" | undefined;
readonly takeover?: {
readonly channels: readonly string[];
} | undefined;
} | undefined;
readonly toolsets?: readonly {
readonly name: string;
readonly description: string;
readonly connection: string;
readonly api: string;
readonly tools: readonly {
readonly name: string;
readonly access: "read" | "write";
readonly fixed: {
readonly [x: string]: string | number | boolean;
};
}[];
readonly actions: readonly {
readonly description: string;
readonly name: string;
readonly input: {
readonly [x: string]: Schema.Json;
};
readonly permission?: string | undefined;
readonly files?: readonly {
readonly entity: string;
readonly property: string;
}[] | undefined;
readonly connections?: readonly string[] | undefined;
readonly anyOf?: readonly string[] | undefined;
readonly retryOnDeadlock?: boolean | undefined;
readonly writes?: readonly string[] | undefined;
readonly hints?: {
readonly readOnly?: boolean | undefined;
readonly connectionsReadOnly?: boolean | undefined;
readonly destructive?: boolean | undefined;
readonly irreversible?: boolean | undefined;
readonly idempotent?: boolean | undefined;
} | undefined;
}[];
}[] | undefined;
} | {
readonly roles: readonly {
readonly description: string;
readonly name: string;
readonly builtIn: boolean;
readonly scopes?: readonly {
readonly permission: string;
readonly where: {
readonly [x: string]: Schema.Json;
};
}[] | undefined;
readonly permissions?: readonly string[] | undefined;
}[];
readonly version: number;
readonly hash: string;
readonly entities: readonly {
readonly id: string;
readonly description: string;
readonly name: string;
readonly label: string;
readonly title: string;
readonly properties: readonly {
readonly optional: boolean;
readonly name: string;
readonly label: string;
readonly unique: boolean;
readonly managed: boolean;
readonly type: "number" | "boolean" | "email" | "text" | "list" | "date" | "timestamp" | "url" | "select" | "integer" | "json" | "blob";
readonly max?: number | undefined;
readonly description?: string | undefined;
readonly options?: readonly {
readonly value: string;
readonly label: string;
readonly description: string;
}[] | undefined;
readonly min?: number | undefined;
readonly column?: string | undefined;
readonly maxLength?: number | undefined;
readonly scope?: readonly string[] | undefined;
readonly default?: Schema.Json | undefined;
readonly renamedFrom?: string | undefined;
readonly excludeFromReplication?: boolean | undefined;
readonly display?: string | undefined;
readonly accept?: readonly string[] | undefined;
readonly maxBytes?: number | undefined;
readonly items?: "number" | "boolean" | "email" | "text" | "list" | "date" | "timestamp" | "url" | "select" | "integer" | "json" | "blob" | undefined;
}[];
readonly actions: readonly {
readonly description: string;
readonly name: string;
readonly input: {
readonly [x: string]: Schema.Json;
};
readonly permission?: string | undefined;
readonly files?: readonly {
readonly entity: string;
readonly property: string;
}[] | undefined;
readonly connections?: readonly string[] | undefined;
readonly anyOf?: readonly string[] | undefined;
readonly retryOnDeadlock?: boolean | undefined;
readonly writes?: readonly string[] | undefined;
readonly hints?: {
readonly readOnly?: boolean | undefined;
readonly connectionsReadOnly?: boolean | undefined;
readonly destructive?: boolean | undefined;
readonly irreversible?: boolean | undefined;
readonly idempotent?: boolean | undefined;
} | undefined;
}[];
readonly relationships: readonly {
readonly description: string;
readonly name: string;
readonly to: string;
readonly phrase: readonly [
string,
string
];
readonly cardinality: "one" | "many";
readonly inverse: string;
readonly optional?: boolean | undefined;
readonly onDelete?: "setNull" | "cascade" | "restrict" | undefined;
readonly on?: {
readonly property: string;
readonly targetProperty: string;
} | undefined;
readonly ordered?: boolean | undefined;
}[];
readonly indexes: readonly {
readonly properties: readonly string[];
readonly unique: boolean;
}[];
readonly plural: string;
readonly builtIn: boolean;
readonly permissions?: {
readonly read: string;
readonly create?: string | undefined;
readonly update?: string | undefined;
readonly delete?: string | undefined;
readonly link?: string | undefined;
readonly unlink?: string | undefined;
} | undefined;
readonly renamedFrom?: string | undefined;
readonly source?: {
readonly key: readonly string[];
readonly asset: string;
readonly currency?: string | undefined;
} | undefined;
readonly metrics?: readonly {
readonly description: string;
readonly name: string;
readonly label: string;
readonly unit: "number" | "currency" | "ratio" | "percent";
readonly format: "decimal" | "currency" | "percent";
readonly expression: Schema.Json;
readonly balanceOver?: string | undefined;
}[] | undefined;
readonly guide?: string | undefined;
readonly writes?: "actions" | undefined;
readonly eraseFromWarehouseOnDelete?: true | undefined;
}[];
readonly chat?: {
readonly telegram?: {
readonly connection: string;
readonly files?: {
readonly keep: boolean;
} | undefined;
readonly signature?: boolean | undefined;
} | undefined;
readonly slack?: {
readonly connection: string;
readonly files?: {
readonly keep: boolean;
} | undefined;
readonly signature?: boolean | undefined;
} | undefined;
readonly whatsapp?: {
readonly connection: string;
readonly files?: {
readonly keep: boolean;
} | undefined;
readonly signature?: boolean | undefined;
} | undefined;
readonly email?: {
readonly connection: string;
readonly files?: {
readonly keep: boolean;
} | undefined;
readonly signature?: boolean | undefined;
} | undefined;
readonly channels?: {
readonly [x: string]: {
readonly kind: "telegram" | "slack" | "whatsapp" | "email" | "custom";
readonly files?: {
readonly keep: boolean;
} | undefined;
readonly connection?: string | undefined;
readonly signature?: boolean | undefined;
};
} | undefined;
readonly attribution?: {
readonly separator?: string | undefined;
readonly template?: string | undefined;
} | undefined;
readonly retentionDays?: number | undefined;
} | undefined;
readonly workflows?: readonly {
readonly description: string;
readonly name: string;
readonly connections: readonly string[];
readonly input: {
readonly [x: string]: Schema.Json;
};
readonly triggers: readonly ({
readonly [x: string]: Schema.Json;
} | {
readonly kind: "cron";
readonly name: string;
readonly description: string;
readonly cron: string;
readonly input: Schema.Json;
} | {
readonly kind: "action";
readonly entity: string;
readonly description: string;
readonly name: string;
readonly action?: string | undefined;
} | {
readonly kind: "webhook";
readonly description: string;
readonly name: string;
readonly connection?: string | undefined;
readonly headers?: readonly string[] | undefined;
readonly signature?: {
readonly scheme: string;
readonly message?: readonly (string | {
readonly body: true | "sorted-json";
} | {
readonly header: string;
} | {
readonly timestamp: true;
})[] | undefined;
readonly key?: {
readonly decode: string;
readonly prefix?: string | undefined;
} | undefined;
readonly timestamp?: {
readonly unit?: string | undefined;
readonly entry?: string | undefined;
readonly tolerance?: number | undefined;
readonly header?: string | undefined;
} | undefined;
readonly generated?: true | undefined;
readonly input?: string | undefined;
readonly algorithm?: string | undefined;
readonly encoding?: string | undefined;
readonly signatures?: {
readonly header: string;
readonly entries?: {
readonly separator: string;
readonly assign: string;
readonly name: string;
} | undefined;
readonly prefix?: string | undefined;
} | undefined;
readonly secret?: string | undefined;
} | undefined;
readonly verification?: {
readonly scheme: string;
readonly input?: string | undefined;
readonly verifyToken?: string | undefined;
} | undefined;
} | {
readonly kind: "platform";
readonly name: string;
readonly description: string;
readonly events: readonly string[];
})[];
readonly role: string;
readonly action?: {
readonly entity: string;
readonly action: string;
} | undefined;
}[] | undefined;
readonly feedback?: {
readonly files: boolean;
readonly builders: readonly string[];
readonly enabled: boolean;
readonly automaticFailureReports?: boolean | undefined;
} | undefined;
readonly connections?: readonly {
readonly description: string;
readonly key: string;
readonly owner?: "user" | undefined;
readonly delivers?: true | undefined;
}[] | undefined;
readonly metrics?: readonly {
readonly name: string;
readonly label: string;
readonly description: string;
readonly unit: "number" | "currency" | "ratio" | "percent";
readonly format: "decimal" | "currency" | "percent";
readonly expression: Schema.Json;
readonly inputs: readonly string[];
readonly align: readonly {
readonly [x: string]: string | null;
}[];
}[] | undefined;
readonly runtimeCapabilities?: readonly string[] | undefined;
readonly executionCompatibility?: {
readonly version: number;
readonly hash: string;
} | undefined;
readonly signIn?: {
readonly policy: string;
readonly guest?: {
readonly channels: readonly string[];
readonly origins: readonly string[];
readonly openOnInvite?: readonly string[] | undefined;
readonly byChannel?: {
readonly [x: string]: readonly string[];
} | undefined;
readonly botCheck?: {
readonly scheme: string;
readonly connection?: string | undefined;
readonly input?: string | undefined;
readonly secret?: string | undefined;
} | undefined;
readonly confirmations?: boolean | undefined;
} | undefined;
readonly browser?: {
readonly methods: readonly string[];
readonly primary: string;
readonly autoRedirect: boolean;
readonly local?: {
readonly port: number;
} | undefined;
} | undefined;
readonly channels?: {
readonly [x: string]: unknown;
} | undefined;
readonly onNewUser?: string | undefined;
readonly codeLink?: boolean | undefined;
readonly cli?: boolean | undefined;
readonly signUp?: {
readonly channels: {
readonly [x: string]: unknown;
};
readonly origins?: readonly string[] | undefined;
} | undefined;
readonly onSignUp?: string | undefined;
readonly invitationEmail?: string | undefined;
readonly linkEmail?: string | undefined;
readonly codeEmail?: string | undefined;
} | undefined;
readonly emails?: {
readonly [x: string]: {
readonly subject: string;
readonly text: string;
readonly html: string;
readonly replyTo?: string | undefined;
} | {
readonly subject: string;
readonly heading: string;
readonly action: string;
readonly replyTo?: string | undefined;
readonly eyebrow?: string | undefined;
readonly card?: {
readonly title: string;
readonly detail?: string | undefined;
} | undefined;
readonly note?: string | undefined;
readonly paragraphs?: readonly string[] | undefined;
readonly sections?: readonly {
readonly title: string;
readonly text?: string | undefined;
readonly items?: readonly {
readonly label: string;
readonly code?: string | undefined;
readonly text?: string | undefined;
}[] | undefined;
readonly note?: string | undefined;
readonly copy?: {
readonly value: string;
readonly label?: string | undefined;
} | undefined;
}[] | undefined;
readonly footer?: string | undefined;
};
} | undefined;
readonly inbox?: {
readonly roles: readonly string[];
readonly channels?: readonly string[] | undefined;
readonly attribution?: "name" | "none" | undefined;
readonly takeover?: {
readonly channels: readonly string[];
} | undefined;
} | undefined;
readonly toolsets?: readonly {
readonly name: string;
readonly description: string;
readonly connection: string;
readonly api: string;
readonly tools: readonly {
readonly name: string;
readonly access: "read" | "write";
readonly fixed: {
readonly [x: string]: string | number | boolean;
};
}[];
readonly actions: readonly {
readonly description: string;
readonly name: string;
readonly input: {
readonly [x: string]: Schema.Json;
};
readonly permission?: string | undefined;
readonly files?: readonly {
readonly entity: string;
readonly property: string;
}[] | undefined;
readonly connections?: readonly string[] | undefined;
readonly anyOf?: readonly string[] | undefined;
readonly retryOnDeadlock?: boolean | undefined;
readonly writes?: readonly string[] | undefined;
readonly hints?: {
readonly readOnly?: boolean | undefined;
readonly connectionsReadOnly?: boolean | undefined;
readonly destructive?: boolean | undefined;
readonly irreversible?: boolean | undefined;
readonly idempotent?: boolean | undefined;
} | undefined;
}[];
}[] | undefined;
}, Schema.SchemaError, never>defineOntology
Resolves and checks the ontology and builds its manifest. Throws {@link InvalidOntology }, carrying every diagnostic, when `check` reports an error.
function defineOntology<const Entities extends ReadonlyArray<AnyEntity>, const Metrics extends ModelMetrics = ModelMetrics>(config: OntologyConfig<Entities, Metrics>): Ontology<Entities, Metrics>;
deployedConnections
The transport of a deployed ontology service: each call goes to backend-next with the deployment's Vercel OIDC token, which proves the workspace application. The organization id only selects the tenant; backend-next admits the call only if the token's project is that tenant's application for the workspace, and only for a connection the deployed ontology declares.
function deployedConnections(environment: {
readonly segmentstreamUrl: string;
readonly workspaceId: string;
readonly organizationId: string;
}, fetchImpl?: Fetch): ConnectionTransportFactory;deploymentFromEnv
function deploymentFromEnv(environment?: Readonly<Record<string, string | undefined>>): DeploymentObservation;
deriveApi
The HttpApi of an ontology: per entity `find`, `query`, `get`, `history`, a traversal per relationship and inverse, and a route per generated and authored action; and the catalog, graph, OpenAPI, status, caller (`me`), sign-in check, prose and metric query routes. There is no PUT, PATCH or DELETE: every change is an action.
function deriveApi(ontology: Ontology, options?: DeriveApiOptions): OntologyApi;
draftFilesOf
The files a draft holds, in order; none for a value that is no list of them.
function draftFilesOf(value: unknown): ReadonlyArray<AgentDraftFile>;