- Generate Ed25519 keypair via Web Crypto API - Persist keypair in IndexedDB (survives page reloads) - Sign connect payload with device private key - Include device object in connect params (id, publicKey, signature, signedAt) - Handle NOT_PAIRED error with 'pairing' connection status - Show pairing-pending banner with instructions to run openclaw devices approve - Extract nonce from connect.challenge for v2 payload signing - Add i18n translations for pairing banner in all 8 languages Closes #6
65 lines
1.8 KiB
TypeScript
65 lines
1.8 KiB
TypeScript
export interface ChatMessage {
|
|
id: string;
|
|
role: 'user' | 'assistant';
|
|
content: string;
|
|
timestamp: number;
|
|
blocks: MessageBlock[];
|
|
isStreaming?: boolean;
|
|
runId?: string;
|
|
isSystemEvent?: boolean;
|
|
metadata?: Record<string, unknown>;
|
|
/** Optimistic send status for user messages */
|
|
sendStatus?: 'sending' | 'sent' | 'error';
|
|
/** Timestamp (ms) when streaming started for this message */
|
|
streamStartedAt?: number;
|
|
/** Total generation time in milliseconds (set when streaming ends) */
|
|
generationTimeMs?: number;
|
|
/** True if this message was restored from local cache (pre-compaction) */
|
|
isArchived?: boolean;
|
|
/** True if this is a visual separator showing where compaction occurred */
|
|
isCompactionSeparator?: boolean;
|
|
}
|
|
|
|
export type MessageBlock =
|
|
| { type: 'text'; text: string }
|
|
| { type: 'thinking'; text: string }
|
|
| { type: 'tool_use'; name: string; input: Record<string, unknown>; id?: string }
|
|
| { type: 'tool_result'; content: string; toolUseId?: string; name?: string }
|
|
| { type: 'image'; mediaType: string; data?: string; url?: string };
|
|
|
|
export interface Session {
|
|
key: string;
|
|
label?: string;
|
|
messageCount?: number;
|
|
isActive?: boolean;
|
|
hasUnread?: boolean;
|
|
unreadCount?: number;
|
|
totalTokens?: number;
|
|
contextTokens?: number;
|
|
inputTokens?: number;
|
|
outputTokens?: number;
|
|
channel?: string;
|
|
kind?: string;
|
|
model?: string;
|
|
agentId?: string;
|
|
updatedAt?: number;
|
|
lastMessagePreview?: string;
|
|
}
|
|
|
|
export interface AgentIdentity {
|
|
name?: string;
|
|
emoji?: string;
|
|
avatar?: string;
|
|
agentId?: string;
|
|
}
|
|
|
|
export type ConnectionStatus = 'disconnected' | 'connecting' | 'connected' | 'pairing';
|
|
|
|
export interface GatewayState {
|
|
status: ConnectionStatus;
|
|
sessions: Session[];
|
|
activeSession: string;
|
|
messages: ChatMessage[];
|
|
isGenerating: boolean;
|
|
}
|