@devries-cameron20 / t3code Mirror · read-only
Fork 0

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

main
ts 110 lines 4.07 KB
Raw
1 import { imageMimeType } from "@t3tools/shared/image";
2 import type {
3 ChatFileAttachment as ContractChatFileAttachment,
4 ChatImageAttachment as ContractChatImageAttachment,
5 ChatUnknownAttachment as ContractChatUnknownAttachment,
6 MessageId,
7 OrchestrationV2Actor,
8 OrchestrationV2CreationSource,
9 OrchestrationV2PlanArtifact,
10 OrchestrationV2UserMessageInputIntent,
11 PlanId,
12 ProjectScript as ContractProjectScript,
13 ProviderInteractionMode,
14 RunId,
15 RuntimeMode,
16 OrchestrationV2LinkedSender,
17 ScheduledTaskId,
18 ThreadId,
19 } from "@t3tools/contracts";
20 import type {
21 EnvironmentProject,
22 EnvironmentThreadShell,
23 ThreadRuntimeSummary,
24 } from "@t3tools/client-runtime/state/shell";
25 import type { ThreadCheckpointSummary } from "@t3tools/client-runtime/state/thread-checkpoints";
26 import { videoMimeType } from "@t3tools/shared/video";
27
28 export { videoMimeType } from "@t3tools/shared/video";
29
30 export type SessionPhase = "disconnected" | "connecting" | "ready" | "running";
31 export const DEFAULT_RUNTIME_MODE: RuntimeMode = "full-access";
32
33 export const DEFAULT_INTERACTION_MODE: ProviderInteractionMode = "default";
34 export const DEFAULT_THREAD_TERMINAL_HEIGHT = 280;
35 export const DEFAULT_THREAD_TERMINAL_ID = "term-1";
36 export const MAX_TERMINALS_PER_GROUP = 4;
37 export type ProjectScript = ContractProjectScript;
38
39 export interface ThreadTerminalGroup {
40 id: string;
41 terminalIds: string[];
42 splitDirection?: "horizontal" | "vertical";
43 }
44
45 export interface ChatImageAttachment extends ContractChatImageAttachment {
46 readonly previewUrl?: string;
47 }
48
49 export interface ChatFileAttachment extends ContractChatFileAttachment {
50 readonly previewUrl?: string;
51 readonly downloadable?: boolean;
52 readonly htmlRender?: boolean;
53 }
54
55 // Render unknown attachment contracts as inert rows so newer servers cannot crash older clients.
56 export type ChatUnknownAttachment = ContractChatUnknownAttachment;
57
58 export type ChatAttachment = ChatImageAttachment | ChatFileAttachment | ChatUnknownAttachment;
59
60 export function isImageAttachment(attachment: ChatAttachment): attachment is ChatImageAttachment {
61 // Legacy file attachments can be images; unknown types must never be reclassified by name.
62 if (attachment.type === "image") return true;
63 return attachment.type === "file" && imageMimeType(attachment) !== null;
64 }
65
66 export function isFileAttachment(attachment: ChatAttachment): attachment is ChatFileAttachment {
67 // Keep disjoint from isImageAttachment so independently filtered sets do not render legacy images twice.
68 return attachment.type === "file" && !isImageAttachment(attachment);
69 }
70
71 export function isVideoAttachment(attachment: ChatFileAttachment): boolean {
72 return videoMimeType(attachment) !== null;
73 }
74
75 export interface ChatMessage {
76 readonly context?: import("@t3tools/contracts").OrchestrationMessageContext | undefined;
77 readonly id: MessageId;
78 readonly role: "user" | "assistant" | "system";
79 readonly text: string;
80 readonly attachments?: ReadonlyArray<ChatAttachment> | undefined;
81 readonly runId: RunId | null;
82 readonly streaming: boolean;
83 readonly createdBy?: OrchestrationV2Actor;
84 readonly creationSource?: OrchestrationV2CreationSource;
85 readonly scheduledTaskId?: ScheduledTaskId;
86 readonly senderThreadId?: ThreadId;
87 readonly linkedSender?: OrchestrationV2LinkedSender;
88 readonly idleCompaction?: import("@t3tools/contracts").OrchestrationV2IdleCompaction;
89 readonly createdAt: string;
90 readonly updatedAt: string;
91 readonly inputIntent?: OrchestrationV2UserMessageInputIntent | undefined;
92 }
93
94 export interface ProposedPlan {
95 readonly id: PlanId;
96 readonly runId: RunId | null;
97 readonly planMarkdown: string;
98 readonly status: OrchestrationV2PlanArtifact["status"];
99 readonly createdAt: string;
100 readonly updatedAt: string;
101 }
102 export type TurnDiffFileChange = ThreadCheckpointSummary["files"][number];
103 export type TurnDiffSummary = ThreadCheckpointSummary;
104
105 export type Project = EnvironmentProject;
106 export type Thread = EnvironmentThreadShell;
107 export type ThreadShell = EnvironmentThreadShell;
108
109 export type SidebarThreadSummary = EnvironmentThreadShell;
110 export type ThreadSession = ThreadRuntimeSummary;