-
-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathproviderStatusPresentation.ts
More file actions
63 lines (54 loc) · 1.79 KB
/
providerStatusPresentation.ts
File metadata and controls
63 lines (54 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import { type ServerProviderStatus } from "@okcode/contracts";
import { redactSensitiveText } from "@okcode/shared/redaction";
export type ProviderSetupPhase = "install" | "authenticate" | "verify" | "ready";
const PROVIDER_LABELS = {
codex: "OpenAI (Codex CLI)",
claudeAgent: "Anthropic (Claude Code)",
openclaw: "OpenClaw",
} as const;
export function getProviderLabel(provider: ServerProviderStatus["provider"]): string {
return PROVIDER_LABELS[provider] ?? provider;
}
export function getProviderSetupPhase(status: ServerProviderStatus): ProviderSetupPhase {
if (!status.available) {
return "install";
}
if (status.authStatus === "unauthenticated") {
return "authenticate";
}
if (status.status === "ready") {
return "ready";
}
return "verify";
}
export function getProviderStatusHeading(status: ServerProviderStatus): string {
const label = getProviderLabel(status.provider);
const phase = getProviderSetupPhase(status);
switch (phase) {
case "install":
return `${label} is not installed`;
case "authenticate":
return `${label} needs authentication`;
case "verify":
return `${label} needs verification`;
case "ready":
return `${label} is ready`;
}
}
export function getProviderStatusDescription(status: ServerProviderStatus): string {
if (status.message) {
return redactSensitiveText(status.message);
}
const label = getProviderLabel(status.provider);
const phase = getProviderSetupPhase(status);
switch (phase) {
case "install":
return `Install ${label} to use this provider.`;
case "authenticate":
return `Authenticate ${label} before starting or resuming turns.`;
case "verify":
return `Verify ${label} setup before continuing.`;
case "ready":
return `${label} is ready.`;
}
}