import type { Push } from "@opencode/schema/push"; import type { Session } from "@opencode/schema/session"; import type { Effect } from "effect"; import type { Hooks } from "./registration.js"; /** * A phone notification about to be sent. Only `title`, `body`, `attention`, `data` and `skip` can be changed; * changes to the other fields are ignored. */ export interface PushSend { /** What a later clear names: the permission request, the form, the session for a finished turn, or a plugin's id. */ readonly id: string; /** `plugin` for a notification a plugin sent. */ readonly type: "turn" | "form" | "permission" | "plugin"; /** The session to open: the top-level one, or the one a plugin named. And the folder it works in. */ readonly sessionID: string; readonly directory: string; /** When the event happened, in ms since the epoch. */ readonly time: number; /** True when the notification needs the person. Phones at the `attention` level get only these. */ attention: boolean; /** * For a `type` it knows, a phone builds what it shows from `data` and falls back to `title` and `body`. To change * what it shows, replace the object: `event.data = { ...event.data, text: summary }`. */ data: Push.Data; title: string; body: string; /** Set to true to not send the notification. */ skip: boolean; } export interface PushHooks { readonly send: PushSend; } /** A phone notification a plugin sends. */ export interface PushNotification { /** Sending the same id again replaces the notification on the phone. */ readonly id: string; /** Tapping the notification opens this session. */ readonly sessionID: Session.ID; /** Defaults to the session's title. */ readonly title?: string; readonly body: string; /** True also reaches phones whose level is `attention`. Defaults to false. */ readonly attention?: boolean; } export interface ExperimentalPushDomain { readonly hook: Hooks; /** Runs this location's `send` hooks, then sends to the phones that want it. Does nothing when no phone is registered. */ readonly send: (notification: PushNotification) => Effect.Effect; /** Removes the notifications sent under these ids from the phones that got them. */ readonly clear: (ids: ReadonlyArray) => Effect.Effect; }