@mupt-ai/dari-gateway 1.0.364 → 1.0.366

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/README.md CHANGED
@@ -126,7 +126,7 @@ native_compaction: false
126
126
  agents: { codex: [openai/gpt-6.1-sol] }
127
127
  ```
128
128
 
129
- Each model lists its `sources`, tried in order: `plan` (connected subscriptions), `reset` (when those plans are out, spend a banked reset, but only if the plan would otherwise be out at least `reset_min_hours`, or the reset would expire first; only right after `plan`), and `api` (the provider's API key). A model without `sources` uses `[plan, api]` here; on hosted Dari a model without them uses `[plan]`. The gateway has no Dari credits. `hosted` settings and a model's `fast` apply only on hosted Dari and are ignored here; `routing.rules` runs only on hosted Dari and is refused. A model's `provider` must be one that serves it, such as `opencode-go` or `fireworks` for the DeepSeek, Kimi, and GLM models; the plan-only provider `vercel-token-pass` serves through a connected subscription.
129
+ Each model lists its `sources`, tried in order: `plan` (connected subscriptions), `reset` (when those plans are out, spend a banked reset, but only if the plan would otherwise be out at least `reset_min_hours`, or the reset would expire first; only right after `plan`), and `api` (the provider's API key). A model without `sources` uses `[plan, api]` here; on hosted Dari a model without them uses `[plan]`. The gateway has no Dari credits. `hosted` settings and a model's `fast` apply only on hosted Dari and are ignored here; `routing.rules` runs only on hosted Dari and is refused. A model's `provider` must be one that serves it, such as `opencode-go`, `fireworks`, `openrouter`, or `vercel-ai-gateway` for the DeepSeek, Kimi, and GLM models; the plan-only provider `vercel-token-pass` serves through a connected subscription. Without a `provider`, a model its maker serves uses its maker's key, and one its maker does not (an open-weights model) uses the first key of any provider that runs it, Fireworks first; `GET /v1/canonical-models` lists each model's `providers`.
130
130
 
131
131
  With any gateway key:
132
132
 
@@ -1,7 +1,8 @@
1
1
  import type { LinkKeyProvider } from "../platform/platform.js";
2
2
  /**
3
3
  * Whose API key a user can add on the approval page: each provider with
4
- * catalog models the gateway can call with a key, then the gateways.
4
+ * catalog models the gateway can call with a key, named for the models'
5
+ * maker, then the gateways.
5
6
  */
6
7
  export declare const LINK_KEY_PROVIDERS: readonly LinkKeyProvider[];
7
8
  /** What a provider is called where a user's key for it is shown: "OpenRouter". */
@@ -2,22 +2,15 @@ import { getBuiltinProviders } from "@mupt-ai/pi-ai/providers/all";
2
2
  import { providerForModel } from "@mupt-ai/dari-router/policy-engine";
3
3
  import { CANONICAL_MODELS } from "../models/canonical.js";
4
4
  import { LINK_KEY_GATEWAYS, gatewayFor } from "../models/gateways.js";
5
- const PROVIDER_NAMES = {
6
- anthropic: "Anthropic",
7
- openai: "OpenAI",
8
- meta: "Meta",
9
- moonshotai: "Moonshot AI",
10
- xai: "xAI",
11
- google: "Google",
12
- };
13
5
  /**
14
6
  * Whose API key a user can add on the approval page: each provider with
15
- * catalog models the gateway can call with a key, then the gateways.
7
+ * catalog models the gateway can call with a key, named for the models'
8
+ * maker, then the gateways.
16
9
  */
17
10
  export const LINK_KEY_PROVIDERS = [
18
- ...[...new Set(CANONICAL_MODELS.map((model) => providerForModel(model.id)))]
19
- .filter((provider) => getBuiltinProviders().includes(provider))
20
- .map((provider) => ({ id: provider, name: PROVIDER_NAMES[provider] ?? provider })),
11
+ ...[...new Map(CANONICAL_MODELS.map((model) => [providerForModel(model.id), model.maker]))]
12
+ .filter(([provider]) => getBuiltinProviders().includes(provider))
13
+ .map(([provider, name]) => ({ id: provider, name })),
21
14
  ...LINK_KEY_GATEWAYS.map((gateway) => ({ id: gateway, name: gatewayFor(gateway).label })),
22
15
  ];
23
16
  /** What a provider is called where a user's key for it is shown: "OpenRouter". */
@@ -1,12 +1,19 @@
1
1
  export type CanonicalModel = {
2
2
  id: string;
3
3
  name: string;
4
+ maker: string;
4
5
  thinking_levels: string[];
6
+ providers: string[];
5
7
  };
6
8
  /** The canonical models Dari serves, from the monorepo's router catalog. */
7
9
  export declare const CANONICAL_MODELS: readonly CanonicalModel[];
8
10
  /** A model's catalog name; a model the catalog does not list keeps its id. */
9
11
  export declare function canonicalModelName(id: string): string;
12
+ /**
13
+ * The providers whose API keys may serve a model a router spec names no
14
+ * provider for; a model the catalog does not list is its id's provider's.
15
+ */
16
+ export declare function modelKeyProviders(id: string): string[];
10
17
  /** A canonical model as a provider other than the one its id names serves it. */
11
18
  export type ProviderModel = {
12
19
  model_id: string;
@@ -17,5 +24,5 @@ export type ProviderModel = {
17
24
  };
18
25
  /** How `provider` serves a model whose id names another provider, if it does. */
19
26
  export declare function providerModel(modelId: string, provider: string): ProviderModel | undefined;
20
- /** The providers besides the one its id names that serve a model. */
27
+ /** The providers and gateways besides the one its id names that serve a model. */
21
28
  export declare function otherModelProviders(modelId: string): string[];
@@ -1,3 +1,4 @@
1
+ import { providerForModel } from "@mupt-ai/dari-router/policy-engine";
1
2
  import canonicalModels from "./canonical_models.json" with { type: "json" };
2
3
  import providerModels from "./provider_models.json" with { type: "json" };
3
4
  /** The canonical models Dari serves, from the monorepo's router catalog. */
@@ -6,12 +7,19 @@ export const CANONICAL_MODELS = canonicalModels;
6
7
  export function canonicalModelName(id) {
7
8
  return CANONICAL_MODELS.find((model) => model.id === id)?.name ?? id;
8
9
  }
10
+ /**
11
+ * The providers whose API keys may serve a model a router spec names no
12
+ * provider for; a model the catalog does not list is its id's provider's.
13
+ */
14
+ export function modelKeyProviders(id) {
15
+ return CANONICAL_MODELS.find((model) => model.id === id)?.providers ?? [providerForModel(id)];
16
+ }
9
17
  const PROVIDER_MODELS = providerModels;
10
18
  /** How `provider` serves a model whose id names another provider, if it does. */
11
19
  export function providerModel(modelId, provider) {
12
20
  return PROVIDER_MODELS.find((row) => row.model_id === modelId && row.provider === provider);
13
21
  }
14
- /** The providers besides the one its id names that serve a model. */
22
+ /** The providers and gateways besides the one its id names that serve a model. */
15
23
  export function otherModelProviders(modelId) {
16
24
  return PROVIDER_MODELS.filter((row) => row.model_id === modelId).map((row) => row.provider);
17
25
  }