UNPKG

eve

Version:

Filesystem-first framework for durable backend AI agents that run anywhere.

69 lines (68 loc) • 3.52 kB
import type { SessionAuthContext, TurnPolicy } from "#channel/types.js"; import { type ChatSdkChannelEvents, type ChatSdkChannelState, type ChatSdkInstrumentationMetadata, type ChatSdkReceiveTarget } from "#public/channels/chat-sdk/index.js"; import type { Channel } from "#public/definitions/channel.js"; import { createLinqAdapter, type LinqWebhookVerifier } from "#compiled/@linqapp/chat-sdk-adapter/index.js"; import type { Message, Thread } from "#compiled/chat/index.js"; /** Context passed to {@link LinqChannelConfig.onMessage}. */ export interface LinqInboundMessageContext { /** Low-level Chat SDK thread for Linq-specific operations. */ readonly thread: Thread; } /** Result of {@link LinqChannelConfig.onMessage}. Return `null` to drop the message. */ export type LinqInboundResult = { readonly auth: SessionAuthContext | null; readonly context?: readonly string[]; /** Overrides the workflow run title without changing the message sent to the model. */ readonly title?: string; } | null; /** Sync or async {@link LinqInboundResult}. */ export type LinqInboundResultOrPromise = LinqInboundResult | Promise<LinqInboundResult>; /** A direct value or lazy resolver for a Linq credential. */ export type LinqCredentialValue = string | (() => string | Promise<string>); /** Linq credentials for outbound API calls and inbound webhook verification. */ export interface LinqChannelCredentials { /** API key for outbound Linq API calls. */ readonly apiKey?: LinqCredentialValue; /** Signing secret for direct Linq webhook delivery. */ readonly signingSecret?: LinqCredentialValue; /** Trusted verifier for webhooks forwarded by a provider such as Vercel Connect. */ readonly webhookVerifier?: LinqWebhookVerifier; } /** Configuration for {@link linqChannel}. */ export interface LinqChannelConfig { /** Optional Linq API base URL, for example a sandbox endpoint. */ readonly baseURL?: string; /** Outbound credentials and inbound webhook verification. */ readonly credentials?: LinqChannelCredentials; /** Per-event overrides for the underlying Chat SDK channel. */ readonly events?: ChatSdkChannelEvents<{ linq: ReturnType<typeof createLinqAdapter>; }>; /** Inbound message policy. Defaults to dispatching with the Linq message author's user auth. */ readonly onMessage?: (ctx: LinqInboundMessageContext, message: Message) => LinqInboundResultOrPromise; /** Override the default webhook route (`/eve/v1/linq`). */ readonly route?: string; /** Policy for accepted messages that arrive while a turn is active. */ readonly turnPolicy?: TurnPolicy; /** Display name used by the Chat SDK runtime. Defaults to `"eve"`. */ readonly userName?: string; } /** First-class eve channel backed by Linq iMessage and SMS. */ export interface LinqChannel extends Channel<ChatSdkChannelState, ChatSdkReceiveTarget, ChatSdkInstrumentationMetadata> { } /** * Creates an eve channel for Linq-powered iMessage and SMS conversations. * * @example * ```ts * import { connectLinqCredentials } from "@vercel/connect/eve"; * import { linqChannel } from "eve/channels/linq"; * * export default linqChannel({ * credentials: connectLinqCredentials("linq/my-agent"), * }); * ``` */ export declare function linqChannel(config: LinqChannelConfig): LinqChannel; /** Default Linq auth projection for inbound Chat SDK message authors. */ export declare function defaultLinqAuth(message: Message): SessionAuthContext;