import { DetailedHTMLProps, HTMLAttributes } from 'react';
import { VoiceAgentController, Theme } from '@microsoft/voice-widget-ui';
import { ClientTools, ConnectionStatus, AgentMode, UnhandledClientToolCall } from '@microsoft/voice-widget-core-client';
import { VoiceAgentError, VoiceAgentTelemetryEvent } from '@microsoft/voice-widget';
/** Typed `detail` for every `voice-agent:*` DOM event the element dispatches. */
interface VoiceAgentEventMap {
"voice-agent:call": CustomEvent<{
config: {
clientTools?: ClientTools;
};
}>;
"voice-agent:connect": CustomEvent<{
sessionId?: string;
}>;
"voice-agent:disconnect": CustomEvent<{
reason?: string;
}>;
"voice-agent:statuschange": CustomEvent;
"voice-agent:mode": CustomEvent;
"voice-agent:transcript": CustomEvent<{
role: "user" | "agent";
text: string;
final: boolean;
}>;
"voice-agent:muted": CustomEvent;
"voice-agent:error": CustomEvent;
"voice-agent:expand": CustomEvent;
"voice-agent:collapse": CustomEvent;
"voice-agent:unhandledtool": CustomEvent;
"voice-agent:telemetry": CustomEvent;
}
/**
* The `` custom element. On connect it parses its attributes and
* mounts the widget — unless `provider` names a provider that has not
* self-registered yet, in which case it waits and mounts as soon as that
* provider registers (reporting a `provider_not_registered` error if none has
* after 10s). On disconnect it tears the controller down (or, if still waiting,
* cancels the wait). Connection attributes are mount-once; theme, accent, and
* language strings update live.
*/
declare class VoiceAgentElement extends HTMLElement {
#private;
static get observedAttributes(): string[];
addEventListener: ((type: K, listener: (this: VoiceAgentElement, ev: VoiceAgentEventMap[K]) => void, options?: boolean | AddEventListenerOptions) => void) & ((type: K, listener: (this: VoiceAgentElement, ev: HTMLElementEventMap[K]) => void, options?: boolean | AddEventListenerOptions) => void) & ((type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions) => void);
removeEventListener: ((type: K, listener: (this: VoiceAgentElement, ev: VoiceAgentEventMap[K]) => void, options?: boolean | EventListenerOptions) => void) & ((type: K, listener: (this: VoiceAgentElement, ev: HTMLElementEventMap[K]) => void, options?: boolean | EventListenerOptions) => void) & ((type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions) => void);
connectedCallback(): void;
disconnectedCallback(): void;
/**
* Imperative UI-locale switch for hosts (e.g. Foundry Portal) driving locale
* from their own i18n runtime. Preferred over the `ui-locale` attribute for
* frequent in-call updates. No-op before the element has mounted.
*/
setUiLocale(locale: Parameters[0]): void;
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
}
/**
* Opt-in React JSX types for ``. Import once in a React/TSX project
* (`import "@microsoft/voice-widget-embed/jsx"`) or add to tsconfig `types`. Kept out of
* the main entry so the framework-neutral package never pulls in `@types/react`.
*/
interface VoiceAgentAttributes extends DetailedHTMLProps, VoiceAgentElement> {
provider: string;
"provider-config"?: string;
"widget-id"?: string;
"auth-endpoint"?: string;
"fetch-credentials"?: string;
variant?: string;
placement?: string;
"start-label"?: string;
"default-expanded"?: boolean | string;
"mute-button"?: boolean | string;
theme?: Theme;
"accent-color"?: string;
"orb-palette"?: string;
"lang-strings"?: string;
"ui-locale"?: string;
}
declare global {
namespace JSX {
interface IntrinsicElements {
"voice-agent": VoiceAgentAttributes;
}
}
}
declare module "react" {
namespace JSX {
interface IntrinsicElements {
"voice-agent": VoiceAgentAttributes;
}
}
}