@tokenite/shared 1.0.1 → 1.1.0
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/assets/providers/anthropic.svg +1 -0
- package/assets/providers/bedrock.svg +1 -0
- package/assets/providers/google.svg +1 -0
- package/assets/providers/grok.svg +1 -0
- package/assets/providers/openai.svg +1 -0
- package/dist/assets.d.ts +5 -0
- package/dist/assets.js +9 -0
- package/dist/catalog/access-models.d.ts +40 -0
- package/dist/catalog/access-models.js +66 -0
- package/dist/catalog/bindings/google.js +3 -0
- package/dist/catalog/bindings/index.d.ts +2 -0
- package/dist/catalog/bindings/index.js +16 -0
- package/dist/catalog/bindings/openai.js +9 -0
- package/dist/catalog/capabilities.js +8 -2
- package/dist/catalog/index.d.ts +2 -0
- package/dist/catalog/index.js +2 -0
- package/dist/catalog/models/google.d.ts +1 -0
- package/dist/catalog/models/google.js +4 -0
- package/dist/catalog/models/grok.js +6 -6
- package/dist/catalog/models/openai.d.ts +9 -0
- package/dist/catalog/models/openai.js +9 -0
- package/dist/catalog/providers/anthropic.js +1 -1
- package/dist/catalog/providers/bedrock.js +1 -1
- package/dist/catalog/providers/google.js +1 -1
- package/dist/catalog/providers/grok.js +1 -1
- package/dist/catalog/providers/index.d.ts +1 -1
- package/dist/catalog/providers/index.js +11 -4
- package/dist/catalog/providers/openai.js +1 -1
- package/dist/catalog/strategy-providers.d.ts +13 -0
- package/dist/catalog/strategy-providers.js +37 -0
- package/dist/catalog/tiers.js +8 -2
- package/dist/index.d.ts +6 -4
- package/dist/index.js +6 -4
- package/dist/parse.d.ts +2 -0
- package/dist/parse.js +11 -2
- package/dist/schemas/access-token.d.ts +2 -0
- package/dist/schemas/access-token.js +1 -0
- package/dist/schemas/app.d.ts +46 -88
- package/dist/schemas/app.js +26 -20
- package/dist/schemas/cli-login.js +2 -1
- package/dist/schemas/error-codes.d.ts +14 -0
- package/dist/schemas/error-codes.js +6 -0
- package/dist/schemas/proxy-response.d.ts +1 -1
- package/dist/schemas/sponsored-api-key.d.ts +9 -3
- package/dist/schemas/sponsored-api-key.js +5 -0
- package/dist/schemas/topup.d.ts +52 -0
- package/dist/schemas/topup.js +44 -0
- package/dist/schemas/user.d.ts +1 -1
- package/dist/schemas/user.js +6 -3
- package/dist/type-utils.d.ts +9 -0
- package/dist/type-utils.js +19 -0
- package/package.json +6 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg fill="#d97757" fill-rule="evenodd" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Claude</title><path d="M4.709 15.955l4.72-2.647.08-.23-.08-.128H9.2l-.79-.048-2.698-.073-2.339-.097-2.266-.122-.571-.121L0 11.784l.055-.352.48-.321.686.06 1.52.103 2.278.158 1.652.097 2.449.255h.389l.055-.157-.134-.098-.103-.097-2.358-1.596-2.552-1.688-1.336-.972-.724-.491-.364-.462-.158-1.008.656-.722.881.06.225.061.893.686 1.908 1.476 2.491 1.833.365.304.145-.103.019-.073-.164-.274-1.355-2.446-1.446-2.49-.644-1.032-.17-.619a2.97 2.97 0 01-.104-.729L6.283.134 6.696 0l.996.134.42.364.62 1.414 1.002 2.229 1.555 3.03.456.898.243.832.091.255h.158V9.01l.128-1.706.237-2.095.23-2.695.08-.76.376-.91.747-.492.584.28.48.685-.067.444-.286 1.851-.559 2.903-.364 1.942h.212l.243-.242.985-1.306 1.652-2.064.73-.82.85-.904.547-.431h1.033l.76 1.129-.34 1.166-1.064 1.347-.881 1.142-1.264 1.7-.79 1.36.073.11.188-.02 2.856-.606 1.543-.28 1.841-.315.833.388.091.395-.328.807-1.969.486-2.309.462-3.439.813-.042.03.049.061 1.549.146.662.036h1.622l3.02.225.79.522.474.638-.079.485-1.215.62-1.64-.389-3.829-.91-1.312-.329h-.182v.11l1.093 1.068 2.006 1.81 2.509 2.33.127.578-.322.455-.34-.049-2.205-1.657-.851-.747-1.926-1.62h-.128v.17l.444.649 2.345 3.521.122 1.08-.17.353-.608.213-.668-.122-1.374-1.925-1.415-2.167-1.143-1.943-.14.08-.674 7.254-.316.37-.729.28-.607-.461-.322-.747.322-1.476.389-1.924.315-1.53.286-1.9.17-.632-.012-.042-.14.018-1.434 1.967-2.18 2.945-1.726 1.845-.414.164-.717-.37.067-.662.401-.589 2.388-3.036 1.44-1.882.93-1.086-.006-.158h-.055L4.132 18.56l-1.13.146-.487-.456.061-.746.231-.243 1.908-1.312-.006.006z"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg fill="#ff9900" fill-rule="evenodd" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Bedrock</title><path d="M12 1L21.526 6.5V17.5L12 23L2.474 17.5V6.5L12 1ZM12 3L19.794 7.5V16.5L12 21L4.206 16.5V7.5L12 3ZM6.5 9H17.5V10.5H6.5V9ZM6.5 11.25H17.5V12.75H6.5V11.25ZM6.5 13.5H17.5V15H6.5V13.5Z"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg fill-rule="evenodd" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Gemini</title><defs><linearGradient id="gemini-grad" x1="0" y1="0" x2="1" y2="1"><stop offset="0%" stop-color="#4893FC"/><stop offset="55%" stop-color="#969DFF"/><stop offset="100%" stop-color="#BD99FE"/></linearGradient></defs><path fill="url(#gemini-grad)" d="M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg fill="#000000" fill-rule="evenodd" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Grok</title><path d="M9.27 15.29l7.978-5.897c.391-.29.95-.177 1.137.272.98 2.369.542 5.215-1.41 7.169-1.951 1.954-4.667 2.382-7.149 1.406l-2.711 1.257c3.889 2.661 8.611 2.003 11.562-.953 2.341-2.344 3.066-5.539 2.388-8.42l.006.007c-.983-4.232.242-5.924 2.75-9.383.06-.082.12-.164.179-.248l-3.301 3.305v-.01L9.267 15.292M7.623 16.723c-2.792-2.67-2.31-6.801.071-9.184 1.761-1.763 4.647-2.483 7.166-1.425l2.705-1.25a7.808 7.808 0 00-1.829-1A8.975 8.975 0 005.984 5.83c-2.533 2.536-3.33 6.436-1.962 9.764 1.022 2.487-.653 4.246-2.34 6.022-.599.63-1.199 1.259-1.682 1.925l7.62-6.815"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg fill="#10a37f" fill-rule="evenodd" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>OpenAI</title><path d="M9.205 8.658v-2.26c0-.19.072-.333.238-.428l4.543-2.616c.619-.357 1.356-.523 2.117-.523 2.854 0 4.662 2.212 4.662 4.566 0 .167 0 .357-.024.547l-4.71-2.759a.797.797 0 00-.856 0l-5.97 3.473zm10.609 8.8V12.06c0-.333-.143-.57-.429-.737l-5.97-3.473 1.95-1.118a.433.433 0 01.476 0l4.543 2.617c1.309.76 2.189 2.378 2.189 3.948 0 1.808-1.07 3.473-2.76 4.163zM7.802 12.703l-1.95-1.142c-.167-.095-.239-.238-.239-.428V5.899c0-2.545 1.95-4.472 4.591-4.472 1 0 1.927.333 2.712.928L8.23 5.067c-.285.166-.428.404-.428.737v6.898zM12 15.128l-2.795-1.57v-3.33L12 8.658l2.795 1.57v3.33L12 15.128zm1.796 7.23c-1 0-1.927-.332-2.712-.927l4.686-2.712c.285-.166.428-.404.428-.737v-6.898l1.974 1.142c.167.095.238.238.238.428v5.233c0 2.545-1.974 4.472-4.614 4.472zm-5.637-5.303l-4.544-2.617c-1.308-.761-2.188-2.378-2.188-3.948A4.482 4.482 0 014.21 6.327v5.423c0 .333.143.571.428.738l5.947 3.449-1.95 1.118a.432.432 0 01-.476 0zm-.262 3.9c-2.688 0-4.662-2.021-4.662-4.519 0-.19.024-.38.047-.57l4.686 2.71c.286.167.571.167.856 0l5.97-3.448v2.26c0 .19-.07.333-.237.428l-4.543 2.616c-.619.357-1.356.523-2.117.523zm5.899 2.83a5.947 5.947 0 005.827-4.756C22.287 18.339 24 15.84 24 13.296c0-1.665-.713-3.282-1.998-4.448.119-.5.19-.999.19-1.498 0-3.401-2.759-5.947-5.946-5.947-.642 0-1.26.095-1.88.31A5.962 5.962 0 0010.205 0a5.947 5.947 0 00-5.827 4.757C1.713 5.447 0 7.945 0 10.49c0 1.666.713 3.283 1.998 4.448-.119.5-.19 1-.19 1.499 0 3.401 2.759 5.946 5.946 5.946.642 0 1.26-.095 1.88-.309a5.96 5.96 0 004.162 1.713z"/></svg>
|
package/dist/assets.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const sharedAssetsDir: string;
|
|
2
|
+
export declare const providerIconPath: (providerId: string) => string;
|
|
3
|
+
export declare const PROVIDER_ICON_URL_PATH = "/assets/providers";
|
|
4
|
+
export declare const providerIconUrlPath: (providerId: string) => string;
|
|
5
|
+
//# sourceMappingURL=assets.d.ts.map
|
package/dist/assets.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { fileURLToPath } from 'node:url';
|
|
2
|
+
import { dirname, join, resolve } from 'node:path';
|
|
3
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
4
|
+
const packageRoot = resolve(here, '..');
|
|
5
|
+
export const sharedAssetsDir = join(packageRoot, 'assets');
|
|
6
|
+
export const providerIconPath = (providerId) => join(sharedAssetsDir, 'providers', `${providerId}.svg`);
|
|
7
|
+
export const PROVIDER_ICON_URL_PATH = '/assets/providers';
|
|
8
|
+
export const providerIconUrlPath = (providerId) => `${PROVIDER_ICON_URL_PATH}/${providerId}.svg`;
|
|
9
|
+
//# sourceMappingURL=assets.js.map
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type ProviderId } from './providers/index.js';
|
|
2
|
+
import { type ModelCreator } from './models/index.js';
|
|
3
|
+
import { type TierId } from './tiers.js';
|
|
4
|
+
import { type CapId } from './capabilities.js';
|
|
5
|
+
import type { StrategyShape } from './strategy-providers.js';
|
|
6
|
+
export type AccessModelPricing = {
|
|
7
|
+
readonly inputPerMillion: number;
|
|
8
|
+
readonly outputPerMillion: number;
|
|
9
|
+
};
|
|
10
|
+
export type AccessModel = {
|
|
11
|
+
readonly slug: string;
|
|
12
|
+
readonly displayName: string;
|
|
13
|
+
readonly creator: ModelCreator;
|
|
14
|
+
readonly creatorLogoUrl: string;
|
|
15
|
+
readonly tiers: readonly TierId[];
|
|
16
|
+
readonly capabilities: readonly CapId[];
|
|
17
|
+
readonly servedBy: readonly ProviderId[];
|
|
18
|
+
readonly callableNow: readonly ProviderId[];
|
|
19
|
+
readonly pricing: AccessModelPricing;
|
|
20
|
+
};
|
|
21
|
+
export type AccessTier = {
|
|
22
|
+
readonly id: TierId;
|
|
23
|
+
readonly reachable: boolean;
|
|
24
|
+
readonly recommendedModel: string | null;
|
|
25
|
+
};
|
|
26
|
+
export type AccessModelCatalog = {
|
|
27
|
+
readonly models: readonly AccessModel[];
|
|
28
|
+
readonly tiers: readonly AccessTier[];
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* The model catalog as seen through one access token: every model the
|
|
32
|
+
* app's strategy permits, each tagged with the providers that serve it
|
|
33
|
+
* (`servedBy`) and the subset the holder can actually run right now
|
|
34
|
+
* (`callableNow` — empty means "needs a key for one of servedBy").
|
|
35
|
+
*
|
|
36
|
+
* `tiers` is the provider-agnostic view: which capability buckets are
|
|
37
|
+
* reachable and a representative model for each.
|
|
38
|
+
*/
|
|
39
|
+
export declare const resolveAccessModelCatalog: (strategy: StrategyShape, availableProviders: readonly ProviderId[]) => AccessModelCatalog;
|
|
40
|
+
//# sourceMappingURL=access-models.d.ts.map
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { providerName, PROVIDERS } from './providers/index.js';
|
|
2
|
+
import { MODEL_GROUPS } from './models/index.js';
|
|
3
|
+
import { bindingsForModel } from './bindings/index.js';
|
|
4
|
+
import { tierName, TIERS } from './tiers.js';
|
|
5
|
+
import { capName } from './capabilities.js';
|
|
6
|
+
import { enumKeys } from '../type-utils.js';
|
|
7
|
+
const unique = (items) => Array.from(new Set(items));
|
|
8
|
+
const strategyAllows = (strategy, m) => {
|
|
9
|
+
switch (strategy.modelStrategy) {
|
|
10
|
+
case 'none': return false;
|
|
11
|
+
case 'any': return true;
|
|
12
|
+
case 'models': return (strategy.allowedModels ?? []).includes(m.slug);
|
|
13
|
+
case 'tier': return strategy.requiredTier !== null
|
|
14
|
+
&& m.tiers.some((t) => tierName(t) === strategy.requiredTier);
|
|
15
|
+
default: return false;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
const toAccessModel = (m, creator, availableProviders) => {
|
|
19
|
+
const bindings = bindingsForModel(m);
|
|
20
|
+
const servedBy = unique(bindings.map((b) => providerName(b.provider)));
|
|
21
|
+
const callableNow = servedBy.filter((p) => availableProviders.includes(p));
|
|
22
|
+
const pricingBinding = bindings.find((b) => callableNow.includes(providerName(b.provider))) ?? bindings[0];
|
|
23
|
+
return {
|
|
24
|
+
slug: m.slug,
|
|
25
|
+
displayName: m.displayName,
|
|
26
|
+
creator,
|
|
27
|
+
creatorLogoUrl: PROVIDERS[creator].logoUrl,
|
|
28
|
+
tiers: m.tiers.map(tierName),
|
|
29
|
+
capabilities: m.capabilities.map(capName),
|
|
30
|
+
servedBy,
|
|
31
|
+
callableNow,
|
|
32
|
+
pricing: {
|
|
33
|
+
inputPerMillion: (pricingBinding?.pricing.inputPerToken ?? 0) * 1_000_000,
|
|
34
|
+
outputPerMillion: (pricingBinding?.pricing.outputPerToken ?? 0) * 1_000_000,
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
const buildTiers = (models) => enumKeys(TIERS).map((id) => {
|
|
39
|
+
const callable = models.filter((m) => m.tiers.includes(id) && m.callableNow.length > 0);
|
|
40
|
+
return {
|
|
41
|
+
id,
|
|
42
|
+
reachable: callable.length > 0,
|
|
43
|
+
recommendedModel: callable[0]?.slug ?? null,
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
/**
|
|
47
|
+
* The model catalog as seen through one access token: every model the
|
|
48
|
+
* app's strategy permits, each tagged with the providers that serve it
|
|
49
|
+
* (`servedBy`) and the subset the holder can actually run right now
|
|
50
|
+
* (`callableNow` — empty means "needs a key for one of servedBy").
|
|
51
|
+
*
|
|
52
|
+
* `tiers` is the provider-agnostic view: which capability buckets are
|
|
53
|
+
* reachable and a representative model for each.
|
|
54
|
+
*/
|
|
55
|
+
export const resolveAccessModelCatalog = (strategy, availableProviders) => {
|
|
56
|
+
const models = [];
|
|
57
|
+
for (const group of MODEL_GROUPS) {
|
|
58
|
+
for (const m of group.models) {
|
|
59
|
+
if (strategyAllows(strategy, m)) {
|
|
60
|
+
models.push(toAccessModel(m, group.creator, availableProviders));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return { models, tiers: buildTiers(models) };
|
|
65
|
+
};
|
|
66
|
+
//# sourceMappingURL=access-models.js.map
|
|
@@ -8,5 +8,8 @@ export const GOOGLE_BINDINGS = [
|
|
|
8
8
|
binding(GEMINI._2_5_Pro, google, 'gemini-2.5-pro', 1.25, 10),
|
|
9
9
|
binding(GEMINI._2_5_Flash, google, 'gemini-2.5-flash', 0.3, 2.5),
|
|
10
10
|
binding(GEMINI._2_5_Flash_Lite, google, 'gemini-2.5-flash-lite', 0.1, 0.4),
|
|
11
|
+
// Image-gen. $0.30/M text-in, $30/M image-out (~1290 tokens/image
|
|
12
|
+
// ≈ $0.039/image). Accept the -preview alias Google still ships.
|
|
13
|
+
binding(GEMINI._2_5_Flash_Image, google, 'gemini-2.5-flash-image', 0.3, 30, ['gemini-2.5-flash-image-preview']),
|
|
11
14
|
];
|
|
12
15
|
//# sourceMappingURL=google.js.map
|
|
@@ -12,7 +12,9 @@ export declare const bindingsForModel: (m: Model) => readonly ModelBinding[];
|
|
|
12
12
|
export declare const bindingsForProvider: (p: Provider) => readonly ModelBinding[];
|
|
13
13
|
export declare const findBinding: (m: Model, p: Provider) => ModelBinding | null;
|
|
14
14
|
export declare const findBindingByVendorName: (providerId: ProviderId, vendorModelName: string) => ModelBinding | null;
|
|
15
|
+
export declare const findBindingByVendorNameAnywhere: (vendorModelName: string) => ModelBinding | null;
|
|
15
16
|
export declare const pricingFor: (providerId: ProviderId, vendorModelName: string) => Pricing;
|
|
17
|
+
export declare const isVendorModelAllowed: (providerId: ProviderId, vendorModelName: string, allowedSlugs: readonly string[]) => boolean;
|
|
16
18
|
export { binding } from './types.js';
|
|
17
19
|
export type { ModelBinding, Pricing } from './types.js';
|
|
18
20
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -27,10 +27,26 @@ export const findBindingByVendorName = (providerId, vendorModelName) => {
|
|
|
27
27
|
}
|
|
28
28
|
return null;
|
|
29
29
|
};
|
|
30
|
+
export const findBindingByVendorNameAnywhere = (vendorModelName) => {
|
|
31
|
+
for (const b of BINDINGS) {
|
|
32
|
+
if (matchesVendor(b, vendorModelName))
|
|
33
|
+
return b;
|
|
34
|
+
}
|
|
35
|
+
return null;
|
|
36
|
+
};
|
|
30
37
|
const DEFAULT_PRICING = {
|
|
31
38
|
inputPerToken: 3 / 1_000_000,
|
|
32
39
|
outputPerToken: 15 / 1_000_000,
|
|
33
40
|
};
|
|
34
41
|
export const pricingFor = (providerId, vendorModelName) => findBindingByVendorName(providerId, vendorModelName)?.pricing ?? DEFAULT_PRICING;
|
|
42
|
+
// Allow-lists on apps are stored as Tokenite model slugs (e.g.
|
|
43
|
+
// `gemini-2-5-flash`), but inbound proxy requests carry the vendor's
|
|
44
|
+
// model name (e.g. `gemini-2.5-flash`) or one of its aliases. Resolve
|
|
45
|
+
// the vendor name through the binding catalog and compare against the
|
|
46
|
+
// slug list so allow-list enforcement actually works.
|
|
47
|
+
export const isVendorModelAllowed = (providerId, vendorModelName, allowedSlugs) => {
|
|
48
|
+
const b = findBindingByVendorName(providerId, vendorModelName);
|
|
49
|
+
return b !== null && allowedSlugs.includes(b.model.slug);
|
|
50
|
+
};
|
|
35
51
|
export { binding } from './types.js';
|
|
36
52
|
//# sourceMappingURL=index.js.map
|
|
@@ -3,12 +3,21 @@ import { PROVIDERS } from '../providers/index.js';
|
|
|
3
3
|
import { GPT, OSERIES } from '../models/openai.js';
|
|
4
4
|
const { openai } = PROVIDERS;
|
|
5
5
|
export const OPENAI_BINDINGS = [
|
|
6
|
+
binding(GPT._5_5, openai, 'gpt-5.5', 5, 30),
|
|
7
|
+
binding(GPT._5_4_Pro, openai, 'gpt-5.4-pro', 30, 180),
|
|
8
|
+
binding(GPT._5_4, openai, 'gpt-5.4', 2.5, 15),
|
|
9
|
+
binding(GPT._5_4_Mini, openai, 'gpt-5.4-mini', 0.75, 4.5),
|
|
10
|
+
binding(GPT._5_4_Nano, openai, 'gpt-5.4-nano', 0.2, 1.25),
|
|
6
11
|
binding(GPT._5, openai, 'gpt-5', 1.25, 10),
|
|
7
12
|
binding(GPT._5_Mini, openai, 'gpt-5-mini', 0.25, 2),
|
|
13
|
+
binding(GPT._5_Nano, openai, 'gpt-5-nano', 0.05, 0.4),
|
|
8
14
|
binding(GPT._4_1, openai, 'gpt-4.1', 2, 8),
|
|
15
|
+
binding(GPT._4_1_Mini, openai, 'gpt-4.1-mini', 0.4, 1.6),
|
|
16
|
+
binding(GPT._4_1_Nano, openai, 'gpt-4.1-nano', 0.1, 0.4),
|
|
9
17
|
binding(GPT._4o, openai, 'gpt-4o', 2.5, 10),
|
|
10
18
|
binding(GPT._4o_Mini, openai, 'gpt-4o-mini', 0.15, 0.6, ['gpt-4o-mini-2024-07-18']),
|
|
11
19
|
binding(OSERIES.o3, openai, 'o3', 2, 8),
|
|
20
|
+
binding(OSERIES.o3_Mini, openai, 'o3-mini', 1.1, 4.4),
|
|
12
21
|
binding(OSERIES.o4_Mini, openai, 'o4-mini', 1.1, 4.4),
|
|
13
22
|
];
|
|
14
23
|
//# sourceMappingURL=openai.js.map
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
+
import { enumEntries } from '../type-utils.js';
|
|
1
2
|
export const CAPS = {
|
|
2
3
|
vision: {},
|
|
3
4
|
tools: {},
|
|
4
5
|
thinking: {},
|
|
5
6
|
jsonMode: {},
|
|
6
7
|
};
|
|
7
|
-
const CAP_NAME = new Map(
|
|
8
|
-
export const capName = (c) =>
|
|
8
|
+
const CAP_NAME = new Map(enumEntries(CAPS).map(([k, v]) => [v, k]));
|
|
9
|
+
export const capName = (c) => {
|
|
10
|
+
const id = CAP_NAME.get(c);
|
|
11
|
+
if (!id)
|
|
12
|
+
throw new Error('capName: unknown Cap instance');
|
|
13
|
+
return id;
|
|
14
|
+
};
|
|
9
15
|
//# sourceMappingURL=capabilities.js.map
|
package/dist/catalog/index.d.ts
CHANGED
|
@@ -5,5 +5,7 @@ export * from './models/index.js';
|
|
|
5
5
|
export * from './bindings/index.js';
|
|
6
6
|
export * from './agent-runtime.js';
|
|
7
7
|
export { FLAVORS, getFlavor } from './flavors/index.js';
|
|
8
|
+
export { derivedProviders, strategyAllowsProvider, providersForTier, providersForModelSlugs, type StrategyShape, } from './strategy-providers.js';
|
|
9
|
+
export { resolveAccessModelCatalog, type AccessModel, type AccessTier, type AccessModelCatalog, type AccessModelPricing, } from './access-models.js';
|
|
8
10
|
export type { FlavorId, FlavorHandler, UsageInfo, RequestedModelExtractor, UsageExtractor, ErrorBody, ErrorHooks, } from './flavors/index.js';
|
|
9
11
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/catalog/index.js
CHANGED
|
@@ -5,4 +5,6 @@ export * from './models/index.js';
|
|
|
5
5
|
export * from './bindings/index.js';
|
|
6
6
|
export * from './agent-runtime.js';
|
|
7
7
|
export { FLAVORS, getFlavor } from './flavors/index.js';
|
|
8
|
+
export { derivedProviders, strategyAllowsProvider, providersForTier, providersForModelSlugs, } from './strategy-providers.js';
|
|
9
|
+
export { resolveAccessModelCatalog, } from './access-models.js';
|
|
8
10
|
//# sourceMappingURL=index.js.map
|
|
@@ -4,5 +4,6 @@ export declare const GEMINI: {
|
|
|
4
4
|
readonly _2_5_Pro: import("./types.js").Model;
|
|
5
5
|
readonly _2_5_Flash: import("./types.js").Model;
|
|
6
6
|
readonly _2_5_Flash_Lite: import("./types.js").Model;
|
|
7
|
+
readonly _2_5_Flash_Image: import("./types.js").Model;
|
|
7
8
|
};
|
|
8
9
|
//# sourceMappingURL=google.d.ts.map
|
|
@@ -7,5 +7,9 @@ export const GEMINI = defineFamily('Gemini ', {
|
|
|
7
7
|
_2_5_Pro: [[TIERS.smart, TIERS.reasoning], [CAPS.vision, CAPS.tools, CAPS.thinking, CAPS.jsonMode]],
|
|
8
8
|
_2_5_Flash: [[TIERS.fast, TIERS.cheap], [CAPS.vision, CAPS.tools, CAPS.thinking, CAPS.jsonMode]],
|
|
9
9
|
_2_5_Flash_Lite: [[TIERS.cheap, TIERS.fast], [CAPS.vision, CAPS.tools, CAPS.jsonMode]],
|
|
10
|
+
// Image-generation variant. Accepts text/image prompts, emits images
|
|
11
|
+
// (Google counts each image as ~1290 output tokens, so per-token
|
|
12
|
+
// pricing naturally reflects per-image cost).
|
|
13
|
+
_2_5_Flash_Image: [[TIERS.fast], [CAPS.vision]],
|
|
10
14
|
});
|
|
11
15
|
//# sourceMappingURL=google.js.map
|
|
@@ -2,12 +2,12 @@ import { defineFamily } from './types.js';
|
|
|
2
2
|
import { TIERS } from '../tiers.js';
|
|
3
3
|
import { CAPS } from '../capabilities.js';
|
|
4
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]],
|
|
5
|
+
_4_1_Fast_Reasoning: [[TIERS.reasoning, TIERS.fast], [CAPS.vision, CAPS.tools, CAPS.thinking, CAPS.jsonMode]],
|
|
6
|
+
_4_1_Fast_Non_Reasoning: [[TIERS.fast, TIERS.cheap], [CAPS.vision, CAPS.tools, CAPS.jsonMode]],
|
|
7
|
+
_4_20_Reasoning: [[TIERS.smart, TIERS.reasoning], [CAPS.vision, CAPS.tools, CAPS.thinking, CAPS.jsonMode]],
|
|
8
|
+
_4_20_Multi_Agent: [[TIERS.smart], [CAPS.vision, CAPS.tools, CAPS.jsonMode]],
|
|
9
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]],
|
|
10
|
+
_3: [[TIERS.smart], [CAPS.vision, CAPS.tools, CAPS.jsonMode]],
|
|
11
|
+
_3_Mini: [[TIERS.cheap, TIERS.fast], [CAPS.vision, CAPS.tools, CAPS.thinking, CAPS.jsonMode]],
|
|
12
12
|
});
|
|
13
13
|
//# sourceMappingURL=grok.js.map
|
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
export declare const GPT: {
|
|
2
|
+
readonly _5_5: import("./types.js").Model;
|
|
3
|
+
readonly _5_4_Pro: import("./types.js").Model;
|
|
4
|
+
readonly _5_4: import("./types.js").Model;
|
|
5
|
+
readonly _5_4_Mini: import("./types.js").Model;
|
|
6
|
+
readonly _5_4_Nano: import("./types.js").Model;
|
|
2
7
|
readonly _5: import("./types.js").Model;
|
|
3
8
|
readonly _5_Mini: import("./types.js").Model;
|
|
9
|
+
readonly _5_Nano: import("./types.js").Model;
|
|
4
10
|
readonly _4_1: import("./types.js").Model;
|
|
11
|
+
readonly _4_1_Mini: import("./types.js").Model;
|
|
12
|
+
readonly _4_1_Nano: import("./types.js").Model;
|
|
5
13
|
readonly _4o: import("./types.js").Model;
|
|
6
14
|
readonly _4o_Mini: import("./types.js").Model;
|
|
7
15
|
};
|
|
8
16
|
export declare const OSERIES: {
|
|
9
17
|
readonly o3: import("./types.js").Model;
|
|
18
|
+
readonly o3_Mini: import("./types.js").Model;
|
|
10
19
|
readonly o4_Mini: import("./types.js").Model;
|
|
11
20
|
};
|
|
12
21
|
//# sourceMappingURL=openai.d.ts.map
|
|
@@ -2,14 +2,23 @@ import { defineFamily } from './types.js';
|
|
|
2
2
|
import { TIERS } from '../tiers.js';
|
|
3
3
|
import { CAPS } from '../capabilities.js';
|
|
4
4
|
export const GPT = defineFamily('GPT-', {
|
|
5
|
+
_5_5: [[TIERS.smart, TIERS.reasoning], [CAPS.vision, CAPS.tools, CAPS.jsonMode, CAPS.thinking]],
|
|
6
|
+
_5_4_Pro: [[TIERS.smart, TIERS.reasoning], [CAPS.vision, CAPS.tools, CAPS.jsonMode, CAPS.thinking]],
|
|
7
|
+
_5_4: [[TIERS.smart, TIERS.reasoning], [CAPS.vision, CAPS.tools, CAPS.jsonMode, CAPS.thinking]],
|
|
8
|
+
_5_4_Mini: [[TIERS.cheap, TIERS.fast, TIERS.reasoning], [CAPS.vision, CAPS.tools, CAPS.jsonMode, CAPS.thinking]],
|
|
9
|
+
_5_4_Nano: [[TIERS.cheap, TIERS.fast], [CAPS.vision, CAPS.tools, CAPS.jsonMode]],
|
|
5
10
|
_5: [[TIERS.smart, TIERS.reasoning], [CAPS.vision, CAPS.tools, CAPS.jsonMode, CAPS.thinking]],
|
|
6
11
|
_5_Mini: [[TIERS.cheap, TIERS.fast, TIERS.reasoning], [CAPS.vision, CAPS.tools, CAPS.jsonMode, CAPS.thinking]],
|
|
12
|
+
_5_Nano: [[TIERS.cheap, TIERS.fast, TIERS.reasoning], [CAPS.vision, CAPS.tools, CAPS.jsonMode, CAPS.thinking]],
|
|
7
13
|
_4_1: [[TIERS.smart], [CAPS.vision, CAPS.tools, CAPS.jsonMode]],
|
|
14
|
+
_4_1_Mini: [[TIERS.cheap, TIERS.fast], [CAPS.vision, CAPS.tools, CAPS.jsonMode]],
|
|
15
|
+
_4_1_Nano: [[TIERS.cheap, TIERS.fast], [CAPS.vision, CAPS.tools, CAPS.jsonMode]],
|
|
8
16
|
_4o: [[TIERS.smart], [CAPS.vision, CAPS.tools, CAPS.jsonMode]],
|
|
9
17
|
_4o_Mini: [[TIERS.cheap, TIERS.fast], [CAPS.vision, CAPS.tools, CAPS.jsonMode]],
|
|
10
18
|
});
|
|
11
19
|
export const OSERIES = defineFamily('', {
|
|
12
20
|
o3: [[TIERS.reasoning, TIERS.smart], [CAPS.vision, CAPS.tools, CAPS.jsonMode, CAPS.thinking]],
|
|
21
|
+
o3_Mini: [[TIERS.reasoning, TIERS.cheap], [CAPS.tools, CAPS.jsonMode, CAPS.thinking]],
|
|
13
22
|
o4_Mini: [[TIERS.reasoning, TIERS.cheap], [CAPS.vision, CAPS.tools, CAPS.jsonMode, CAPS.thinking]],
|
|
14
23
|
});
|
|
15
24
|
//# sourceMappingURL=openai.js.map
|
|
@@ -2,7 +2,7 @@ import { defineProvider } from './types.js';
|
|
|
2
2
|
export const anthropic = defineProvider({
|
|
3
3
|
displayName: 'Anthropic',
|
|
4
4
|
color: '#d97706',
|
|
5
|
-
logoUrl: '/providers/anthropic.svg',
|
|
5
|
+
logoUrl: '/assets/providers/anthropic.svg',
|
|
6
6
|
logoStyle: 'symbol',
|
|
7
7
|
flavor: 'anthropic',
|
|
8
8
|
baseUrl: 'https://api.anthropic.com',
|
|
@@ -9,7 +9,7 @@ const adaptToBedrock = (_flavorPath, body, model) => {
|
|
|
9
9
|
export const bedrock = defineProvider({
|
|
10
10
|
displayName: 'Bedrock',
|
|
11
11
|
color: '#ff9900',
|
|
12
|
-
logoUrl: '/providers/bedrock.svg',
|
|
12
|
+
logoUrl: '/assets/providers/bedrock.svg',
|
|
13
13
|
logoStyle: 'symbol',
|
|
14
14
|
flavor: 'anthropic',
|
|
15
15
|
baseUrl: 'https://bedrock-runtime.us-east-1.amazonaws.com',
|
|
@@ -2,7 +2,7 @@ import { defineProvider } from './types.js';
|
|
|
2
2
|
export const google = defineProvider({
|
|
3
3
|
displayName: 'Gemini',
|
|
4
4
|
color: '#4285f4',
|
|
5
|
-
logoUrl: '/providers/google.svg',
|
|
5
|
+
logoUrl: '/assets/providers/google.svg',
|
|
6
6
|
logoStyle: 'symbol',
|
|
7
7
|
flavor: 'gemini',
|
|
8
8
|
baseUrl: 'https://generativelanguage.googleapis.com',
|
|
@@ -2,7 +2,7 @@ import { defineProvider } from './types.js';
|
|
|
2
2
|
export const grok = defineProvider({
|
|
3
3
|
displayName: 'Grok',
|
|
4
4
|
color: '#000000',
|
|
5
|
-
logoUrl: '/providers/grok.svg',
|
|
5
|
+
logoUrl: '/assets/providers/grok.svg',
|
|
6
6
|
logoStyle: 'symbol',
|
|
7
7
|
flavor: 'openai',
|
|
8
8
|
baseUrl: 'https://api.x.ai',
|
|
@@ -8,7 +8,7 @@ export declare const PROVIDERS: {
|
|
|
8
8
|
readonly bedrock: Provider;
|
|
9
9
|
};
|
|
10
10
|
export type ProviderId = keyof typeof PROVIDERS;
|
|
11
|
-
export declare const PROVIDER_IDS: [
|
|
11
|
+
export declare const PROVIDER_IDS: readonly ["anthropic" | "openai" | "bedrock" | "google" | "grok", ...("anthropic" | "openai" | "bedrock" | "google" | "grok")[]];
|
|
12
12
|
export declare const providerName: (p: Provider) => ProviderId;
|
|
13
13
|
export declare const getProvider: (id: ProviderId) => Provider;
|
|
14
14
|
export declare const tryGetProvider: (id: string) => Provider | null;
|
|
@@ -3,6 +3,7 @@ import { openai } from './openai.js';
|
|
|
3
3
|
import { google } from './google.js';
|
|
4
4
|
import { grok } from './grok.js';
|
|
5
5
|
import { bedrock } from './bedrock.js';
|
|
6
|
+
import { enumKeys, enumEntries } from '../../type-utils.js';
|
|
6
7
|
export { defineProvider } from './types.js';
|
|
7
8
|
export const PROVIDERS = {
|
|
8
9
|
anthropic,
|
|
@@ -11,11 +12,17 @@ export const PROVIDERS = {
|
|
|
11
12
|
grok,
|
|
12
13
|
bedrock,
|
|
13
14
|
};
|
|
14
|
-
export const PROVIDER_IDS =
|
|
15
|
-
const PROVIDER_NAME = new Map(
|
|
16
|
-
export const providerName = (p) =>
|
|
15
|
+
export const PROVIDER_IDS = enumKeys(PROVIDERS);
|
|
16
|
+
const PROVIDER_NAME = new Map(enumEntries(PROVIDERS).map(([k, v]) => [v, k]));
|
|
17
|
+
export const providerName = (p) => {
|
|
18
|
+
const id = PROVIDER_NAME.get(p);
|
|
19
|
+
if (!id)
|
|
20
|
+
throw new Error('providerName: unknown Provider instance');
|
|
21
|
+
return id;
|
|
22
|
+
};
|
|
17
23
|
export const getProvider = (id) => PROVIDERS[id];
|
|
18
|
-
|
|
24
|
+
const isProviderId = (id) => id in PROVIDERS;
|
|
25
|
+
export const tryGetProvider = (id) => isProviderId(id) ? PROVIDERS[id] : null;
|
|
19
26
|
export const listProviders = () => Object.values(PROVIDERS);
|
|
20
27
|
export const guessProviderFromKey = (apiKey) => {
|
|
21
28
|
for (const id of PROVIDER_IDS) {
|
|
@@ -2,7 +2,7 @@ import { defineProvider } from './types.js';
|
|
|
2
2
|
export const openai = defineProvider({
|
|
3
3
|
displayName: 'OpenAI',
|
|
4
4
|
color: '#10a37f',
|
|
5
|
-
logoUrl: '/providers/openai.svg',
|
|
5
|
+
logoUrl: '/assets/providers/openai.svg',
|
|
6
6
|
logoStyle: 'symbol',
|
|
7
7
|
flavor: 'openai',
|
|
8
8
|
baseUrl: 'https://api.openai.com',
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type ProviderId } from './providers/index.js';
|
|
2
|
+
import type { ModelStrategy, RequiredTier } from '../schemas/app.js';
|
|
3
|
+
export type StrategyShape = {
|
|
4
|
+
readonly modelStrategy: ModelStrategy;
|
|
5
|
+
readonly requiredTier: RequiredTier | null;
|
|
6
|
+
readonly allowedModels: readonly string[] | null;
|
|
7
|
+
};
|
|
8
|
+
declare const providersForTier: (t: RequiredTier) => readonly ProviderId[];
|
|
9
|
+
declare const providersForModelSlugs: (slugs: readonly string[]) => readonly ProviderId[];
|
|
10
|
+
export declare const derivedProviders: (s: StrategyShape) => readonly ProviderId[] | null;
|
|
11
|
+
export declare const strategyAllowsProvider: (s: StrategyShape, providerId: ProviderId) => boolean;
|
|
12
|
+
export { providersForTier, providersForModelSlugs };
|
|
13
|
+
//# sourceMappingURL=strategy-providers.d.ts.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { BINDINGS } from './bindings/index.js';
|
|
2
|
+
import { providerName } from './providers/index.js';
|
|
3
|
+
import { tierName } from './tiers.js';
|
|
4
|
+
const providersForTier = (t) => {
|
|
5
|
+
const ids = new Set();
|
|
6
|
+
for (const b of BINDINGS) {
|
|
7
|
+
if (b.model.tiers.some((x) => tierName(x) === t))
|
|
8
|
+
ids.add(providerName(b.provider));
|
|
9
|
+
}
|
|
10
|
+
return Array.from(ids);
|
|
11
|
+
};
|
|
12
|
+
const providersForModelSlugs = (slugs) => {
|
|
13
|
+
const ids = new Set();
|
|
14
|
+
for (const b of BINDINGS) {
|
|
15
|
+
if (slugs.includes(b.model.slug))
|
|
16
|
+
ids.add(providerName(b.provider));
|
|
17
|
+
}
|
|
18
|
+
return Array.from(ids);
|
|
19
|
+
};
|
|
20
|
+
export const derivedProviders = (s) => {
|
|
21
|
+
if (s.modelStrategy === 'none')
|
|
22
|
+
return [];
|
|
23
|
+
if (s.modelStrategy === 'tier' && s.requiredTier)
|
|
24
|
+
return providersForTier(s.requiredTier);
|
|
25
|
+
if (s.modelStrategy === 'models' && s.allowedModels && s.allowedModels.length > 0) {
|
|
26
|
+
return providersForModelSlugs(s.allowedModels);
|
|
27
|
+
}
|
|
28
|
+
return null;
|
|
29
|
+
};
|
|
30
|
+
export const strategyAllowsProvider = (s, providerId) => {
|
|
31
|
+
if (s.modelStrategy === 'none')
|
|
32
|
+
return false;
|
|
33
|
+
const list = derivedProviders(s);
|
|
34
|
+
return list === null || list.includes(providerId);
|
|
35
|
+
};
|
|
36
|
+
export { providersForTier, providersForModelSlugs };
|
|
37
|
+
//# sourceMappingURL=strategy-providers.js.map
|
package/dist/catalog/tiers.js
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
|
+
import { enumEntries } from '../type-utils.js';
|
|
1
2
|
export const TIERS = {
|
|
2
3
|
cheap: {},
|
|
3
4
|
fast: {},
|
|
4
5
|
smart: {},
|
|
5
6
|
reasoning: {},
|
|
6
7
|
};
|
|
7
|
-
const TIER_NAME = new Map(
|
|
8
|
-
export const tierName = (t) =>
|
|
8
|
+
const TIER_NAME = new Map(enumEntries(TIERS).map(([k, v]) => [v, k]));
|
|
9
|
+
export const tierName = (t) => {
|
|
10
|
+
const id = TIER_NAME.get(t);
|
|
11
|
+
if (!id)
|
|
12
|
+
throw new Error('tierName: unknown Tier instance');
|
|
13
|
+
return id;
|
|
14
|
+
};
|
|
9
15
|
//# sourceMappingURL=tiers.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
export { type Result, ok, err, type AppError } from './result.js';
|
|
2
|
+
export { enumKeys, enumValues, enumEntries, type NonEmptyKeyTuple, type NonEmptyValueTuple, type NonEmptyEntryTuple, } from './type-utils.js';
|
|
2
3
|
export { providerSchema, type Provider, } from './schemas/provider.js';
|
|
3
4
|
export { userSchema, createUserRequest, userResponse, type User, type CreateUserRequest, type UserResponse, } from './schemas/user.js';
|
|
4
|
-
export { accountTypeSchema, accountSchema, createAccountRequest, updateAccountRequest, type AccountType, type Account, type CreateAccountRequest, type UpdateAccountRequest, } from './schemas/account.js';
|
|
5
|
+
export { accountTypeSchema, accountSchema, createAccountRequest, updateAccountRequest, poolResetPeriodSchema, type AccountType, type Account, type CreateAccountRequest, type UpdateAccountRequest, type PoolResetPeriod, } from './schemas/account.js';
|
|
5
6
|
export { accountRoleSchema, accountMemberSchema, hasAtLeastRole, type AccountRole, type AccountMember, } from './schemas/account-member.js';
|
|
6
7
|
export { accountInvitationSchema, createInvitationRequest, invitationWithClaimUrl, type AccountInvitation, type CreateInvitationRequest, type InvitationWithClaimUrl, } from './schemas/account-invitation.js';
|
|
7
|
-
export { appSchema, createAppRequest, updateAppRequest, appResponse, modelStrategySchema, tierSchema, type App, type CreateAppRequest, type UpdateAppRequest, type AppResponse, type ModelStrategy, type RequiredTier, } from './schemas/app.js';
|
|
8
|
+
export { appSchema, createAppRequest, updateAppRequest, appResponse, modelStrategySchema, tierSchema, hasAtLeastOneCapability, AT_LEAST_ONE_CAPABILITY_MESSAGE, type App, type CreateAppRequest, type UpdateAppRequest, type AppResponse, type ModelStrategy, type RequiredTier, } from './schemas/app.js';
|
|
8
9
|
export { apiKeySchema, addApiKeyRequest, apiKeyResponse, type ApiKey, type AddApiKeyRequest, type ApiKeyResponse, } from './schemas/api-key.js';
|
|
9
|
-
export { sponsoredApiKeySchema, addSponsoredApiKeyRequest, sponsoredApiKeyResponse, sponsoredKeyConsumerSchema, type SponsoredApiKey, type AddSponsoredApiKeyRequest, type SponsoredApiKeyResponse, type SponsoredKeyConsumer, } from './schemas/sponsored-api-key.js';
|
|
10
|
+
export { sponsoredApiKeySchema, addSponsoredApiKeyRequest, updateSponsoredApiKeyRequest, sponsoredApiKeyResponse, sponsoredKeyConsumerSchema, type SponsoredApiKey, type AddSponsoredApiKeyRequest, type UpdateSponsoredApiKeyRequest, type SponsoredApiKeyResponse, type SponsoredKeyConsumer, } from './schemas/sponsored-api-key.js';
|
|
10
11
|
export { budgetSchema, type Budget, DEBT_TOLERANCE_USD, isBudgetAvailable, remainingBudget, } from './schemas/budget.js';
|
|
11
12
|
export { accessTokenSchema, authorizeAppRequest, updateConnectionRequest, connectionResponse, type AccessToken, type AuthorizeAppRequest, type UpdateConnectionRequest, type ConnectionResponse, } from './schemas/access-token.js';
|
|
13
|
+
export { TopupMessageType, AuthMessageType, topupContextResponse, topupRaiseRequest, topupRaiseResponse, topupPostMessage, topupSuccessMessage, topupCancelledMessage, fundingErrorDetails, type TopupContextResponse, type TopupRaiseRequest, type TopupRaiseResponse, type TopupPostMessage, type FundingErrorDetails, } from './schemas/topup.js';
|
|
12
14
|
export { usageLogSchema, type UsageLog, PLATFORM_FEE_RATE, calculatePlatformFee, calculateTotalDebit, } from './schemas/usage.js';
|
|
13
15
|
export { errorResponseSchema, errorSourceSchema, proxyErrorCodes, providerErrorCodes, apiErrorCodes, type ErrorResponse, type ErrorSource, type ProxyErrorCode, type ProviderErrorCode, type ApiErrorCode, type ErrorCode, } from './schemas/error.js';
|
|
14
16
|
export { proxyUsageSchema, proxySuccessSchema, proxyResponseSchema, type ProxyUsage, type ProxySuccess, type ProxyResponse, } from './schemas/proxy-response.js';
|
|
15
17
|
export { discoverySchema, type Discovery, } from './schemas/discovery.js';
|
|
16
18
|
export { CliLoopbackHost, cliLoginParamsSchema, cliLoginMintRequestSchema, cliLoginMintResponseSchema, cliLoginExchangeRequestSchema, cliLoginExchangeResponseSchema, type CliLoginParams, type CliLoginMintRequest, type CliLoginMintResponse, type CliLoginExchangeRequest, type CliLoginExchangeResponse, } from './schemas/cli-login.js';
|
|
17
19
|
export { requireEnv, optionalEnv } from './config.js';
|
|
18
|
-
export { safeParseJson } from './parse.js';
|
|
20
|
+
export { safeParseJson, safeParseJsonSchema } from './parse.js';
|
|
19
21
|
export { rateLimits, ACCESS_TOKEN_LIFETIME_DAYS, OAUTH_CODE_TTL_SECONDS, TOKEN_CACHE_TTL_SECONDS } from './constants.js';
|
|
20
22
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
export { ok, err } from './result.js';
|
|
2
|
+
export { enumKeys, enumValues, enumEntries, } from './type-utils.js';
|
|
2
3
|
export { providerSchema, } from './schemas/provider.js';
|
|
3
4
|
export { userSchema, createUserRequest, userResponse, } from './schemas/user.js';
|
|
4
|
-
export { accountTypeSchema, accountSchema, createAccountRequest, updateAccountRequest, } from './schemas/account.js';
|
|
5
|
+
export { accountTypeSchema, accountSchema, createAccountRequest, updateAccountRequest, poolResetPeriodSchema, } from './schemas/account.js';
|
|
5
6
|
export { accountRoleSchema, accountMemberSchema, hasAtLeastRole, } from './schemas/account-member.js';
|
|
6
7
|
export { accountInvitationSchema, createInvitationRequest, invitationWithClaimUrl, } from './schemas/account-invitation.js';
|
|
7
|
-
export { appSchema, createAppRequest, updateAppRequest, appResponse, modelStrategySchema, tierSchema, } from './schemas/app.js';
|
|
8
|
+
export { appSchema, createAppRequest, updateAppRequest, appResponse, modelStrategySchema, tierSchema, hasAtLeastOneCapability, AT_LEAST_ONE_CAPABILITY_MESSAGE, } from './schemas/app.js';
|
|
8
9
|
export { apiKeySchema, addApiKeyRequest, apiKeyResponse, } from './schemas/api-key.js';
|
|
9
|
-
export { sponsoredApiKeySchema, addSponsoredApiKeyRequest, sponsoredApiKeyResponse, sponsoredKeyConsumerSchema, } from './schemas/sponsored-api-key.js';
|
|
10
|
+
export { sponsoredApiKeySchema, addSponsoredApiKeyRequest, updateSponsoredApiKeyRequest, sponsoredApiKeyResponse, sponsoredKeyConsumerSchema, } from './schemas/sponsored-api-key.js';
|
|
10
11
|
export { budgetSchema, DEBT_TOLERANCE_USD, isBudgetAvailable, remainingBudget, } from './schemas/budget.js';
|
|
11
12
|
export { accessTokenSchema, authorizeAppRequest, updateConnectionRequest, connectionResponse, } from './schemas/access-token.js';
|
|
13
|
+
export { TopupMessageType, AuthMessageType, topupContextResponse, topupRaiseRequest, topupRaiseResponse, topupPostMessage, topupSuccessMessage, topupCancelledMessage, fundingErrorDetails, } from './schemas/topup.js';
|
|
12
14
|
export { usageLogSchema, PLATFORM_FEE_RATE, calculatePlatformFee, calculateTotalDebit, } from './schemas/usage.js';
|
|
13
15
|
export { errorResponseSchema, errorSourceSchema, proxyErrorCodes, providerErrorCodes, apiErrorCodes, } from './schemas/error.js';
|
|
14
16
|
export { proxyUsageSchema, proxySuccessSchema, proxyResponseSchema, } from './schemas/proxy-response.js';
|
|
15
17
|
export { discoverySchema, } from './schemas/discovery.js';
|
|
16
18
|
export { CliLoopbackHost, cliLoginParamsSchema, cliLoginMintRequestSchema, cliLoginMintResponseSchema, cliLoginExchangeRequestSchema, cliLoginExchangeResponseSchema, } from './schemas/cli-login.js';
|
|
17
19
|
export { requireEnv, optionalEnv } from './config.js';
|
|
18
|
-
export { safeParseJson } from './parse.js';
|
|
20
|
+
export { safeParseJson, safeParseJsonSchema } from './parse.js';
|
|
19
21
|
export { rateLimits, ACCESS_TOKEN_LIFETIME_DAYS, OAUTH_CODE_TTL_SECONDS, TOKEN_CACHE_TTL_SECONDS } from './constants.js';
|
|
20
22
|
//# sourceMappingURL=index.js.map
|
package/dist/parse.d.ts
CHANGED
package/dist/parse.js
CHANGED
|
@@ -1,12 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
const parseJsonObject = (text) => {
|
|
2
2
|
try {
|
|
3
3
|
const parsed = JSON.parse(text);
|
|
4
|
-
if (typeof parsed === 'object' && parsed !== null)
|
|
4
|
+
if (typeof parsed === 'object' && parsed !== null && !Array.isArray(parsed)) {
|
|
5
5
|
return parsed;
|
|
6
|
+
}
|
|
6
7
|
return null;
|
|
7
8
|
}
|
|
8
9
|
catch {
|
|
9
10
|
return null;
|
|
10
11
|
}
|
|
11
12
|
};
|
|
13
|
+
export const safeParseJson = (text) => parseJsonObject(text);
|
|
14
|
+
export const safeParseJsonSchema = (text, schema) => {
|
|
15
|
+
const parsed = parseJsonObject(text);
|
|
16
|
+
if (!parsed)
|
|
17
|
+
return null;
|
|
18
|
+
const result = schema.safeParse(parsed);
|
|
19
|
+
return result.success ? result.data : null;
|
|
20
|
+
};
|
|
12
21
|
//# sourceMappingURL=parse.js.map
|
|
@@ -7,6 +7,7 @@ export declare const accessTokenSchema: z.ZodObject<{
|
|
|
7
7
|
budgetLimit: z.ZodNumber;
|
|
8
8
|
budgetSpent: z.ZodDefault<z.ZodNumber>;
|
|
9
9
|
isRevoked: z.ZodDefault<z.ZodBoolean>;
|
|
10
|
+
consentVersionAtIssue: z.ZodDefault<z.ZodNumber>;
|
|
10
11
|
createdAt: z.ZodString;
|
|
11
12
|
}, z.core.$strip>;
|
|
12
13
|
export type AccessToken = z.infer<typeof accessTokenSchema>;
|
|
@@ -27,6 +28,7 @@ export declare const connectionResponse: z.ZodObject<{
|
|
|
27
28
|
budgetLimit: z.ZodNumber;
|
|
28
29
|
budgetSpent: z.ZodDefault<z.ZodNumber>;
|
|
29
30
|
isRevoked: z.ZodDefault<z.ZodBoolean>;
|
|
31
|
+
consentVersionAtIssue: z.ZodDefault<z.ZodNumber>;
|
|
30
32
|
}, z.core.$strip>;
|
|
31
33
|
export type ConnectionResponse = z.infer<typeof connectionResponse>;
|
|
32
34
|
//# sourceMappingURL=access-token.d.ts.map
|