dsh-coding-subscription-oauth 0.6.4 → 0.6.5

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 (144) hide show
  1. package/CHANGELOG.md +280 -255
  2. package/CONTRIBUTING.md +138 -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 +141 -137
  19. package/docs/02-architecture.zh-CN.md +141 -137
  20. package/lib/bin.js.map +1 -1
  21. package/lib/client.js +1 -1
  22. package/lib/client.js.map +1 -1
  23. package/lib/gateway-protocol.d.ts +3 -46
  24. package/lib/gateway-protocol.d.ts.map +1 -1
  25. package/lib/gateway-routes.d.ts.map +1 -1
  26. package/lib/grok-errors.d.ts +2 -12
  27. package/lib/grok-errors.d.ts.map +1 -1
  28. package/lib/grok-imagine/client.d.ts +73 -0
  29. package/lib/grok-imagine/client.d.ts.map +1 -0
  30. package/lib/grok-imagine/index.d.ts +8 -0
  31. package/lib/grok-imagine/index.d.ts.map +1 -0
  32. package/lib/grok-imagine/net.d.ts +10 -0
  33. package/lib/grok-imagine/net.d.ts.map +1 -0
  34. package/lib/grok-imagine/parse.d.ts +20 -0
  35. package/lib/grok-imagine/parse.d.ts.map +1 -0
  36. package/lib/grok-imagine/types.d.ts +191 -0
  37. package/lib/grok-imagine/types.d.ts.map +1 -0
  38. package/lib/grok-imagine.d.ts +3 -263
  39. package/lib/grok-imagine.d.ts.map +1 -1
  40. package/lib/http-json.d.ts +2 -9
  41. package/lib/http-json.d.ts.map +1 -1
  42. package/lib/index.js +57 -37
  43. package/lib/index.js.map +4 -4
  44. package/lib/invariant.js.map +1 -1
  45. package/lib/kimi-errors.d.ts +2 -12
  46. package/lib/kimi-errors.d.ts.map +1 -1
  47. package/lib/runtime/gateway-protocol.d.ts +47 -0
  48. package/lib/runtime/gateway-protocol.d.ts.map +1 -0
  49. package/lib/runtime/grok-errors.d.ts +13 -0
  50. package/lib/runtime/grok-errors.d.ts.map +1 -0
  51. package/lib/runtime/http-json.d.ts +10 -0
  52. package/lib/runtime/http-json.d.ts.map +1 -0
  53. package/lib/runtime/kimi-errors.d.ts +13 -0
  54. package/lib/runtime/kimi-errors.d.ts.map +1 -0
  55. package/media/en/settings_accounts.png +0 -0
  56. package/media/en/settings_capabilities.png +0 -0
  57. package/media/en/settings_gateway.png +0 -0
  58. package/media/settings_accounts.png +0 -0
  59. package/media/settings_capabilities.png +0 -0
  60. package/media/settings_gateway.png +0 -0
  61. package/media/settings_overview.png +0 -0
  62. package/media/zh-CN/settings_accounts.png +0 -0
  63. package/media/zh-CN/settings_capabilities.png +0 -0
  64. package/media/zh-CN/settings_gateway.png +0 -0
  65. package/package.json +225 -220
  66. package/patches/dsh-agy@0.1.2.patch +25 -25
  67. package/scripts/release.mjs +187 -186
  68. package/scripts/smoke-deployed-routes.mjs +146 -146
  69. package/scripts/verify-deployed-catalog.mjs +87 -87
  70. package/src/adapter.ts +0 -348
  71. package/src/alias-adapter.ts +0 -147
  72. package/src/auth-routes.ts +0 -921
  73. package/src/auth.ts +0 -67
  74. package/src/bin.ts +0 -350
  75. package/src/capability-routes.ts +0 -279
  76. package/src/capability-runtime.ts +0 -314
  77. package/src/capability-settings.ts +0 -671
  78. package/src/capability-tools.ts +0 -685
  79. package/src/catalog.ts +0 -271
  80. package/src/client/GrokBuildSettings.tsx +0 -771
  81. package/src/client/api.ts +0 -88
  82. package/src/client/components/AboutTab.tsx +0 -30
  83. package/src/client/components/AccountsTab.tsx +0 -241
  84. package/src/client/components/Badge.tsx +0 -33
  85. package/src/client/components/CapabilitiesTab.tsx +0 -265
  86. package/src/client/components/CliPullPreview.tsx +0 -116
  87. package/src/client/components/CopyButton.tsx +0 -57
  88. package/src/client/components/GatewayTab.tsx +0 -469
  89. package/src/client/components/NoticeBanner.tsx +0 -46
  90. package/src/client/components/ProgressBar.tsx +0 -53
  91. package/src/client/components/ProviderCard.tsx +0 -606
  92. package/src/client/components/SettingsTabs.tsx +0 -75
  93. package/src/client/components/ToggleSwitch.tsx +0 -71
  94. package/src/client/constants.ts +0 -230
  95. package/src/client/display.ts +0 -61
  96. package/src/client/dshClientAdapter.ts +0 -127
  97. package/src/client/gatewaySnippets.ts +0 -37
  98. package/src/client/index.tsx +0 -156
  99. package/src/client/locales.ts +0 -540
  100. package/src/client/microStyles.ts +0 -52
  101. package/src/client/parsers.ts +0 -398
  102. package/src/client/styles.ts +0 -325
  103. package/src/client/types.ts +0 -199
  104. package/src/codex-http.ts +0 -447
  105. package/src/codex-images.ts +0 -503
  106. package/src/codex-model-capabilities.ts +0 -320
  107. package/src/codex-search.ts +0 -245
  108. package/src/codex-usage.ts +0 -263
  109. package/src/compatibility.ts +0 -55
  110. package/src/dsh-host-adapter.ts +0 -173
  111. package/src/gateway-anthropic-messages.ts +0 -84
  112. package/src/gateway-auth.ts +0 -102
  113. package/src/gateway-backend.ts +0 -274
  114. package/src/gateway-body.ts +0 -49
  115. package/src/gateway-config.ts +0 -76
  116. package/src/gateway-http.ts +0 -104
  117. package/src/gateway-openai-chat.ts +0 -124
  118. package/src/gateway-openai-responses.ts +0 -53
  119. package/src/gateway-parse.ts +0 -224
  120. package/src/gateway-protocol.ts +0 -52
  121. package/src/gateway-routes.ts +0 -158
  122. package/src/gateway.ts +0 -258
  123. package/src/grok-errors.ts +0 -24
  124. package/src/grok-imagine.ts +0 -1627
  125. package/src/grok-import.ts +0 -151
  126. package/src/http-json.ts +0 -82
  127. package/src/ids.ts +0 -59
  128. package/src/imagine-routes.ts +0 -463
  129. package/src/index.ts +0 -735
  130. package/src/invariant.ts +0 -17
  131. package/src/kimi-errors.ts +0 -26
  132. package/src/media-store.ts +0 -927
  133. package/src/oauth-import-routes.ts +0 -324
  134. package/src/oauth-providers.ts +0 -152
  135. package/src/oauth-session.ts +0 -183
  136. package/src/oauth-sources.ts +0 -1104
  137. package/src/oauth.ts +0 -620
  138. package/src/provider.ts +0 -128
  139. package/src/proxy.ts +0 -11
  140. package/src/redact.ts +0 -72
  141. package/src/session.ts +0 -218
  142. package/src/store.ts +0 -217
  143. package/src/web-origin.ts +0 -296
  144. package/src/web-routes.ts +0 -38
@@ -5,267 +5,7 @@
5
5
  * a signed upstream URL.
6
6
  * @module dsh-coding-subscription-oauth/grok-imagine
7
7
  */
8
- import { IMAGINE_MEDIA_ROUTE_PREFIX, imagineMediaPath, isTrustedImaginePeer, type MediaArtifactMeta, type MediaStore, type MediaStoreVideoType, type TrustedImagineAuthz } from "./media-store.js";
9
- export declare const XAI_API_ORIGIN = "https://api.x.ai";
10
- export declare const GROK_IMAGINE_IMAGE_PATH = "/v1/images/generations";
11
- export declare const GROK_IMAGINE_VIDEO_START_PATH = "/v1/videos/generations";
12
- export declare const GROK_IMAGINE_IMAGE_MODEL = "grok-imagine-image-2.0";
13
- export declare const GROK_IMAGINE_VIDEO_MODEL = "grok-imagine-video-1.5";
14
- export declare const GROK_IMAGINE_IMAGE_TOOL = "grok_imagine_image";
15
- export declare const GROK_IMAGINE_VIDEO_TOOL = "grok_imagine_video";
16
- export declare const GROK_IMAGINE_VIDEO_STATUS_TOOL = "grok_imagine_video_status";
17
- export declare const IMAGINE_IMAGE_ROUTE_PREFIX = "/plugins/dsh-grok-build/imagine/images/";
18
- /** Frozen xAI output hosts. Callers cannot widen this list. */
19
- export declare const XAI_OUTPUT_HOSTS: readonly ["imgen.x.ai", "videogen.x.ai", "vidgen.x.ai"];
20
- export declare const IMAGINE_IMAGE_RESOLUTIONS: readonly ["1k", "2k"];
21
- export declare const IMAGINE_VIDEO_RESOLUTIONS: readonly ["480p", "720p", "1080p"];
22
- export declare const IMAGINE_IMAGE_ASPECT_RATIOS: readonly ["1:1", "3:4", "4:3", "9:16", "16:9", "2:3", "3:2", "9:19.5", "19.5:9", "9:20", "20:9", "1:2", "2:1", "auto"];
23
- export declare const IMAGINE_VIDEO_ASPECT_RATIOS: readonly ["1:1", "16:9", "9:16", "4:3", "3:4", "3:2", "2:3"];
24
- export declare const IMAGINE_VIDEO_MIN_DURATION_SECONDS = 1;
25
- export declare const IMAGINE_VIDEO_MAX_DURATION_SECONDS = 15;
26
- export declare const IMAGINE_IMAGE_MAX_N = 10;
27
- /**
28
- * Hard ceilings enforced both at the tool boundary (consumer guard) and inside
29
- * the Imagine client (defence-in-depth). The prompt ceiling uses UTF-16 code
30
- * units because that is what the JSON wire format bounds; the image-id arrays
31
- * are bounded so a runaway caller cannot exhaust the bounded body reader.
32
- */
33
- export declare const IMAGINE_PROMPT_MAX_LENGTH = 4000;
34
- export declare const IMAGINE_IMAGE_IDS_MIN = 1;
35
- export declare const IMAGINE_IMAGE_IDS_MAX = 5;
36
- export declare const DEFAULT_IMAGE_DOWNLOAD_MAX_BYTES: number;
37
- export declare const DEFAULT_API_TIMEOUT_MS = 30000;
38
- export declare const DEFAULT_IMAGE_DOWNLOAD_TIMEOUT_MS = 15000;
39
- export declare const DEFAULT_VIDEO_DOWNLOAD_TIMEOUT_MS = 60000;
40
- export declare const DEFAULT_MAX_REDIRECTS = 3;
41
- export declare const DEFAULT_API_JSON_MAX_BYTES: number;
42
- export declare const MAX_CACHED_VIDEO_JOBS = 256;
43
- export type ImagineOperation = "image.generate" | "video.start" | "video.status";
44
- export type ImagineImageResolution = (typeof IMAGINE_IMAGE_RESOLUTIONS)[number];
45
- export type ImagineVideoResolution = (typeof IMAGINE_VIDEO_RESOLUTIONS)[number];
46
- export type ImagineImageAspectRatio = (typeof IMAGINE_IMAGE_ASPECT_RATIOS)[number];
47
- export type ImagineVideoAspectRatio = (typeof IMAGINE_VIDEO_ASPECT_RATIOS)[number];
48
- export type ImagineApiKeyResolver = (operation: ImagineOperation) => Promise<string>;
49
- export type ImagineFetch = (input: string | URL, init?: RequestInit) => Promise<Response>;
50
- export type ImagineDnsLookup = (hostname: string) => Promise<readonly string[]>;
51
- export type ImagineImageMediaType = "image/png" | "image/jpeg" | "image/webp" | "image/gif";
52
- export interface ImagineMediaHopRequest {
53
- timeoutMs: number;
54
- maxBytes: number;
55
- accept: string;
56
- signal?: AbortSignal;
57
- }
58
- export interface ImagineMediaHop {
59
- status: number;
60
- location?: string;
61
- contentType?: string;
62
- data?: Uint8Array;
63
- }
64
- /** Single-hop GET. Must not follow redirects or attach credentials. */
65
- export interface ImagineMediaTransport {
66
- get(url: URL, request: ImagineMediaHopRequest): Promise<ImagineMediaHop>;
67
- }
68
- export interface ImagineDownloadRequest {
69
- url: string;
70
- timeoutMs: number;
71
- maxBytes: number;
72
- accept: string;
73
- signal?: AbortSignal;
74
- }
75
- export interface ImagineDownloadResult {
76
- data: Uint8Array;
77
- contentType?: string;
78
- }
79
- /** Full download including redirect revalidation. Production default is pinned. */
80
- export interface ImagineDownloader {
81
- download(request: ImagineDownloadRequest): Promise<ImagineDownloadResult>;
82
- }
83
- export type GrokImagineErrorCode = "MISSING_CREDENTIAL" | "AUTH" | "QUOTA" | "RATE_LIMIT" | "SSRF" | "INVALID_INPUT" | "UPSTREAM" | "TIMEOUT" | "MEDIA";
84
- export declare class GrokImagineError extends Error {
85
- readonly code: GrokImagineErrorCode;
86
- readonly status?: number;
87
- constructor(code: GrokImagineErrorCode, message: string, options?: {
88
- cause?: unknown;
89
- status?: number;
90
- });
91
- }
92
- export interface ImagineImageAttachmentRef {
93
- attachmentId: string;
94
- mediaType: ImagineImageMediaType;
95
- bytes: number;
96
- width: number;
97
- height: number;
98
- name?: string;
99
- }
100
- export interface ImagineImageLimits {
101
- maxImageBytes?: number;
102
- mediaTypes?: readonly string[];
103
- }
104
- /** Structural AttachmentStore surface used by Imagine. */
105
- export interface ImagineAttachmentStore {
106
- imageLimits?: ImagineImageLimits;
107
- saveImage(input: {
108
- data: Uint8Array;
109
- mediaType: ImagineImageMediaType;
110
- name?: string;
111
- }): Promise<ImagineImageAttachmentRef>;
112
- readImage?(ref: ImagineImageAttachmentRef, signal?: AbortSignal): Promise<{
113
- ref: ImagineImageAttachmentRef;
114
- data: Uint8Array;
115
- }>;
116
- }
117
- export interface GenerateImagineImageInput {
118
- prompt: string;
119
- model?: string;
120
- n?: number;
121
- aspectRatio?: string;
122
- resolution?: string;
123
- name?: string;
124
- }
125
- export interface ImagineImageResult {
126
- model: string;
127
- images: readonly ImaginePersistedImage[];
128
- attachment: ImagineImageAttachmentRef;
129
- path: string;
130
- }
131
- export interface ImaginePersistedImage {
132
- attachment: ImagineImageAttachmentRef;
133
- path: string;
134
- }
135
- export interface StartImagineVideoInput {
136
- prompt: string;
137
- model?: string;
138
- duration?: number;
139
- aspectRatio?: string;
140
- resolution?: string;
141
- name?: string;
142
- }
143
- export interface ImagineVideoStartResult {
144
- model: string;
145
- requestId: string;
146
- status: "pending";
147
- }
148
- export type ImagineVideoJobStatus = "pending" | "completed" | "failed";
149
- export interface ImagineVideoStatusResult {
150
- requestId: string;
151
- status: ImagineVideoJobStatus;
152
- artifact?: MediaArtifactMeta;
153
- path?: string;
154
- error?: string;
155
- }
156
- export interface GrokImagineClientOptions {
157
- resolveApiKey: ImagineApiKeyResolver;
158
- attachments: ImagineAttachmentStore;
159
- media: MediaStore;
160
- /** API-only test seam. Never used for media and never a production default. */
161
- fetch?: ImagineFetch;
162
- /** Media downloads. Production default pins DNS at connect time via undici. */
163
- downloader?: ImagineDownloader;
164
- now?: () => number;
165
- imageDownloadTimeoutMs?: number;
166
- videoDownloadTimeoutMs?: number;
167
- apiTimeoutMs?: number;
168
- maxRedirects?: number;
169
- imageMaxBytes?: number;
170
- apiJsonMaxBytes?: number;
171
- }
172
- export interface ImagineImageDownloadHeaders {
173
- "Content-Type": string;
174
- "Content-Length": string;
175
- "Content-Disposition": string;
176
- "Cache-Control": string;
177
- "X-Content-Type-Options": "nosniff";
178
- }
179
- export interface ImagineImageDownloadView {
180
- ref: ImagineImageAttachmentRef;
181
- body: Uint8Array;
182
- headers: ImagineImageDownloadHeaders;
183
- }
184
- export declare function redactImagineMessage(error: unknown): string;
185
- /** True when an address is loopback, private, reserved, documentation, or an embedded special form. */
186
- export declare function isBlockedIp(address: string): boolean;
187
- export declare function isAllowlistedImagineHost(hostname: string): boolean;
188
- export declare function grokImagineVideoStatusPath(requestId: string): string;
189
- export declare function isSafeImagineAttachmentId(attachmentId: string): boolean;
190
- export declare function imagineImagePath(attachmentId: string): string;
191
- export declare function parseImagineImagePath(pathname: string): string | undefined;
192
- export declare function imagineImageDownloadHeaders(ref: ImagineImageAttachmentRef): ImagineImageDownloadHeaders;
193
- export { IMAGINE_MEDIA_ROUTE_PREFIX, imagineMediaPath, isTrustedImaginePeer };
194
- export declare function detectImageMediaType(data: Uint8Array): ImagineImageMediaType | undefined;
195
- export declare function detectVideoMediaType(data: Uint8Array): MediaStoreVideoType | undefined;
196
- export declare function defaultImagineLookup(hostname: string): Promise<readonly string[]>;
197
- export declare function assertSafeRemoteMediaUrl(raw: string, lookup: ImagineDnsLookup): Promise<URL>;
198
- export declare function createPinnedMediaTransport(lookup?: ImagineDnsLookup): ImagineMediaTransport;
199
- export declare function createPinnedApiFetch(lookup?: ImagineDnsLookup, maxBytes?: number): ImagineFetch;
200
- export declare function downloadRemoteImagineMedia(initialUrl: string, transport: ImagineMediaTransport, options: {
201
- lookup: ImagineDnsLookup;
202
- timeoutMs: number;
203
- maxBytes: number;
204
- accept: string;
205
- maxRedirects: number;
206
- signal?: AbortSignal;
207
- }): Promise<ImagineDownloadResult>;
208
- export declare function createPinnedImagineDownloader(options?: {
209
- lookup?: ImagineDnsLookup;
210
- maxRedirects?: number;
211
- }): ImagineDownloader;
212
- /**
213
- * Test-only adapter around an injected fetch. Ordinary mock fetch is not
214
- * production-safe: it cannot pin DNS at connect time.
215
- */
216
- export declare function createImagineDownloaderFromFetch(fetchImpl: ImagineFetch, options: {
217
- trustedTestTransport: true;
218
- lookup?: ImagineDnsLookup;
219
- maxRedirects?: number;
220
- }): ImagineDownloader;
221
- /**
222
- * Validate a tool-supplied Imagine video `requestId`. Returns the id unchanged
223
- * on success or throws an `INVALID_INPUT` error. Exposed so capability tools
224
- * fail closed at the boundary instead of dispatching a malformed id to the
225
- * internal client.
226
- */
227
- export declare function parseVideoRequestId(value: unknown): string;
228
- /** Enforce min/max bounds on a candidate image-id array. */
229
- export declare function clampImagineImageIds(ids: readonly unknown[]): readonly string[];
230
- export declare class GrokImagineClient {
231
- private readonly resolveApiKey;
232
- private readonly attachments;
233
- private readonly media;
234
- private readonly apiFetch;
235
- private readonly downloader;
236
- private readonly imageDownloadTimeoutMs;
237
- private readonly videoDownloadTimeoutMs;
238
- private readonly apiTimeoutMs;
239
- private readonly maxRedirects;
240
- private readonly imageMaxBytes;
241
- private readonly apiJsonMaxBytes;
242
- private readonly videoResults;
243
- private readonly videoInflight;
244
- private readonly disposeController;
245
- private disposed;
246
- constructor(options: GrokImagineClientOptions);
247
- /**
248
- * Permanently retire this client. In-flight API calls, downloads, and
249
- * media persistence operations are aborted; subsequent operations fail
250
- * closed with an `INVALID_INPUT` error until callers construct a new client.
251
- */
252
- dispose(): void;
253
- /** @returns true once {@link dispose} has been called. */
254
- get isDisposed(): boolean;
255
- private assertWritable;
256
- generateImage(input: GenerateImagineImageInput, signal?: AbortSignal): Promise<ImagineImageResult>;
257
- startVideo(input: StartImagineVideoInput, signal?: AbortSignal): Promise<ImagineVideoStartResult>;
258
- videoStatus(requestId: string, options?: {
259
- name?: string;
260
- signal?: AbortSignal;
261
- }): Promise<ImagineVideoStatusResult>;
262
- private pollVideo;
263
- private rememberVideo;
264
- private persistGeneratedImage;
265
- private resolveCredential;
266
- private apiJson;
267
- }
268
- export declare function createGrokImagineClient(options: GrokImagineClientOptions): GrokImagineClient;
269
- /** Gate a same-origin image download. Requires an explicit trusted/authz token. */
270
- export declare function openTrustedImagineImageDownload(attachments: ImagineAttachmentStore, ref: ImagineImageAttachmentRef, authz: TrustedImagineAuthz): Promise<ImagineImageDownloadView>;
8
+ export type { GenerateImagineImageInput, GrokImagineClientOptions, GrokImagineErrorCode, ImagineApiKeyResolver, ImagineAttachmentStore, ImagineDnsLookup, ImagineDownloader, ImagineDownloadRequest, ImagineDownloadResult, ImagineFetch, ImagineImageAspectRatio, ImagineImageAttachmentRef, ImagineImageDownloadHeaders, ImagineImageDownloadView, ImagineImageLimits, ImagineImageMediaType, ImagineImageResolution, ImagineImageResult, ImagineMediaHop, ImagineMediaHopRequest, ImagineMediaTransport, ImagineOperation, ImaginePersistedImage, ImagineVideoAspectRatio, ImagineVideoJobStatus, ImagineVideoResolution, ImagineVideoStartResult, ImagineVideoStatusResult, StartImagineVideoInput, } from "./grok-imagine/index.js";
9
+ export { assertSafeRemoteMediaUrl, clampImagineImageIds, createGrokImagineClient, createImagineDownloaderFromFetch, createPinnedApiFetch, createPinnedImagineDownloader, createPinnedMediaTransport, DEFAULT_API_JSON_MAX_BYTES, DEFAULT_API_TIMEOUT_MS, DEFAULT_IMAGE_DOWNLOAD_MAX_BYTES, DEFAULT_IMAGE_DOWNLOAD_TIMEOUT_MS, DEFAULT_MAX_REDIRECTS, DEFAULT_VIDEO_DOWNLOAD_TIMEOUT_MS, defaultImagineLookup, detectImageMediaType, detectVideoMediaType, downloadRemoteImagineMedia, GROK_IMAGINE_IMAGE_MODEL, GROK_IMAGINE_IMAGE_PATH, GROK_IMAGINE_IMAGE_TOOL, GROK_IMAGINE_VIDEO_MODEL, GROK_IMAGINE_VIDEO_START_PATH, GROK_IMAGINE_VIDEO_STATUS_TOOL, GROK_IMAGINE_VIDEO_TOOL, GrokImagineClient, GrokImagineError, grokImagineVideoStatusPath, IMAGINE_IMAGE_ASPECT_RATIOS, IMAGINE_IMAGE_IDS_MAX, IMAGINE_IMAGE_IDS_MIN, IMAGINE_IMAGE_MAX_N, IMAGINE_IMAGE_RESOLUTIONS, IMAGINE_IMAGE_ROUTE_PREFIX, IMAGINE_PROMPT_MAX_LENGTH, IMAGINE_VIDEO_ASPECT_RATIOS, IMAGINE_VIDEO_MAX_DURATION_SECONDS, IMAGINE_VIDEO_MIN_DURATION_SECONDS, IMAGINE_VIDEO_RESOLUTIONS, imagineImageDownloadHeaders, imagineImagePath, isAllowlistedImagineHost, isBlockedIp, isSafeImagineAttachmentId, MAX_CACHED_VIDEO_JOBS, openTrustedImagineImageDownload, parseImagineImagePath, parseVideoRequestId, redactImagineMessage, XAI_API_ORIGIN, XAI_OUTPUT_HOSTS, } from "./grok-imagine/index.js";
10
+ export { IMAGINE_MEDIA_ROUTE_PREFIX, imagineMediaPath, isTrustedImaginePeer } from "./media-store.js";
271
11
  //# sourceMappingURL=grok-imagine.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"grok-imagine.d.ts","sourceRoot":"","sources":["../../src/grok-imagine.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,OAAO,EAEN,0BAA0B,EAC1B,gBAAgB,EAChB,oBAAoB,EACpB,KAAK,iBAAiB,EACtB,KAAK,UAAU,EACf,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,MAAM,kBAAkB,CAAC;AAG1B,eAAO,MAAM,cAAc,qBAAqB,CAAC;AACjD,eAAO,MAAM,uBAAuB,2BAA2B,CAAC;AAChE,eAAO,MAAM,6BAA6B,2BAA2B,CAAC;AACtE,eAAO,MAAM,wBAAwB,2BAA2B,CAAC;AACjE,eAAO,MAAM,wBAAwB,2BAA2B,CAAC;AAEjE,eAAO,MAAM,uBAAuB,uBAAuB,CAAC;AAC5D,eAAO,MAAM,uBAAuB,uBAAuB,CAAC;AAC5D,eAAO,MAAM,8BAA8B,8BAA8B,CAAC;AAE1E,eAAO,MAAM,0BAA0B,4CAA4C,CAAC;AAEpF,+DAA+D;AAC/D,eAAO,MAAM,gBAAgB,yDAA0D,CAAC;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,EACjB,OAAO,GAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,WAAW,CAAA;KAAO,GACnD,OAAO,CAAC,wBAAwB,CAAC;YAsCtB,SAAS;IAsEvB,OAAO,CAAC,aAAa;YAOP,qBAAqB;YAgErB,iBAAiB;YAcjB,OAAO;CA2DrB;AAUD,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,wBAAwB,GAAG,iBAAiB,CAE5F;AAED,mFAAmF;AACnF,wBAAsB,+BAA+B,CACpD,WAAW,EAAE,sBAAsB,EACnC,GAAG,EAAE,yBAAyB,EAC9B,KAAK,EAAE,mBAAmB,GACxB,OAAO,CAAC,wBAAwB,CAAC,CAcnC"}
1
+ {"version":3,"file":"grok-imagine.d.ts","sourceRoot":"","sources":["../../src/grok-imagine.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,YAAY,EACX,yBAAyB,EACzB,wBAAwB,EACxB,oBAAoB,EACpB,qBAAqB,EACrB,sBAAsB,EACtB,gBAAgB,EAChB,iBAAiB,EACjB,sBAAsB,EACtB,qBAAqB,EACrB,YAAY,EACZ,uBAAuB,EACvB,yBAAyB,EACzB,2BAA2B,EAC3B,wBAAwB,EACxB,kBAAkB,EAClB,qBAAqB,EACrB,sBAAsB,EACtB,kBAAkB,EAClB,eAAe,EACf,sBAAsB,EACtB,qBAAqB,EACrB,gBAAgB,EAChB,qBAAqB,EACrB,uBAAuB,EACvB,qBAAqB,EACrB,sBAAsB,EACtB,uBAAuB,EACvB,wBAAwB,EACxB,sBAAsB,GACtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACN,wBAAwB,EACxB,oBAAoB,EACpB,uBAAuB,EACvB,gCAAgC,EAChC,oBAAoB,EACpB,6BAA6B,EAC7B,0BAA0B,EAC1B,0BAA0B,EAC1B,sBAAsB,EACtB,gCAAgC,EAChC,iCAAiC,EACjC,qBAAqB,EACrB,iCAAiC,EACjC,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,0BAA0B,EAC1B,wBAAwB,EACxB,uBAAuB,EACvB,uBAAuB,EACvB,wBAAwB,EACxB,6BAA6B,EAC7B,8BAA8B,EAC9B,uBAAuB,EACvB,iBAAiB,EACjB,gBAAgB,EAChB,0BAA0B,EAC1B,2BAA2B,EAC3B,qBAAqB,EACrB,qBAAqB,EACrB,mBAAmB,EACnB,yBAAyB,EACzB,0BAA0B,EAC1B,yBAAyB,EACzB,2BAA2B,EAC3B,kCAAkC,EAClC,kCAAkC,EAClC,yBAAyB,EACzB,2BAA2B,EAC3B,gBAAgB,EAChB,wBAAwB,EACxB,WAAW,EACX,yBAAyB,EACzB,qBAAqB,EACrB,+BAA+B,EAC/B,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,cAAc,EACd,gBAAgB,GAChB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,0BAA0B,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC"}
@@ -1,10 +1,3 @@
1
- import type { IncomingMessage } from "node:http";
2
- export declare const JSON_BODY_LIMIT_BYTES: number;
3
- export declare class JsonRequestError extends Error {
4
- readonly statusCode: 400 | 413;
5
- constructor(statusCode: 400 | 413, message: string);
6
- }
7
- /** Read one JSON request body with a strict in-memory ceiling. */
8
- export declare function readJsonRequest(request: IncomingMessage, limit?: number): Promise<unknown>;
9
- export declare function requestErrorStatus(error: unknown, fallback: number): number;
1
+ /** Compatibility facade implementation lives in `src/runtime/` (mirrored from Hub vendor core). */
2
+ export { JSON_BODY_LIMIT_BYTES, JsonRequestError, readJsonRequest, requestErrorStatus, } from "./runtime/http-json.js";
10
3
  //# sourceMappingURL=http-json.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"http-json.d.ts","sourceRoot":"","sources":["../../src/http-json.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAEjD,eAAO,MAAM,qBAAqB,QAAY,CAAC;AAE/C,qBAAa,gBAAiB,SAAQ,KAAK;IAC1C,QAAQ,CAAC,UAAU,EAAE,GAAG,GAAG,GAAG,CAAC;gBAEnB,UAAU,EAAE,GAAG,GAAG,GAAG,EAAE,OAAO,EAAE,MAAM;CAKlD;AASD,kEAAkE;AAClE,wBAAgB,eAAe,CAAC,OAAO,EAAE,eAAe,EAAE,KAAK,SAAwB,GAAG,OAAO,CAAC,OAAO,CAAC,CAuDzG;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE3E"}
1
+ {"version":3,"file":"http-json.d.ts","sourceRoot":"","sources":["../../src/http-json.ts"],"names":[],"mappings":"AAAA,qGAAqG;AAErG,OAAO,EACN,qBAAqB,EACrB,gBAAgB,EAChB,eAAe,EACf,kBAAkB,GAClB,MAAM,wBAAwB,CAAC"}
package/lib/index.js CHANGED
@@ -14906,7 +14906,7 @@ var require_dump = __commonJS({
14906
14906
  var require_dns = __commonJS({
14907
14907
  "node_modules/.pnpm/undici@7.29.0/node_modules/undici/lib/interceptor/dns.js"(exports, module) {
14908
14908
  "use strict";
14909
- var { isIP: isIP2 } = __require("node:net");
14909
+ var { isIP: isIP3 } = __require("node:net");
14910
14910
  var { lookup } = __require("node:dns");
14911
14911
  var DecoratorHandler = require_decorator_handler();
14912
14912
  var { InvalidArgumentError, InformationalError } = require_errors();
@@ -15312,7 +15312,7 @@ var require_dns = __commonJS({
15312
15312
  return (dispatch) => {
15313
15313
  return function dnsInterceptor(origDispatchOpts, handler) {
15314
15314
  const origin = origDispatchOpts.origin.constructor === URL ? origDispatchOpts.origin : new URL(origDispatchOpts.origin);
15315
- if (isIP2(origin.hostname) !== 0) {
15315
+ if (isIP3(origin.hostname) !== 0) {
15316
15316
  return dispatch(origDispatchOpts, handler);
15317
15317
  }
15318
15318
  instance.runLookup(origin, origDispatchOpts, (err, newOrigin) => {
@@ -26069,7 +26069,7 @@ import { PiAiAdapter } from "@deepseek-ai/dsh-llm-pi-ai";
26069
26069
  // src/alias-adapter.ts
26070
26070
  import { LlmAdapter, LlmError } from "@deepseek-ai/dsh-llm";
26071
26071
 
26072
- // src/grok-errors.ts
26072
+ // src/runtime/grok-errors.ts
26073
26073
  var XAI_CAPACITY = /\b(?:at\s+capacity|high\s+demand|priority\s+processing|overloaded)\b/i;
26074
26074
  function isXaiCapacityError(detail) {
26075
26075
  return XAI_CAPACITY.test(detail);
@@ -26079,7 +26079,7 @@ function remapXaiCapacityFailure(failure) {
26079
26079
  return { ...failure, code: "RATE_LIMIT" };
26080
26080
  }
26081
26081
 
26082
- // src/kimi-errors.ts
26082
+ // src/runtime/kimi-errors.ts
26083
26083
  import { CONTEXT_WINDOW_EXCEEDED_CODE, isContextWindowExceededError } from "@deepseek-ai/dsh-llm";
26084
26084
  var KIMI_CONTEXT_CAPACITY = /\bsupports only\s+\d+\s*k\s+context\b/i;
26085
26085
  function isMisclassifiedContextWindowError(detail) {
@@ -28248,7 +28248,7 @@ async function importGrokBuildSession(session, filename) {
28248
28248
  await session.refreshLiveCatalog();
28249
28249
  }
28250
28250
 
28251
- // src/http-json.ts
28251
+ // src/runtime/http-json.ts
28252
28252
  var JSON_BODY_LIMIT_BYTES = 64 * 1024;
28253
28253
  var JsonRequestError = class extends Error {
28254
28254
  statusCode;
@@ -30589,11 +30589,11 @@ function createCodexImageController(options) {
30589
30589
  };
30590
30590
  }
30591
30591
 
30592
- // src/grok-imagine.ts
30592
+ // src/grok-imagine/client.ts
30593
30593
  var import_undici2 = __toESM(require_undici());
30594
30594
  import { Buffer as Buffer3 } from "node:buffer";
30595
30595
  import { lookup as dnsLookup } from "node:dns/promises";
30596
- import { BlockList, isIP } from "node:net";
30596
+ import { isIP as isIP2 } from "node:net";
30597
30597
 
30598
30598
  // src/media-store.ts
30599
30599
  import { createHash as createHash3, randomBytes as randomBytes3 } from "node:crypto";
@@ -31330,7 +31330,10 @@ var MediaStore = class {
31330
31330
  }
31331
31331
  };
31332
31332
 
31333
- // src/grok-imagine.ts
31333
+ // src/grok-imagine/net.ts
31334
+ import { BlockList, isIP } from "node:net";
31335
+
31336
+ // src/grok-imagine/types.ts
31334
31337
  var XAI_API_ORIGIN = "https://api.x.ai";
31335
31338
  var GROK_IMAGINE_IMAGE_PATH = "/v1/images/generations";
31336
31339
  var GROK_IMAGINE_VIDEO_START_PATH = "/v1/videos/generations";
@@ -31387,6 +31390,8 @@ var IMAGE_RESOLUTION_SET = new Set(IMAGINE_IMAGE_RESOLUTIONS);
31387
31390
  var VIDEO_RESOLUTION_SET = new Set(IMAGINE_VIDEO_RESOLUTIONS);
31388
31391
  var IMAGE_ASPECT_SET = new Set(IMAGINE_IMAGE_ASPECT_RATIOS);
31389
31392
  var VIDEO_ASPECT_SET = new Set(IMAGINE_VIDEO_ASPECT_RATIOS);
31393
+
31394
+ // src/grok-imagine/net.ts
31390
31395
  var blockedNetworks = new BlockList();
31391
31396
  blockedNetworks.addSubnet("0.0.0.0", 8, "ipv4");
31392
31397
  blockedNetworks.addSubnet("10.0.0.0", 8, "ipv4");
@@ -31418,16 +31423,6 @@ blockedNetworks.addSubnet("5f00::", 16, "ipv6");
31418
31423
  blockedNetworks.addSubnet("fc00::", 7, "ipv6");
31419
31424
  blockedNetworks.addSubnet("fe80::", 10, "ipv6");
31420
31425
  blockedNetworks.addSubnet("ff00::", 8, "ipv6");
31421
- function isRecord5(value) {
31422
- return typeof value === "object" && value !== null && !Array.isArray(value);
31423
- }
31424
- function redactImagineMessage(error) {
31425
- const withoutRemoteUrls = (error instanceof Error ? error.message : String(error)).replace(
31426
- /https?:\/\/[^\s"'<>\\]+/giu,
31427
- "[redacted-url]"
31428
- );
31429
- return safeMessage(withoutRemoteUrls);
31430
- }
31431
31426
  function dottedFromWords(high, low) {
31432
31427
  return `${high >> 8 & 255}.${high & 255}.${low >> 8 & 255}.${low & 255}`;
31433
31428
  }
@@ -31520,6 +31515,18 @@ function isBlockedHostname(hostname) {
31520
31515
  function isAllowlistedImagineHost(hostname) {
31521
31516
  return FROZEN_OUTPUT_HOSTS.has(normalizeHostname(hostname));
31522
31517
  }
31518
+
31519
+ // src/grok-imagine/parse.ts
31520
+ function isRecord5(value) {
31521
+ return typeof value === "object" && value !== null && !Array.isArray(value);
31522
+ }
31523
+ function redactImagineMessage(error) {
31524
+ const withoutRemoteUrls = (error instanceof Error ? error.message : String(error)).replace(
31525
+ /https?:\/\/[^\s"'<>\\]+/giu,
31526
+ "[redacted-url]"
31527
+ );
31528
+ return safeMessage(withoutRemoteUrls);
31529
+ }
31523
31530
  function grokImagineVideoStatusPath(requestId) {
31524
31531
  if (!VIDEO_REQUEST_ID_PATTERN.test(requestId)) {
31525
31532
  throw new GrokImagineError("INVALID_INPUT", "video request id is not a safe identifier");
@@ -31614,6 +31621,20 @@ function detectVideoMediaType(data) {
31614
31621
  }
31615
31622
  return void 0;
31616
31623
  }
31624
+ function parseVideoRequestId(value) {
31625
+ if (typeof value !== "string") {
31626
+ throw new GrokImagineError("INVALID_INPUT", "video request id must be a string");
31627
+ }
31628
+ if (!VIDEO_REQUEST_ID_PATTERN.test(value)) {
31629
+ throw new GrokImagineError(
31630
+ "INVALID_INPUT",
31631
+ "video request id must match ^[A-Za-z0-9_-]{1,256}$ and be a safe ASCII identifier"
31632
+ );
31633
+ }
31634
+ return value;
31635
+ }
31636
+
31637
+ // src/grok-imagine/client.ts
31617
31638
  function parseContentType(value) {
31618
31639
  if (value === null || value === void 0 || value.trim() === "") return void 0;
31619
31640
  return value.split(";", 1)[0]?.trim().toLowerCase();
@@ -31639,7 +31660,7 @@ async function assertSafeRemoteMediaUrl(raw, lookup) {
31639
31660
  throw new GrokImagineError("SSRF", "generated media URL must use port 443");
31640
31661
  }
31641
31662
  const host = normalizeHostname(url.hostname);
31642
- if (host === "" || isBlockedHostname(host) || isIP(host) !== 0) {
31663
+ if (host === "" || isBlockedHostname(host) || isIP2(host) !== 0) {
31643
31664
  throw new GrokImagineError("SSRF", "generated media host is not allowed");
31644
31665
  }
31645
31666
  if (!isAllowlistedImagineHost(host)) {
@@ -31658,7 +31679,7 @@ async function assertSafeRemoteMediaUrl(raw, lookup) {
31658
31679
  }
31659
31680
  async function resolvePublicAddresses(hostname, lookup) {
31660
31681
  const host = normalizeHostname(hostname);
31661
- if (host === "" || isBlockedHostname(host) || isIP(host) !== 0) {
31682
+ if (host === "" || isBlockedHostname(host) || isIP2(host) !== 0) {
31662
31683
  throw new GrokImagineError("SSRF", "host is not allowed");
31663
31684
  }
31664
31685
  const addresses = [...await lookup(host)];
@@ -31671,7 +31692,7 @@ async function resolvePublicAddresses(hostname, lookup) {
31671
31692
  function createPinnedAgent(hostname, addresses) {
31672
31693
  const expected = normalizeHostname(hostname);
31673
31694
  const records = addresses.map((address) => {
31674
- const family = isIP(address);
31695
+ const family = isIP2(address);
31675
31696
  if (family !== 4 && family !== 6) {
31676
31697
  throw new GrokImagineError("SSRF", "pinned address is not a valid IP");
31677
31698
  }
@@ -31926,18 +31947,6 @@ function requirePrompt(prompt) {
31926
31947
  }
31927
31948
  return prompt;
31928
31949
  }
31929
- function parseVideoRequestId(value) {
31930
- if (typeof value !== "string") {
31931
- throw new GrokImagineError("INVALID_INPUT", "video request id must be a string");
31932
- }
31933
- if (!VIDEO_REQUEST_ID_PATTERN.test(value)) {
31934
- throw new GrokImagineError(
31935
- "INVALID_INPUT",
31936
- "video request id must match ^[A-Za-z0-9_-]{1,256}$ and be a safe ASCII identifier"
31937
- );
31938
- }
31939
- return value;
31940
- }
31941
31950
  var ImagineAbortError = class extends Error {
31942
31951
  name = "ImagineAbortError";
31943
31952
  constructor(reason) {
@@ -33628,7 +33637,7 @@ async function persistGatewayKeyDocument(path, document) {
33628
33637
  `, { mode: 384 });
33629
33638
  }
33630
33639
 
33631
- // src/gateway-protocol.ts
33640
+ // src/runtime/gateway-protocol.ts
33632
33641
  function isThinkingLevel(value) {
33633
33642
  return value === "off" || value === "minimal" || value === "low" || value === "medium" || value === "high" || value === "xhigh" || value === "max";
33634
33643
  }
@@ -34645,6 +34654,17 @@ function createCodingOAuthGatewayController(options) {
34645
34654
  }
34646
34655
 
34647
34656
  // src/gateway-routes.ts
34657
+ function authorizeGatewayControl(req, ownerRequestPolicy) {
34658
+ return ownerRequestPolicy.authorize(req);
34659
+ }
34660
+ function authorizeGatewaySecret(req, ownerRequestPolicy) {
34661
+ const decision = ownerRequestPolicy.authorize(req);
34662
+ if (!decision.authorized) return decision;
34663
+ if (decision.accessMode !== "loopback") {
34664
+ return { authorized: false, reason: "loopback-only" };
34665
+ }
34666
+ return decision;
34667
+ }
34648
34668
  function registerGatewayRoutes(ctx, controller, ownerRequestPolicy = LOOPBACK_OWNER_REQUEST_POLICY) {
34649
34669
  let dispose = () => void 0;
34650
34670
  ctx.effect(() => {
@@ -34670,7 +34690,7 @@ function registerGatewayRoutes(ctx, controller, ownerRequestPolicy = LOOPBACK_OW
34670
34690
  return () => dispose();
34671
34691
  }
34672
34692
  async function handleGatewaySettings(req, res, controller, ownerRequestPolicy) {
34673
- if (!ownerRequestPolicy.authorize(req).authorized) {
34693
+ if (!authorizeGatewayControl(req, ownerRequestPolicy).authorized) {
34674
34694
  json3(res, 403, { error: "forbidden" });
34675
34695
  return;
34676
34696
  }
@@ -34715,7 +34735,7 @@ async function handleGatewaySettings(req, res, controller, ownerRequestPolicy) {
34715
34735
  }
34716
34736
  }
34717
34737
  async function handleGatewayReveal(req, res, controller, ownerRequestPolicy) {
34718
- if (!ownerRequestPolicy.authorize(req).authorized) {
34738
+ if (!authorizeGatewaySecret(req, ownerRequestPolicy).authorized) {
34719
34739
  json3(res, 403, { error: "forbidden" });
34720
34740
  return;
34721
34741
  }
@@ -34730,7 +34750,7 @@ async function handleGatewayReveal(req, res, controller, ownerRequestPolicy) {
34730
34750
  }
34731
34751
  }
34732
34752
  async function handleGatewayRotate(req, res, controller, ownerRequestPolicy) {
34733
- if (!ownerRequestPolicy.authorize(req).authorized) {
34753
+ if (!authorizeGatewaySecret(req, ownerRequestPolicy).authorized) {
34734
34754
  json3(res, 403, { error: "forbidden" });
34735
34755
  return;
34736
34756
  }