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