dsh-coding-subscription-oauth 0.6.3 → 0.6.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.
Files changed (116) hide show
  1. package/CHANGELOG.md +258 -250
  2. package/CONTRIBUTING.md +129 -129
  3. package/INSTALL.md +256 -255
  4. package/LICENSE +19 -19
  5. package/NOTICE +11 -11
  6. package/README.de.md +303 -303
  7. package/README.es.md +304 -304
  8. package/README.fr.md +304 -304
  9. package/README.ja.md +304 -304
  10. package/README.ko.md +304 -304
  11. package/README.md +320 -320
  12. package/README.pt-BR.md +304 -304
  13. package/README.ru.md +304 -304
  14. package/README.zh-CN.md +318 -318
  15. package/compatibility/dsh-bom.json +30 -30
  16. package/cordis.patch.yml +13 -13
  17. package/docs/00-project-rules.md +212 -212
  18. package/docs/02-architecture.md +138 -138
  19. package/docs/02-architecture.zh-CN.md +138 -138
  20. package/lib/bin.js +1333 -569
  21. package/lib/bin.js.map +4 -4
  22. package/lib/client.js +1 -1
  23. package/lib/client.js.map +2 -2
  24. package/lib/index.js +689 -25492
  25. package/lib/index.js.map +4 -4
  26. package/lib/invariant.js.map +1 -1
  27. package/media/en/settings_accounts.png +0 -0
  28. package/media/en/settings_capabilities.png +0 -0
  29. package/media/en/settings_gateway.png +0 -0
  30. package/media/settings_accounts.png +0 -0
  31. package/media/settings_capabilities.png +0 -0
  32. package/media/settings_gateway.png +0 -0
  33. package/media/settings_overview.png +0 -0
  34. package/media/zh-CN/settings_accounts.png +0 -0
  35. package/media/zh-CN/settings_capabilities.png +0 -0
  36. package/media/zh-CN/settings_gateway.png +0 -0
  37. package/package.json +223 -223
  38. package/patches/dsh-agy@0.1.2.patch +25 -25
  39. package/scripts/release.mjs +186 -186
  40. package/scripts/smoke-deployed-routes.mjs +146 -146
  41. package/scripts/verify-deployed-catalog.mjs +87 -87
  42. package/src/adapter.ts +348 -348
  43. package/src/alias-adapter.ts +147 -147
  44. package/src/auth-routes.ts +921 -921
  45. package/src/auth.ts +67 -67
  46. package/src/bin.ts +350 -350
  47. package/src/capability-routes.ts +279 -279
  48. package/src/capability-runtime.ts +314 -314
  49. package/src/capability-settings.ts +671 -671
  50. package/src/capability-tools.ts +685 -685
  51. package/src/catalog.ts +271 -271
  52. package/src/client/GrokBuildSettings.tsx +771 -771
  53. package/src/client/api.ts +88 -88
  54. package/src/client/components/AboutTab.tsx +30 -30
  55. package/src/client/components/AccountsTab.tsx +241 -241
  56. package/src/client/components/Badge.tsx +33 -33
  57. package/src/client/components/CapabilitiesTab.tsx +265 -265
  58. package/src/client/components/CliPullPreview.tsx +116 -116
  59. package/src/client/components/CopyButton.tsx +57 -57
  60. package/src/client/components/GatewayTab.tsx +469 -469
  61. package/src/client/components/NoticeBanner.tsx +46 -46
  62. package/src/client/components/ProgressBar.tsx +53 -53
  63. package/src/client/components/ProviderCard.tsx +606 -606
  64. package/src/client/components/SettingsTabs.tsx +75 -75
  65. package/src/client/components/ToggleSwitch.tsx +71 -71
  66. package/src/client/constants.ts +230 -230
  67. package/src/client/display.ts +61 -61
  68. package/src/client/dshClientAdapter.ts +127 -127
  69. package/src/client/gatewaySnippets.ts +37 -37
  70. package/src/client/index.tsx +156 -156
  71. package/src/client/locales.ts +540 -540
  72. package/src/client/microStyles.ts +52 -52
  73. package/src/client/parsers.ts +398 -398
  74. package/src/client/styles.ts +325 -325
  75. package/src/client/types.ts +199 -199
  76. package/src/codex-http.ts +447 -447
  77. package/src/codex-images.ts +503 -503
  78. package/src/codex-model-capabilities.ts +320 -320
  79. package/src/codex-search.ts +245 -245
  80. package/src/codex-usage.ts +263 -263
  81. package/src/compatibility.ts +55 -55
  82. package/src/dsh-host-adapter.ts +173 -173
  83. package/src/gateway-anthropic-messages.ts +84 -84
  84. package/src/gateway-auth.ts +102 -102
  85. package/src/gateway-backend.ts +274 -274
  86. package/src/gateway-body.ts +49 -49
  87. package/src/gateway-config.ts +76 -76
  88. package/src/gateway-http.ts +104 -104
  89. package/src/gateway-openai-chat.ts +124 -124
  90. package/src/gateway-openai-responses.ts +53 -53
  91. package/src/gateway-parse.ts +224 -224
  92. package/src/gateway-protocol.ts +52 -52
  93. package/src/gateway-routes.ts +158 -158
  94. package/src/gateway.ts +258 -258
  95. package/src/grok-errors.ts +24 -24
  96. package/src/grok-imagine.ts +1627 -1627
  97. package/src/grok-import.ts +151 -151
  98. package/src/http-json.ts +82 -82
  99. package/src/ids.ts +59 -59
  100. package/src/imagine-routes.ts +463 -463
  101. package/src/index.ts +735 -735
  102. package/src/invariant.ts +17 -17
  103. package/src/kimi-errors.ts +26 -26
  104. package/src/media-store.ts +927 -927
  105. package/src/oauth-import-routes.ts +324 -324
  106. package/src/oauth-providers.ts +152 -152
  107. package/src/oauth-session.ts +183 -183
  108. package/src/oauth-sources.ts +1104 -1104
  109. package/src/oauth.ts +620 -620
  110. package/src/provider.ts +128 -128
  111. package/src/proxy.ts +11 -11
  112. package/src/redact.ts +72 -72
  113. package/src/session.ts +218 -218
  114. package/src/store.ts +217 -217
  115. package/src/web-origin.ts +296 -296
  116. package/src/web-routes.ts +38 -38
@@ -1,230 +1,230 @@
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
- {
121
- key: "codexImagesAnyModel",
122
- label: "capCodexImagesAnyModel",
123
- hint: "capCodexImagesAnyModelHint",
124
- requiresImages: true,
125
- },
126
- { key: "codexUsage", label: "capCodexUsage", hint: "capCodexUsageHint" },
127
- { key: "codexFast", label: "capCodexFast", hint: "capCodexFastHint" },
128
- { key: "grokImagineImage", label: "capGrokImagineImage", hint: "capGrokImagineImageHint" },
129
- { key: "grokImagineVideo", label: "capGrokImagineVideo", hint: "capGrokImagineVideoHint" },
130
- ];
131
-
132
- export const CAPABILITY_LIMITS: readonly {
133
- key: CapabilityLimitKey;
134
- label: GrokBuildSettingsKey;
135
- hint: GrokBuildSettingsKey;
136
- min: number;
137
- max: number;
138
- scale: number;
139
- }[] = [
140
- { key: "searchResults", label: "capSearchResults", hint: "capSearchResultsHint", min: 1, max: 20, scale: 1 },
141
- { key: "imageCount", label: "capImageCount", hint: "capImageCountHint", min: 1, max: 4, scale: 1 },
142
- {
143
- key: "videoArtifactTtlMs",
144
- label: "capVideoTtlHours",
145
- hint: "capVideoTtlHoursHint",
146
- min: 1,
147
- max: 168,
148
- scale: HOUR_MS,
149
- },
150
- ];
151
-
152
- export const IMAGINE_SOURCE_KEY: { readonly [source: string]: GrokBuildSettingsKey } = {
153
- none: "imagineSourceNone",
154
- env: "imagineSourceEnv",
155
- environment: "imagineSourceEnv",
156
- "xai-api-key": "imagineSourceEnv",
157
- xai_api_key: "imagineSourceEnv",
158
- "api-key": "imagineSourceApiKey",
159
- api_key: "imagineSourceApiKey",
160
- apikey: "imagineSourceApiKey",
161
- key: "imagineSourceApiKey",
162
- settings: "imagineSourceApiKey",
163
- oauth: "imagineSourceOAuth",
164
- "oauth-access": "imagineSourceOAuth",
165
- "grok-cli-key": "imagineSourceCliKey",
166
- "cli-key": "imagineSourceCliKey",
167
- };
168
-
169
- export const PROVIDERS: readonly ProviderCardDefinition[] = [
170
- {
171
- slug: "grok",
172
- route: "grok-build",
173
- titleKey: "grokTitle",
174
- descriptionKey: "grokDescription",
175
- methods: ["pkce", "device"],
176
- recommended: "pkce",
177
- remoteRecommended: "device",
178
- },
179
- {
180
- slug: "codex",
181
- route: "codex-oauth",
182
- titleKey: "codexTitle",
183
- descriptionKey: "codexDescription",
184
- methods: ["device", "browser"],
185
- recommended: "device",
186
- remoteRecommended: "device",
187
- },
188
- {
189
- slug: "kimi",
190
- route: "kimi-code-oauth",
191
- titleKey: "kimiTitle",
192
- descriptionKey: "kimiDescription",
193
- methods: ["device"],
194
- recommended: "device",
195
- remoteRecommended: "device",
196
- },
197
- {
198
- slug: "claude",
199
- route: "claude-code-oauth",
200
- titleKey: "claudeTitle",
201
- descriptionKey: "claudeDescription",
202
- methods: ["browser"],
203
- recommended: "browser",
204
- remoteRecommended: "browser",
205
- },
206
- ];
207
-
208
- export const SETTINGS_TABS: readonly { id: SettingsTabId; label: GrokBuildSettingsKey }[] = [
209
- { id: "accounts", label: "tabAccounts" },
210
- { id: "gateway", label: "tabGateway" },
211
- { id: "capabilities", label: "tabCapabilities" },
212
- { id: "about", label: "tabAbout" },
213
- ];
214
-
215
- export const GATEWAY_PORT_MIN = 1024;
216
- export const GATEWAY_PORT_MAX = 65_535;
217
- export const GATEWAY_RANDOM_PORT_MIN = 18_100;
218
- export const GATEWAY_RANDOM_PORT_MAX = 18_999;
219
- export const GATEWAY_RANDOM_RESERVED = new Set([22, 53, 3080, 7890, 9090, 18_080]);
220
-
221
- export const CONSUMED_PREVIEW_CODES = new Set([
222
- "preview_invalid",
223
- "preview_expired",
224
- "source_changed",
225
- "destination_changed",
226
- "confirm_required",
227
- "unsafe_destination",
228
- ]);
229
-
230
- export const PLUGIN_VERSION = "0.6.3";
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
+ {
121
+ key: "codexImagesAnyModel",
122
+ label: "capCodexImagesAnyModel",
123
+ hint: "capCodexImagesAnyModelHint",
124
+ requiresImages: true,
125
+ },
126
+ { key: "codexUsage", label: "capCodexUsage", hint: "capCodexUsageHint" },
127
+ { key: "codexFast", label: "capCodexFast", hint: "capCodexFastHint" },
128
+ { key: "grokImagineImage", label: "capGrokImagineImage", hint: "capGrokImagineImageHint" },
129
+ { key: "grokImagineVideo", label: "capGrokImagineVideo", hint: "capGrokImagineVideoHint" },
130
+ ];
131
+
132
+ export const CAPABILITY_LIMITS: readonly {
133
+ key: CapabilityLimitKey;
134
+ label: GrokBuildSettingsKey;
135
+ hint: GrokBuildSettingsKey;
136
+ min: number;
137
+ max: number;
138
+ scale: number;
139
+ }[] = [
140
+ { key: "searchResults", label: "capSearchResults", hint: "capSearchResultsHint", min: 1, max: 20, scale: 1 },
141
+ { key: "imageCount", label: "capImageCount", hint: "capImageCountHint", min: 1, max: 4, scale: 1 },
142
+ {
143
+ key: "videoArtifactTtlMs",
144
+ label: "capVideoTtlHours",
145
+ hint: "capVideoTtlHoursHint",
146
+ min: 1,
147
+ max: 168,
148
+ scale: HOUR_MS,
149
+ },
150
+ ];
151
+
152
+ export const IMAGINE_SOURCE_KEY: { readonly [source: string]: GrokBuildSettingsKey } = {
153
+ none: "imagineSourceNone",
154
+ env: "imagineSourceEnv",
155
+ environment: "imagineSourceEnv",
156
+ "xai-api-key": "imagineSourceEnv",
157
+ xai_api_key: "imagineSourceEnv",
158
+ "api-key": "imagineSourceApiKey",
159
+ api_key: "imagineSourceApiKey",
160
+ apikey: "imagineSourceApiKey",
161
+ key: "imagineSourceApiKey",
162
+ settings: "imagineSourceApiKey",
163
+ oauth: "imagineSourceOAuth",
164
+ "oauth-access": "imagineSourceOAuth",
165
+ "grok-cli-key": "imagineSourceCliKey",
166
+ "cli-key": "imagineSourceCliKey",
167
+ };
168
+
169
+ export const PROVIDERS: readonly ProviderCardDefinition[] = [
170
+ {
171
+ slug: "grok",
172
+ route: "grok-build",
173
+ titleKey: "grokTitle",
174
+ descriptionKey: "grokDescription",
175
+ methods: ["pkce", "device"],
176
+ recommended: "pkce",
177
+ remoteRecommended: "device",
178
+ },
179
+ {
180
+ slug: "codex",
181
+ route: "codex-oauth",
182
+ titleKey: "codexTitle",
183
+ descriptionKey: "codexDescription",
184
+ methods: ["device", "browser"],
185
+ recommended: "device",
186
+ remoteRecommended: "device",
187
+ },
188
+ {
189
+ slug: "kimi",
190
+ route: "kimi-code-oauth",
191
+ titleKey: "kimiTitle",
192
+ descriptionKey: "kimiDescription",
193
+ methods: ["device"],
194
+ recommended: "device",
195
+ remoteRecommended: "device",
196
+ },
197
+ {
198
+ slug: "claude",
199
+ route: "claude-code-oauth",
200
+ titleKey: "claudeTitle",
201
+ descriptionKey: "claudeDescription",
202
+ methods: ["browser"],
203
+ recommended: "browser",
204
+ remoteRecommended: "browser",
205
+ },
206
+ ];
207
+
208
+ export const SETTINGS_TABS: readonly { id: SettingsTabId; label: GrokBuildSettingsKey }[] = [
209
+ { id: "accounts", label: "tabAccounts" },
210
+ { id: "gateway", label: "tabGateway" },
211
+ { id: "capabilities", label: "tabCapabilities" },
212
+ { id: "about", label: "tabAbout" },
213
+ ];
214
+
215
+ export const GATEWAY_PORT_MIN = 1024;
216
+ export const GATEWAY_PORT_MAX = 65_535;
217
+ export const GATEWAY_RANDOM_PORT_MIN = 18_100;
218
+ export const GATEWAY_RANDOM_PORT_MAX = 18_999;
219
+ export const GATEWAY_RANDOM_RESERVED = new Set([22, 53, 3080, 7890, 9090, 18_080]);
220
+
221
+ export const CONSUMED_PREVIEW_CODES = new Set([
222
+ "preview_invalid",
223
+ "preview_expired",
224
+ "source_changed",
225
+ "destination_changed",
226
+ "confirm_required",
227
+ "unsafe_destination",
228
+ ]);
229
+
230
+ export const PLUGIN_VERSION = "0.6.4";
@@ -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
+ }