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