Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

types.ts

168 lines4.3 KB

1import type {
2 EnvironmentId,
3 ModelSelection,
4 OrchestrationLatestTurn,
5 OrchestrationProposedPlanId,
6 RepositoryIdentity,
7 OrchestrationSessionStatus,
8 OrchestrationThreadActivity,
9 ProjectScript as ContractProjectScript,
10 ThreadId,
11 ProjectId,
12 TurnId,
13 MessageId,
14 ProviderKind,
15 CheckpointRef,
16 ProviderInteractionMode,
17 RuntimeMode,
18} from "@t3tools/contracts";
19​
20export type SessionPhase = "disconnected" | "connecting" | "ready" | "running";
21export const DEFAULT_RUNTIME_MODE: RuntimeMode = "full-access";
22​
23export const DEFAULT_INTERACTION_MODE: ProviderInteractionMode = "default";
24export const DEFAULT_THREAD_TERMINAL_HEIGHT = 280;
25export const DEFAULT_THREAD_TERMINAL_ID = "default";
26export const MAX_TERMINALS_PER_GROUP = 4;
27export type ProjectScript = ContractProjectScript;
28​
29export interface ThreadTerminalGroup {
30 id: string;
31 terminalIds: string[];
33​
34export interface ChatImageAttachment {
35 type: "image";
36 id: string;
37 name: string;
38 mimeType: string;
39 sizeBytes: number;
40 previewUrl?: string;
42​
43export type ChatAttachment = ChatImageAttachment;
44​
45export interface ChatMessage {
46 id: MessageId;
47 role: "user" | "assistant" | "system";
48 text: string;
49 attachments?: ChatAttachment[];
50 turnId?: TurnId | null;
51 createdAt: string;
52 completedAt?: string | undefined;
53 streaming: boolean;
55​
56export interface ProposedPlan {
57 id: OrchestrationProposedPlanId;
58 turnId: TurnId | null;
59 planMarkdown: string;
60 implementedAt: string | null;
61 implementationThreadId: ThreadId | null;
62 createdAt: string;
63 updatedAt: string;
65​
66export interface TurnDiffFileChange {
67 path: string;
68 kind?: string | undefined;
69 additions?: number | undefined;
70 deletions?: number | undefined;
72​
73export interface TurnDiffSummary {
74 turnId: TurnId;
75 completedAt: string;
76 status?: string | undefined;
77 files: TurnDiffFileChange[];
78 checkpointRef?: CheckpointRef | undefined;
79 assistantMessageId?: MessageId | undefined;
80 checkpointTurnCount?: number | undefined;
82​
83export interface Project {
84 id: ProjectId;
85 environmentId: EnvironmentId;
86 name: string;
87 cwd: string;
88 repositoryIdentity?: RepositoryIdentity | null;
89 defaultModelSelection: ModelSelection | null;
90 createdAt?: string | undefined;
91 updatedAt?: string | undefined;
92 scripts: ProjectScript[];
94​
95export interface Thread {
96 id: ThreadId;
97 environmentId: EnvironmentId;
98 codexThreadId: string | null;
99 projectId: ProjectId;
100 title: string;
101 modelSelection: ModelSelection;
102 runtimeMode: RuntimeMode;
103 interactionMode: ProviderInteractionMode;
104 session: ThreadSession | null;
105 messages: ChatMessage[];
106 proposedPlans: ProposedPlan[];
107 error: string | null;
108 createdAt: string;
109 archivedAt: string | null;
110 updatedAt?: string | undefined;
111 latestTurn: OrchestrationLatestTurn | null;
112 pendingSourceProposedPlan?: OrchestrationLatestTurn["sourceProposedPlan"];
113 branch: string | null;
114 worktreePath: string | null;
115 turnDiffSummaries: TurnDiffSummary[];
116 activities: OrchestrationThreadActivity[];
118​
119export interface ThreadShell {
120 id: ThreadId;
121 environmentId: EnvironmentId;
122 codexThreadId: string | null;
123 projectId: ProjectId;
124 title: string;
125 modelSelection: ModelSelection;
126 runtimeMode: RuntimeMode;
127 interactionMode: ProviderInteractionMode;
128 error: string | null;
129 createdAt: string;
130 archivedAt: string | null;
131 updatedAt?: string | undefined;
132 branch: string | null;
133 worktreePath: string | null;
135​
136export interface ThreadTurnState {
137 latestTurn: OrchestrationLatestTurn | null;
138 pendingSourceProposedPlan?: OrchestrationLatestTurn["sourceProposedPlan"];
140​
141export interface SidebarThreadSummary {
142 id: ThreadId;
143 environmentId: EnvironmentId;
144 projectId: ProjectId;
145 title: string;
146 interactionMode: ProviderInteractionMode;
147 session: ThreadSession | null;
148 createdAt: string;
149 archivedAt: string | null;
150 updatedAt?: string | undefined;
151 latestTurn: OrchestrationLatestTurn | null;
152 branch: string | null;
153 worktreePath: string | null;
154 latestUserMessageAt: string | null;
155 hasPendingApprovals: boolean;
156 hasPendingUserInput: boolean;
157 hasActionableProposedPlan: boolean;
159​
160export interface ThreadSession {
161 provider: ProviderKind;
162 status: SessionPhase | "error" | "closed";
163 activeTurnId?: TurnId | undefined;
164 createdAt: string;
165 updatedAt: string;
166 lastError?: string;
167 orchestrationStatus: OrchestrationSessionStatus;