import { type WorkbenchSurface } from './agent-workbench-model.js'; export type WorkbenchBrand = 'feishu' | 'lark'; export interface FeishuJsApiOptions { openChatId: string; needBadge?: boolean; success?: (value?: unknown) => void; fail?: (error?: unknown) => void; complete?: () => void; } export interface FeishuJsApi { toggleChat?: (options: FeishuJsApiOptions) => unknown; enterChat?: (options: FeishuJsApiOptions) => unknown; } export interface WorkbenchH5Context { enabled: boolean; appId: string; brand: WorkbenchBrand; entryPath: string; } export interface OpenWorkbenchChatOptions { chatId: string; appLink?: string; preferSplit: boolean; /** JSAPI is only attempted when this is not false. An unsigned page gets * refused anyway (errno=105) — but only after an async round-trip, and that * await is what strips user activation off the AppLink fallback, which the * client then demotes to a page-initiated open. False keeps the dispatch * inside the click's own task, like the Dashboard's plain anchor. */ nativeEnabled?: boolean; sdk?: FeishuJsApi | null; timeoutMs?: number; openExternal?: (url: string) => void; } export type OpenWorkbenchChatResult = { kind: 'native-split'; method: 'toggleChat'; } | { kind: 'native-jump'; method: 'enterChat'; } /** `rejectedBecause` is the client's own reason the native path failed, * when it gave one. Absent means the SDK was simply not present. */ | { kind: 'applink'; method: 'AppLink'; url: string; rejectedBecause?: string; }; declare global { interface Window { tt?: FeishuJsApi; h5sdk?: { ready?: (callback: () => void) => void; }; } } /** chat/open must stay a bare link: sidebar-semi/width params are a web_url * container contract, and a chat/open carrying them makes the client abandon * in-place placement and navigate — the exact jump this module exists to * avoid. Chat-panel width is client-owned; do not try to smuggle it in here. */ export declare function buildChatAppLink(chatId: string, brand?: WorkbenchBrand): string; export declare function buildWorkbenchWebAppLink(options: { appId: string; brand?: WorkbenchBrand; surface: WorkbenchSurface; targetOrigin: string; sessionId?: string; }): string | null; export declare function buildWorkbenchLoginUrl(entryPath: string, surface: WorkbenchSurface, sessionId?: string): string; /** * Three-state on purpose. Opening a chat is a side effect that has already * happened by the time we are waiting: a client that performs the action but * never invokes `success` is not the same as one that reports `fail`. Collapsing * both into false made the caller run its fallback on top of a chat the client * had already opened — the visible double navigation. */ type JsApiOutcome = 'ok' | 'failed' | 'no-response'; /** Why the call ended that way. `detail` carries the client's own error (errno * and message) so a rejection can be reported as observed rather than guessed * at — "unauthorised JSAPI" is a diagnosis that has to come from the client. */ export interface JsApiResult { outcome: JsApiOutcome; detail?: string; } /** Capability-first PC split, then enterChat, then a stable AppLink. */ export declare function openWorkbenchChat(options: OpenWorkbenchChatOptions): Promise; /** Lazy, UA-gated SDK load: ordinary browsers do not fetch or assume Feishu globals. */ export declare function ensureFeishuJsApi(userAgent?: string): Promise; export {}; //# sourceMappingURL=agent-workbench-chat.d.ts.map