@oisin-ee/pi-tiers 0.9.1 → 0.9.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oisin-ee/pi-tiers",
3
- "version": "0.9.1",
3
+ "version": "0.9.2",
4
4
  "description": "Sticky virtual model tiers with quota-aware recovery for pi.",
5
5
  "keywords": [
6
6
  "pi-extension",
package/src/policy.ts CHANGED
@@ -77,7 +77,9 @@ const ZERO = 0,
77
77
  ["minimax-", "minimax"],
78
78
  ],
79
79
  pool =
80
- pools.find(([prefix]: readonly string[]) => id.startsWith(prefix ?? ""))?.[ONE] ?? provider;
80
+ pools.find(([prefix]: readonly string[]) => id.toLowerCase().startsWith(prefix ?? ""))?.[
81
+ ONE
82
+ ] ?? provider;
81
83
  return { id, pool, provider };
82
84
  };
83
85
 
package/src/router.ts CHANGED
@@ -12,19 +12,25 @@ const ZERO = 0,
12
12
  ONE = 1,
13
13
  CACHE_MS = 60_000,
14
14
  /**
15
- * Keeps only targets the model registry lists, so a provider model that is not
16
- * configured yet behaves like an unavailable target instead of a terminal error.
15
+ * Resolves tier targets to the references the model registry lists. Provider model
16
+ * ids differ in case from the tier file (`MiniMax-M3.1-Flash`), so matching ignores
17
+ * case and returns the registry's exact reference. A target that is not listed yet
18
+ * behaves like an unavailable target instead of a terminal error.
17
19
  * @param {readonly string[]} targets Ordered tier.
18
20
  * @param {Context} ctx Pi authority.
19
- * @returns {readonly string[]} Listed targets, in tier order.
21
+ * @returns {readonly string[]} Listed registry references, in tier order.
20
22
  */
21
23
  listed = (targets: readonly string[], ctx: Context): readonly string[] => {
22
- const available = new Set(
23
- ctx.modelRegistry.getAvailable().map((candidate) => `${candidate.provider}/${candidate.id}`),
24
+ const available = new Map(
25
+ ctx.modelRegistry.getAvailable().map((candidate) => {
26
+ const reference = `${candidate.provider}/${candidate.id}`;
27
+ return [reference.toLowerCase(), reference];
28
+ }),
24
29
  );
25
- return targets.filter((reference) => {
26
- const parsed = target(reference);
27
- return available.has(`${parsed.provider}/${parsed.id}`);
30
+ return targets.flatMap((reference) => {
31
+ const parsed = target(reference),
32
+ found = available.get(`${parsed.provider}/${parsed.id}`.toLowerCase());
33
+ return found === undefined ? [] : [found];
28
34
  });
29
35
  };
30
36