Kit services
Use the configured services on EngineContext inside an engine hook or task. They already have the selected instance and its connection configuration.
| Context member | Reference | Use |
|---|---|---|
airtable | AirtableService | Use fetchRecord for one ID, listRecords for a provider page, and queryRecords for a bounded result across pages. |
slack | SlackService | Send or update messages, read threads, and check channel access. Keep the returned channel and timestamp when a later operation needs the same message. |
schema | SchemaCacheService | Read full-base or single-table schema. Use getCachedSchemaIndex when a cache miss must avoid a provider request. |
power | PowerService | Share the scoped engine record and lazy provider clients across the operation. |
credentials | CredentialService | Store encrypted credentials and read the latest value for the engine, user, platform, and key type. |
initLlmService() | LlmService | Reuse one service per operation. Use RunStructuredPromptInput for schema and model settings and RunStructuredPromptResult for the parsed data and usage. |
getExternalPostgres() | ExternalPostgresConnectionService | Run queries against the engine's database. See ExternalPostgresExecutorOptions before opting a callback into replay. |
ServerContext.initAuthService(request) | AuthService | Bind identity checks to a request before using privileged repositories or provider services. See Authenticate a custom route. |
If you set retrySafety on withClient, a connection failure can replay the whole callback. Use read_only for a read and idempotent only when all effects in the callback are safe to repeat, including calls outside Postgres. Leave the option unset for other writes.
Generated for Kit 0.8.0 and Core 0.10.1.
Classes
AirtableService
Airtable operations scoped to an engine connection. In hooks and tasks, use context.airtable so token recovery and request policy stay on that connection.
Constructors
Constructor
new AirtableService(options:
| AirtableServiceOptions
| ConfiguredAirtableServiceOptions
| AirtableServiceReuseOptions): AirtableService;Methods
bulkCreateRecords()
bulkCreateRecords(
baseId: string,
tableId: string,
records: {
fields: Record<string, unknown>;
}[]
): Promise<AirtableListRecordsResponse>;bulkUpdateRecords()
bulkUpdateRecords(
baseId: string,
tableId: string,
records: object[]
): Promise<any>;createComment()
createComment(
baseId: string,
tableId: string,
recordId: string,
text: string
): Promise<any>;createField()
createField(
baseId: string,
tableId: string,
field: AirtableMetadataFieldInput
): Promise<any>;createRecord()
createRecord(
baseId: string,
tableId: string,
data: Record<string, any>
): Promise<AirtableRecordResponse>;Create a new record. Repeating the request can create another record.
createTable()
createTable(baseId: string, table: AirtableMetadataTableInput): Promise<any>;createWebhook()
createWebhook(baseId: string, options: WebhookOptions): Promise<DirectWebhookInfo>;deleteRecord()
deleteRecord(
baseId: string,
tableId: string,
recordId: string
): Promise<void>;deleteWebhook()
deleteWebhook(baseId: string, webhookId: string): Promise<void>;enableWebhookNotifications()
enableWebhookNotifications(baseId: string, webhookId: string): Promise<any>;fetch()
fetch(path: string, params?: AirtableRequestParams): Promise<Response>;fetchRecord()
fetchRecord(
baseId: string,
tableId: string,
recordId: string
): Promise<AirtableRecordResponse>;Fetch one record with JSON cell values keyed by field ID.
fetchWebhookPayloads()
fetchWebhookPayloads(
baseId: string,
webhookId: string,
cursor: number | undefined
): Promise<AirtableWebhookPayloadsResponse>;findRecordsByIds()
findRecordsByIds(
baseId: string,
tableId: string,
recordIds: string[],
options?: object
): Promise<AirtableListRecordsResponse>;findRecordsByPrimaryFieldValues()
findRecordsByPrimaryFieldValues(
baseId: string,
tableId: string,
primaryFieldName: string,
values: string[],
options?: {
maxRecords?: number;
}
): Promise<AirtableListRecordsResponse>;getAccessToken()
getAccessToken(refresh?: boolean): Promise<string>;getAccount()
getAccount(refresh?: boolean): Promise<Account>;getBaseTables()
getBaseTables(baseId: string): Promise<AirtableSchemaResponse>;listRecords()
listRecords(
baseId: string,
tableId: string,
options?: AirtableListRecordsOptions
): Promise<AirtableListRecordsResponse>;Fetch one page of records with fields keyed by ID. Supply the response offset to continue paging, and pass a signal to cancel the request.
listWebhooks()
listWebhooks(baseId: string): Promise<AirtableWebhookListResponse>;queryRecords()
queryRecords(
baseId: string,
tableId: string,
options: AirtableQueryRecordsOptions
): Promise<{
hasMore: boolean;
records: AirtableRecordResponse[];
}>;Collect a bounded query across provider pages; hasMore distinguishes truncation from exhaustion.
refreshWebhook()
refreshWebhook(baseId: string, webhookId: string): Promise<{
cursorForNextPayload: string;
expirationTime: string;
secret: string;
}>;request()
request(path: string, params?: AirtableRequestParams): Promise<any>;updateField()
updateField(
baseId: string,
tableId: string,
fieldId: string,
field: object
): Promise<any>;updateRecord()
updateRecord(
baseId: string,
tableId: string,
recordId: string,
data: Record<string, any>
): Promise<AirtableRecordResponse>;Patch fields on an existing record. Airtable may return field names in the response.
withRequestExpiration()
withRequestExpiration(requestExpirationMs: number): AirtableService;Properties
CredentialService
Constructors
Constructor
new CredentialService(params: object): CredentialService;Methods
decrypt()
decrypt(
encryptedKey: string,
ivBase64: string,
version: string
): string;encrypt()
encrypt(plaintext: string): object;getKey()
getKey(params: CredentialKeyParams): Promise<CredentialValue | null>;Return the latest matching credential as plaintext or null when absent. Avoid logging the value.
storeKey()
storeKey(params: CredentialKeyParams & object): Promise<void>;Encrypt and upsert a secret for the supplied engine, user, platform and key type.
storeKeys()
storeKeys(entries: object[]): Promise<void>;ExternalPostgresConnectionService
Accessors
connectionIdentity
Get Signature
get connectionIdentity(): object;Opaque pool-generation identity for engine-owned readiness caches.
Constructors
Constructor
new ExternalPostgresConnectionService(connectionString: string, options?: ExternalPostgresConnectionOptions): ExternalPostgresConnectionService;Methods
checkConnectivity()
checkConnectivity(): Promise<void>;getClientConfig()
getClientConfig(): ClientConfig & {
replication?: string;
};For SDKs which create their own client; retains validated DNS pinning and TLS.
warmConnection()
warmConnection(): Promise<void>;withClient()
withClient<T>(
run: (client: Client) => Promise<T>,
options?: ExternalPostgresExecutorOptions,
operationPhase?: string
): Promise<T>;Borrow a connection for the callback. Finish all work inside the callback and let the service release the connection. Use an explicit transaction for multiple statements that must commit together.
closeAllConnections()
static closeAllConnections(owner?: object): Promise<void>;closeIdleConnections()
static closeIdleConnections(maxIdleMs: number): Promise<void>;forEngine()
static forEngine(__namedParameters: object & Omit<ExternalPostgresConnectionOptions, "resolvedAddress">): Promise<ExternalPostgresConnectionService>;hasActivePool()
static hasActivePool(connectionString: string, owner?: object): boolean;Properties
| Property | Modifier | Type |
|---|---|---|
connectionString | readonly | string |
log? | readonly | EngineLogger |
LlmService
Constructors
Constructor
new LlmService(dependencies: LlmServiceDependencies): LlmService;Methods
createAssistantDebugTrace()
createAssistantDebugTrace(params: Omit<Parameters<typeof createAssistantDebugTrace>[0], "enabled" | "retentionLimit">): AssistantDebugTrace | null;runAgent()
runAgent<Tools extends ToolSet, GeneratedOutput extends Output<any, any, any> = Output<string, string, never>>(input: AgentCoreInput<Tools, GeneratedOutput>): StreamTextResult<Tools, Record<string, unknown>, GeneratedOutput>;Start an agent with the caller's tools and streaming options.
runAgentPrompt()
runAgentPrompt<Tools extends ToolSet, GeneratedOutput extends Output<any, any, any>>(input: Omit<(LanguageModelCallOptions & (RequestOptions<Tools> & Prompt)) & { tools?: Tools | undefined; } & ToolsContextSettings<Tools> & object, "model" | "stopWhen"> & object & Pick<RunStructuredPromptInput,
| "log"
| "syncId"
| "signal"
| "systemPrompt"
| "userPrompt"
| "outputJsonSchema"
| "schemaName"
| "debugNamespace"
| "debugFilePrefix">): Promise<{
data: Awaited<InferCompleteOutput<GeneratedOutput>>;
finishReason: FinishReason;
providerRequestId: string;
usage: LanguageModelUsage;
}>;Agent steps use the same debug files as structured prompts, including tool inputs/results.
runStructuredPrompt()
runStructuredPrompt<T = unknown>(input: RunStructuredPromptInput): Promise<RunStructuredPromptResult<T>>;Run a bounded prompt with the supplied JSON schema. Omitted provider and model use host defaults. Parse the returned data against the application's schema before relying on application-specific invariants.
PowerService
Shares the engine record and lazy provider clients within one operation. Prefer the configured EngineContext services inside an engine hook.
Accessors
airtable
Get Signature
get airtable(): AirtableService;slack
Get Signature
get slack(): SlackService;Constructors
Constructor
new PowerService<Logger extends EngineLogger & object & object = PowerLogger>(options: object, reuseFrom?: PowerService<Logger>): PowerService<Logger>;Methods
airtableFetch()
airtableFetch(path: string, params?: AirtableRequestParams): Promise<Response>;airtableRequest()
airtableRequest(path: string, params?: AirtableRequestParams): Promise<any>;getAirtableAccessToken()
getAirtableAccessToken(refresh?: boolean): Promise<string>;getSlackAccessToken()
getSlackAccessToken(options: {
refresh?: boolean;
}): Promise<string>;getSync()
getSync(refresh?: boolean): Promise<SyncRecord>;slackRequest()
slackRequest(endpoint: string, options?: SlackRequestParams): Promise<any>;updateSyncConfig()
updateSyncConfig(config: SyncConfig | null): Promise<void>;withAirtableRequestExpiration()
withAirtableRequestExpiration(requestExpirationMs: number): PowerService<Logger>;Properties
| Property | Modifier | Type |
|---|---|---|
log | readonly | Logger |
syncId | readonly | string |
SchemaCacheService
Constructors
Constructor
new SchemaCacheService(input: object): SchemaCacheService;Methods
applyFullSchemaTables()
applyFullSchemaTables(tables: any[], opts?: {
pruneMissing?: boolean;
}): Promise<void>;getCachedSchemaIndex()
getCachedSchemaIndex(): Promise<SchemaIndex | undefined>;Read schema metadata from Redis only; a miss must not fetch Airtable.
getField()
getField(tableId: string, fieldId: string): Field | undefined;getFieldName()
getFieldName(tableId: string, fieldId: string): string;getFieldOptions()
getFieldOptions(tableId: string, fieldId: string): any;getFields()
getFields(tableId: string): Field[];getFieldType()
getFieldType(tableId: string, fieldId: string): FieldType;getFieldVersions()
getFieldVersions(tableId: string, fieldId: string): object;Expose field versions for diffing (per-table snapshots).
getPrimaryFieldId()
getPrimaryFieldId(tableId: string): string | undefined;getSchema()
getSchema(opts?: object): Promise<SchemaCache>;Read the selected base schema, or one table when tableId is supplied. forceRefresh requests fresh metadata rather than using the current cache.
getSchemaIndex()
getSchemaIndex(opts?: object): Promise<SchemaIndex>;Read the full base's metadata index, warming it on a cache miss.
getTableName()
getTableName(tableId: string): string;patchSchemaFromDiff()
patchSchemaFromDiff(diff: SchemaDiff): Promise<void>;Patch the cached FULL schema with info coming from a webhook diff.
refreshSchema()
refreshSchema(opts?: object): Promise<SchemaRefreshSummary>;Refresh and publish the schema without reconstructing every table in memory.
snapshotPrevious()
snapshotPrevious(tableIds: string[]): Promise<void>;Capture a deep snapshot of specific tables into prevCache. Call this BEFORE mutating via patchSchemaFromDiff.
SlackService
Slack operations for the current engine connection. Use context.slack inside an engine hook to reuse its configured client and request limits.
Constructors
Constructor
new SlackService(options: SlackServiceOptions | ConfiguredSlackServiceOptions): SlackService;Methods
addReaction()
addReaction(__namedParameters: object): Promise<void>;completeUploadExternal()
completeUploadExternal(files: SlackUploadFile[]): Promise<{
file?: {
id?: string;
};
files?: {
id?: string;
}[];
}>;createMessage()
createMessage<Block extends object = Record<string, unknown>>(__namedParameters: object): Promise<{
channel: string;
ts: string;
}>;Post with the current connection. Omit the channel to use the configured default, or pass threadTs to reply to an existing message. Retain the returned channel and timestamp to update the message or route replies.
ensureChannelAccess()
ensureChannelAccess(channelId: string, __namedParameters: object): Promise<SlackChannelAccess>;Report membership; joining public channels is an explicit caller choice.
fetchFile()
fetchFile(url: string, signal?: AbortSignal): Promise<Response>;getAccessToken()
getAccessToken(options?: {
refresh?: boolean;
}): Promise<string>;getChannelName()
getChannelName(channel: string): Promise<string | null>;getConversationInfo()
getConversationInfo(channel: string, __namedParameters?: {
signal?: AbortSignal;
}): Promise<SlackConversationInfo>;getFileInfo()
getFileInfo(fileId: string): Promise<SlackFileInfo>;getThreadMessagesBefore()
getThreadMessagesBefore(__namedParameters: object): Promise<SlackThreadMessage[]>;Read thread history before the supplied cutoff timestamp.
getUser()
getUser(userId: string): Promise<{
email?: string;
id: string;
label: string;
name: string;
realName?: string;
}>;getUserLabel()
getUserLabel(userId: string): Promise<string>;joinConversation()
joinConversation(channel: string, __namedParameters?: {
signal?: AbortSignal;
}): Promise<{
channel: SlackConversationInfo;
warning?: string;
}>;listConversations()
listConversations(__namedParameters: object): Promise<{
channels: SlackConversationInfo[];
nextCursor?: string;
}>;openView()
Call Signature
openView<View extends object>(
triggerId: string,
load: SlackViewLoader<View>,
options: SlackViewLoadOptions
): Promise<SlackViewResponse>;Call Signature
openView<View extends object>(
triggerId: string,
view: View,
options?: {
signal?: AbortSignal;
}
): Promise<SlackViewResponse>;removeReaction()
removeReaction(__namedParameters: object): Promise<void>;request()
request<Response>(endpoint: string, options?: SlackRequestOptions): Promise<Response>;resolveChannelId()
resolveChannelId(value: string, __namedParameters?: {
signal?: AbortSignal;
}): Promise<string | null>;IDs pass through; names search the active channels visible to this connection.
setThreadStatus()
setThreadStatus(__namedParameters: object): Promise<{
ok: boolean;
warning?: string;
}>;updateMessage()
updateMessage<Block extends object = Record<string, unknown>>(__namedParameters: object): Promise<{
channel: string;
ts: string;
}>;Update a posted message using its timestamp and the original channel.
updateView()
updateView<View extends object>(
viewId: string,
hash: string,
view: View,
options?: {
signal?: AbortSignal;
}
): Promise<SlackViewResponse>;Interfaces
AuthService
Methods
canAccessEngine()
canAccessEngine(sync: string | EngineAccessRecord, params?: GetUserParams): Promise<boolean>;Check this caller's access to the engine. Enforce write policy separately.
findUserById()
findUserById(userId: string): Promise<User | null>;forVerifiedUser()
forVerifiedUser(user: User): AuthService;Trusted server-only binding after validating an MCP credential; never a bearer-token fallback.
getTokenFromHeader()
getTokenFromHeader(request: AuthRequest): string;getUser()
getUser(params?: GetUserParams): Promise<User | null>;getUserClaims()
getUserClaims(params?: GetUserParams): Promise<UserClaims | null>;Verify the bearer credential and return its authenticated subject.
validateAdminToken()
validateAdminToken(request: AuthRequest): void;Type Aliases
AirtableListRecordsOptions
type AirtableListRecordsOptions = {
fields?: string[];
filterByFormula?: string;
maxRecords?: number;
offset?: string;
pageSize?: number;
signal?: AbortSignal;
sort?: object;
};Provider pagination, projection, and filter options for one Airtable page. Use the returned offset to request the next page.
Properties
fields?
fields?: string[];filterByFormula?
filterByFormula?: string;maxRecords?
maxRecords?: number;offset?
offset?: string;pageSize?
pageSize?: number;signal?
signal?: AbortSignal;sort?
sort?: object;direction
direction: "asc" | "desc";field
field: string;AirtableQueryRecordsOptions
type AirtableQueryRecordsOptions = Omit<AirtableListRecordsOptions, "maxRecords" | "pageSize" | "offset"> & {
limit: number;
};A bounded query that follows Airtable offsets internally.
Type Declaration
limit
limit: number;ExternalPostgresExecutorOptions
type ExternalPostgresExecutorOptions = {
retrySafety?: "read_only" | "idempotent";
signal?: AbortSignal;
};Properties
retrySafety?
retrySafety?: "read_only" | "idempotent";signal?
signal?: AbortSignal;LlmProvider
type LlmProvider = "gemini" | "mistral" | "openai" | "vertex" | "xai";RunStructuredPromptInput
type RunStructuredPromptInput = {
debugFilePrefix?: string;
debugNamespace?: string;
log: LlmLogger;
maxOutputTokens?: number;
model?: string;
openAiReasoningEffort?: OpenAiReasoningEffort;
outputJsonSchema: Record<string, unknown>;
provider?: LlmProvider;
schemaName?: string;
schemaStrict?: boolean;
signal?: AbortSignal;
store?: boolean;
syncId: string;
systemPrompt: string;
userPrompt: string;
};Properties
debugFilePrefix?
debugFilePrefix?: string;debugNamespace?
debugNamespace?: string;log
log: LlmLogger;maxOutputTokens?
maxOutputTokens?: number;model?
model?: string;openAiReasoningEffort?
openAiReasoningEffort?: OpenAiReasoningEffort;outputJsonSchema
outputJsonSchema: Record<string, unknown>;provider?
provider?: LlmProvider;schemaName?
schemaName?: string;schemaStrict?
schemaStrict?: boolean;signal?
signal?: AbortSignal;store?
store?: boolean;syncId
syncId: string;systemPrompt
systemPrompt: string;userPrompt
userPrompt: string;RunStructuredPromptResult
type RunStructuredPromptResult<T = unknown> = {
data: T;
finishReason?: string | null;
providerRequestId?: string;
usage?: AiActionUsage;
};Properties
data
data: T;finishReason?
finishReason?: string | null;providerRequestId?
providerRequestId?: string;usage?
usage?: AiActionUsage;