gitdataai/src/ws/constants.ts
ZhenYi 14f6e1e500 feat(core): initialize project with access control and AI integration
- Add gitignore and prettier configuration files for project scaffolding
- Implement room access control service with project member verification
- Create user access key management with CRUD operations and activity logging
- Add accordion UI component for frontend expandable sections
- Implement room AI configuration with list, upsert, and delete operations
- Add AI event types for agent join/leave/status change tracking
- Create streaming AI processing services for mode and react patterns
- Build room AI service with model detection and idempotency handling
- Integrate chat service orchestration for AI message processing
- Add typing indicators and stream cancellation for AI interactions
- Implement mention parsing and context extraction for AI agents
2026-05-03 06:04:31 +08:00

48 lines
1.6 KiB
TypeScript

/**
* WS transport constants — mirrors Rust `session.rs` constants.
*/
/** Server heartbeat interval (30s) — client should send ping within this window. */
export const HEARTBEAT_INTERVAL_MS = 30_000;
/** Server heartbeat timeout (60s) — disconnect if no pong received. */
export const HEARTBEAT_TIMEOUT_MS = 60_000;
/** Max idle timeout (300s) — disconnect if no activity. */
export const MAX_IDLE_TIMEOUT_MS = 300_000;
/** Client-side ping interval — send ping every 25s (before server 30s timeout). */
export const CLIENT_PING_INTERVAL_MS = 25_000;
/** Rate limit: max messages per second per connection. */
export const MAX_MESSAGES_PER_SECOND = 1000;
/** Max text message length (64KB). */
export const MAX_TEXT_MESSAGE_LEN = 64 * 1024;
/** Deduplication window (5 minutes). */
export const DEDUP_WINDOW_MS = 5 * 60_000;
/** Reconnection base delay (1 second). */
export const RECONNECT_BASE_DELAY_MS = 1_000;
/** Reconnection max delay (30 seconds). */
export const RECONNECT_MAX_DELAY_MS = 30_000;
/** Reconnection max attempts before giving up. */
export const RECONNECT_MAX_ATTEMPTS = 20;
/** Protocol version — incremented when event types or fields change. */
export const WS_PROTOCOL_VERSION = 1;
/** Default WS endpoint path on the Rust backend. */
export const DEFAULT_WS_PATH = '/ws';
/** WS token endpoint (POST /api/ws/token). */
export const WS_TOKEN_ENDPOINT = '/api/ws/token';
/** WS token TTL (from server response). */
export const WS_TOKEN_TTL_SECONDS = 300;
/** SSE AI stream endpoint pattern. */
export const SSE_AI_STREAM_PATTERN = '/ws/ai-stream/{room_id}/{message_id}';