dsh-coding-subscription-oauth 0.5.8 → 0.6.2
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 +217 -188
- package/CONTRIBUTING.md +120 -120
- package/INSTALL.md +241 -209
- package/LICENSE +19 -19
- package/NOTICE +11 -11
- package/README.de.md +298 -294
- package/README.es.md +299 -295
- package/README.fr.md +299 -295
- package/README.ja.md +299 -295
- package/README.ko.md +299 -295
- package/README.md +313 -307
- package/README.pt-BR.md +299 -295
- package/README.ru.md +299 -295
- package/README.zh-CN.md +311 -305
- package/compatibility/dsh-bom.json +30 -0
- package/cordis.patch.yml +13 -13
- package/docs/00-project-rules.md +195 -195
- package/docs/02-architecture.md +134 -129
- package/docs/02-architecture.zh-CN.md +134 -129
- package/lib/adapter.d.ts.map +1 -1
- package/lib/alias-adapter.d.ts +3 -1
- package/lib/alias-adapter.d.ts.map +1 -1
- package/lib/auth-routes.d.ts +8 -15
- package/lib/auth-routes.d.ts.map +1 -1
- package/lib/bin.js +746 -1402
- package/lib/bin.js.map +4 -4
- package/lib/capability-routes.d.ts +3 -3
- package/lib/capability-routes.d.ts.map +1 -1
- package/lib/capability-settings.d.ts +5 -4
- package/lib/capability-settings.d.ts.map +1 -1
- package/lib/client.js +27 -8
- package/lib/client.js.map +4 -4
- package/lib/compatibility.d.ts +46 -0
- package/lib/compatibility.d.ts.map +1 -0
- package/lib/dsh-host-adapter.d.ts +18 -0
- package/lib/dsh-host-adapter.d.ts.map +1 -0
- package/lib/gateway-auth.d.ts +1 -2
- package/lib/gateway-auth.d.ts.map +1 -1
- package/lib/gateway-routes.d.ts +3 -4
- package/lib/gateway-routes.d.ts.map +1 -1
- package/lib/gateway.d.ts +4 -0
- package/lib/gateway.d.ts.map +1 -1
- package/lib/ids.d.ts +3 -32
- package/lib/ids.d.ts.map +1 -1
- package/lib/imagine-routes.d.ts +2 -0
- package/lib/imagine-routes.d.ts.map +1 -1
- package/lib/index.d.ts +19 -4
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +26627 -1047
- package/lib/index.js.map +4 -4
- package/lib/invariant.js.map +1 -1
- package/lib/oauth-import-routes.d.ts +3 -4
- package/lib/oauth-import-routes.d.ts.map +1 -1
- package/lib/proxy.d.ts +3 -16
- package/lib/proxy.d.ts.map +1 -1
- package/lib/web-origin.d.ts +28 -4
- package/lib/web-origin.d.ts.map +1 -1
- package/lib/web-routes.d.ts.map +1 -1
- package/media/en/settings_accounts.png +0 -0
- package/media/en/settings_capabilities.png +0 -0
- package/media/en/settings_gateway.png +0 -0
- 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/media/zh-CN/settings_accounts.png +0 -0
- package/media/zh-CN/settings_capabilities.png +0 -0
- package/media/zh-CN/settings_gateway.png +0 -0
- package/package.json +211 -174
- package/patches/dsh-agy@0.1.2.patch +25 -25
- package/scripts/release.mjs +186 -170
- package/scripts/smoke-deployed-routes.mjs +146 -146
- package/scripts/verify-deployed-catalog.mjs +87 -87
- package/src/adapter.ts +329 -268
- package/src/alias-adapter.ts +141 -147
- package/src/auth-routes.ts +921 -871
- package/src/auth.ts +67 -67
- package/src/bin.ts +350 -350
- package/src/capability-routes.ts +279 -275
- package/src/capability-runtime.ts +313 -313
- package/src/capability-settings.ts +658 -657
- package/src/capability-tools.ts +666 -666
- package/src/catalog.ts +271 -271
- package/src/client/GrokBuildSettings.tsx +770 -718
- package/src/client/api.ts +88 -88
- package/src/client/components/AboutTab.tsx +30 -30
- package/src/client/components/AccountsTab.tsx +241 -224
- package/src/client/components/Badge.tsx +33 -33
- package/src/client/components/CapabilitiesTab.tsx +265 -227
- package/src/client/components/CliPullPreview.tsx +116 -107
- package/src/client/components/CopyButton.tsx +57 -57
- package/src/client/components/GatewayTab.tsx +469 -409
- package/src/client/components/NoticeBanner.tsx +46 -46
- package/src/client/components/ProgressBar.tsx +53 -53
- package/src/client/components/ProviderCard.tsx +606 -502
- package/src/client/components/SettingsTabs.tsx +75 -75
- package/src/client/components/ToggleSwitch.tsx +71 -62
- package/src/client/constants.ts +224 -206
- package/src/client/display.ts +61 -61
- package/src/client/dshClientAdapter.ts +127 -0
- package/src/client/gatewaySnippets.ts +37 -36
- package/src/client/index.tsx +156 -37
- package/src/client/locales.ts +535 -491
- package/src/client/microStyles.ts +52 -33
- package/src/client/parsers.ts +396 -386
- package/src/client/styles.ts +325 -307
- package/src/client/types.ts +197 -185
- package/src/codex-http.ts +447 -447
- package/src/codex-images.ts +485 -485
- package/src/codex-model-capabilities.ts +320 -320
- package/src/codex-search.ts +245 -245
- package/src/codex-usage.ts +263 -263
- package/src/compatibility.ts +55 -0
- package/src/dsh-host-adapter.ts +173 -0
- package/src/gateway-anthropic-messages.ts +84 -84
- package/src/gateway-auth.ts +102 -100
- package/src/gateway-backend.ts +274 -274
- package/src/gateway-body.ts +49 -49
- package/src/gateway-config.ts +76 -76
- package/src/gateway-http.ts +104 -104
- package/src/gateway-openai-chat.ts +124 -124
- package/src/gateway-openai-responses.ts +53 -53
- package/src/gateway-parse.ts +224 -224
- package/src/gateway-protocol.ts +52 -52
- package/src/gateway-routes.ts +158 -152
- package/src/gateway.ts +258 -242
- package/src/grok-errors.ts +24 -24
- package/src/grok-imagine.ts +1627 -1627
- package/src/grok-import.ts +151 -151
- package/src/http-json.ts +82 -82
- package/src/ids.ts +59 -45
- package/src/imagine-routes.ts +463 -461
- package/src/index.ts +729 -592
- package/src/invariant.ts +17 -17
- package/src/kimi-errors.ts +26 -26
- package/src/media-store.ts +927 -927
- package/src/oauth-import-routes.ts +324 -314
- package/src/oauth-providers.ts +152 -152
- package/src/oauth-session.ts +183 -183
- package/src/oauth-sources.ts +1104 -1104
- package/src/oauth.ts +620 -620
- package/src/provider.ts +128 -128
- package/src/proxy.ts +11 -99
- package/src/redact.ts +72 -72
- package/src/session.ts +218 -218
- package/src/store.ts +217 -217
- package/src/web-origin.ts +296 -60
- package/src/web-routes.ts +38 -75
package/src/client/constants.ts
CHANGED
|
@@ -1,206 +1,224 @@
|
|
|
1
|
-
/** Static tables for the Coding OAuth settings UI. */
|
|
2
|
-
|
|
3
|
-
import
|
|
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
|
-
export const
|
|
36
|
-
export const
|
|
37
|
-
export const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
export const
|
|
47
|
-
export const
|
|
48
|
-
|
|
49
|
-
export const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
{ key: "
|
|
118
|
-
{
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
{
|
|
165
|
-
slug: "
|
|
166
|
-
route: "
|
|
167
|
-
titleKey: "
|
|
168
|
-
descriptionKey: "
|
|
169
|
-
methods: ["device"],
|
|
170
|
-
recommended: "
|
|
171
|
-
remoteRecommended: "device",
|
|
172
|
-
},
|
|
173
|
-
{
|
|
174
|
-
slug: "
|
|
175
|
-
route: "
|
|
176
|
-
titleKey: "
|
|
177
|
-
descriptionKey: "
|
|
178
|
-
methods: ["browser"],
|
|
179
|
-
recommended: "
|
|
180
|
-
remoteRecommended: "
|
|
181
|
-
},
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
"
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
1
|
+
/** Static tables for the Coding OAuth settings UI. */
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
CAPABILITY_SETTINGS_PATH,
|
|
5
|
+
CODING_OAUTH_LOGIN_CANCEL_PATH,
|
|
6
|
+
CODING_OAUTH_LOGIN_CODE_PATH,
|
|
7
|
+
CODING_OAUTH_LOGIN_PATH,
|
|
8
|
+
CODING_OAUTH_LOGOUT_PATH,
|
|
9
|
+
CODING_OAUTH_MODELS_PATH,
|
|
10
|
+
CODING_OAUTH_STATUS_PATH,
|
|
11
|
+
CODEX_USAGE_PATH as CORE_CODEX_USAGE_PATH,
|
|
12
|
+
GATEWAY_REVEAL_PATH as CORE_GATEWAY_REVEAL_PATH,
|
|
13
|
+
GATEWAY_ROTATE_PATH as CORE_GATEWAY_ROTATE_PATH,
|
|
14
|
+
GATEWAY_SETTINGS_PATH,
|
|
15
|
+
IMAGINE_CREDENTIAL_STATUS_PATH,
|
|
16
|
+
OAUTH_IMPORT_CANCEL_PATH,
|
|
17
|
+
OAUTH_IMPORT_COMMIT_PATH,
|
|
18
|
+
OAUTH_IMPORT_PREVIEW_PATH,
|
|
19
|
+
OAUTH_IMPORT_SOURCES_PATH,
|
|
20
|
+
} from "dsh-coding-oauth-core/contracts";
|
|
21
|
+
import type { GrokBuildSettingsKey } from "./locales.ts";
|
|
22
|
+
import type {
|
|
23
|
+
CapabilityFlagKey,
|
|
24
|
+
CapabilityLimitKey,
|
|
25
|
+
ProviderCardDefinition,
|
|
26
|
+
SettingsTabId,
|
|
27
|
+
SourceCommitAction,
|
|
28
|
+
SourceConflict,
|
|
29
|
+
SourceKind,
|
|
30
|
+
SourcePreviewAction,
|
|
31
|
+
SourceReason,
|
|
32
|
+
} from "./types.ts";
|
|
33
|
+
|
|
34
|
+
export const STATUS_PATH = CODING_OAUTH_STATUS_PATH;
|
|
35
|
+
export const LOGIN_PATH = CODING_OAUTH_LOGIN_PATH;
|
|
36
|
+
export const LOGIN_CODE_PATH = CODING_OAUTH_LOGIN_CODE_PATH;
|
|
37
|
+
export const LOGIN_CANCEL_PATH = CODING_OAUTH_LOGIN_CANCEL_PATH;
|
|
38
|
+
export const LOGOUT_PATH = CODING_OAUTH_LOGOUT_PATH;
|
|
39
|
+
export const MODELS_PATH = CODING_OAUTH_MODELS_PATH;
|
|
40
|
+
export const SOURCES_PATH = OAUTH_IMPORT_SOURCES_PATH;
|
|
41
|
+
export const SOURCES_PREVIEW_PATH = OAUTH_IMPORT_PREVIEW_PATH;
|
|
42
|
+
export const SOURCES_COMMIT_PATH = OAUTH_IMPORT_COMMIT_PATH;
|
|
43
|
+
export const SOURCES_CANCEL_PATH = OAUTH_IMPORT_CANCEL_PATH;
|
|
44
|
+
export const CAPABILITIES_PATH = CAPABILITY_SETTINGS_PATH;
|
|
45
|
+
export const CODEX_USAGE_PATH = CORE_CODEX_USAGE_PATH;
|
|
46
|
+
export const IMAGINE_CREDENTIAL_PATH = IMAGINE_CREDENTIAL_STATUS_PATH;
|
|
47
|
+
export const GATEWAY_PATH = GATEWAY_SETTINGS_PATH;
|
|
48
|
+
export const GATEWAY_REVEAL_PATH = CORE_GATEWAY_REVEAL_PATH;
|
|
49
|
+
export const GATEWAY_ROTATE_PATH = CORE_GATEWAY_ROTATE_PATH;
|
|
50
|
+
export const POLL_INTERVAL_MS = 1_000;
|
|
51
|
+
export const HOUR_MS = 60 * 60 * 1000;
|
|
52
|
+
|
|
53
|
+
export const SOURCE_KINDS: readonly SourceKind[] = ["grok", "codex", "kimi", "claude"];
|
|
54
|
+
export const SOURCE_REASONS: readonly SourceReason[] = ["missing", "unsafe", "invalid", "too_large"];
|
|
55
|
+
export const SOURCE_CONFLICTS: readonly SourceConflict[] = [
|
|
56
|
+
"none",
|
|
57
|
+
"same_credential",
|
|
58
|
+
"same_account",
|
|
59
|
+
"different_account",
|
|
60
|
+
"unknown_account",
|
|
61
|
+
"unreadable_destination",
|
|
62
|
+
"unsafe_destination",
|
|
63
|
+
];
|
|
64
|
+
export const SOURCE_PREVIEW_ACTIONS: readonly SourcePreviewAction[] = ["import", "reuse", "overwrite", "blocked"];
|
|
65
|
+
export const SOURCE_COMMIT_ACTIONS: readonly SourceCommitAction[] = ["imported", "unchanged", "overwritten"];
|
|
66
|
+
|
|
67
|
+
export const SOURCE_DEFAULT_PATH: { readonly [K in SourceKind]: string } = {
|
|
68
|
+
grok: "~/.grok/auth.json",
|
|
69
|
+
codex: "~/.codex/auth.json",
|
|
70
|
+
kimi: "~/.kimi/credentials/kimi-code.json",
|
|
71
|
+
claude: "~/.claude/.credentials.json",
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export const SOURCE_KIND_KEY: { readonly [K in SourceKind]: GrokBuildSettingsKey } = {
|
|
75
|
+
grok: "sourceKindGrok",
|
|
76
|
+
codex: "sourceKindCodex",
|
|
77
|
+
kimi: "sourceKindKimi",
|
|
78
|
+
claude: "sourceKindClaude",
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export const SOURCE_REASON_KEY: { readonly [K in SourceReason]: GrokBuildSettingsKey } = {
|
|
82
|
+
missing: "sourceReasonMissing",
|
|
83
|
+
unsafe: "sourceReasonUnsafe",
|
|
84
|
+
invalid: "sourceReasonInvalid",
|
|
85
|
+
too_large: "sourceReasonTooLarge",
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export const SOURCE_CONFLICT_KEY: { readonly [K in SourceConflict]: GrokBuildSettingsKey } = {
|
|
89
|
+
none: "sourceConflictNone",
|
|
90
|
+
same_credential: "sourceConflictSameCredential",
|
|
91
|
+
same_account: "sourceConflictSameAccount",
|
|
92
|
+
different_account: "sourceConflictDifferentAccount",
|
|
93
|
+
unknown_account: "sourceConflictUnknownAccount",
|
|
94
|
+
unreadable_destination: "sourceConflictUnreadableDestination",
|
|
95
|
+
unsafe_destination: "sourceConflictUnsafeDestination",
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export const SOURCE_PREVIEW_ACTION_KEY: { readonly [K in SourcePreviewAction]: GrokBuildSettingsKey } = {
|
|
99
|
+
import: "sourceActionImport",
|
|
100
|
+
reuse: "sourceActionReuse",
|
|
101
|
+
overwrite: "sourceActionOverwrite",
|
|
102
|
+
blocked: "sourceActionBlocked",
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export const SOURCE_COMMIT_ACTION_KEY: { readonly [K in SourceCommitAction]: GrokBuildSettingsKey } = {
|
|
106
|
+
imported: "sourceCommitImported",
|
|
107
|
+
unchanged: "sourceCommitUnchanged",
|
|
108
|
+
overwritten: "sourceCommitOverwritten",
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
export const CAPABILITY_TOGGLES: readonly {
|
|
112
|
+
key: CapabilityFlagKey;
|
|
113
|
+
label: GrokBuildSettingsKey;
|
|
114
|
+
hint: GrokBuildSettingsKey;
|
|
115
|
+
requiresImages?: true;
|
|
116
|
+
}[] = [
|
|
117
|
+
{ key: "codexSearch", label: "capCodexSearch", hint: "capCodexSearchHint" },
|
|
118
|
+
{ key: "codexImages", label: "capCodexImages", hint: "capCodexImagesHint" },
|
|
119
|
+
{ key: "codexImageEdits", label: "capCodexImageEdits", hint: "capCodexImageEditsHint", requiresImages: true },
|
|
120
|
+
{ key: "codexUsage", label: "capCodexUsage", hint: "capCodexUsageHint" },
|
|
121
|
+
{ key: "codexFast", label: "capCodexFast", hint: "capCodexFastHint" },
|
|
122
|
+
{ key: "grokImagineImage", label: "capGrokImagineImage", hint: "capGrokImagineImageHint" },
|
|
123
|
+
{ key: "grokImagineVideo", label: "capGrokImagineVideo", hint: "capGrokImagineVideoHint" },
|
|
124
|
+
];
|
|
125
|
+
|
|
126
|
+
export const CAPABILITY_LIMITS: readonly {
|
|
127
|
+
key: CapabilityLimitKey;
|
|
128
|
+
label: GrokBuildSettingsKey;
|
|
129
|
+
hint: GrokBuildSettingsKey;
|
|
130
|
+
min: number;
|
|
131
|
+
max: number;
|
|
132
|
+
scale: number;
|
|
133
|
+
}[] = [
|
|
134
|
+
{ key: "searchResults", label: "capSearchResults", hint: "capSearchResultsHint", min: 1, max: 20, scale: 1 },
|
|
135
|
+
{ key: "imageCount", label: "capImageCount", hint: "capImageCountHint", min: 1, max: 4, scale: 1 },
|
|
136
|
+
{
|
|
137
|
+
key: "videoArtifactTtlMs",
|
|
138
|
+
label: "capVideoTtlHours",
|
|
139
|
+
hint: "capVideoTtlHoursHint",
|
|
140
|
+
min: 1,
|
|
141
|
+
max: 168,
|
|
142
|
+
scale: HOUR_MS,
|
|
143
|
+
},
|
|
144
|
+
];
|
|
145
|
+
|
|
146
|
+
export const IMAGINE_SOURCE_KEY: { readonly [source: string]: GrokBuildSettingsKey } = {
|
|
147
|
+
none: "imagineSourceNone",
|
|
148
|
+
env: "imagineSourceEnv",
|
|
149
|
+
environment: "imagineSourceEnv",
|
|
150
|
+
"xai-api-key": "imagineSourceEnv",
|
|
151
|
+
xai_api_key: "imagineSourceEnv",
|
|
152
|
+
"api-key": "imagineSourceApiKey",
|
|
153
|
+
api_key: "imagineSourceApiKey",
|
|
154
|
+
apikey: "imagineSourceApiKey",
|
|
155
|
+
key: "imagineSourceApiKey",
|
|
156
|
+
settings: "imagineSourceApiKey",
|
|
157
|
+
oauth: "imagineSourceOAuth",
|
|
158
|
+
"oauth-access": "imagineSourceOAuth",
|
|
159
|
+
"grok-cli-key": "imagineSourceCliKey",
|
|
160
|
+
"cli-key": "imagineSourceCliKey",
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
export const PROVIDERS: readonly ProviderCardDefinition[] = [
|
|
164
|
+
{
|
|
165
|
+
slug: "grok",
|
|
166
|
+
route: "grok-build",
|
|
167
|
+
titleKey: "grokTitle",
|
|
168
|
+
descriptionKey: "grokDescription",
|
|
169
|
+
methods: ["pkce", "device"],
|
|
170
|
+
recommended: "pkce",
|
|
171
|
+
remoteRecommended: "device",
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
slug: "codex",
|
|
175
|
+
route: "codex-oauth",
|
|
176
|
+
titleKey: "codexTitle",
|
|
177
|
+
descriptionKey: "codexDescription",
|
|
178
|
+
methods: ["device", "browser"],
|
|
179
|
+
recommended: "device",
|
|
180
|
+
remoteRecommended: "device",
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
slug: "kimi",
|
|
184
|
+
route: "kimi-code-oauth",
|
|
185
|
+
titleKey: "kimiTitle",
|
|
186
|
+
descriptionKey: "kimiDescription",
|
|
187
|
+
methods: ["device"],
|
|
188
|
+
recommended: "device",
|
|
189
|
+
remoteRecommended: "device",
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
slug: "claude",
|
|
193
|
+
route: "claude-code-oauth",
|
|
194
|
+
titleKey: "claudeTitle",
|
|
195
|
+
descriptionKey: "claudeDescription",
|
|
196
|
+
methods: ["browser"],
|
|
197
|
+
recommended: "browser",
|
|
198
|
+
remoteRecommended: "browser",
|
|
199
|
+
},
|
|
200
|
+
];
|
|
201
|
+
|
|
202
|
+
export const SETTINGS_TABS: readonly { id: SettingsTabId; label: GrokBuildSettingsKey }[] = [
|
|
203
|
+
{ id: "accounts", label: "tabAccounts" },
|
|
204
|
+
{ id: "gateway", label: "tabGateway" },
|
|
205
|
+
{ id: "capabilities", label: "tabCapabilities" },
|
|
206
|
+
{ id: "about", label: "tabAbout" },
|
|
207
|
+
];
|
|
208
|
+
|
|
209
|
+
export const GATEWAY_PORT_MIN = 1024;
|
|
210
|
+
export const GATEWAY_PORT_MAX = 65_535;
|
|
211
|
+
export const GATEWAY_RANDOM_PORT_MIN = 18_100;
|
|
212
|
+
export const GATEWAY_RANDOM_PORT_MAX = 18_999;
|
|
213
|
+
export const GATEWAY_RANDOM_RESERVED = new Set([22, 53, 3080, 7890, 9090, 18_080]);
|
|
214
|
+
|
|
215
|
+
export const CONSUMED_PREVIEW_CODES = new Set([
|
|
216
|
+
"preview_invalid",
|
|
217
|
+
"preview_expired",
|
|
218
|
+
"source_changed",
|
|
219
|
+
"destination_changed",
|
|
220
|
+
"confirm_required",
|
|
221
|
+
"unsafe_destination",
|
|
222
|
+
]);
|
|
223
|
+
|
|
224
|
+
export const PLUGIN_VERSION = "0.6.2";
|
package/src/client/display.ts
CHANGED
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
/** Pure display helpers for remote UX and CLI pull noise control. */
|
|
2
|
-
|
|
3
|
-
import type { GrokBuildSettingsInjected, LoginMethod, ProviderCardDefinition, SourceStatus } from "./types.ts";
|
|
4
|
-
|
|
5
|
-
const LOOPBACK_HOSTS = new Set(["localhost", "127.0.0.1", "[::1]", "::1"]);
|
|
6
|
-
|
|
7
|
-
/** True when the Settings page is served from a non-loopback host (typical remote DSH). */
|
|
8
|
-
export function isLikelyRemoteHost(hostname: string): boolean {
|
|
9
|
-
const normalized = hostname.trim().toLowerCase();
|
|
10
|
-
if (normalized.length === 0) return false;
|
|
11
|
-
if (LOOPBACK_HOSTS.has(normalized)) return false;
|
|
12
|
-
if (normalized.endsWith(".localhost")) return false;
|
|
13
|
-
return true;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function preferredLoginMethod(definition: ProviderCardDefinition, remote: boolean): LoginMethod {
|
|
17
|
-
if (
|
|
18
|
-
remote &&
|
|
19
|
-
definition.remoteRecommended !== undefined &&
|
|
20
|
-
definition.methods.includes(definition.remoteRecommended)
|
|
21
|
-
) {
|
|
22
|
-
return definition.remoteRecommended;
|
|
23
|
-
}
|
|
24
|
-
return definition.recommended;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/** Put the recommended method first so the primary CTA is unambiguous. */
|
|
28
|
-
export function orderedLoginMethods(definition: ProviderCardDefinition, remote: boolean): LoginMethod[] {
|
|
29
|
-
const preferred = preferredLoginMethod(definition, remote);
|
|
30
|
-
const rest = definition.methods.filter((method) => method !== preferred);
|
|
31
|
-
return definition.methods.includes(preferred) ? [preferred, ...rest] : [...definition.methods];
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/** Per-card CLI “missing” copy is noisy on remote hosts; keep only actionable reasons. */
|
|
35
|
-
export function shouldShowPerCardSourceReason(source: SourceStatus | undefined): boolean {
|
|
36
|
-
if (source === undefined || source.available) return false;
|
|
37
|
-
if (source.reason === undefined) return false;
|
|
38
|
-
return source.reason !== "missing";
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export function allOfficialCliMissing(sources: readonly SourceStatus[] | undefined): boolean {
|
|
42
|
-
if (sources === undefined || sources.length === 0) return false;
|
|
43
|
-
return sources.every((source) => !source.available && (source.reason === undefined || source.reason === "missing"));
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export function anyOfficialCliAvailable(sources: readonly SourceStatus[] | undefined): boolean {
|
|
47
|
-
return sources?.some((source) => source.available) === true;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export function methodLabel(
|
|
51
|
-
method: LoginMethod,
|
|
52
|
-
t: GrokBuildSettingsInjected["t"],
|
|
53
|
-
options?: { remote?: boolean; primary?: boolean },
|
|
54
|
-
): string {
|
|
55
|
-
if (method === "device") {
|
|
56
|
-
if (options?.remote === true && options.primary === true) return t("deviceLoginRemote");
|
|
57
|
-
return t("deviceLogin");
|
|
58
|
-
}
|
|
59
|
-
if (method === "browser") return t("browserLogin");
|
|
60
|
-
return t("pkceLogin");
|
|
61
|
-
}
|
|
1
|
+
/** Pure display helpers for remote UX and CLI pull noise control. */
|
|
2
|
+
|
|
3
|
+
import type { GrokBuildSettingsInjected, LoginMethod, ProviderCardDefinition, SourceStatus } from "./types.ts";
|
|
4
|
+
|
|
5
|
+
const LOOPBACK_HOSTS = new Set(["localhost", "127.0.0.1", "[::1]", "::1"]);
|
|
6
|
+
|
|
7
|
+
/** True when the Settings page is served from a non-loopback host (typical remote DSH). */
|
|
8
|
+
export function isLikelyRemoteHost(hostname: string): boolean {
|
|
9
|
+
const normalized = hostname.trim().toLowerCase();
|
|
10
|
+
if (normalized.length === 0) return false;
|
|
11
|
+
if (LOOPBACK_HOSTS.has(normalized)) return false;
|
|
12
|
+
if (normalized.endsWith(".localhost")) return false;
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function preferredLoginMethod(definition: ProviderCardDefinition, remote: boolean): LoginMethod {
|
|
17
|
+
if (
|
|
18
|
+
remote &&
|
|
19
|
+
definition.remoteRecommended !== undefined &&
|
|
20
|
+
definition.methods.includes(definition.remoteRecommended)
|
|
21
|
+
) {
|
|
22
|
+
return definition.remoteRecommended;
|
|
23
|
+
}
|
|
24
|
+
return definition.recommended;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Put the recommended method first so the primary CTA is unambiguous. */
|
|
28
|
+
export function orderedLoginMethods(definition: ProviderCardDefinition, remote: boolean): LoginMethod[] {
|
|
29
|
+
const preferred = preferredLoginMethod(definition, remote);
|
|
30
|
+
const rest = definition.methods.filter((method) => method !== preferred);
|
|
31
|
+
return definition.methods.includes(preferred) ? [preferred, ...rest] : [...definition.methods];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Per-card CLI “missing” copy is noisy on remote hosts; keep only actionable reasons. */
|
|
35
|
+
export function shouldShowPerCardSourceReason(source: SourceStatus | undefined): boolean {
|
|
36
|
+
if (source === undefined || source.available) return false;
|
|
37
|
+
if (source.reason === undefined) return false;
|
|
38
|
+
return source.reason !== "missing";
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function allOfficialCliMissing(sources: readonly SourceStatus[] | undefined): boolean {
|
|
42
|
+
if (sources === undefined || sources.length === 0) return false;
|
|
43
|
+
return sources.every((source) => !source.available && (source.reason === undefined || source.reason === "missing"));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function anyOfficialCliAvailable(sources: readonly SourceStatus[] | undefined): boolean {
|
|
47
|
+
return sources?.some((source) => source.available) === true;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function methodLabel(
|
|
51
|
+
method: LoginMethod,
|
|
52
|
+
t: GrokBuildSettingsInjected["t"],
|
|
53
|
+
options?: { remote?: boolean; primary?: boolean },
|
|
54
|
+
): string {
|
|
55
|
+
if (method === "device") {
|
|
56
|
+
if (options?.remote === true && options.primary === true) return t("deviceLoginRemote");
|
|
57
|
+
return t("deviceLogin");
|
|
58
|
+
}
|
|
59
|
+
if (method === "browser") return t("browserLogin");
|
|
60
|
+
return t("pkceLogin");
|
|
61
|
+
}
|