import type { WorkbenchH5Context } from './agent-workbench-chat.js'; export interface TerminalControlState { mode: 'readonly' | 'controlled'; owned: boolean; expiresAt?: number; reused?: boolean; /** Trusted platform owners have a fixed role, not a releasable takeover lease. */ fixed?: boolean; /** * Which acquisition the lease is currently on. Present only when this login * owns a real lease. * * It carries no authority — it is an equality nonce for compare-and-swap * release. The lease lives on (session x login), so a second pane of the SAME * login reuses the very same lease: without naming the acquisition, a late * compensation for a pane that is already gone would release the lease the * user is actively typing into. * * The value is minted by THIS browser before the takeover goes out (see * {@link newTerminalAcquisitionId}) — a server-minted one would only ever come * back on a successful response, i.e. never in the one case that needs it. */ acquisition?: string; } /** * A fresh acquisition id for one takeover. * * Minted BEFORE the POST leaves, which is the whole point: if the response is * lost the pane still knows exactly which acquisition it may have caused, and * can compensate for that one and no other. Opaque and non-secret — the server * only ever compares it for equality against the acquisition it bound. */ export declare function newTerminalAcquisitionId(): string; export interface PreviewInteractionState { mode: 'preview' | 'interactive'; label: string; securityNotice: string; idleExpiresAt?: number; } export interface WorkbenchApi { getTerminalControl(sessionId: string, signal?: AbortSignal): Promise; /** `acquisitionId` names THIS takeover. The caller mints it before calling so * a lost response still leaves it able to compensate for exactly this * acquisition; the server binds it to the lease. */ takeoverTerminal(sessionId: string, signal?: AbortSignal, acquisitionId?: string): Promise; /** `expectedAcquisition` turns the release into a compare-and-swap: the server * only gives the lease up while it is still the acquisition the caller names, * and answers `control_lease_superseded` once somebody else has taken it over. * Compensation paths (a receipt that outlived its pane, a pane closing before * its socket ever bridged) must pass it. */ releaseTerminal(sessionId: string, signal?: AbortSignal, expectedAcquisition?: string): Promise; getPreviewInteraction(sessionId: string, signal?: AbortSignal): Promise; unlockPreview(sessionId: string, signal?: AbortSignal): Promise; touchPreview(sessionId: string, signal?: AbortSignal): Promise; lockPreview(sessionId: string, signal?: AbortSignal): Promise; getH5Context(signal?: AbortSignal): Promise; /** Capability URL for the read-only terminal (viewToken-bearing). The frame * authenticates by this capability, so it also works where no Dashboard * cookie exists — a Feishu WebView being the case that motivated it. * The server answers with a same-origin path and this client refuses * anything else (P1-5) — see `sameOriginViewLink`. * The capability is short-lived and bound to this login (P1-5): `expiresAt` * is when the server stops honoring it, so callers should fetch a fresh * link shortly before then (null when the server did not say). */ getTerminalViewLink(sessionId: string, signal?: AbortSignal): Promise<{ url: string; expiresAt: number | null; } | null>; /** 让 bot 在会话原话题里发一条 @ 拥有者的定位标记。服务端对每个会话有 30s * 限流,超了返回 429 + `retry-after`(见 WorkbenchApiError.retryAfterSeconds)。 */ locateSession(sessionId: string, signal?: AbortSignal): Promise; /** owner 自取的**常驻**工作台入口(`/workbench?t=<当前活跃 token>`), * 用来收藏进浏览器书签。只有本机完整管理身份取得到;其它身份服务端 401/404, * 这里一律回落 null——「取不到」就是「没有这个入口」,绝不半开。 * 与 view-link 那条短时能力 URL 不同,这里返回的是长期凭证,所以调用方只在 * 用户显式点开弹层时才请求,不做预取。 */ getStandingLink(signal?: AbortSignal): Promise<{ url: string; } | null>; } export declare class WorkbenchApiError extends Error { readonly status: number; readonly code: string; /** 仅 429 有值:还要等多少秒才能重试。调用方据此显示冷却而不是报错。 */ readonly retryAfterSeconds?: number | undefined; constructor(status: number, code: string, /** 仅 429 有值:还要等多少秒才能重试。调用方据此显示冷却而不是报错。 */ retryAfterSeconds?: number | undefined); } export declare function createWorkbenchApi(fetchImpl?: typeof fetch): WorkbenchApi; //# sourceMappingURL=agent-workbench-api.d.ts.map