forked from vhaudiquet/rhema-together
feat: add the multiplayer room server and client
A room is one conversation, one ssh sandbox, and one agent. Accounts create rooms; friends join through a single-use invite link and a display name; the agent speaks only through the message tool. The server is Axum and SQLite. It serves the built Nuxt client, streams room events over SSE, and runs one serialized turn loop per room with turn-level steering copied from rhema-code. The client has the chat, preview iframe, read-only file pane, xterm terminal, and presence. Preview URLs are signed wildcard hosts, and the proxy tunnels HTTP over ssh direct-tcpip. HostAgent::step remains deferred in the framework.
This commit is contained in:
1 parent
04dd63c4ca
commit
0035f4e031
69 files changed
+22501
-48
No files matched your search
@@ -0,0 +1,54 @@
|
||||
const MINUTE = 60_000
|
||||
const HOUR = 3_600_000
|
||||
const DAY = 86_400_000
|
||||
|
||||
export function relativeTime(at: number | null | undefined): string {
|
||||
if (!at) return ''
|
||||
const diff = Date.now() - at
|
||||
if (diff < 45_000) return 'just now'
|
||||
if (diff < HOUR) return `${Math.max(1, Math.round(diff / MINUTE))}m ago`
|
||||
if (diff < DAY) return `${Math.round(diff / HOUR)}h ago`
|
||||
if (diff < 7 * DAY) return `${Math.round(diff / DAY)}d ago`
|
||||
return new Date(at).toLocaleDateString('en', { month: 'short', day: 'numeric' })
|
||||
}
|
||||
|
||||
export function fullTime(at: number | null | undefined): string {
|
||||
if (!at) return ''
|
||||
return new Date(at).toLocaleString('en', {
|
||||
year: 'numeric',
|
||||
month: 'short',
|
||||
day: 'numeric',
|
||||
hour: 'numeric',
|
||||
minute: '2-digit',
|
||||
})
|
||||
}
|
||||
|
||||
export function formatDate(at: number | null | undefined): string {
|
||||
if (!at) return ''
|
||||
return new Date(at).toLocaleDateString('en', { year: 'numeric', month: 'short', day: 'numeric' })
|
||||
}
|
||||
|
||||
export function formatSize(bytes: number): string {
|
||||
if (bytes < 1024) return `${bytes} B`
|
||||
if (bytes < 1024 * 1024) return `${Math.round((bytes / 1024) * 10) / 10} KB`
|
||||
return `${Math.round((bytes / (1024 * 1024)) * 10) / 10} MB`
|
||||
}
|
||||
|
||||
export function initials(name: string): string {
|
||||
const parts = name.trim().split(/\s+/).filter(Boolean)
|
||||
if (parts.length === 0) return '?'
|
||||
const first = parts[0]?.[0] ?? ''
|
||||
const second = parts.length > 1 ? (parts[parts.length - 1]?.[0] ?? '') : ''
|
||||
return (first + second).toUpperCase()
|
||||
}
|
||||
|
||||
export function formatCost(cost: number | null | undefined): string {
|
||||
if (cost === null || cost === undefined) return ''
|
||||
if (cost === 0) return '$0.00'
|
||||
if (cost < 0.01) return `$${cost.toFixed(4)}`
|
||||
return `$${cost.toFixed(2)}`
|
||||
}
|
||||
|
||||
export function plural(count: number, one: string, many: string): string {
|
||||
return count === 1 ? one : many
|
||||
}
|
||||
Reference in new issue
Block a user