dsh-coding-subscription-oauth 0.6.2 → 0.6.3

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 (121) hide show
  1. package/CHANGELOG.md +222 -206
  2. package/CONTRIBUTING.md +129 -120
  3. package/INSTALL.md +218 -218
  4. package/LICENSE +19 -19
  5. package/NOTICE +11 -11
  6. package/README.de.md +289 -289
  7. package/README.es.md +290 -290
  8. package/README.fr.md +290 -290
  9. package/README.ja.md +290 -290
  10. package/README.ko.md +290 -290
  11. package/README.md +304 -304
  12. package/README.pt-BR.md +290 -290
  13. package/README.ru.md +290 -290
  14. package/README.zh-CN.md +302 -302
  15. package/compatibility/dsh-bom.json +0 -0
  16. package/cordis.patch.yml +13 -13
  17. package/docs/00-project-rules.md +212 -195
  18. package/docs/02-architecture.md +130 -130
  19. package/docs/02-architecture.zh-CN.md +130 -130
  20. package/lib/bin.js.map +1 -1
  21. package/lib/capability-settings.d.ts +8 -2
  22. package/lib/capability-settings.d.ts.map +1 -1
  23. package/lib/capability-tools.d.ts +7 -2
  24. package/lib/capability-tools.d.ts.map +1 -1
  25. package/lib/client.js +3 -3
  26. package/lib/client.js.map +2 -2
  27. package/lib/codex-images.d.ts +8 -0
  28. package/lib/codex-images.d.ts.map +1 -1
  29. package/lib/index.js +32 -7
  30. package/lib/index.js.map +2 -2
  31. package/lib/invariant.js.map +1 -1
  32. package/media/en/settings_accounts.png +0 -0
  33. package/media/en/settings_capabilities.png +0 -0
  34. package/media/en/settings_gateway.png +0 -0
  35. package/media/settings_accounts.png +0 -0
  36. package/media/settings_capabilities.png +0 -0
  37. package/media/settings_gateway.png +0 -0
  38. package/media/settings_overview.png +0 -0
  39. package/media/zh-CN/settings_accounts.png +0 -0
  40. package/media/zh-CN/settings_capabilities.png +0 -0
  41. package/media/zh-CN/settings_gateway.png +0 -0
  42. package/package.json +148 -148
  43. package/patches/dsh-agy@0.1.2.patch +25 -25
  44. package/scripts/release.mjs +186 -186
  45. package/scripts/smoke-deployed-routes.mjs +146 -146
  46. package/scripts/verify-deployed-catalog.mjs +87 -87
  47. package/src/adapter.ts +273 -273
  48. package/src/alias-adapter.ts +130 -130
  49. package/src/auth-routes.ts +921 -921
  50. package/src/auth.ts +67 -67
  51. package/src/bin.ts +350 -350
  52. package/src/capability-routes.ts +279 -279
  53. package/src/capability-runtime.ts +314 -313
  54. package/src/capability-settings.ts +671 -658
  55. package/src/capability-tools.ts +685 -666
  56. package/src/catalog.ts +271 -271
  57. package/src/client/GrokBuildSettings.tsx +771 -770
  58. package/src/client/api.ts +88 -88
  59. package/src/client/components/AboutTab.tsx +30 -30
  60. package/src/client/components/AccountsTab.tsx +241 -241
  61. package/src/client/components/Badge.tsx +33 -33
  62. package/src/client/components/CapabilitiesTab.tsx +265 -265
  63. package/src/client/components/CliPullPreview.tsx +116 -116
  64. package/src/client/components/CopyButton.tsx +57 -57
  65. package/src/client/components/GatewayTab.tsx +469 -469
  66. package/src/client/components/NoticeBanner.tsx +46 -46
  67. package/src/client/components/ProgressBar.tsx +53 -53
  68. package/src/client/components/ProviderCard.tsx +606 -606
  69. package/src/client/components/SettingsTabs.tsx +75 -75
  70. package/src/client/components/ToggleSwitch.tsx +71 -71
  71. package/src/client/constants.ts +230 -224
  72. package/src/client/display.ts +61 -61
  73. package/src/client/dshClientAdapter.ts +127 -127
  74. package/src/client/gatewaySnippets.ts +37 -37
  75. package/src/client/index.tsx +156 -156
  76. package/src/client/locales.ts +540 -535
  77. package/src/client/microStyles.ts +52 -52
  78. package/src/client/parsers.ts +398 -396
  79. package/src/client/styles.ts +325 -325
  80. package/src/client/types.ts +199 -197
  81. package/src/codex-http.ts +447 -447
  82. package/src/codex-images.ts +503 -485
  83. package/src/codex-model-capabilities.ts +320 -320
  84. package/src/codex-search.ts +245 -245
  85. package/src/codex-usage.ts +263 -263
  86. package/src/compatibility.ts +41 -41
  87. package/src/dsh-host-adapter.ts +173 -173
  88. package/src/gateway-anthropic-messages.ts +84 -84
  89. package/src/gateway-auth.ts +102 -102
  90. package/src/gateway-backend.ts +274 -274
  91. package/src/gateway-body.ts +49 -49
  92. package/src/gateway-config.ts +76 -76
  93. package/src/gateway-http.ts +104 -104
  94. package/src/gateway-openai-chat.ts +124 -124
  95. package/src/gateway-openai-responses.ts +53 -53
  96. package/src/gateway-parse.ts +224 -224
  97. package/src/gateway-protocol.ts +52 -52
  98. package/src/gateway-routes.ts +158 -158
  99. package/src/gateway.ts +258 -258
  100. package/src/grok-errors.ts +24 -24
  101. package/src/grok-imagine.ts +1627 -1627
  102. package/src/grok-import.ts +151 -151
  103. package/src/http-json.ts +82 -82
  104. package/src/ids.ts +59 -59
  105. package/src/imagine-routes.ts +463 -463
  106. package/src/index.ts +709 -709
  107. package/src/invariant.ts +17 -17
  108. package/src/kimi-errors.ts +26 -26
  109. package/src/media-store.ts +927 -927
  110. package/src/oauth-import-routes.ts +324 -324
  111. package/src/oauth-providers.ts +152 -152
  112. package/src/oauth-session.ts +183 -183
  113. package/src/oauth-sources.ts +1104 -1104
  114. package/src/oauth.ts +620 -620
  115. package/src/provider.ts +128 -128
  116. package/src/proxy.ts +11 -11
  117. package/src/redact.ts +72 -72
  118. package/src/session.ts +218 -218
  119. package/src/store.ts +217 -217
  120. package/src/web-origin.ts +296 -296
  121. package/src/web-routes.ts +38 -38
@@ -1,224 +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
- { 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";
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,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
+ }