@tokenite/shared 1.0.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.
Files changed (107) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +42 -0
  3. package/dist/catalog/agent-runtime.d.ts +3 -0
  4. package/dist/catalog/agent-runtime.js +3 -0
  5. package/dist/catalog/bindings/anthropic.d.ts +2 -0
  6. package/dist/catalog/bindings/anthropic.js +11 -0
  7. package/dist/catalog/bindings/bedrock.d.ts +2 -0
  8. package/dist/catalog/bindings/bedrock.js +10 -0
  9. package/dist/catalog/bindings/google.d.ts +2 -0
  10. package/dist/catalog/bindings/google.js +12 -0
  11. package/dist/catalog/bindings/grok.d.ts +2 -0
  12. package/dist/catalog/bindings/grok.js +14 -0
  13. package/dist/catalog/bindings/index.d.ts +18 -0
  14. package/dist/catalog/bindings/index.js +36 -0
  15. package/dist/catalog/bindings/openai.d.ts +2 -0
  16. package/dist/catalog/bindings/openai.js +14 -0
  17. package/dist/catalog/bindings/types.d.ts +15 -0
  18. package/dist/catalog/bindings/types.js +11 -0
  19. package/dist/catalog/capabilities.d.ts +12 -0
  20. package/dist/catalog/capabilities.js +9 -0
  21. package/dist/catalog/flavors/anthropic.d.ts +3 -0
  22. package/dist/catalog/flavors/anthropic.js +26 -0
  23. package/dist/catalog/flavors/gemini.d.ts +3 -0
  24. package/dist/catalog/flavors/gemini.js +16 -0
  25. package/dist/catalog/flavors/index.d.ts +10 -0
  26. package/dist/catalog/flavors/index.js +10 -0
  27. package/dist/catalog/flavors/openai.d.ts +3 -0
  28. package/dist/catalog/flavors/openai.js +20 -0
  29. package/dist/catalog/flavors/types.d.ts +22 -0
  30. package/dist/catalog/flavors/types.js +2 -0
  31. package/dist/catalog/helpers.d.ts +5 -0
  32. package/dist/catalog/helpers.js +5 -0
  33. package/dist/catalog/index.d.ts +9 -0
  34. package/dist/catalog/index.js +8 -0
  35. package/dist/catalog/models/anthropic.d.ts +7 -0
  36. package/dist/catalog/models/anthropic.js +10 -0
  37. package/dist/catalog/models/google.d.ts +8 -0
  38. package/dist/catalog/models/google.js +11 -0
  39. package/dist/catalog/models/grok.d.ts +10 -0
  40. package/dist/catalog/models/grok.js +13 -0
  41. package/dist/catalog/models/index.d.ts +20 -0
  42. package/dist/catalog/models/index.js +19 -0
  43. package/dist/catalog/models/openai.d.ts +12 -0
  44. package/dist/catalog/models/openai.js +15 -0
  45. package/dist/catalog/models/types.d.ts +17 -0
  46. package/dist/catalog/models/types.js +45 -0
  47. package/dist/catalog/providers/anthropic.d.ts +2 -0
  48. package/dist/catalog/providers/anthropic.js +13 -0
  49. package/dist/catalog/providers/bedrock.d.ts +2 -0
  50. package/dist/catalog/providers/bedrock.js +20 -0
  51. package/dist/catalog/providers/google.d.ts +2 -0
  52. package/dist/catalog/providers/google.js +12 -0
  53. package/dist/catalog/providers/grok.d.ts +2 -0
  54. package/dist/catalog/providers/grok.js +12 -0
  55. package/dist/catalog/providers/index.d.ts +17 -0
  56. package/dist/catalog/providers/index.js +28 -0
  57. package/dist/catalog/providers/openai.d.ts +2 -0
  58. package/dist/catalog/providers/openai.js +12 -0
  59. package/dist/catalog/providers/types.d.ts +32 -0
  60. package/dist/catalog/providers/types.js +2 -0
  61. package/dist/catalog/tiers.d.ts +12 -0
  62. package/dist/catalog/tiers.js +9 -0
  63. package/dist/config.d.ts +3 -0
  64. package/dist/config.js +11 -0
  65. package/dist/constants.d.ts +31 -0
  66. package/dist/constants.js +11 -0
  67. package/dist/index.d.ts +20 -0
  68. package/dist/index.js +20 -0
  69. package/dist/parse.d.ts +2 -0
  70. package/dist/parse.js +12 -0
  71. package/dist/providers/index.d.ts +3 -0
  72. package/dist/providers/index.js +3 -0
  73. package/dist/result.d.ts +18 -0
  74. package/dist/result.js +9 -0
  75. package/dist/schemas/access-token.d.ts +32 -0
  76. package/dist/schemas/access-token.js +20 -0
  77. package/dist/schemas/account-invitation.d.ts +39 -0
  78. package/dist/schemas/account-invitation.js +20 -0
  79. package/dist/schemas/account-member.d.ts +19 -0
  80. package/dist/schemas/account-member.js +15 -0
  81. package/dist/schemas/account.d.ts +45 -0
  82. package/dist/schemas/account.js +25 -0
  83. package/dist/schemas/api-key.d.ts +44 -0
  84. package/dist/schemas/api-key.js +17 -0
  85. package/dist/schemas/app.d.ts +185 -0
  86. package/dist/schemas/app.js +41 -0
  87. package/dist/schemas/budget.d.ts +10 -0
  88. package/dist/schemas/budget.js +9 -0
  89. package/dist/schemas/cli-login.d.ts +42 -0
  90. package/dist/schemas/cli-login.js +25 -0
  91. package/dist/schemas/discovery.d.ts +7 -0
  92. package/dist/schemas/discovery.js +6 -0
  93. package/dist/schemas/error-codes.d.ts +154 -0
  94. package/dist/schemas/error-codes.js +62 -0
  95. package/dist/schemas/error.d.ts +20 -0
  96. package/dist/schemas/error.js +12 -0
  97. package/dist/schemas/provider.d.ts +11 -0
  98. package/dist/schemas/provider.js +4 -0
  99. package/dist/schemas/proxy-response.d.ts +49 -0
  100. package/dist/schemas/proxy-response.js +15 -0
  101. package/dist/schemas/sponsored-api-key.d.ts +65 -0
  102. package/dist/schemas/sponsored-api-key.js +30 -0
  103. package/dist/schemas/usage.d.ts +25 -0
  104. package/dist/schemas/usage.js +19 -0
  105. package/dist/schemas/user.d.ts +20 -0
  106. package/dist/schemas/user.js +13 -0
  107. package/package.json +60 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Eran Broder
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,42 @@
1
+ # @tokenite/shared
2
+
3
+ Public protocol surface for the [Tokenite](https://www.npmjs.com/package/@tokenite/sdk) SDK and CLI.
4
+
5
+ This package contains:
6
+
7
+ - **Zod schemas + types** for the OAuth, app, account, connection, key, budget, usage, and proxy-error surfaces.
8
+ - **Provider registry** — supported LLM providers (Anthropic, OpenAI, Google, Grok, AWS Bedrock), their key prefix hints, display names, and brand colors.
9
+ - **Model catalog** — known models per provider with pricing (input / output / cache), context window, and capability tiers.
10
+ - **Result types** — small `Result<T, E>` helper used by the SDK error envelope.
11
+
12
+ You normally don't install this directly — it's a transitive dependency of `@tokenite/sdk` and `@tokenite/cli`. Install one of those:
13
+
14
+ ```bash
15
+ npm install @tokenite/sdk
16
+ # or
17
+ npm install -g @tokenite/cli
18
+ ```
19
+
20
+ ## Direct use
21
+
22
+ If you want to validate an incoming Tokenite proxy response in your own code, or look up pricing for a model:
23
+
24
+ ```typescript
25
+ import {
26
+ proxyResponseSchema,
27
+ isProxyError,
28
+ providerSchema,
29
+ type Provider,
30
+ } from '@tokenite/shared';
31
+
32
+ import { listProviders, tryGetProvider } from '@tokenite/shared/providers';
33
+ import { catalog, pricingFor } from '@tokenite/shared/catalog';
34
+
35
+ const parsed = proxyResponseSchema.parse(unknownInput);
36
+ const anthropic = tryGetProvider('anthropic');
37
+ const cost = pricingFor('anthropic', 'claude-sonnet-4-6');
38
+ ```
39
+
40
+ ## License
41
+
42
+ MIT
@@ -0,0 +1,3 @@
1
+ export declare const AGENT_RUNTIME_USD_PER_HOUR = 0.08;
2
+ export declare const AGENT_RUNTIME_USD_PER_SECOND: number;
3
+ //# sourceMappingURL=agent-runtime.d.ts.map
@@ -0,0 +1,3 @@
1
+ export const AGENT_RUNTIME_USD_PER_HOUR = 0.08;
2
+ export const AGENT_RUNTIME_USD_PER_SECOND = AGENT_RUNTIME_USD_PER_HOUR / 3600;
3
+ //# sourceMappingURL=agent-runtime.js.map
@@ -0,0 +1,2 @@
1
+ export declare const ANTHROPIC_BINDINGS: import("./types.js").ModelBinding[];
2
+ //# sourceMappingURL=anthropic.d.ts.map
@@ -0,0 +1,11 @@
1
+ import { binding } from './types.js';
2
+ import { PROVIDERS } from '../providers/index.js';
3
+ import { CLAUDE } from '../models/anthropic.js';
4
+ const { anthropic } = PROVIDERS;
5
+ export const ANTHROPIC_BINDINGS = [
6
+ binding(CLAUDE.Opus_4_7, anthropic, 'claude-opus-4-7', 5, 25),
7
+ binding(CLAUDE.Sonnet_4_6, anthropic, 'claude-sonnet-4-6', 3, 15),
8
+ binding(CLAUDE.Haiku_4_5, anthropic, 'claude-haiku-4-5', 1, 5, ['claude-haiku-4-5-20251001']),
9
+ binding(CLAUDE.Haiku_3, anthropic, 'claude-3-haiku-20240307', 0.25, 1.25),
10
+ ];
11
+ //# sourceMappingURL=anthropic.js.map
@@ -0,0 +1,2 @@
1
+ export declare const BEDROCK_BINDINGS: import("./types.js").ModelBinding[];
2
+ //# sourceMappingURL=bedrock.d.ts.map
@@ -0,0 +1,10 @@
1
+ import { binding } from './types.js';
2
+ import { PROVIDERS } from '../providers/index.js';
3
+ import { CLAUDE } from '../models/anthropic.js';
4
+ const { bedrock } = PROVIDERS;
5
+ export const BEDROCK_BINDINGS = [
6
+ binding(CLAUDE.Opus_4_7, bedrock, 'us.anthropic.claude-opus-4-7', 5, 25),
7
+ binding(CLAUDE.Sonnet_4_6, bedrock, 'us.anthropic.claude-sonnet-4-6', 3, 15),
8
+ binding(CLAUDE.Haiku_4_5, bedrock, 'us.anthropic.claude-haiku-4-5-20251001-v1:0', 1, 5),
9
+ ];
10
+ //# sourceMappingURL=bedrock.js.map
@@ -0,0 +1,2 @@
1
+ export declare const GOOGLE_BINDINGS: import("./types.js").ModelBinding[];
2
+ //# sourceMappingURL=google.d.ts.map
@@ -0,0 +1,12 @@
1
+ import { binding } from './types.js';
2
+ import { PROVIDERS } from '../providers/index.js';
3
+ import { GEMINI } from '../models/google.js';
4
+ const { google } = PROVIDERS;
5
+ export const GOOGLE_BINDINGS = [
6
+ binding(GEMINI._3_1_Pro, google, 'gemini-3.1-pro-preview', 2, 12),
7
+ binding(GEMINI._3_Flash, google, 'gemini-3-flash-preview', 0.3, 2.5),
8
+ binding(GEMINI._2_5_Pro, google, 'gemini-2.5-pro', 1.25, 10),
9
+ binding(GEMINI._2_5_Flash, google, 'gemini-2.5-flash', 0.3, 2.5),
10
+ binding(GEMINI._2_5_Flash_Lite, google, 'gemini-2.5-flash-lite', 0.1, 0.4),
11
+ ];
12
+ //# sourceMappingURL=google.js.map
@@ -0,0 +1,2 @@
1
+ export declare const GROK_BINDINGS: import("./types.js").ModelBinding[];
2
+ //# sourceMappingURL=grok.d.ts.map
@@ -0,0 +1,14 @@
1
+ import { binding } from './types.js';
2
+ import { PROVIDERS } from '../providers/index.js';
3
+ import { GROK } from '../models/grok.js';
4
+ const { grok } = PROVIDERS;
5
+ export const GROK_BINDINGS = [
6
+ binding(GROK._4_1_Fast_Reasoning, grok, 'grok-4-1-fast-reasoning', 0.2, 0.5),
7
+ binding(GROK._4_1_Fast_Non_Reasoning, grok, 'grok-4-1-fast-non-reasoning', 0.2, 0.5),
8
+ binding(GROK._4_20_Reasoning, grok, 'grok-4.20-0309-reasoning', 2, 6),
9
+ binding(GROK._4_20_Multi_Agent, grok, 'grok-4.20-multi-agent-0309', 2, 6),
10
+ binding(GROK.Code_Fast_1, grok, 'grok-code-fast-1', 0.2, 1.5),
11
+ binding(GROK._3, grok, 'grok-3', 3, 15),
12
+ binding(GROK._3_Mini, grok, 'grok-3-mini', 0.3, 0.5),
13
+ ];
14
+ //# sourceMappingURL=grok.js.map
@@ -0,0 +1,18 @@
1
+ import type { Model } from '../models/types.js';
2
+ import type { Provider } from '../providers/index.js';
3
+ import { type ProviderId } from '../providers/index.js';
4
+ import type { ModelBinding, Pricing } from './types.js';
5
+ export { ANTHROPIC_BINDINGS } from './anthropic.js';
6
+ export { OPENAI_BINDINGS } from './openai.js';
7
+ export { GOOGLE_BINDINGS } from './google.js';
8
+ export { GROK_BINDINGS } from './grok.js';
9
+ export { BEDROCK_BINDINGS } from './bedrock.js';
10
+ export declare const BINDINGS: readonly ModelBinding[];
11
+ export declare const bindingsForModel: (m: Model) => readonly ModelBinding[];
12
+ export declare const bindingsForProvider: (p: Provider) => readonly ModelBinding[];
13
+ export declare const findBinding: (m: Model, p: Provider) => ModelBinding | null;
14
+ export declare const findBindingByVendorName: (providerId: ProviderId, vendorModelName: string) => ModelBinding | null;
15
+ export declare const pricingFor: (providerId: ProviderId, vendorModelName: string) => Pricing;
16
+ export { binding } from './types.js';
17
+ export type { ModelBinding, Pricing } from './types.js';
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,36 @@
1
+ import { providerName } from '../providers/index.js';
2
+ import { ANTHROPIC_BINDINGS } from './anthropic.js';
3
+ import { OPENAI_BINDINGS } from './openai.js';
4
+ import { GOOGLE_BINDINGS } from './google.js';
5
+ import { GROK_BINDINGS } from './grok.js';
6
+ import { BEDROCK_BINDINGS } from './bedrock.js';
7
+ export { ANTHROPIC_BINDINGS } from './anthropic.js';
8
+ export { OPENAI_BINDINGS } from './openai.js';
9
+ export { GOOGLE_BINDINGS } from './google.js';
10
+ export { GROK_BINDINGS } from './grok.js';
11
+ export { BEDROCK_BINDINGS } from './bedrock.js';
12
+ export const BINDINGS = [
13
+ ...ANTHROPIC_BINDINGS,
14
+ ...OPENAI_BINDINGS,
15
+ ...GOOGLE_BINDINGS,
16
+ ...GROK_BINDINGS,
17
+ ...BEDROCK_BINDINGS,
18
+ ];
19
+ export const bindingsForModel = (m) => BINDINGS.filter((b) => b.model === m);
20
+ export const bindingsForProvider = (p) => BINDINGS.filter((b) => b.provider === p);
21
+ export const findBinding = (m, p) => BINDINGS.find((b) => b.model === m && b.provider === p) ?? null;
22
+ const matchesVendor = (b, name) => b.vendorModelName === name || b.vendorModelAliases?.includes(name) === true;
23
+ export const findBindingByVendorName = (providerId, vendorModelName) => {
24
+ for (const b of BINDINGS) {
25
+ if (providerName(b.provider) === providerId && matchesVendor(b, vendorModelName))
26
+ return b;
27
+ }
28
+ return null;
29
+ };
30
+ const DEFAULT_PRICING = {
31
+ inputPerToken: 3 / 1_000_000,
32
+ outputPerToken: 15 / 1_000_000,
33
+ };
34
+ export const pricingFor = (providerId, vendorModelName) => findBindingByVendorName(providerId, vendorModelName)?.pricing ?? DEFAULT_PRICING;
35
+ export { binding } from './types.js';
36
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,2 @@
1
+ export declare const OPENAI_BINDINGS: import("./types.js").ModelBinding[];
2
+ //# sourceMappingURL=openai.d.ts.map
@@ -0,0 +1,14 @@
1
+ import { binding } from './types.js';
2
+ import { PROVIDERS } from '../providers/index.js';
3
+ import { GPT, OSERIES } from '../models/openai.js';
4
+ const { openai } = PROVIDERS;
5
+ export const OPENAI_BINDINGS = [
6
+ binding(GPT._5, openai, 'gpt-5', 1.25, 10),
7
+ binding(GPT._5_Mini, openai, 'gpt-5-mini', 0.25, 2),
8
+ binding(GPT._4_1, openai, 'gpt-4.1', 2, 8),
9
+ binding(GPT._4o, openai, 'gpt-4o', 2.5, 10),
10
+ binding(GPT._4o_Mini, openai, 'gpt-4o-mini', 0.15, 0.6, ['gpt-4o-mini-2024-07-18']),
11
+ binding(OSERIES.o3, openai, 'o3', 2, 8),
12
+ binding(OSERIES.o4_Mini, openai, 'o4-mini', 1.1, 4.4),
13
+ ];
14
+ //# sourceMappingURL=openai.js.map
@@ -0,0 +1,15 @@
1
+ import type { Model } from '../models/types.js';
2
+ import type { Provider } from '../providers/index.js';
3
+ export type Pricing = {
4
+ readonly inputPerToken: number;
5
+ readonly outputPerToken: number;
6
+ };
7
+ export type ModelBinding = {
8
+ readonly model: Model;
9
+ readonly provider: Provider;
10
+ readonly vendorModelName: string;
11
+ readonly vendorModelAliases?: readonly string[];
12
+ readonly pricing: Pricing;
13
+ };
14
+ export declare const binding: (model: ModelBinding["model"], provider: ModelBinding["provider"], vendorModelName: ModelBinding["vendorModelName"], inputPerMillion: number, outputPerMillion: number, aliases?: ModelBinding["vendorModelAliases"]) => ModelBinding;
15
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,11 @@
1
+ export const binding = (model, provider, vendorModelName, inputPerMillion, outputPerMillion, aliases) => ({
2
+ model,
3
+ provider,
4
+ vendorModelName,
5
+ ...(aliases ? { vendorModelAliases: aliases } : {}),
6
+ pricing: {
7
+ inputPerToken: inputPerMillion / 1_000_000,
8
+ outputPerToken: outputPerMillion / 1_000_000,
9
+ },
10
+ });
11
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,12 @@
1
+ export type Cap = {
2
+ readonly __tag: 'cap';
3
+ };
4
+ export declare const CAPS: {
5
+ readonly vision: Cap;
6
+ readonly tools: Cap;
7
+ readonly thinking: Cap;
8
+ readonly jsonMode: Cap;
9
+ };
10
+ export type CapId = keyof typeof CAPS;
11
+ export declare const capName: (c: Cap) => CapId;
12
+ //# sourceMappingURL=capabilities.d.ts.map
@@ -0,0 +1,9 @@
1
+ export const CAPS = {
2
+ vision: {},
3
+ tools: {},
4
+ thinking: {},
5
+ jsonMode: {},
6
+ };
7
+ const CAP_NAME = new Map(Object.entries(CAPS).map(([k, v]) => [v, k]));
8
+ export const capName = (c) => CAP_NAME.get(c);
9
+ //# sourceMappingURL=capabilities.js.map
@@ -0,0 +1,3 @@
1
+ import type { FlavorHandler } from './types.js';
2
+ export declare const anthropicFlavor: FlavorHandler;
3
+ //# sourceMappingURL=anthropic.d.ts.map
@@ -0,0 +1,26 @@
1
+ import { z } from 'zod';
2
+ import { asRecord, asNumber, asString } from '../helpers.js';
3
+ const requestSchema = z.object({ model: z.string() }).passthrough();
4
+ export const anthropicFlavor = {
5
+ getRequestedModel: ({ parsedBody }) => {
6
+ const parsed = requestSchema.safeParse(parsedBody);
7
+ return parsed.success ? parsed.data.model : null;
8
+ },
9
+ extractUsage: (body, fallbackModel) => {
10
+ const usage = asRecord(body['usage']);
11
+ if (!usage)
12
+ return null;
13
+ return {
14
+ model: asString(body['model'], fallbackModel),
15
+ inputTokens: asNumber(usage['input_tokens']),
16
+ outputTokens: asNumber(usage['output_tokens']),
17
+ };
18
+ },
19
+ errors: {
20
+ isContentFilterError: (_message, body) => {
21
+ const error = asRecord(body?.['error']);
22
+ return error?.['type'] === 'content_policy_violation';
23
+ },
24
+ },
25
+ };
26
+ //# sourceMappingURL=anthropic.js.map
@@ -0,0 +1,3 @@
1
+ import type { FlavorHandler } from './types.js';
2
+ export declare const geminiFlavor: FlavorHandler;
3
+ //# sourceMappingURL=gemini.d.ts.map
@@ -0,0 +1,16 @@
1
+ import { asRecord, asNumber } from '../helpers.js';
2
+ const MODEL_IN_PATH = /\/models\/([^:/]+)/;
3
+ export const geminiFlavor = {
4
+ getRequestedModel: ({ path }) => path.match(MODEL_IN_PATH)?.[1] ?? null,
5
+ extractUsage: (body, fallbackModel) => {
6
+ const usage = asRecord(body['usageMetadata']);
7
+ if (!usage)
8
+ return null;
9
+ return {
10
+ model: fallbackModel,
11
+ inputTokens: asNumber(usage['promptTokenCount']),
12
+ outputTokens: asNumber(usage['candidatesTokenCount']),
13
+ };
14
+ },
15
+ };
16
+ //# sourceMappingURL=gemini.js.map
@@ -0,0 +1,10 @@
1
+ import type { FlavorHandler } from './types.js';
2
+ export declare const FLAVORS: {
3
+ readonly anthropic: FlavorHandler;
4
+ readonly openai: FlavorHandler;
5
+ readonly gemini: FlavorHandler;
6
+ };
7
+ export type FlavorId = keyof typeof FLAVORS;
8
+ export declare const getFlavor: (id: FlavorId) => FlavorHandler;
9
+ export type { FlavorHandler, UsageInfo, RequestedModelExtractor, UsageExtractor, ErrorBody, ErrorHooks } from './types.js';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,10 @@
1
+ import { anthropicFlavor } from './anthropic.js';
2
+ import { openaiFlavor } from './openai.js';
3
+ import { geminiFlavor } from './gemini.js';
4
+ export const FLAVORS = {
5
+ anthropic: anthropicFlavor,
6
+ openai: openaiFlavor,
7
+ gemini: geminiFlavor,
8
+ };
9
+ export const getFlavor = (id) => FLAVORS[id];
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,3 @@
1
+ import type { FlavorHandler } from './types.js';
2
+ export declare const openaiFlavor: FlavorHandler;
3
+ //# sourceMappingURL=openai.d.ts.map
@@ -0,0 +1,20 @@
1
+ import { z } from 'zod';
2
+ import { asRecord, asNumber, asString } from '../helpers.js';
3
+ const requestSchema = z.object({ model: z.string() }).passthrough();
4
+ export const openaiFlavor = {
5
+ getRequestedModel: ({ parsedBody }) => {
6
+ const parsed = requestSchema.safeParse(parsedBody);
7
+ return parsed.success ? parsed.data.model : null;
8
+ },
9
+ extractUsage: (body, fallbackModel) => {
10
+ const usage = asRecord(body['usage']);
11
+ if (!usage)
12
+ return null;
13
+ return {
14
+ model: asString(body['model'], fallbackModel),
15
+ inputTokens: asNumber(usage['prompt_tokens']),
16
+ outputTokens: asNumber(usage['completion_tokens']),
17
+ };
18
+ },
19
+ };
20
+ //# sourceMappingURL=openai.js.map
@@ -0,0 +1,22 @@
1
+ export type UsageInfo = {
2
+ readonly model: string;
3
+ readonly inputTokens: number;
4
+ readonly outputTokens: number;
5
+ };
6
+ export type RequestedModelExtractor = (input: {
7
+ readonly path: string;
8
+ readonly parsedBody: unknown;
9
+ }) => string | null;
10
+ export type UsageExtractor = (body: Record<string, unknown>, fallbackModel: string) => UsageInfo | null;
11
+ export type ErrorBody = Record<string, unknown> | null;
12
+ export type ErrorHooks = {
13
+ readonly extractMessage?: (body: ErrorBody) => string | undefined;
14
+ readonly isContextLengthError?: (message: string | undefined, body: ErrorBody) => boolean;
15
+ readonly isContentFilterError?: (message: string | undefined, body: ErrorBody) => boolean;
16
+ };
17
+ export type FlavorHandler = {
18
+ readonly getRequestedModel: RequestedModelExtractor;
19
+ readonly extractUsage: UsageExtractor;
20
+ readonly errors?: ErrorHooks;
21
+ };
22
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,5 @@
1
+ export declare const asRecord: (value: unknown) => Record<string, unknown> | null;
2
+ export declare const asNumber: (value: unknown) => number;
3
+ export declare const asString: (value: unknown, fallback: string) => string;
4
+ export declare const perMillion: (dollars: number) => number;
5
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1,5 @@
1
+ export const asRecord = (value) => typeof value === 'object' && value !== null ? value : null;
2
+ export const asNumber = (value) => typeof value === 'number' ? value : Number(value ?? 0);
3
+ export const asString = (value, fallback) => typeof value === 'string' ? value : fallback;
4
+ export const perMillion = (dollars) => dollars / 1_000_000;
5
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1,9 @@
1
+ export * from './tiers.js';
2
+ export * from './capabilities.js';
3
+ export * from './providers/index.js';
4
+ export * from './models/index.js';
5
+ export * from './bindings/index.js';
6
+ export * from './agent-runtime.js';
7
+ export { FLAVORS, getFlavor } from './flavors/index.js';
8
+ export type { FlavorId, FlavorHandler, UsageInfo, RequestedModelExtractor, UsageExtractor, ErrorBody, ErrorHooks, } from './flavors/index.js';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,8 @@
1
+ export * from './tiers.js';
2
+ export * from './capabilities.js';
3
+ export * from './providers/index.js';
4
+ export * from './models/index.js';
5
+ export * from './bindings/index.js';
6
+ export * from './agent-runtime.js';
7
+ export { FLAVORS, getFlavor } from './flavors/index.js';
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ export declare const CLAUDE: {
2
+ readonly Opus_4_7: import("./types.js").Model;
3
+ readonly Sonnet_4_6: import("./types.js").Model;
4
+ readonly Haiku_4_5: import("./types.js").Model;
5
+ readonly Haiku_3: import("./types.js").Model;
6
+ };
7
+ //# sourceMappingURL=anthropic.d.ts.map
@@ -0,0 +1,10 @@
1
+ import { defineFamily } from './types.js';
2
+ import { TIERS } from '../tiers.js';
3
+ import { CAPS } from '../capabilities.js';
4
+ export const CLAUDE = defineFamily('Claude ', {
5
+ Opus_4_7: [[TIERS.smart, TIERS.reasoning], [CAPS.vision, CAPS.tools, CAPS.thinking]],
6
+ Sonnet_4_6: [[TIERS.smart], [CAPS.vision, CAPS.tools, CAPS.thinking]],
7
+ Haiku_4_5: [[TIERS.fast, TIERS.cheap], [CAPS.vision, CAPS.tools, CAPS.thinking]],
8
+ Haiku_3: [[TIERS.cheap, TIERS.fast], [CAPS.vision, CAPS.tools]],
9
+ });
10
+ //# sourceMappingURL=anthropic.js.map
@@ -0,0 +1,8 @@
1
+ export declare const GEMINI: {
2
+ readonly _3_1_Pro: import("./types.js").Model;
3
+ readonly _3_Flash: import("./types.js").Model;
4
+ readonly _2_5_Pro: import("./types.js").Model;
5
+ readonly _2_5_Flash: import("./types.js").Model;
6
+ readonly _2_5_Flash_Lite: import("./types.js").Model;
7
+ };
8
+ //# sourceMappingURL=google.d.ts.map
@@ -0,0 +1,11 @@
1
+ import { defineFamily } from './types.js';
2
+ import { TIERS } from '../tiers.js';
3
+ import { CAPS } from '../capabilities.js';
4
+ export const GEMINI = defineFamily('Gemini ', {
5
+ _3_1_Pro: [[TIERS.smart, TIERS.reasoning], [CAPS.vision, CAPS.tools, CAPS.thinking, CAPS.jsonMode]],
6
+ _3_Flash: [[TIERS.fast], [CAPS.vision, CAPS.tools, CAPS.thinking, CAPS.jsonMode]],
7
+ _2_5_Pro: [[TIERS.smart, TIERS.reasoning], [CAPS.vision, CAPS.tools, CAPS.thinking, CAPS.jsonMode]],
8
+ _2_5_Flash: [[TIERS.fast, TIERS.cheap], [CAPS.vision, CAPS.tools, CAPS.thinking, CAPS.jsonMode]],
9
+ _2_5_Flash_Lite: [[TIERS.cheap, TIERS.fast], [CAPS.vision, CAPS.tools, CAPS.jsonMode]],
10
+ });
11
+ //# sourceMappingURL=google.js.map
@@ -0,0 +1,10 @@
1
+ export declare const GROK: {
2
+ readonly _4_1_Fast_Reasoning: import("./types.js").Model;
3
+ readonly _4_1_Fast_Non_Reasoning: import("./types.js").Model;
4
+ readonly _4_20_Reasoning: import("./types.js").Model;
5
+ readonly _4_20_Multi_Agent: import("./types.js").Model;
6
+ readonly Code_Fast_1: import("./types.js").Model;
7
+ readonly _3: import("./types.js").Model;
8
+ readonly _3_Mini: import("./types.js").Model;
9
+ };
10
+ //# sourceMappingURL=grok.d.ts.map
@@ -0,0 +1,13 @@
1
+ import { defineFamily } from './types.js';
2
+ import { TIERS } from '../tiers.js';
3
+ import { CAPS } from '../capabilities.js';
4
+ export const GROK = defineFamily('Grok ', {
5
+ _4_1_Fast_Reasoning: [[TIERS.reasoning, TIERS.fast], [CAPS.tools, CAPS.thinking, CAPS.jsonMode]],
6
+ _4_1_Fast_Non_Reasoning: [[TIERS.fast, TIERS.cheap], [CAPS.tools, CAPS.jsonMode]],
7
+ _4_20_Reasoning: [[TIERS.smart, TIERS.reasoning], [CAPS.tools, CAPS.thinking, CAPS.jsonMode]],
8
+ _4_20_Multi_Agent: [[TIERS.smart], [CAPS.tools, CAPS.jsonMode]],
9
+ Code_Fast_1: [[TIERS.cheap, TIERS.fast], [CAPS.tools, CAPS.jsonMode]],
10
+ _3: [[TIERS.smart], [CAPS.tools, CAPS.jsonMode]],
11
+ _3_Mini: [[TIERS.cheap, TIERS.fast], [CAPS.tools, CAPS.thinking, CAPS.jsonMode]],
12
+ });
13
+ //# sourceMappingURL=grok.js.map
@@ -0,0 +1,20 @@
1
+ import type { Model } from './types.js';
2
+ import type { Tier } from '../tiers.js';
3
+ import type { Cap } from '../capabilities.js';
4
+ export { CLAUDE } from './anthropic.js';
5
+ export { GPT, OSERIES } from './openai.js';
6
+ export { GEMINI } from './google.js';
7
+ export { GROK } from './grok.js';
8
+ export type ModelCreator = 'anthropic' | 'openai' | 'google' | 'grok';
9
+ export type ModelGroup = {
10
+ readonly creator: ModelCreator;
11
+ readonly displayName: string;
12
+ readonly models: readonly Model[];
13
+ };
14
+ export declare const MODEL_GROUPS: readonly ModelGroup[];
15
+ export declare const ALL_MODELS: readonly Model[];
16
+ export declare const modelsByTier: (t: Tier) => readonly Model[];
17
+ export declare const modelsWithCap: (c: Cap) => readonly Model[];
18
+ export { model, defineFamily, humanize } from './types.js';
19
+ export type { Model, ModelSpec } from './types.js';
20
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,19 @@
1
+ import { CLAUDE } from './anthropic.js';
2
+ import { GPT, OSERIES } from './openai.js';
3
+ import { GEMINI } from './google.js';
4
+ import { GROK } from './grok.js';
5
+ export { CLAUDE } from './anthropic.js';
6
+ export { GPT, OSERIES } from './openai.js';
7
+ export { GEMINI } from './google.js';
8
+ export { GROK } from './grok.js';
9
+ export const MODEL_GROUPS = [
10
+ { creator: 'anthropic', displayName: 'Anthropic', models: Object.values(CLAUDE) },
11
+ { creator: 'openai', displayName: 'OpenAI', models: [...Object.values(GPT), ...Object.values(OSERIES)] },
12
+ { creator: 'google', displayName: 'Google', models: Object.values(GEMINI) },
13
+ { creator: 'grok', displayName: 'xAI Grok', models: Object.values(GROK) },
14
+ ];
15
+ export const ALL_MODELS = MODEL_GROUPS.flatMap((g) => g.models);
16
+ export const modelsByTier = (t) => ALL_MODELS.filter((m) => m.tiers.includes(t));
17
+ export const modelsWithCap = (c) => ALL_MODELS.filter((m) => m.capabilities.includes(c));
18
+ export { model, defineFamily, humanize } from './types.js';
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,12 @@
1
+ export declare const GPT: {
2
+ readonly _5: import("./types.js").Model;
3
+ readonly _5_Mini: import("./types.js").Model;
4
+ readonly _4_1: import("./types.js").Model;
5
+ readonly _4o: import("./types.js").Model;
6
+ readonly _4o_Mini: import("./types.js").Model;
7
+ };
8
+ export declare const OSERIES: {
9
+ readonly o3: import("./types.js").Model;
10
+ readonly o4_Mini: import("./types.js").Model;
11
+ };
12
+ //# sourceMappingURL=openai.d.ts.map
@@ -0,0 +1,15 @@
1
+ import { defineFamily } from './types.js';
2
+ import { TIERS } from '../tiers.js';
3
+ import { CAPS } from '../capabilities.js';
4
+ export const GPT = defineFamily('GPT-', {
5
+ _5: [[TIERS.smart, TIERS.reasoning], [CAPS.vision, CAPS.tools, CAPS.jsonMode, CAPS.thinking]],
6
+ _5_Mini: [[TIERS.cheap, TIERS.fast, TIERS.reasoning], [CAPS.vision, CAPS.tools, CAPS.jsonMode, CAPS.thinking]],
7
+ _4_1: [[TIERS.smart], [CAPS.vision, CAPS.tools, CAPS.jsonMode]],
8
+ _4o: [[TIERS.smart], [CAPS.vision, CAPS.tools, CAPS.jsonMode]],
9
+ _4o_Mini: [[TIERS.cheap, TIERS.fast], [CAPS.vision, CAPS.tools, CAPS.jsonMode]],
10
+ });
11
+ export const OSERIES = defineFamily('', {
12
+ o3: [[TIERS.reasoning, TIERS.smart], [CAPS.vision, CAPS.tools, CAPS.jsonMode, CAPS.thinking]],
13
+ o4_Mini: [[TIERS.reasoning, TIERS.cheap], [CAPS.vision, CAPS.tools, CAPS.jsonMode, CAPS.thinking]],
14
+ });
15
+ //# sourceMappingURL=openai.js.map
@@ -0,0 +1,17 @@
1
+ import type { Tier } from '../tiers.js';
2
+ import type { Cap } from '../capabilities.js';
3
+ export type Model = {
4
+ readonly __tag: 'model';
5
+ readonly slug: string;
6
+ readonly displayName: string;
7
+ readonly tiers: readonly Tier[];
8
+ readonly capabilities: readonly Cap[];
9
+ };
10
+ export type ModelSpec = readonly [
11
+ tiers: Model['tiers'],
12
+ capabilities: Model['capabilities']
13
+ ];
14
+ export declare const defineFamily: <K extends string>(prefix: string, entries: Readonly<Record<K, ModelSpec>>) => { readonly [P in K]: Model; };
15
+ export declare const humanize: (key: string) => string;
16
+ export declare const model: (displayName: Model["displayName"], tiers: Model["tiers"], capabilities: Model["capabilities"]) => Model;
17
+ //# sourceMappingURL=types.d.ts.map