1import {
2 PROVIDER_DISPLAY_NAMES,
3 type OrchestrationV2TurnItem,
4 type ProviderDriverKind,
5 type ProviderInstanceId,
6} from "@t3tools/contracts";
7
8export function resolveThreadActivityMetadata(input: {
9 readonly providerDriver: ProviderDriverKind | null;
10 readonly providerInstanceId: ProviderInstanceId | null;
11 readonly model: string | null;
12}): string {
13 const providerLabel = input.providerDriver
14 ? (PROVIDER_DISPLAY_NAMES[input.providerDriver] ?? input.providerInstanceId)
15 : input.providerInstanceId;
16 const values = [providerLabel, input.model].filter(
17 (value): value is string => value !== null && value.length > 0,
18 );
19 return [...new Set(values)].join(" · ");
20}
21
22export function resolveThreadActivityStatus(status: OrchestrationV2TurnItem["status"]): {
23 readonly label: string;
24 readonly tone: "active" | "danger" | "success" | "warning" | "neutral";
25} {
26 const label = status.charAt(0).toUpperCase() + status.slice(1).replaceAll("_", " ");
27 switch (status) {
28 case "idle":
29 return { label, tone: "neutral" };
30 case "completed":
31 return { label, tone: "success" };
32 case "failed":
33 return { label, tone: "danger" };
34 case "cancelled":
35 case "interrupted":
36 return { label, tone: "warning" };
37 case "pending":
38 case "running":
39 case "waiting":
40 return { label, tone: "active" };
41 }
42}