Spaces:
Running
Running
Download shared/api-types.ts from evalstate/mcp-webcam: direct link, hf CLI and curl.
- Browser
- Download file 4.2 kB
-
https://huggingface.co/spaces/evalstate/mcp-webcam/resolve/main/shared/api-types.ts
- Command line
-
hf download hf://spaces/evalstate/mcp-webcam/shared/api-types.ts
-
curl -L -o api-types.ts https://huggingface.co/spaces/evalstate/mcp-webcam/resolve/main/shared/api-types.ts
4.2 kB
| export type Era = 'modern' | 'legacy'; | |
| export type McpTransportKind = 'http' | 'stdio'; | |
| export interface ClientIdentity { | |
| key: string; // stable grouping key (name@version|ua|ip or stdio) | |
| name?: string; | |
| version?: string; | |
| title?: string; | |
| source: 'envelope' | 'initialize' | 'session' | 'inferred' | 'user-agent' | 'unknown'; | |
| era: Era; | |
| protocolVersion?: string; | |
| transport: McpTransportKind; | |
| userAgent?: string; | |
| remoteAddress?: string; | |
| eventsCapable?: boolean; | |
| } | |
| export interface PushStreamView { | |
| streamId: string; | |
| subscriptionId: string | number; | |
| client: ClientIdentity; | |
| eventName: string; | |
| arguments: Record<string, unknown>; | |
| cursor: string | null; | |
| heartbeatMs: number; | |
| openedAt: string; | |
| lastFrameAt: string; | |
| lastHeartbeatAt?: string; | |
| delivered: number; | |
| } | |
| export interface PollerView { | |
| pollerId: string; | |
| client: ClientIdentity; | |
| eventName: string; | |
| arguments: Record<string, unknown>; | |
| cursor: string | null; | |
| polls: number; | |
| delivered: number; | |
| firstSeenAt: string; | |
| lastPollAt: string; | |
| nextPollMs: number; | |
| status: 'active' | 'idle' | 'gone'; | |
| revokePending: boolean; | |
| lastError?: string; | |
| } | |
| export interface CallerView { | |
| client: ClientIdentity; | |
| firstSeenAt: string; | |
| lastSeenAt: string; | |
| requests: number; | |
| lastMethod: string; | |
| lastDetail?: string; // e.g. tool name / resource uri / event name | |
| lastResponse?: 'json' | 'sse' | 'accepted' | 'error'; | |
| methods: Record<string, number>; | |
| status: 'active' | 'idle' | 'stale'; | |
| open?: boolean; // stdio connection open | |
| } | |
| export interface CameraTabView { | |
| tabId: string; | |
| connectedAt: string; | |
| primary: boolean; | |
| userAgent?: string; | |
| frozen?: boolean; | |
| deviceLabel?: string; | |
| width?: number; | |
| height?: number; | |
| pendingCaptures: number; | |
| } | |
| export interface SnapshotRefView { | |
| eventId: string; | |
| mimeType: string; | |
| width?: number; | |
| height?: number; | |
| bytes: number; | |
| frozen: boolean; | |
| url: string; | |
| available: boolean; | |
| } | |
| export interface EventLogEntry { | |
| eventId: string; | |
| seq: number; | |
| name: string; | |
| timestamp: string; | |
| cursor: string; | |
| source: 'ui' | 'auto' | 'api'; | |
| message: string | null; | |
| snapshot: SnapshotRefView | null; | |
| delivery: { | |
| push: number; | |
| poll: number; | |
| recipients: string[]; | |
| }; | |
| } | |
| export type ActivityKind = | |
| | 'event.fired' | |
| | 'stream.opened' | |
| | 'stream.closed' | |
| | 'stream.dropped' | |
| | 'stream.revoked' | |
| | 'stream.error' | |
| | 'poll' | |
| | 'poll.error' | |
| | 'call' | |
| | 'capture' | |
| | 'capture.error' | |
| | 'tab.joined' | |
| | 'tab.left' | |
| | 'config'; | |
| export interface ActivityEntry { | |
| id: number; | |
| at: string; | |
| kind: ActivityKind; | |
| summary: string; | |
| client?: string; | |
| detail?: Record<string, unknown>; | |
| count?: number; | |
| } | |
| export interface EventsConfig { | |
| pushEnabled: boolean; | |
| pollEnabled: boolean; | |
| heartbeatMs: number; | |
| nextPollMs: number; | |
| } | |
| export interface DashboardState { | |
| user: string; | |
| serverTime: string; | |
| epoch: string; | |
| headCursor: string; | |
| config: EventsConfig; | |
| tabs: CameraTabView[]; | |
| push: PushStreamView[]; | |
| pollers: PollerView[]; | |
| callers: CallerView[]; | |
| events: EventLogEntry[]; // newest first, <= 50 | |
| activity: ActivityEntry[]; // newest first, <= 100 (empty polls coalesced via count) | |
| } | |
| export interface AppConfigView { | |
| version: string; | |
| mode: 'http' | 'stdio'; | |
| mcpPath: '/mcp'; | |
| mcpHost: string; | |
| mcpHostConfigured: boolean; | |
| modernProtocol: '2026-07-28'; | |
| legacyFallback: boolean; | |
| stdioUser?: string; | |
| } | |
| export type FeedMessage = | |
| | { type: 'hello'; tabId: string; serverTime: string } | |
| | { type: 'state'; state: DashboardState } | |
| | { type: 'capture'; requestId: string; kind: 'webcam' | 'screen'; reason: string } | |
| | { type: 'pulse'; channel: 'push' | 'poll' | 'call' | 'event' | 'heartbeat'; ref?: string; at: string }; | |
| export interface FireEventRequest { | |
| name: 'webcam.message' | 'webcam.snapshot'; | |
| message?: string; | |
| snapshot?: string; // data URL | |
| frozen?: boolean; | |
| width?: number; | |
| height?: number; | |
| source?: 'ui' | 'auto' | 'api'; | |
| } | |
| export interface FireEventResponse { | |
| eventId: string; | |
| cursor: string; | |
| seq: number; | |
| pushTargets: number; | |
| pollers: number; | |
| } | |
| export interface CaptureResultRequest { | |
| image?: string; | |
| error?: string; | |
| } | |