The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 03:37 UTC
| 1 | import type { |
| 2 | GuestShareView, |
| 3 | GuestThreadModel, |
| 4 | OrchestrationV2AppThread, |
| 5 | ServerProvider, |
| 6 | } from "@t3tools/contracts"; |
| 7 | |
| 8 | /** The thread's model as the owner's composer labels it, from the configured providers. */ |
| 9 | export function guestThreadModel( |
| 10 | selection: OrchestrationV2AppThread["modelSelection"], |
| 11 | providers: ReadonlyArray<Pick<ServerProvider, "instanceId" | "driver" | "models">>, |
| 12 | ): GuestThreadModel { |
| 13 | const provider = providers.find((candidate) => candidate.instanceId === selection.instanceId); |
| 14 | const model = provider?.models.find((candidate) => candidate.slug === selection.model); |
| 15 | return { |
| 16 | driver: provider?.driver ?? null, |
| 17 | name: model?.name ?? selection.model, |
| 18 | ...(model?.shortName === undefined ? {} : { shortName: model.shortName }), |
| 19 | ...(model?.subProvider === undefined ? {} : { subProvider: model.subProvider }), |
| 20 | }; |
| 21 | } |
| 22 | |
| 23 | /** The share as its guest sees it, or null before the guest has joined. */ |
| 24 | export function guestShareView( |
| 25 | thread: OrchestrationV2AppThread, |
| 26 | model: GuestThreadModel, |
| 27 | ): GuestShareView | null { |
| 28 | const share = thread.guestShare; |
| 29 | if (!share || share.guestName === null) return null; |
| 30 | return { |
| 31 | shareId: share.id, |
| 32 | title: thread.title, |
| 33 | guestName: share.guestName, |
| 34 | expiresAt: share.expiresAt, |
| 35 | messages: share.messages, |
| 36 | model, |
| 37 | }; |
| 38 | } |