Something went wrong. Try again.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251// Shared shapes. Doc/model/recent types mirror the server's (src/server/store.ts).
export interface DocInfo { id: string; path: string; name: string; damaged: boolean; damage?: string; hasIcon: boolean; /** Direct icon URL (web: an object/blob URL; overrides the API route). */ icon?: string; modelName?: string; modelId?: string; size: number; mtime: number; fingerprint: string; /** Modes the tile declares (manifest `modes`); first is the default. The runtime shows a switcher only when there is more than one. */ modes?: string[];}
export interface RecentEntry extends DocInfo { lastOpened: number; /** Last known geometry of this document's window; reused on reopen. */ bounds?: Bounds; /** The doc's space (doc = space); absent for purely local files. */ space?: string; /** Who created the document (DID). */ creator?: string; /** Everyone else in the doc (DIDs, creator excluded). */ contributors?: string[]; /** When the document was created (ms since epoch). */ createdAt?: number; /** Freshest write anywhere in the doc (ms since epoch). */ updatedAt?: number; /** The doc's live session is running right now. */ live?: boolean;}
/** A published tile, as the Store renders it. */export interface StoreTileView { publisher: string; name: string; title: string; summary?: string; kind: 'model' | 'app'; iconUrl?: string; screenshotUrls?: string[]; createdAt?: string; /** Already in this person's sidebar. */ installed?: boolean;}
/** A sidebar entry: an installed store tile. */export interface InstallEntry { rkey: string; publisher: string; name: string; kind: 'model' | 'app'; title: string; summary?: string; iconUrl?: string;}
export interface ModelEntry { id: string; stem: string; name: string; description?: string; hasIcon: boolean; /** Direct icon URL (web: a static asset; overrides the API route). */ icon?: string;}
export interface SyncMember { did: string; handle?: string; role: string; /** The role's capabilities (NSIDs) — what tiles and chrome check. */ capabilities?: string[]; /** False: known member, not around right now (Spaces presence aged out). */ present?: boolean; /** Invited, has not joined yet. */ pending?: boolean;}
/** Who a DID is as a person (server-cached, read from their own repo). */export interface AtProfile { did: string; handle?: string; displayName?: string; avatar?: string;}
export interface SyncFrame { seq: number; author: string; role: string; b64: string;}
export interface PendingInvitation { token: string; docId: string; title: string; /** The space the document lives in, when it differs from the title. */ spaceName?: string; /** The doc's model, human-named ("Rich text"). */ modelName?: string; inviterDid: string; inviterHandle?: string; role: string; createdAt: number; /** Issued before this person had collaboration keys; the inviter still has to finish it (happens by itself once both are online). */ pending?: boolean;}
export interface SyncSpace { ref: string; name: string; /** This identity owns the space (owner-only invites). */ mine: boolean; /** The single-person home space (never a go-live target). */ home?: boolean; /** Everyone in the space (pending = invited, not yet arrived). */ members?: Array<{ did: string; pending?: boolean }>; /** Freshest write in the space (ms since epoch). */ updatedAt?: number; /** Docs in the space that are not instantiated on this machine yet. */ available: Array<{ docRkey: string; name: string; creator: string; createdAt?: number; /** The doc's icon blob (from its checkpoint manifest). */ icon?: { author: string; cid: string; type?: string }; }>;}
export interface SyncState { /** Which collaboration backend is running (relay+MLS, or AT Proto Spaces). */ provider?: 'relay' | 'spaces'; identity: { did: string; handle: string }; /** True under an explicit ZIRAN_DID or env Spaces credentials (dev mode). */ devIdentity?: boolean; at: { signedIn: boolean; handle?: string; did?: string; displayName?: string; hasAvatar?: boolean; /** Direct avatar URL (web: straight from the person's PDS). When set it wins over the hasAvatar/same-origin-proxy path. */ avatarUrl?: string; /** The stored sign-in was retired: it predated the permissions live documents need, so a fresh sign-in is required. */ staleScope?: boolean; /** The sign-in died mid-flight — revoked, or its session consumed by another process. A fresh sign-in is all it takes. */ sessionLost?: boolean; }; /** The collaboration backend is reachable (field names kept from the relay era: read as "backend ok / backend address / why not"). */ relayOk: boolean; relay?: string; /** The raw failure text, verbatim (shown in full, selectable, copyable). */ relayError?: string; /** 'unsupported' = the server doesn't speak Spaces; 'permission' = the sign-in lacks the grant; 'other' = anything else. */ errorKind?: 'unsupported' | 'permission' | 'other'; invitations: PendingInvitation[]; docs: Record<string, { syncId: string; role: string; /** False: shared, but the live session isn't running right now. */ live?: boolean; members: SyncMember[]; inviteBase: string; /** My capabilities in this doc (NSIDs, e.g. space.ziran.changeTitle). */ capabilities?: string[]; roles: Array<{ name: string; label: string; invitable: boolean; full: boolean; capabilities?: string[] }>; /** Spaces: the space this document lives in. */ space?: string; /** Spaces: this doc lives in the single-person home space — sharing it means moving it into a shared space. */ home?: boolean; /** Spaces: the shareable HTTPS link to this document. */ link?: string; /** This identity owns the doc's space (may remove members). */ owner?: boolean; /** This identity shared the doc (may assign roles). */ mine?: boolean; }>; /** Spaces: this identity's known spaces (go-live picker, Documents column). */ spaces?: SyncSpace[];}
export interface ServerState { recents: RecentEntry[]; models: ModelEntry[]; /** Installed store tiles — the sidebar's content. */ installs?: InstallEntry[]; open: DocInfo[]; windows: DocWindowRec[]; mainBounds?: Bounds; tileServerPort: number; desktop: boolean; sync?: SyncState;}
export interface Bounds { x: number; y: number; w: number; h: number;}
/** Layout persisted to session.json; tabs are stored as tile paths so a restore can re-open them (doc ids are derived from paths server-side). Geometry is reported by each window page (screenX/outerWidth) since the desktop API exposes no bounds events. */export interface DeskSession { main?: Bounds; windows: Array<{ panes: Array<{ tabs: string[]; active: string }>; ratio: number; bounds?: Bounds; }>;}
export interface Pane { id: string; /** Doc ids. */ tabs: string[]; active: string;}
/** A real OS document window's content layout, owned by the server. */export interface DocWindowRec { id: string; /** One pane = single view; two panes = vertical split. */ panes: Pane[]; /** Width fraction of the first pane when split. */ ratio: number; bounds?: Bounds; /** Spawn time; a freshly created window has no sockets yet and must not be mistaken for a zombie. */ createdAt: number;}