import type { ErrorInfo, ServerEvent } from '@optima-chat/gateway-protocol'; import type { ChatStore, MidTurnSink } from '../store/chat-store.js'; import { GatewayClient } from '../client/gateway-client.js'; import { MidTurnCoordinator } from '../client/midturn-coordinator.js'; import type { OutboundQueue } from '../client/outbound-queue.js'; import type { ChatProviderProps } from '../types.js'; import type { StoreApi } from 'zustand/vanilla'; /** * Detect server `error` events meaning "the access token the SDK presented * has been rejected" — canonical `AUTH_TOKEN_INVALID` code, casing variants, * or a legacy server with no code but a recognizable message. Used by the * ChatProvider event handler to trigger Layer A token recovery (#54). */ export declare function isAuthExpiredSignal(error: ErrorInfo): boolean; /** * ac#1021:把 `MidTurnCoordinator` 的依赖注入口接到真 store + 真 GatewayClient 上。 * * `getClient` 是**惰性**的(读 `clientRef.current`):coordinator 在 `useMemo` 里先于 * `new GatewayClient` 创建,构造那一刻 client 还不存在。client 为 null 时三个 client 侧 * 依赖各自退化成「发不出去 / 未武装 / 纪元 0」,submit 走 ④ 直发腿返 false,宿主照旧 throw。 * * ⛔ 本函数**绝不写 store**:它在渲染期(`useMemo`)跑,而本 provider 里有一处裸 * `store.subscribe`(restoring-timeout 对账),渲染期 set() 会同步把它拉起来。 */ export declare function createMidTurnCoordinator(store: StoreApi, getClient: () => Pick | null): MidTurnCoordinator; /** ac#1021:store 的两个会话收尾原语 → coordinator 的对应入口。 */ export declare const midTurnSinkFor: (coordinator: MidTurnCoordinator) => MidTurnSink; /** * ac#1053 Plan B(spec Δ4 / Δ7):provider 实际注册的 sink —— store 的两个会话收尾原语同时通知 * 本地排队(`OutboundQueue`)与 coordinator。不新增 sink 方法:`settleStuckTurn(C,'escape_hatch')` * 的队列腿 = `onSettle`(清在途账),`removeConversation` 的队列腿 = `onConversationGone`。 * * ⚠️ 逃生口腿里**队列先清是承重的**:B 档直发时若 C 上还有 A 档留下的 inflight 机器,那条已 * `track()` 的消息被 coordinator T0 暂存为 held、尚未入账;逃生口时 coordinator drain 出它、经 R1 * 入账 —— 它此刻真在飞。先 drain 再清,会把这个真在飞的 id 清掉。(gone 腿换序等价: * coordinator 先把 held 判 lost、drain 跳过。) * `midTurnSinkFor` 保留原签名与原行为(非公开 API,接线测试直接用它)。 */ export declare const composedMidTurnSink: (coordinator: MidTurnCoordinator, queue: OutboundQueue) => MidTurnSink; /** * — wires GatewayClient + ConversationAPI + Store together, * parses incoming ServerEvents into store mutations, and forwards selected * events to the consumer-supplied callbacks. */ export declare function ChatProvider(props: ChatProviderProps): React.ReactElement; /** * Core event dispatch: parse → apply store mutations → forward to callbacks. * Exposed as a pure function so it can be unit-tested. */ export declare function handleServerEvent(event: ServerEvent, store: StoreApi, props: ChatProviderProps): void; //# sourceMappingURL=chat-provider.d.ts.map