dsh-coding-subscription-oauth 0.5.2 → 0.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/INSTALL.md +11 -11
- package/README.de.md +34 -9
- package/README.es.md +35 -9
- package/README.fr.md +35 -9
- package/README.ja.md +35 -9
- package/README.ko.md +35 -9
- package/README.md +34 -13
- package/README.pt-BR.md +35 -9
- package/README.ru.md +35 -9
- package/README.zh-CN.md +34 -13
- package/docs/02-architecture.md +4 -3
- package/docs/02-architecture.zh-CN.md +8 -3
- package/lib/adapter.d.ts.map +1 -1
- package/lib/alias-adapter.d.ts.map +1 -1
- package/lib/client.js +1 -1
- package/lib/client.js.map +4 -4
- package/lib/grok-errors.d.ts +13 -0
- package/lib/grok-errors.d.ts.map +1 -0
- package/lib/index.js +13 -3
- package/lib/index.js.map +3 -3
- package/media/settings_accounts.png +0 -0
- package/media/settings_capabilities.png +0 -0
- package/media/settings_gateway.png +0 -0
- package/media/settings_overview.png +0 -0
- package/package.json +2 -1
- package/src/adapter.ts +7 -2
- package/src/alias-adapter.ts +2 -1
- package/src/client/GrokBuildSettings.tsx +247 -1772
- package/src/client/api.ts +88 -0
- package/src/client/components/AboutTab.tsx +20 -0
- package/src/client/components/AccountsTab.tsx +224 -0
- package/src/client/components/CapabilitiesTab.tsx +214 -0
- package/src/client/components/CliPullPreview.tsx +107 -0
- package/src/client/components/GatewayTab.tsx +287 -0
- package/src/client/components/ProviderCard.tsx +322 -0
- package/src/client/components/SettingsTabs.tsx +65 -0
- package/src/client/constants.ts +206 -0
- package/src/client/display.ts +61 -0
- package/src/client/locales.ts +47 -15
- package/src/client/parsers.ts +386 -0
- package/src/client/styles.ts +180 -0
- package/src/client/types.ts +185 -0
- package/src/grok-errors.ts +24 -0
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
/** Shared client types for the Coding OAuth settings UI. */
|
|
2
|
+
|
|
3
|
+
import type { GrokBuildSettingsKey } from "./locales.ts";
|
|
4
|
+
|
|
5
|
+
export type ProviderSlug = "grok" | "codex" | "kimi" | "claude";
|
|
6
|
+
export type LoginMethod = "pkce" | "device" | "browser";
|
|
7
|
+
export type CatalogSource = "live" | "cache" | "fallback";
|
|
8
|
+
export type SourceKind = ProviderSlug;
|
|
9
|
+
export type SourceReason = "missing" | "unsafe" | "invalid" | "too_large";
|
|
10
|
+
export type SourceConflict =
|
|
11
|
+
| "none"
|
|
12
|
+
| "same_credential"
|
|
13
|
+
| "same_account"
|
|
14
|
+
| "different_account"
|
|
15
|
+
| "unknown_account"
|
|
16
|
+
| "unreadable_destination"
|
|
17
|
+
| "unsafe_destination";
|
|
18
|
+
export type SourcePreviewAction = "import" | "reuse" | "overwrite" | "blocked";
|
|
19
|
+
export type SourceCommitAction = "imported" | "unchanged" | "overwritten";
|
|
20
|
+
export type CapabilityFlagKey =
|
|
21
|
+
| "codexSearch"
|
|
22
|
+
| "codexImages"
|
|
23
|
+
| "codexImageEdits"
|
|
24
|
+
| "codexUsage"
|
|
25
|
+
| "codexFast"
|
|
26
|
+
| "grokImagineImage"
|
|
27
|
+
| "grokImagineVideo";
|
|
28
|
+
export type CapabilityLimitKey = "searchResults" | "imageCount" | "videoArtifactTtlMs";
|
|
29
|
+
export type CapabilitySettingKey = CapabilityFlagKey | CapabilityLimitKey;
|
|
30
|
+
export type SettingsTabId = "accounts" | "capabilities" | "gateway" | "about";
|
|
31
|
+
export type CopyField = "openai" | "anthropic" | "key";
|
|
32
|
+
|
|
33
|
+
export type GrokStatus =
|
|
34
|
+
| { status: "signed-out"; grokImportAvailable: boolean }
|
|
35
|
+
| { status: "signing-in"; method: "pkce" | "device"; url?: string; userCode?: string; grokImportAvailable: boolean }
|
|
36
|
+
| {
|
|
37
|
+
status: "signed-in";
|
|
38
|
+
models: string[];
|
|
39
|
+
available: string[];
|
|
40
|
+
selected: string[];
|
|
41
|
+
catalogSource: CatalogSource;
|
|
42
|
+
catalogError?: string;
|
|
43
|
+
grokImportAvailable: boolean;
|
|
44
|
+
}
|
|
45
|
+
| { status: "error"; message: string; grokImportAvailable: boolean };
|
|
46
|
+
|
|
47
|
+
export type SubscriptionStatus = {
|
|
48
|
+
provider: Exclude<ProviderSlug, "grok">;
|
|
49
|
+
route: string;
|
|
50
|
+
displayName: string;
|
|
51
|
+
loginMethods: readonly ("browser" | "device")[];
|
|
52
|
+
recommendedLoginMethod: "browser" | "device";
|
|
53
|
+
models: string[];
|
|
54
|
+
available: string[];
|
|
55
|
+
selected: string[];
|
|
56
|
+
} & (
|
|
57
|
+
| { status: "signed-out" }
|
|
58
|
+
| { status: "signing-in"; method: "browser" | "device"; url?: string; userCode?: string }
|
|
59
|
+
| { status: "signed-in"; expiresAt?: number }
|
|
60
|
+
| { status: "error"; message: string }
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
export type ProviderStatus = GrokStatus | SubscriptionStatus;
|
|
64
|
+
|
|
65
|
+
export interface CodingOAuthStatus {
|
|
66
|
+
providers: {
|
|
67
|
+
grok: GrokStatus;
|
|
68
|
+
codex: SubscriptionStatus;
|
|
69
|
+
kimi: SubscriptionStatus;
|
|
70
|
+
claude: SubscriptionStatus;
|
|
71
|
+
};
|
|
72
|
+
antigravity: { installed: boolean; route: "agy"; management: "cli" };
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface LoginChallenge {
|
|
76
|
+
method: LoginMethod;
|
|
77
|
+
url: string;
|
|
78
|
+
userCode?: string;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface ProviderCardDefinition {
|
|
82
|
+
slug: ProviderSlug;
|
|
83
|
+
route: string;
|
|
84
|
+
titleKey: GrokBuildSettingsKey;
|
|
85
|
+
descriptionKey: GrokBuildSettingsKey;
|
|
86
|
+
methods: readonly LoginMethod[];
|
|
87
|
+
recommended: LoginMethod;
|
|
88
|
+
/** Preferred method when the Settings UI is opened on a remote / non-loopback host. */
|
|
89
|
+
remoteRecommended?: LoginMethod;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export interface SourceStatus {
|
|
93
|
+
kind: SourceKind;
|
|
94
|
+
displayPath: string;
|
|
95
|
+
available: boolean;
|
|
96
|
+
expiresAt?: number;
|
|
97
|
+
reason?: SourceReason;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface SourcePreview {
|
|
101
|
+
previewId: string;
|
|
102
|
+
kind: SourceKind;
|
|
103
|
+
displayPath: string;
|
|
104
|
+
expiresAt?: number;
|
|
105
|
+
ticketExpiresAt?: number;
|
|
106
|
+
conflict?: SourceConflict;
|
|
107
|
+
action?: SourcePreviewAction;
|
|
108
|
+
warnings: string[];
|
|
109
|
+
confirmOverwriteRequired: boolean;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export interface CapabilityFlags {
|
|
113
|
+
codexSearch: boolean;
|
|
114
|
+
codexImages: boolean;
|
|
115
|
+
codexImageEdits: boolean;
|
|
116
|
+
codexUsage: boolean;
|
|
117
|
+
codexFast: boolean;
|
|
118
|
+
grokImagineImage: boolean;
|
|
119
|
+
grokImagineVideo: boolean;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export interface CapabilitySettingsView extends CapabilityFlags {
|
|
123
|
+
searchResults: number;
|
|
124
|
+
imageCount: number;
|
|
125
|
+
videoArtifactTtlMs: number;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export interface CapabilitySnapshot {
|
|
129
|
+
value: CapabilitySettingsView;
|
|
130
|
+
revision: number;
|
|
131
|
+
writable: boolean;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export interface UsageWindowView {
|
|
135
|
+
usedPercent?: number;
|
|
136
|
+
remainingPercent?: number;
|
|
137
|
+
windowSeconds?: number;
|
|
138
|
+
resetsAt?: number;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export interface UsageLimitView {
|
|
142
|
+
id: string;
|
|
143
|
+
name?: string;
|
|
144
|
+
windows: UsageWindowView[];
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export interface UsageView {
|
|
148
|
+
rateLimits: UsageLimitView[];
|
|
149
|
+
creditsUnlimited?: boolean;
|
|
150
|
+
creditsBalance?: string;
|
|
151
|
+
individualLimit?: string;
|
|
152
|
+
individualUsed?: string;
|
|
153
|
+
individualRemaining?: string;
|
|
154
|
+
individualRemainingPercent?: number;
|
|
155
|
+
individualResetsAt?: number;
|
|
156
|
+
spendControlReached?: boolean;
|
|
157
|
+
resetCredits?: number;
|
|
158
|
+
fetchedAt?: number;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export interface ImagineCredentialView {
|
|
162
|
+
configured: boolean;
|
|
163
|
+
source?: string;
|
|
164
|
+
writable?: boolean;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export interface PluginRequestError extends Error {
|
|
168
|
+
status: number;
|
|
169
|
+
code?: string;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export interface GatewayView {
|
|
173
|
+
enabled: boolean;
|
|
174
|
+
running: boolean;
|
|
175
|
+
bind: string;
|
|
176
|
+
port: number;
|
|
177
|
+
keyHint: string;
|
|
178
|
+
warning: string;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export interface GrokBuildSettingsInjected {
|
|
182
|
+
t: (key: GrokBuildSettingsKey, params?: Record<string, unknown>) => string;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export type GrokBuildSettingsProps = Partial<GrokBuildSettingsInjected>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* xAI / Grok Build error remapping.
|
|
3
|
+
* @module dsh-coding-subscription-oauth/grok-errors
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* xAI returns capacity / overload messages that pi-ai classifies as
|
|
8
|
+
* `PI_AI_ERROR` (or occasionally mislabels as AUTH) because the payload has
|
|
9
|
+
* `error.code: null` and no HTTP 429 / rate-limit wording. Without a remap the
|
|
10
|
+
* harness retry policy never runs.
|
|
11
|
+
*/
|
|
12
|
+
const XAI_CAPACITY = /\b(?:at\s+capacity|high\s+demand|priority\s+processing|overloaded)\b/i;
|
|
13
|
+
|
|
14
|
+
export function isXaiCapacityError(detail: string): boolean {
|
|
15
|
+
return XAI_CAPACITY.test(detail);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function remapXaiCapacityFailure(failure: { message: string; code: string }): {
|
|
19
|
+
message: string;
|
|
20
|
+
code: string;
|
|
21
|
+
} {
|
|
22
|
+
if (!isXaiCapacityError(failure.message)) return failure;
|
|
23
|
+
return { ...failure, code: "RATE_LIMIT" };
|
|
24
|
+
}
|