The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import * as Schema from "effect/Schema"; |
| 2 | |
| 3 | import { GuestShareId, IsoDateTime, TrimmedNonEmptyString } from "./baseSchemas.ts"; |
| 4 | import { ThreadGuestMessage } from "./guestShare.ts"; |
| 5 | import { OrchestrationV2ThreadStreamItem } from "./orchestrationV2.ts"; |
| 6 | import { ProviderDriverKind } from "./providerInstance.ts"; |
| 7 | |
| 8 | // This lives apart from guestShare.ts because orchestrationV2.ts imports that file. |
| 9 | |
| 10 | /** |
| 11 | * What the composer's model label shows; nothing else from the owner's provider settings. The |
| 12 | * driver is null when the thread's provider is no longer configured. |
| 13 | */ |
| 14 | export const GuestThreadModel = Schema.Struct({ |
| 15 | driver: Schema.NullOr(ProviderDriverKind), |
| 16 | name: TrimmedNonEmptyString, |
| 17 | shortName: Schema.optional(TrimmedNonEmptyString), |
| 18 | subProvider: Schema.optional(TrimmedNonEmptyString), |
| 19 | }); |
| 20 | export type GuestThreadModel = typeof GuestThreadModel.Type; |
| 21 | |
| 22 | export const GuestShareView = Schema.Struct({ |
| 23 | shareId: GuestShareId, |
| 24 | title: Schema.String, |
| 25 | guestName: TrimmedNonEmptyString, |
| 26 | expiresAt: IsoDateTime, |
| 27 | messages: Schema.Array(ThreadGuestMessage), |
| 28 | model: GuestThreadModel, |
| 29 | }); |
| 30 | export type GuestShareView = typeof GuestShareView.Type; |
| 31 | |
| 32 | /** |
| 33 | * The shared thread as the owner's client gets it: `thread` carries the same stream items the |
| 34 | * owner's thread subscription sends, starting with a snapshot on every (re)connect. `view` is the |
| 35 | * share itself, sent first and again when it changes. |
| 36 | */ |
| 37 | export const GuestStreamEvent = Schema.Union([ |
| 38 | Schema.Struct({ type: Schema.Literal("view"), view: GuestShareView }), |
| 39 | Schema.Struct({ type: Schema.Literal("thread"), item: OrchestrationV2ThreadStreamItem }), |
| 40 | Schema.Struct({ type: Schema.Literal("ended") }), |
| 41 | ]); |
| 42 | export type GuestStreamEvent = typeof GuestStreamEvent.Type; |