Open History to see the last commit
1import type {
2 EnvironmentId,
3 OrchestrationMessage,
4 OrchestrationProjectShell,
5 OrchestrationShellSnapshot,
6 OrchestrationThread,
7 OrchestrationThreadShell,
8 ThreadId,
9} from "@t3tools/contracts";
10
11export interface EnvironmentProject extends OrchestrationProjectShell {
12 readonly environmentId: EnvironmentId;
13}
14
15export interface EnvironmentThreadShell extends OrchestrationThreadShell {
16 readonly environmentId: EnvironmentId;
17}
18
19export type EnvironmentMessage = OrchestrationMessage;
20
21export interface EnvironmentThread extends OrchestrationThread {
22 readonly environmentId: EnvironmentId;
23}
24
25export function scopeProject(
26 environmentId: EnvironmentId,
27 project: OrchestrationProjectShell,
28): EnvironmentProject {
29 return { ...project, environmentId };
30}
31
32export function scopeThreadShell(
33 environmentId: EnvironmentId,
34 thread: OrchestrationThreadShell,
35): EnvironmentThreadShell {
36 return { ...thread, environmentId };
37}
38
39export function scopeThread(
40 environmentId: EnvironmentId,
41 thread: OrchestrationThread,
42): EnvironmentThread {
43 return { ...thread, environmentId };
44}
45
46export function selectEnvironmentThreadShell(
47 snapshot: OrchestrationShellSnapshot | null,
48 environmentId: EnvironmentId,
49 threadId: ThreadId,
50): EnvironmentThreadShell | null {
51 const thread = snapshot?.threads.find((candidate) => candidate.id === threadId) ?? null;
52 return thread ? scopeThreadShell(environmentId, thread) : null;
53}