interface CallUser { id: string; email?: string; displayName?: string; } interface CallOpenPayload { agentId: string; workspaceToken: string; user: CallUser; context?: string; locale?: string; } /** Reason for call end. Possible values are available on {@link https://docs.quarterzip.ai}. */ type CallEndReason = string; /** Code for call error. Possible values are available on {@link https://docs.quarterzip.ai}. */ type CallErrorCode = string; /** * Public API types for the Quarterzip embeddable SDK loader. * * Fields here are stable across minor versions; any breaking change ships in a new major version. */ /** * Identity of the end user starting the call. Supplied by the integrating site. * * Only `id` is required: an opaque or hashed identifier from your own system. * Send `email`/`displayName` only if you want them to appear in Quarterzip's call records. */ type QuarterzipUser = CallUser; /** Reported to the `close` callback when the call finishes. */ interface CallCloseEvent { /** Why the call ended. */ reason: CallEndReason; } /** Reported to the `error` callback when the call fails. */ interface CallErrorEvent { /** The type of call error. */ code: CallErrorCode; /** * Whether the call could not continue. Reported by the frame. * * When `true`, `close` follows — but not necessarily straight away. A failure before the call * starts leaves the panel up so the user can read the message, and `close` arrives when they * dismiss it, or you call `close()`. Treat `error` as "this call is over" and `close` as "the * session has torn down". */ fatal: boolean; } /** Event callbacks that can be registered via {@link OpenArgs.on}. All optional. */ interface EventHandlers { /** Called when the call conversation begins (user joined, bot connected). */ callStarted: () => void; /** Called when the call conversation ends. The panel may still be showing the feedback screen. */ callEnded: () => void; /** Called once when the SDK panel is torn down, regardless of reason. */ close: (event: CallCloseEvent) => void; /** Called when the call fails. Followed by `close` when the failure is fatal. */ error: (event: CallErrorEvent) => void; } /** Arguments passed to `Quarterzip.open()`. */ interface OpenArgs extends CallOpenPayload { /** Event callbacks for the call lifecycle. */ on?: Partial; } type LogLevel = 'silent' | 'error' | 'warn' | 'log' | 'debug'; /** Per-call overrides accepted as the optional second argument to `open()`. */ interface OpenOptions { /** * Console verbosity for this call, applied to both this loader and the frames it stands up. * Defaults to `warn`, so a call adds nothing to your console unless something is wrong. */ logLevel?: LogLevel; /** * Whether the floating Document Picture-in-Picture window may be used at all. Defaults to `true`, * and falls back silently to the in-frame UI where unsupported (browser-specific). */ pip?: boolean; /** * Override the origin the iframes are loaded from. Use only if Quarterzip has told you to * point at a different host. For the sandbox isolation to hold, this MUST be an origin * distinct from your own site e.g. cross-origin. */ frameOrigin?: string; } /** Global configuration set once via `Quarterzip.configure()`. Merged into every `open()`. */ interface QuarterzipConfig { /** Default origin for the iframes. See {@link OpenOptions.frameOrigin}. */ frameOrigin?: string; /** Dev-only: Suppress the console warning emitted when the frames resolve to the host page's own origin. */ allowSameOrigin?: boolean; /** Default console verbosity for every call. See {@link OpenOptions.logLevel}. */ logLevel?: LogLevel; } /** The shape installed at `window.Quarterzip` for script-tag / CDN usage. */ interface QuarterzipAPI { open: (args: OpenArgs, options?: OpenOptions) => void; close: () => void; configure: (config: QuarterzipConfig) => void; /** * Open the floating Picture-in-Picture window on demand. Optional — the window appears by itself * when the user switches tabs, so most integrations never call this. Use it to offer a "pop out" * control, typically to bring back a window the user closed. * * Must be called synchronously from a user gesture on your page (a click handler). The browser * only grants a PiP window inside a real gesture, and that permission cannot be forwarded from * inside the Quarterzip frame. */ openPip: () => void; /** Close the floating window. The call keeps running in the on-page frame. */ closePip: () => void; /** Command queue drained on load — populated by the async loader stub before the script runs. */ _q?: Array<[keyof QuarterzipAPI, unknown[]]>; } declare global { interface Window { Quarterzip?: QuarterzipAPI; _quarterzipLoaded?: boolean; } } /** * Start (or switch) a call. Call this from a user gesture. * @param args Agent, workspace token, end-user identity, and lifecycle callbacks via `on`. * @param options Optional per-call overrides (frame URL, PiP on/off). */ declare const open: (args: OpenArgs, options?: OpenOptions) => void; /** Close the active call and remove all iframes / PiP windows. Safe to call when nothing is open. */ declare const close: () => void; /** Set global defaults merged into every subsequent `open()`. */ declare const configure: (config: QuarterzipConfig) => void; /** * Open the floating PiP window. Optional — it appears on its own when the user switches tabs. * Call synchronously from a click handler on your page; see {@link QuarterzipAPI.openPip}. */ declare const openPip: () => void; /** Close the floating PiP window; the call continues in the on-page frame. */ declare const closePip: () => void; declare const Quarterzip: QuarterzipAPI; export { type CallCloseEvent, type CallEndReason, type CallErrorCode, type CallErrorEvent, type EventHandlers, type LogLevel, type OpenArgs, type OpenOptions, Quarterzip, type QuarterzipAPI, type QuarterzipConfig, type QuarterzipUser, close, closePip, configure, open, openPip };