@linxiraos/pi-catalog 1.3.2 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/types/compat/auth-ids.d.ts +2 -2
- package/dist/types/compat/image-tokenization.d.ts +13 -1
- package/dist/types/compat/prompt-cache-persistent.d.ts +7 -0
- package/dist/types/compat/provider-ids.d.ts +1 -1
- package/dist/types/compat/request-size.d.ts +11 -6
- package/dist/types/discovery/devin.d.ts +1 -1
- package/dist/types/hosts.d.ts +3 -1
- package/dist/types/provider-models/openai-compat.d.ts +9 -2
- package/dist/types/types.d.ts +10 -3
- package/dist/types/wire/codex.d.ts +4 -2
- package/dist/types/wire/devin.d.ts +1 -15
- package/package.json +4 -4
- package/src/compat/auth-ids.ts +2 -0
- package/src/compat/axes.ts +25 -2
- package/src/compat/image-tokenization.ts +55 -1
- package/src/compat/prompt-cache-persistent.ts +12 -0
- package/src/compat/provider-ids.d.ts +1 -1
- package/src/compat/provider-ids.ts +1 -0
- package/src/compat/request-size.ts +18 -8
- package/src/compat/resolve.ts +1 -0
- package/src/compat/rules/README.md +8 -2
- package/src/compat/rules/auth/_order.kdl +1 -1
- package/src/compat/rules/auth/inception.kdl +11 -0
- package/src/compat/rules/classes/anthropic.kdl +23 -21
- package/src/compat/rules/classes/deepseek.kdl +31 -0
- package/src/compat/rules/classes/gemma.kdl +11 -0
- package/src/compat/rules/classes/minimax.kdl +13 -8
- package/src/compat/rules/providers/amazon-bedrock.kdl +56 -0
- package/src/compat/rules/providers/factory-droid.kdl +12 -0
- package/src/compat/rules/providers/inception.kdl +61 -0
- package/src/compat/rules/providers/moonshot.kdl +3 -3
- package/src/compat/rules/providers/openai-codex.kdl +3 -0
- package/src/compat/rules/providers/yolo-auto.kdl +33 -37
- package/src/compat/rules/taxonomy/qwen.kdl +1 -1
- package/src/compat/rules.json +1 -1
- package/src/discovery/devin.d.ts +1 -1
- package/src/discovery/devin.ts +33 -66
- package/src/hosts.d.ts +3 -1
- package/src/hosts.ts +5 -2
- package/src/models.json +1 -1
- package/src/provider-models/descriptors.ts +2 -0
- package/src/provider-models/openai-compat.d.ts +9 -2
- package/src/provider-models/openai-compat.ts +47 -5
- package/src/types.d.ts +10 -3
- package/src/types.ts +10 -3
- package/src/wire/codex.d.ts +4 -2
- package/src/wire/codex.ts +11 -3
- package/src/wire/devin.d.ts +1 -15
- package/src/wire/devin.ts +16 -20
package/src/discovery/devin.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { FetchImpl, ModelSpec } from "../types";
|
|
|
3
3
|
* Options for fetching dynamic Devin (Codeium Cascade) models from `GetCliModelConfigs`.
|
|
4
4
|
*/
|
|
5
5
|
export interface DevinModelDiscoveryOptions {
|
|
6
|
-
/**
|
|
6
|
+
/** Stored Devin credential; encoded into protobuf `Metadata.apiKey` by shape. */
|
|
7
7
|
apiKey?: string;
|
|
8
8
|
/** Optional Codeium API base URL override. */
|
|
9
9
|
baseUrl?: string;
|
package/src/discovery/devin.ts
CHANGED
|
@@ -11,7 +11,6 @@ import {
|
|
|
11
11
|
GetCliModelConfigsRequestSchema,
|
|
12
12
|
type GetCliModelConfigsResponse,
|
|
13
13
|
GetCliModelConfigsResponseSchema,
|
|
14
|
-
type Metadata,
|
|
15
14
|
MetadataSchema,
|
|
16
15
|
ModelDimensionKind,
|
|
17
16
|
} from "./devin-proto";
|
|
@@ -293,7 +292,7 @@ function devinDynamicFamilies(lanes: Iterable<DevinFamilyLane>): EffortVariantFa
|
|
|
293
292
|
* Options for fetching dynamic Devin (Codeium Cascade) models from `GetCliModelConfigs`.
|
|
294
293
|
*/
|
|
295
294
|
export interface DevinModelDiscoveryOptions {
|
|
296
|
-
/**
|
|
295
|
+
/** Stored Devin credential; encoded into protobuf `Metadata.apiKey` by shape. */
|
|
297
296
|
apiKey?: string;
|
|
298
297
|
/** Optional Codeium API base URL override. */
|
|
299
298
|
baseUrl?: string;
|
|
@@ -322,77 +321,45 @@ export async function fetchDevinModels(
|
|
|
322
321
|
const controller = new AbortController();
|
|
323
322
|
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
324
323
|
const signal = options.signal ? AbortSignal.any([controller.signal, options.signal]) : controller.signal;
|
|
325
|
-
const fetchImpl = discoveryFetch(options.fetch);
|
|
326
324
|
|
|
327
|
-
const
|
|
328
|
-
|
|
329
|
-
const request = create(GetCliModelConfigsRequestSchema, { metadata });
|
|
330
|
-
const body = toBinary(GetCliModelConfigsRequestSchema, request);
|
|
331
|
-
const response = await fetchImpl(requestUrl, {
|
|
332
|
-
method: "POST",
|
|
333
|
-
headers: {
|
|
334
|
-
"content-type": "application/proto",
|
|
335
|
-
"connect-protocol-version": "1",
|
|
336
|
-
accept: "*/*",
|
|
337
|
-
},
|
|
338
|
-
body,
|
|
339
|
-
signal,
|
|
340
|
-
});
|
|
341
|
-
if (!response.ok) return null;
|
|
342
|
-
|
|
343
|
-
const decoded = decodeDevinUnaryMessage(
|
|
344
|
-
GetCliModelConfigsResponseSchema,
|
|
345
|
-
new Uint8Array(await response.arrayBuffer()),
|
|
346
|
-
);
|
|
347
|
-
return decoded ? normalizeDevinModels(decoded, options.baseUrl) : null;
|
|
348
|
-
} catch {
|
|
349
|
-
return null;
|
|
350
|
-
}
|
|
351
|
-
};
|
|
352
|
-
|
|
353
|
-
try {
|
|
354
|
-
const nativeMetadata = create(MetadataSchema, {
|
|
325
|
+
const request = create(GetCliModelConfigsRequestSchema, {
|
|
326
|
+
metadata: create(MetadataSchema, {
|
|
355
327
|
...devinDiscoveryMetadata(options.apiKey),
|
|
356
328
|
supportedModelDisplays: [...DEVIN_SUPPORTED_MODEL_DISPLAYS],
|
|
329
|
+
}),
|
|
330
|
+
});
|
|
331
|
+
let payload: Uint8Array;
|
|
332
|
+
try {
|
|
333
|
+
const response = await discoveryFetch(options.fetch)(requestUrl, {
|
|
334
|
+
method: "POST",
|
|
335
|
+
headers: {
|
|
336
|
+
"content-type": "application/proto",
|
|
337
|
+
"connect-protocol-version": "1",
|
|
338
|
+
accept: "*/*",
|
|
339
|
+
},
|
|
340
|
+
body: toBinary(GetCliModelConfigsRequestSchema, request),
|
|
341
|
+
signal,
|
|
357
342
|
});
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
nativeModels.every(model => model.id === "swe-1-6" || model.id === "swe-1-6-fast");
|
|
363
|
-
if (nativeModels !== null && nativeModels.length > 0 && !nativeIsSeedOnly) {
|
|
364
|
-
return nativeModels;
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
// Legacy Windsurf Enterprise seats expose their full credential-scoped
|
|
368
|
-
// roster only to the editor identity and raw windsurf_api_key. Native
|
|
369
|
-
// chisel discovery returns the two-row fallback seed for those seats.
|
|
370
|
-
const legacyMetadata = create(MetadataSchema, {
|
|
371
|
-
apiKey: options.apiKey ?? "",
|
|
372
|
-
ideName: "windsurf",
|
|
373
|
-
ideVersion: "3.2.23",
|
|
374
|
-
extensionName: "windsurf",
|
|
375
|
-
extensionVersion: "1.48.2",
|
|
376
|
-
locale: "en",
|
|
377
|
-
});
|
|
378
|
-
const legacyModels = await fetchCatalog(legacyMetadata);
|
|
379
|
-
const models =
|
|
380
|
-
legacyModels !== null && (nativeModels === null || legacyModels.length > nativeModels.length)
|
|
381
|
-
? legacyModels
|
|
382
|
-
: nativeModels;
|
|
383
|
-
if (models === null || models.length === 0) {
|
|
384
|
-
// The backend gates the native catalog on the pinned client identity;
|
|
385
|
-
// an empty-but-200 response is the failure signature of a stale pin.
|
|
386
|
-
logger.warn("Devin returned an empty model catalog; the pinned client identities may be stale", {
|
|
387
|
-
metadata: devinDiscoveryMetadata(undefined),
|
|
388
|
-
});
|
|
389
|
-
return null;
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
return models;
|
|
343
|
+
if (!response.ok) return null;
|
|
344
|
+
payload = new Uint8Array(await response.arrayBuffer());
|
|
345
|
+
} catch {
|
|
346
|
+
return null;
|
|
393
347
|
} finally {
|
|
394
348
|
clearTimeout(timer);
|
|
395
349
|
}
|
|
350
|
+
|
|
351
|
+
const decoded = decodeDevinUnaryMessage(GetCliModelConfigsResponseSchema, payload);
|
|
352
|
+
if (!decoded) return null;
|
|
353
|
+
const models = normalizeDevinModels(decoded, options.baseUrl);
|
|
354
|
+
if (models.length === 0) {
|
|
355
|
+
// The backend gates the native catalog on the pinned client identity;
|
|
356
|
+
// an empty-but-200 response is the failure signature of a stale pin.
|
|
357
|
+
logger.warn("Devin returned an empty model catalog; the pinned client identity may be stale", {
|
|
358
|
+
metadata: devinDiscoveryMetadata(undefined),
|
|
359
|
+
});
|
|
360
|
+
return null;
|
|
361
|
+
}
|
|
362
|
+
return models;
|
|
396
363
|
}
|
|
397
364
|
|
|
398
365
|
/**
|
package/src/hosts.d.ts
CHANGED
|
@@ -175,11 +175,13 @@ export declare function isAzureDeploymentsUrl(baseUrl: string): boolean;
|
|
|
175
175
|
* - `anthropic`: the Anthropic Messages API under `/anthropic`.
|
|
176
176
|
* - `openai`: the OpenAI-compatible APIs under `/openai`, plus Mantle's
|
|
177
177
|
* documented `/v1` base (`https://bedrock-mantle.<region>.api.aws/v1`).
|
|
178
|
+
* - `runtime`: the bedrock-runtime origin itself, where Converse and
|
|
179
|
+
* InvokeModel live under `/model/<id>/…`.
|
|
178
180
|
*
|
|
179
181
|
* Hostnames are parsed strictly so proxies that embed these hosts in a path
|
|
180
182
|
* do not match.
|
|
181
183
|
*/
|
|
182
|
-
export declare function isBedrockRouteUrl(baseUrl: string | undefined, route: "openai" | "anthropic"): boolean;
|
|
184
|
+
export declare function isBedrockRouteUrl(baseUrl: string | undefined, route: "openai" | "anthropic" | "runtime"): boolean;
|
|
183
185
|
/** Amazon Bedrock's OpenAI-compatible routes; see {@link isBedrockRouteUrl}. */
|
|
184
186
|
export declare function isBedrockOpenAIUrl(baseUrl: string | undefined): boolean;
|
|
185
187
|
/** Alibaba DashScope consumer `compatible-mode` endpoint (rejects multimodal arrays for some text-only SKUs). */
|
package/src/hosts.ts
CHANGED
|
@@ -193,11 +193,13 @@ function hasPathPrefix(pathname: string, prefix: string): boolean {
|
|
|
193
193
|
* - `anthropic`: the Anthropic Messages API under `/anthropic`.
|
|
194
194
|
* - `openai`: the OpenAI-compatible APIs under `/openai`, plus Mantle's
|
|
195
195
|
* documented `/v1` base (`https://bedrock-mantle.<region>.api.aws/v1`).
|
|
196
|
+
* - `runtime`: the bedrock-runtime origin itself, where Converse and
|
|
197
|
+
* InvokeModel live under `/model/<id>/…`.
|
|
196
198
|
*
|
|
197
199
|
* Hostnames are parsed strictly so proxies that embed these hosts in a path
|
|
198
200
|
* do not match.
|
|
199
201
|
*/
|
|
200
|
-
export function isBedrockRouteUrl(baseUrl: string | undefined, route: "openai" | "anthropic"): boolean {
|
|
202
|
+
export function isBedrockRouteUrl(baseUrl: string | undefined, route: "openai" | "anthropic" | "runtime"): boolean {
|
|
201
203
|
if (!baseUrl) return false;
|
|
202
204
|
let url: URL;
|
|
203
205
|
try {
|
|
@@ -208,8 +210,9 @@ export function isBedrockRouteUrl(baseUrl: string | undefined, route: "openai" |
|
|
|
208
210
|
if (url.protocol !== "https:") return false;
|
|
209
211
|
const host = BEDROCK_PUBLIC_HOST.exec(url.hostname) ?? BEDROCK_PRIVATELINK_HOST.exec(url.hostname);
|
|
210
212
|
if (!host) return false;
|
|
211
|
-
if (route === "anthropic") return hasPathPrefix(url.pathname, "/anthropic");
|
|
212
213
|
const isMantle = host.groups?.runtime === undefined;
|
|
214
|
+
if (route === "runtime") return !isMantle && url.pathname === "/";
|
|
215
|
+
if (route === "anthropic") return hasPathPrefix(url.pathname, "/anthropic");
|
|
213
216
|
return hasPathPrefix(url.pathname, "/openai") || (isMantle && hasPathPrefix(url.pathname, "/v1"));
|
|
214
217
|
}
|
|
215
218
|
|