@linxiraos/pi-catalog 1.4.0 → 1.4.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 (50) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/types/compat/auth-ids.d.ts +2 -2
  3. package/dist/types/compat/image-tokenization.d.ts +13 -1
  4. package/dist/types/compat/prompt-cache-persistent.d.ts +7 -0
  5. package/dist/types/compat/provider-ids.d.ts +1 -1
  6. package/dist/types/compat/request-size.d.ts +11 -6
  7. package/dist/types/discovery/devin.d.ts +1 -1
  8. package/dist/types/hosts.d.ts +3 -1
  9. package/dist/types/provider-models/openai-compat.d.ts +9 -2
  10. package/dist/types/types.d.ts +10 -3
  11. package/dist/types/wire/codex.d.ts +4 -2
  12. package/dist/types/wire/devin.d.ts +1 -15
  13. package/package.json +4 -4
  14. package/src/compat/auth-ids.ts +2 -0
  15. package/src/compat/axes.ts +25 -2
  16. package/src/compat/image-tokenization.ts +55 -1
  17. package/src/compat/prompt-cache-persistent.ts +12 -0
  18. package/src/compat/provider-ids.d.ts +1 -1
  19. package/src/compat/provider-ids.ts +1 -0
  20. package/src/compat/request-size.ts +18 -8
  21. package/src/compat/resolve.ts +1 -0
  22. package/src/compat/rules/README.md +8 -2
  23. package/src/compat/rules/auth/_order.kdl +1 -1
  24. package/src/compat/rules/auth/inception.kdl +11 -0
  25. package/src/compat/rules/classes/anthropic.kdl +23 -21
  26. package/src/compat/rules/classes/deepseek.kdl +31 -0
  27. package/src/compat/rules/classes/gemma.kdl +11 -0
  28. package/src/compat/rules/classes/minimax.kdl +13 -8
  29. package/src/compat/rules/providers/amazon-bedrock.kdl +56 -0
  30. package/src/compat/rules/providers/factory-droid.kdl +12 -0
  31. package/src/compat/rules/providers/inception.kdl +61 -0
  32. package/src/compat/rules/providers/moonshot.kdl +3 -3
  33. package/src/compat/rules/providers/openai-codex.kdl +3 -0
  34. package/src/compat/rules/providers/yolo-auto.kdl +33 -37
  35. package/src/compat/rules/taxonomy/qwen.kdl +1 -1
  36. package/src/compat/rules.json +1 -1
  37. package/src/discovery/devin.d.ts +1 -1
  38. package/src/discovery/devin.ts +33 -66
  39. package/src/hosts.d.ts +3 -1
  40. package/src/hosts.ts +5 -2
  41. package/src/models.json +1 -1
  42. package/src/provider-models/descriptors.ts +2 -0
  43. package/src/provider-models/openai-compat.d.ts +9 -2
  44. package/src/provider-models/openai-compat.ts +47 -5
  45. package/src/types.d.ts +10 -3
  46. package/src/types.ts +10 -3
  47. package/src/wire/codex.d.ts +4 -2
  48. package/src/wire/codex.ts +11 -3
  49. package/src/wire/devin.d.ts +1 -15
  50. package/src/wire/devin.ts +16 -20
@@ -40,6 +40,7 @@ import {
40
40
  groqModelManagerOptions,
41
41
  helmcodeModelManagerOptions,
42
42
  huggingfaceModelManagerOptions,
43
+ inceptionModelManagerOptions,
43
44
  kiloModelManagerOptions,
44
45
  kimiCodeModelManagerOptions,
45
46
  litellmModelManagerOptions,
@@ -126,6 +127,7 @@ const MODEL_MANAGER_FACTORIES: Readonly<Partial<Record<KnownProvider, ModelManag
126
127
  groq: config => groqModelManagerOptions(config),
127
128
  helmcode: config => helmcodeModelManagerOptions(config),
128
129
  huggingface: config => huggingfaceModelManagerOptions(config),
130
+ inception: config => inceptionModelManagerOptions(config),
129
131
  kilo: config => kiloModelManagerOptions(config),
130
132
  "kimi-code": config => kimiCodeModelManagerOptions(config),
131
133
  litellm: config => litellmModelManagerOptions(config),
@@ -419,6 +419,13 @@ export interface TogetherModelManagerConfig {
419
419
  fetch?: FetchImpl;
420
420
  }
421
421
  export declare function togetherModelManagerOptions(config?: TogetherModelManagerConfig): ModelManagerOptions<"openai-completions">;
422
+ /**
423
+ * Builds Inception's authenticated model-discovery manager. A successful
424
+ * `/v1/models` fetch is the complete roster, keeping only rows that advertise
425
+ * `chat.completions` (the shared roster also lists FIM/edit and Decisions-only
426
+ * models); without an API key the bundled Mercury seeds are served.
427
+ */
428
+ export declare function inceptionModelManagerOptions(config?: ModelManagerConfig): ModelManagerOptions<"openai-completions">;
422
429
  export interface CoreWeaveModelManagerConfig {
423
430
  apiKey?: string;
424
431
  baseUrl?: string;
@@ -468,8 +475,8 @@ export interface YoloAutoModelManagerConfig {
468
475
  fetch?: FetchImpl;
469
476
  }
470
477
  /**
471
- * Yolo-Auto model manager: OpenAI-compatible chat completions at the
472
- * flat-rate `deepseek-flash-v4` endpoint. Live `/v1/models` discovery replaces the
478
+ * Yolo-Auto model manager: flat-rate OpenAI-compatible chat completions
479
+ * (`qwen3.8-27b`, `yolo`, ...). Live `/v1/models` discovery replaces the
473
480
  * bundled seed once a key is stored or present in `YOLO_AUTO_API_KEY`. Models
474
481
  * the provider adds later inherit metadata (reasoning, thinking, context)
475
482
  * from the global bundled reference index, so new ids work without a per-id
@@ -569,8 +569,8 @@ function perTokenPricingCost(pricing: unknown): TokenCost {
569
569
  return {
570
570
  input: toPositiveNumber(rates.prompt, 0) * 1_000_000,
571
571
  output: toPositiveNumber(rates.completion, 0) * 1_000_000,
572
- cacheRead: toPositiveNumber(rates.input_cache_read, 0) * 1_000_000,
573
- cacheWrite: toPositiveNumber(rates.input_cache_write, 0) * 1_000_000,
572
+ cacheRead: toPositiveNumber(rates.input_cache_read ?? rates.input_cache_reads, 0) * 1_000_000,
573
+ cacheWrite: toPositiveNumber(rates.input_cache_write ?? rates.input_cache_writes, 0) * 1_000_000,
574
574
  };
575
575
  }
576
576
 
@@ -4740,6 +4740,48 @@ export function togetherModelManagerOptions(
4740
4740
  return createSimpleOpenAICompletionsOptions("together", "https://api.together.xyz/v1", config);
4741
4741
  }
4742
4742
 
4743
+ // ---------------------------------------------------------------------------
4744
+ // Inception
4745
+ // ---------------------------------------------------------------------------
4746
+
4747
+ /**
4748
+ * Builds Inception's authenticated model-discovery manager. A successful
4749
+ * `/v1/models` fetch is the complete roster, keeping only rows that advertise
4750
+ * `chat.completions` (the shared roster also lists FIM/edit and Decisions-only
4751
+ * models); without an API key the bundled Mercury seeds are served.
4752
+ */
4753
+ export function inceptionModelManagerOptions(config?: ModelManagerConfig): ModelManagerOptions<"openai-completions"> {
4754
+ return {
4755
+ ...createOpenAICompatibleModelManagerOptions({
4756
+ api: "openai-completions",
4757
+ providerId: "inception",
4758
+ defaultBaseUrl: "https://api.inceptionlabs.ai/v1",
4759
+ config,
4760
+ requireApiKey: true,
4761
+ dynamicModelsAuthoritative: true,
4762
+ mapModel: (entry, defaults, reference) => {
4763
+ // The shared roster also contains FIM/edit and Decisions-only models;
4764
+ // `supported_endpoints` is required, so a row without it is not chat.
4765
+ if (!Array.isArray(entry.supported_endpoints) || !entry.supported_endpoints.includes("chat.completions")) {
4766
+ return null;
4767
+ }
4768
+ const model = mapWithBundledReference(entry, defaults, reference);
4769
+ return {
4770
+ ...model,
4771
+ input: Array.isArray(entry.input_modalities) ? toInputCapabilities(entry.input_modalities) : model.input,
4772
+ cost: isRecord(entry.pricing) ? perTokenPricingCost(entry.pricing) : model.cost,
4773
+ contextWindow: toPositiveNumber(entry.context_length, model.contextWindow),
4774
+ maxTokens: toPositiveNumber(entry.max_output_length, model.maxTokens),
4775
+ ...(Array.isArray(entry.supported_features) && {
4776
+ supportsTools: entry.supported_features.includes("tools"),
4777
+ }),
4778
+ };
4779
+ },
4780
+ }),
4781
+ staticModels: seedModels<"openai-completions">("inception"),
4782
+ };
4783
+ }
4784
+
4743
4785
  // ---------------------------------------------------------------------------
4744
4786
  // 15.5 CoreWeave Serverless Inference
4745
4787
  // ---------------------------------------------------------------------------
@@ -4928,7 +4970,7 @@ export interface MoonshotModelManagerConfig {
4928
4970
  * use the K2.x binary `thinking: { type }` block, so the wire path routes it
4929
4971
  * through OpenAI-style `reasoning_effort` (see `buildOpenAICompat`).
4930
4972
  */
4931
- const MOONSHOT_KIMI_K3_COST = { input: 3, output: 15, cacheRead: 0.3, cacheWrite: 0 } as const;
4973
+ const MOONSHOT_KIMI_K3_COST = { input: 3, output: 15, cacheRead: 0.3, cacheWrite: 3 } as const;
4932
4974
  export function moonshotModelManagerOptions(
4933
4975
  config?: MoonshotModelManagerConfig,
4934
4976
  ): ModelManagerOptions<"openai-completions"> {
@@ -5271,8 +5313,8 @@ function mapYoloAutoModel(
5271
5313
  };
5272
5314
  }
5273
5315
  /**
5274
- * Yolo-Auto model manager: OpenAI-compatible chat completions at the
5275
- * flat-rate `deepseek-flash-v4` endpoint. Live `/v1/models` discovery replaces the
5316
+ * Yolo-Auto model manager: flat-rate OpenAI-compatible chat completions
5317
+ * (`qwen3.8-27b`, `yolo`, ...). Live `/v1/models` discovery replaces the
5276
5318
  * bundled seed once a key is stored or present in `YOLO_AUTO_API_KEY`. Models
5277
5319
  * the provider adds later inherit metadata (reasoning, thinking, context)
5278
5320
  * from the global bundled reference index, so new ids work without a per-id
package/src/types.d.ts CHANGED
@@ -688,8 +688,8 @@ export interface AnthropicCompat {
688
688
  fastMode?: boolean;
689
689
  }
690
690
  /**
691
- * Compatibility settings for Bedrock Converse prompt caching. Cache pricing is
692
- * deliberately not used to infer these request-shape capabilities.
691
+ * Compatibility settings for Bedrock Converse requests and native streaming
692
+ * side-compaction. Cache pricing does not imply these capabilities.
693
693
  */
694
694
  export interface BedrockCompat {
695
695
  /** Explicit disabled-thinking wire form; unset preserves the provider's existing behavior. */
@@ -737,8 +737,13 @@ export interface BedrockCompat {
737
737
  * local prefix-binding safeguards. Default: true.
738
738
  */
739
739
  supportsThinkingBindingControls?: boolean;
740
+ /**
741
+ * Whether the model supports a compaction-only Bedrock Runtime
742
+ * InvokeModelWithResponseStream request. Ordinary turns still use Converse.
743
+ */
744
+ supportsServerCompaction?: boolean;
740
745
  }
741
- /** Fully-resolved Bedrock Converse prompt-cache capabilities, materialized once by `buildModel`. */
746
+ /** Fully-resolved Bedrock Converse and side-compaction capabilities, materialized once by `buildModel`. */
742
747
  export interface ResolvedBedrockCompat {
743
748
  /** See {@link BedrockCompat.disabledThinking}. */
744
749
  disabledThinking?: BedrockCompat["disabledThinking"];
@@ -753,6 +758,8 @@ export interface ResolvedBedrockCompat {
753
758
  supportsForcedToolChoice: boolean;
754
759
  /** See {@link BedrockCompat.supportsThinkingBindingControls}. */
755
760
  supportsThinkingBindingControls: boolean;
761
+ /** See {@link BedrockCompat.supportsServerCompaction}; false unless the Bedrock model-card policy opts in. */
762
+ supportsServerCompaction: boolean;
756
763
  /**
757
764
  * Stream-watchdog idle-timeout fallback in ms for hosts with no keepalive
758
765
  * events; 0 disables the idle watchdog. Undefined defers to
package/src/types.ts CHANGED
@@ -810,8 +810,8 @@ export interface AnthropicCompat {
810
810
  }
811
811
 
812
812
  /**
813
- * Compatibility settings for Bedrock Converse prompt caching. Cache pricing is
814
- * deliberately not used to infer these request-shape capabilities.
813
+ * Compatibility settings for Bedrock Converse requests and native streaming
814
+ * side-compaction. Cache pricing does not imply these capabilities.
815
815
  */
816
816
  export interface BedrockCompat {
817
817
  /** Explicit disabled-thinking wire form; unset preserves the provider's existing behavior. */
@@ -859,9 +859,14 @@ export interface BedrockCompat {
859
859
  * local prefix-binding safeguards. Default: true.
860
860
  */
861
861
  supportsThinkingBindingControls?: boolean;
862
+ /**
863
+ * Whether the model supports a compaction-only Bedrock Runtime
864
+ * InvokeModelWithResponseStream request. Ordinary turns still use Converse.
865
+ */
866
+ supportsServerCompaction?: boolean;
862
867
  }
863
868
 
864
- /** Fully-resolved Bedrock Converse prompt-cache capabilities, materialized once by `buildModel`. */
869
+ /** Fully-resolved Bedrock Converse and side-compaction capabilities, materialized once by `buildModel`. */
865
870
  export interface ResolvedBedrockCompat {
866
871
  /** See {@link BedrockCompat.disabledThinking}. */
867
872
  disabledThinking?: BedrockCompat["disabledThinking"];
@@ -876,6 +881,8 @@ export interface ResolvedBedrockCompat {
876
881
  supportsForcedToolChoice: boolean;
877
882
  /** See {@link BedrockCompat.supportsThinkingBindingControls}. */
878
883
  supportsThinkingBindingControls: boolean;
884
+ /** See {@link BedrockCompat.supportsServerCompaction}; false unless the Bedrock model-card policy opts in. */
885
+ supportsServerCompaction: boolean;
879
886
  /**
880
887
  * Stream-watchdog idle-timeout fallback in ms for hosts with no keepalive
881
888
  * events; 0 disables the idle watchdog. Undefined defers to
@@ -78,8 +78,10 @@ export declare function getCodexAccountId(accessToken: string): string | undefin
78
78
  * needed: `chatgpt_data_residency` is the authoritative claim, with
79
79
  * `chatgpt_compute_residency` as the fallback for tokens that only carry that.
80
80
  *
81
- * Returns undefined for a non-JWT token, or for the (common) accounts whose
82
- * claims omit residency entirely — those workspaces are not region-pinned.
81
+ * Returns undefined for a non-JWT token, or for the (common) accounts that are
82
+ * not region-pinned: their claims omit residency or carry the
83
+ * {@link CODEX_UNCONSTRAINED_RESIDENCY} sentinel. The backend answers 404 to a
84
+ * declared `no_constraint`, and codex-rs never sends it.
83
85
  */
84
86
  export declare function getCodexResidency(accessToken: string): string | undefined;
85
87
  /**
package/src/wire/codex.ts CHANGED
@@ -105,6 +105,9 @@ export function getCodexAccountId(accessToken: string): string | undefined {
105
105
  }
106
106
  }
107
107
 
108
+ /** Residency claim value of an account that is not region-pinned. */
109
+ const CODEX_UNCONSTRAINED_RESIDENCY = "no_constraint";
110
+
108
111
  /**
109
112
  * Extract the account's data residency from a Codex JWT access token.
110
113
  *
@@ -115,8 +118,10 @@ export function getCodexAccountId(accessToken: string): string | undefined {
115
118
  * needed: `chatgpt_data_residency` is the authoritative claim, with
116
119
  * `chatgpt_compute_residency` as the fallback for tokens that only carry that.
117
120
  *
118
- * Returns undefined for a non-JWT token, or for the (common) accounts whose
119
- * claims omit residency entirely — those workspaces are not region-pinned.
121
+ * Returns undefined for a non-JWT token, or for the (common) accounts that are
122
+ * not region-pinned: their claims omit residency or carry the
123
+ * {@link CODEX_UNCONSTRAINED_RESIDENCY} sentinel. The backend answers 404 to a
124
+ * declared `no_constraint`, and codex-rs never sends it.
120
125
  */
121
126
  export function getCodexResidency(accessToken: string): string | undefined {
122
127
  try {
@@ -130,7 +135,10 @@ export function getCodexResidency(accessToken: string): string | undefined {
130
135
  for (const claim of [auth?.chatgpt_data_residency, auth?.chatgpt_compute_residency]) {
131
136
  if (typeof claim !== "string") continue;
132
137
  const residency = claim.trim();
133
- if (residency.length > 0) return residency;
138
+ if (residency.length === 0) continue;
139
+ // The first present claim is authoritative, so an unconstrained data
140
+ // residency is not overridden by a compute residency.
141
+ return residency.toLowerCase() === CODEX_UNCONSTRAINED_RESIDENCY ? undefined : residency;
134
142
  }
135
143
  return undefined;
136
144
  } catch {
@@ -6,23 +6,9 @@
6
6
  */
7
7
  /** Base host for Codeium/Windsurf's Cascade API (Connect protocol over HTTP/1.1). */
8
8
  export declare const DEVIN_DEFAULT_BASE_URL = "https://server.codeium.com";
9
- /** Session token as the wire format carries it: the scheme prefix is required. */
10
- export declare function normalizeDevinSessionToken(apiKey: string | undefined): string;
11
- /** Released-CLI metadata with credential bytes already encoded for the wire. */
12
- export declare function devinWireMetadata(apiKey: string | undefined, userJwt?: string): {
13
- ideName: "devin-cli";
14
- ideType: "chisel";
15
- ideVersion: "3000.11.3";
16
- extensionName: "chisel";
17
- extensionVersion: "3000.11.3";
18
- locale: "en";
19
- os: "darwin" | "linux" | "windows";
20
- apiKey: string;
21
- userJwt: string;
22
- };
23
9
  /**
24
10
  * Fields for `Metadata` on released-CLI calls (`GetUserJwt`, `AssignModel`,
25
- * `GetChatMessage`, `GetUserStatus`) authenticated by a Devin session token.
11
+ * `GetChatMessage`, `GetUserStatus`).
26
12
  */
27
13
  export declare function devinCliMetadata(apiKey: string | undefined, userJwt?: string): {
28
14
  ideName: "devin-cli";
package/src/wire/devin.ts CHANGED
@@ -17,7 +17,7 @@ const DEVIN_LOCALE = "en";
17
17
  /**
18
18
  * Released Devin CLI request identity. The backend gates behavior on this
19
19
  * tuple: `ideType: "chisel"` is what unlocks router assignment (`AssignModel`)
20
- * and the CLI model surface, which the older Windsurf identity does not reach.
20
+ * and the CLI model surface.
21
21
  */
22
22
  const DEVIN_CLI_METADATA = {
23
23
  ideName: "devin-cli",
@@ -31,9 +31,8 @@ const DEVIN_CLI_METADATA = {
31
31
 
32
32
  /**
33
33
  * Native discovery identity. The Devin CLI announces itself as the `chisel`
34
- * client on its dev channel for `GetCliModelConfigs`; that identity — not the
35
- * released chat identity or the legacy Windsurf one — unlocks the full native
36
- * config set.
34
+ * client on its dev channel for `GetCliModelConfigs`; that identity, not the
35
+ * released chat identity, unlocks the full native config set.
37
36
  */
38
37
  const DEVIN_DISCOVERY_METADATA = {
39
38
  ideName: "chisel",
@@ -44,33 +43,30 @@ const DEVIN_DISCOVERY_METADATA = {
44
43
  os: DEVIN_OS,
45
44
  } as const;
46
45
 
47
- /** Session token as the wire format carries it: the scheme prefix is required. */
48
- export function normalizeDevinSessionToken(apiKey: string | undefined): string {
49
- if (!apiKey) return "";
50
- return apiKey.startsWith(DEVIN_SESSION_TOKEN_PREFIX) ? apiKey : `${DEVIN_SESSION_TOKEN_PREFIX}${apiKey}`;
51
- }
52
-
53
- /** Released-CLI metadata with credential bytes already encoded for the wire. */
54
- export function devinWireMetadata(apiKey: string | undefined, userJwt = "") {
55
- return {
56
- apiKey: apiKey ?? "",
57
- userJwt,
58
- ...DEVIN_CLI_METADATA,
59
- };
46
+ /** Prefixes bare JWT-shaped session tokens; every other key, legacy `sk-ws-` ones included, goes out as stored. */
47
+ function encodeDevinCredential(apiKey: string | undefined): string {
48
+ const key = apiKey?.trim();
49
+ if (!key) return "";
50
+ if (key.startsWith(DEVIN_SESSION_TOKEN_PREFIX)) return key;
51
+ return key.split(".").length === 3 ? `${DEVIN_SESSION_TOKEN_PREFIX}${key}` : key;
60
52
  }
61
53
 
62
54
  /**
63
55
  * Fields for `Metadata` on released-CLI calls (`GetUserJwt`, `AssignModel`,
64
- * `GetChatMessage`, `GetUserStatus`) authenticated by a Devin session token.
56
+ * `GetChatMessage`, `GetUserStatus`).
65
57
  */
66
58
  export function devinCliMetadata(apiKey: string | undefined, userJwt = "") {
67
- return devinWireMetadata(normalizeDevinSessionToken(apiKey), userJwt);
59
+ return {
60
+ apiKey: encodeDevinCredential(apiKey),
61
+ userJwt,
62
+ ...DEVIN_CLI_METADATA,
63
+ };
68
64
  }
69
65
 
70
66
  /** Fields for `Metadata` on the dev-channel `GetCliModelConfigs` call. */
71
67
  export function devinDiscoveryMetadata(apiKey: string | undefined) {
72
68
  return {
73
- apiKey: normalizeDevinSessionToken(apiKey),
69
+ apiKey: encodeDevinCredential(apiKey),
74
70
  ...DEVIN_DISCOVERY_METADATA,
75
71
  };
76
72
  }