eve
Version:
Filesystem-first framework for durable backend AI agents that run anywhere.
61 lines (60 loc) • 3.18 kB
TypeScript
import type { SessionAuthContext, TurnPolicy } from "#channel/types.js";
import { type ChatSdkChannel, type ChatSdkChannelEvents } from "#public/channels/chat-sdk/index.js";
import type { Message, Thread } from "#compiled/chat/index.js";
import { type iMessageAdapter, type iMessageCredentialProvider, type iMessageWebhookVerifier } from "#compiled/@photon-ai/chat-adapter-imessage/index.js";
/** Photon project credentials used by {@link photonIMessageChannel}. */
export type PhotonIMessageChannelCredentials = iMessageCredentialProvider;
/** Context passed to {@link PhotonIMessageChannelConfig.onMessage}. */
export interface PhotonInboundMessageContext {
/** Low-level Chat SDK thread for iMessage-specific operations. */
readonly thread: Thread;
}
/** Result of {@link PhotonIMessageChannelConfig.onMessage}. Return `null` to drop the message. */
export type PhotonInboundResult = {
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 PhotonInboundResult}. */
export type PhotonInboundResultOrPromise = PhotonInboundResult | Promise<PhotonInboundResult>;
/** Configuration for {@link photonIMessageChannel}. */
export interface PhotonIMessageChannelConfig {
/** Lazy Photon project credentials, such as `connectPhotonCredentials(...)`. */
readonly credentials: PhotonIMessageChannelCredentials;
/** Per-event overrides for the underlying Chat SDK channel. */
readonly events?: ChatSdkChannelEvents<{
imessage: iMessageAdapter;
}>;
/** Inbound message policy. Defaults to dispatching with the Photon message author's user auth. */
readonly onMessage?: (ctx: PhotonInboundMessageContext, message: Message) => PhotonInboundResultOrPromise;
/** Override the default webhook route (`/eve/v1/photon`). */
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;
/** Photon webhook signing secret. Falls back to `IMESSAGE_WEBHOOK_SECRET`. */
readonly webhookSecret?: string;
/** Trusted webhook verifier. Takes precedence over `webhookSecret`. */
readonly webhookVerifier?: iMessageWebhookVerifier;
}
/** First-class eve channel backed by Photon iMessage. */
export interface PhotonIMessageChannel extends ChatSdkChannel {
}
/**
* Creates an eve channel for Photon-powered iMessage.
*
* @example
* ```ts
* import { connectPhotonCredentials } from "@vercel/connect/eve";
* import { photonIMessageChannel } from "eve/channels/photon";
*
* export default photonIMessageChannel({
* credentials: connectPhotonCredentials("photon/my-agent"),
* });
* ```
*/
export declare function photonIMessageChannel(config: PhotonIMessageChannelConfig): PhotonIMessageChannel;
/** Default Photon auth projection for inbound Chat SDK message authors. */
export declare function defaultPhotonAuth(message: Message): SessionAuthContext;