@rigelbuild/omp-catalog 18.0.3

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 (117) hide show
  1. package/CHANGELOG.md +1204 -0
  2. package/LICENSE +22 -0
  3. package/README.md +43 -0
  4. package/THIRD-PARTY-NOTICES.txt +22909 -0
  5. package/dist/types/build.d.ts +19 -0
  6. package/dist/types/compat/anthropic.d.ts +18 -0
  7. package/dist/types/compat/apply.d.ts +7 -0
  8. package/dist/types/compat/bedrock.d.ts +3 -0
  9. package/dist/types/compat/devin.d.ts +9 -0
  10. package/dist/types/compat/openai.d.ts +28 -0
  11. package/dist/types/discovery/antigravity.d.ts +70 -0
  12. package/dist/types/discovery/codex.d.ts +36 -0
  13. package/dist/types/discovery/cursor-proto.d.ts +5368 -0
  14. package/dist/types/discovery/cursor.d.ts +23 -0
  15. package/dist/types/discovery/devin-proto.d.ts +1549 -0
  16. package/dist/types/discovery/devin.d.ts +24 -0
  17. package/dist/types/discovery/gemini-cli.d.ts +33 -0
  18. package/dist/types/discovery/gemini.d.ts +25 -0
  19. package/dist/types/discovery/gitlab-duo-workflow.d.ts +30 -0
  20. package/dist/types/discovery/index.d.ts +7 -0
  21. package/dist/types/discovery/openai-compatible.d.ts +89 -0
  22. package/dist/types/discovery/protobuf.d.ts +102 -0
  23. package/dist/types/effort.d.ts +10 -0
  24. package/dist/types/fireworks-model-id.d.ts +23 -0
  25. package/dist/types/hosts.d.ts +169 -0
  26. package/dist/types/identity/bundled.d.ts +3 -0
  27. package/dist/types/identity/classify.d.ts +69 -0
  28. package/dist/types/identity/dialect.d.ts +3 -0
  29. package/dist/types/identity/family.d.ts +239 -0
  30. package/dist/types/identity/id.d.ts +12 -0
  31. package/dist/types/identity/index.d.ts +8 -0
  32. package/dist/types/identity/markers.d.ts +4 -0
  33. package/dist/types/identity/priority.d.ts +1 -0
  34. package/dist/types/identity/reference.d.ts +29 -0
  35. package/dist/types/index.d.ts +19 -0
  36. package/dist/types/model-cache.d.ts +23 -0
  37. package/dist/types/model-manager.d.ts +77 -0
  38. package/dist/types/model-thinking.d.ts +70 -0
  39. package/dist/types/model-tokenizer.d.ts +8 -0
  40. package/dist/types/models.d.ts +14 -0
  41. package/dist/types/openai-pricing.d.ts +17 -0
  42. package/dist/types/provider-models/bundled-references.d.ts +13 -0
  43. package/dist/types/provider-models/cache-provider-id.d.ts +11 -0
  44. package/dist/types/provider-models/descriptor-types.d.ts +76 -0
  45. package/dist/types/provider-models/descriptors.d.ts +505 -0
  46. package/dist/types/provider-models/google.d.ts +29 -0
  47. package/dist/types/provider-models/index.d.ts +7 -0
  48. package/dist/types/provider-models/ollama.d.ts +22 -0
  49. package/dist/types/provider-models/openai-compat.d.ts +646 -0
  50. package/dist/types/provider-models/special.d.ts +53 -0
  51. package/dist/types/types.d.ts +876 -0
  52. package/dist/types/utils.d.ts +20 -0
  53. package/dist/types/variant-collapse.d.ts +137 -0
  54. package/dist/types/wire/alibaba-token-plan.d.ts +22 -0
  55. package/dist/types/wire/codex.d.ts +66 -0
  56. package/dist/types/wire/coreweave.d.ts +12 -0
  57. package/dist/types/wire/gemini-headers.d.ts +62 -0
  58. package/dist/types/wire/github-copilot.d.ts +47 -0
  59. package/dist/types/wire/image-fetchers.d.ts +76 -0
  60. package/package.json +102 -0
  61. package/src/build.ts +103 -0
  62. package/src/compat/anthropic.ts +179 -0
  63. package/src/compat/apply.ts +15 -0
  64. package/src/compat/bedrock.ts +153 -0
  65. package/src/compat/devin.ts +12 -0
  66. package/src/compat/openai.ts +864 -0
  67. package/src/discovery/antigravity.ts +257 -0
  68. package/src/discovery/codex.ts +456 -0
  69. package/src/discovery/cursor-proto.ts +8329 -0
  70. package/src/discovery/cursor.ts +409 -0
  71. package/src/discovery/devin-proto.ts +2037 -0
  72. package/src/discovery/devin.ts +152 -0
  73. package/src/discovery/gemini-cli.ts +198 -0
  74. package/src/discovery/gemini.ts +260 -0
  75. package/src/discovery/gitlab-duo-workflow.ts +859 -0
  76. package/src/discovery/index.ts +7 -0
  77. package/src/discovery/openai-compatible.ts +266 -0
  78. package/src/discovery/protobuf.ts +1073 -0
  79. package/src/effort.ts +18 -0
  80. package/src/fireworks-model-id.ts +50 -0
  81. package/src/hosts.ts +178 -0
  82. package/src/identity/bundled.ts +28 -0
  83. package/src/identity/classify.ts +242 -0
  84. package/src/identity/dialect.ts +42 -0
  85. package/src/identity/family.ts +477 -0
  86. package/src/identity/id.ts +81 -0
  87. package/src/identity/index.ts +8 -0
  88. package/src/identity/markers.ts +49 -0
  89. package/src/identity/priority.ts +59 -0
  90. package/src/identity/reference.ts +167 -0
  91. package/src/index.ts +19 -0
  92. package/src/model-cache.ts +346 -0
  93. package/src/model-manager.ts +683 -0
  94. package/src/model-thinking.ts +925 -0
  95. package/src/model-tokenizer.ts +75 -0
  96. package/src/models.json +304657 -0
  97. package/src/models.json.d.ts +9 -0
  98. package/src/models.ts +108 -0
  99. package/src/openai-pricing.ts +29 -0
  100. package/src/provider-models/bundled-references.ts +87 -0
  101. package/src/provider-models/cache-provider-id.ts +97 -0
  102. package/src/provider-models/descriptor-types.ts +85 -0
  103. package/src/provider-models/descriptors.ts +585 -0
  104. package/src/provider-models/google.ts +117 -0
  105. package/src/provider-models/index.ts +7 -0
  106. package/src/provider-models/ollama.ts +204 -0
  107. package/src/provider-models/openai-compat.ts +6405 -0
  108. package/src/provider-models/special.ts +213 -0
  109. package/src/types.ts +1032 -0
  110. package/src/utils.ts +69 -0
  111. package/src/variant-collapse.ts +1555 -0
  112. package/src/wire/alibaba-token-plan.ts +54 -0
  113. package/src/wire/codex.ts +117 -0
  114. package/src/wire/coreweave.ts +51 -0
  115. package/src/wire/gemini-headers.ts +135 -0
  116. package/src/wire/github-copilot.ts +147 -0
  117. package/src/wire/image-fetchers.ts +159 -0
@@ -0,0 +1,75 @@
1
+ import { bareModelId, parseAnthropicModel, parseGlmModel, semverGte } from "./identity/classify";
2
+ import type { ModelTokenizer } from "./types";
3
+
4
+ const DEEPSEEK_V3_ALIASES: Record<string, true> = {
5
+ "deepseek-chat": true,
6
+ "deepseek-reasoner": true,
7
+ };
8
+ const KIMI_K2_ALIASES: Record<string, true> = {
9
+ "kimi-for-coding": true,
10
+ "kimi-for-coding-highspeed": true,
11
+ };
12
+
13
+ // Resolution is pure and catalog ids recur across providers and aliases.
14
+ const MAX_TOKENIZER_CACHE_ENTRIES = 2_048;
15
+ const modelTokenizerCache = new Map<string, ModelTokenizer | null>();
16
+
17
+ function claudeTokenizer(modelId: string): ModelTokenizer | undefined {
18
+ const parsed = parseAnthropicModel(modelId);
19
+ if (parsed) {
20
+ if (parsed.kind === "opus") {
21
+ if (semverGte(parsed.version, "5")) return "claude-v5";
22
+ if (semverGte(parsed.version, "4.7")) return "claude-v47";
23
+ return "claude-v3";
24
+ }
25
+ return semverGte(parsed.version, "5") ? "claude-v5-sonnet" : "claude-v3";
26
+ }
27
+ return /(^|[-/.:])claude([-.:]|$)/i.test(modelId) ? "claude-v3" : undefined;
28
+ }
29
+
30
+ function qwenTokenizer(modelId: string): ModelTokenizer | undefined {
31
+ const version = /qwen[-_ ]?(\d+)\.(\d+)(?![\dbB])/i.exec(modelId);
32
+ if (!version) return undefined;
33
+ const major = Number.parseInt(version[1], 10);
34
+ const minor = Number.parseInt(version[2], 10);
35
+ return major > 3 || (major === 3 && minor >= 5) ? "qwen3" : undefined;
36
+ }
37
+
38
+ function deepSeekTokenizer(modelId: string): ModelTokenizer | undefined {
39
+ const lower = modelId.toLowerCase();
40
+ if (lower.includes("distill")) return undefined;
41
+ if (DEEPSEEK_V3_ALIASES[lower]) return "deepseek-v3";
42
+ return /(?:^|[-_.:])(?:v?[34]|r1)(?:[-_.:]|$)/.test(lower) && lower.includes("deepseek") ? "deepseek-v3" : undefined;
43
+ }
44
+
45
+ function kimiTokenizer(modelId: string): ModelTokenizer | undefined {
46
+ const lower = modelId.toLowerCase();
47
+ if (KIMI_K2_ALIASES[lower]) return "kimi-k2";
48
+ return /(?:^|[-_.:])kimi[-_.:]?k?[23](?:[-_.:]|$)/.test(lower) ? "kimi-k2" : undefined;
49
+ }
50
+
51
+ function glmTokenizer(modelId: string): ModelTokenizer | undefined {
52
+ const glm = parseGlmModel(modelId);
53
+ return glm && semverGte(glm.version, "5") ? "glm5" : undefined;
54
+ }
55
+
56
+ /**
57
+ * Resolve the exact locally embedded tokenizer for a canonical model id.
58
+ *
59
+ * This is catalog policy, not a runtime caller heuristic: [`buildModel`](./build.ts)
60
+ * materializes the result as `Model.tokenizer`; consumers read that property.
61
+ */
62
+ export function resolveModelTokenizer(modelId: string): ModelTokenizer | undefined {
63
+ const cached = modelTokenizerCache.get(modelId);
64
+ if (cached !== undefined) return cached ?? undefined;
65
+ const bare = bareModelId(modelId);
66
+ const tokenizer =
67
+ claudeTokenizer(bare) ??
68
+ qwenTokenizer(bare) ??
69
+ deepSeekTokenizer(bare) ??
70
+ kimiTokenizer(bare) ??
71
+ glmTokenizer(bare);
72
+ if (modelTokenizerCache.size === MAX_TOKENIZER_CACHE_ENTRIES) modelTokenizerCache.clear();
73
+ modelTokenizerCache.set(modelId, tokenizer ?? null);
74
+ return tokenizer;
75
+ }