@maxceem/agw 0.7.1 → 0.7.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.
Files changed (2) hide show
  1. package/dist/agw.mjs +96 -1
  2. package/package.json +2 -1
package/dist/agw.mjs CHANGED
@@ -6,7 +6,7 @@ var __export = (target, all) => {
6
6
  };
7
7
 
8
8
  // <define:__AGW_MANIFEST__>
9
- var define_AGW_MANIFEST_default = { version: "0.7.1", wrangler: "4.96.0", upgradeFrom: ["0.7.1", "0.7.0", "0.6.4", "0.6.3", "0.6.2", "0.6.1", "0.6.0", "0.5.2", "0.5.1", "0.5.0", "0.4.0"], release: { url: "https://github.com/maxceem/app-ai-gateway/releases/download/v0.7.1/gateway-0.7.1.tar.gz", sha256: "1b3ac4141c993b30bf1e90404dee7a21785a38b686c3f2562ec7b0c07fd4534d", manifest: "8455d531a2dc7df63af0fcbe1d8a181c3b6c74796e5f5a69cacf7890ca2dc42a" } };
9
+ var define_AGW_MANIFEST_default = { version: "0.7.2", wrangler: "4.96.0", upgradeFrom: ["0.7.2", "0.7.1", "0.7.0", "0.6.4", "0.6.3", "0.6.2", "0.6.1", "0.6.0", "0.5.2", "0.5.1", "0.5.0", "0.4.0"], release: { url: "https://github.com/maxceem/app-ai-gateway/releases/download/v0.7.2/gateway-0.7.2.tar.gz", sha256: "6673bdde6e77fcdbe5da4c13013d084e99354b67cc4ba43704b9dc81b40e1ff7", manifest: "ff987daf1a4740041f3410ac7f852a3b0bce4d98a8fc9abe2cf835f35b2d4d3a" } };
10
10
 
11
11
  // src/main.ts
12
12
  import { Writable as Writable2 } from "node:stream";
@@ -14841,6 +14841,13 @@ var PROVIDER_DESCRIPTORS = {
14841
14841
  directBaseUrl: "https://api.openai.com/",
14842
14842
  auth: { header: "authorization", scheme: "Bearer " },
14843
14843
  nativeClampStyle: "responses",
14844
+ // Images, which report token usage, embeddings and speech.
14845
+ inferencePaths: [
14846
+ "v1/images/generations",
14847
+ "v1/images/edits",
14848
+ "v1/embeddings",
14849
+ "v1/audio/speech"
14850
+ ],
14844
14851
  probePath: "v1/models",
14845
14852
  examplePath: "v1/responses",
14846
14853
  // OpenAI's chat-completions surface deprecated `max_tokens` in favour of
@@ -14850,6 +14857,9 @@ var PROVIDER_DESCRIPTORS = {
14850
14857
  // The two types whose Responses and transcription request shapes the
14851
14858
  // gateway composes itself for custom endpoints.
14852
14859
  endpointPaths: { responses: "v1/responses", audio_transcription: "v1/audio/transcriptions" },
14860
+ // Every JSON answer reports `usage`: tokens for the GPT transcription
14861
+ // models, `{ type: "duration", seconds }` for whisper-1.
14862
+ transcriptionFormats: { metered: ["json", "verbose_json", "diarized_json"], default: "json" },
14853
14863
  modelAuthor: "OpenAI"
14854
14864
  },
14855
14865
  anthropic: {
@@ -14872,6 +14882,14 @@ var PROVIDER_DESCRIPTORS = {
14872
14882
  directBaseUrl: "https://api.x.ai/",
14873
14883
  auth: { header: "authorization", scheme: "Bearer " },
14874
14884
  nativeClampStyle: "responses",
14885
+ // Images and their edits report their cost like chat does; embeddings and
14886
+ // legacy completions answer in tokens, the latter capped in `max_tokens`.
14887
+ inferencePaths: [
14888
+ "v1/images/generations",
14889
+ "v1/images/edits",
14890
+ "v1/embeddings",
14891
+ { path: "v1/completions", clamp: "chat_completions" }
14892
+ ],
14875
14893
  probePath: "v1/models",
14876
14894
  // Native provider paths: xAI transcribes at `v1/stt`, where OpenAI serves
14877
14895
  // `v1/audio/transcriptions`.
@@ -14888,6 +14906,13 @@ var PROVIDER_DESCRIPTORS = {
14888
14906
  directBaseUrl: "https://generativelanguage.googleapis.com/",
14889
14907
  auth: { header: "x-goog-api-key" },
14890
14908
  nativeClampStyle: "gemini_native",
14909
+ // Embeddings. `generateContent` already carries text, images, speech and
14910
+ // transcription; `batchEmbedContents` is left out because each item may name
14911
+ // a model the one in the URL does not.
14912
+ inferencePaths: [
14913
+ "v1beta/models/{model}:embedContent",
14914
+ "v1/models/{model}:embedContent"
14915
+ ],
14891
14916
  probePath: "v1beta/models",
14892
14917
  // Native Gemini generation requests carry the model in the URL rather than
14893
14918
  // in the JSON body, so there is no example path without a model.
@@ -14899,6 +14924,15 @@ var PROVIDER_DESCRIPTORS = {
14899
14924
  directBaseUrl: "https://api.perplexity.ai/",
14900
14925
  auth: { header: "authorization", scheme: "Bearer " },
14901
14926
  nativeClampStyle: "responses",
14927
+ // The Agent API, its model router's three formats, and embeddings.
14928
+ inferencePaths: [
14929
+ { path: "v1/agent", clamp: "responses" },
14930
+ { path: "router/v1/chat/completions", clamp: "chat_completions" },
14931
+ { path: "router/v1/responses", clamp: "responses" },
14932
+ { path: "router/v1/messages", clamp: "anthropic" },
14933
+ "v1/embeddings",
14934
+ "v1/contextualizedembeddings"
14935
+ ],
14902
14936
  // No `probePath`: Perplexity has no unmetered authenticated endpoint.
14903
14937
  examplePath: "chat/completions",
14904
14938
  modelAuthor: "Perplexity"
@@ -14914,6 +14948,13 @@ var PROVIDER_DESCRIPTORS = {
14914
14948
  directBaseUrl: "https://api.deepseek.com/",
14915
14949
  auth: { header: "authorization", scheme: "Bearer " },
14916
14950
  nativeClampStyle: "chat_completions",
14951
+ // Responses, fill-in-the-middle completions and the Anthropic-format API,
14952
+ // which like its chat path carry no `v1/` prefix of their own.
14953
+ inferencePaths: [
14954
+ { path: "responses", clamp: "responses" },
14955
+ { path: "beta/completions", clamp: "chat_completions" },
14956
+ { path: "anthropic/v1/messages", clamp: "anthropic" }
14957
+ ],
14917
14958
  // DeepSeek's OpenAI base URL carries no `v1` segment.
14918
14959
  probePath: "models",
14919
14960
  examplePath: "chat/completions",
@@ -14926,6 +14967,15 @@ var PROVIDER_DESCRIPTORS = {
14926
14967
  directBaseUrl: "https://api.groq.com/",
14927
14968
  auth: { header: "authorization", scheme: "Bearer " },
14928
14969
  nativeClampStyle: "chat_completions",
14970
+ // Its default `json` answer is the transcript alone; `verbose_json` adds the
14971
+ // duration it bills by, and the same `text` a client reads.
14972
+ transcriptionFormats: {
14973
+ metered: ["verbose_json"],
14974
+ default: "json",
14975
+ upgrades: { json: "verbose_json" }
14976
+ },
14977
+ // Speech; transcriptions are a default style already.
14978
+ inferencePaths: ["openai/v1/audio/speech"],
14929
14979
  // Groq's OpenAI-compatible surface is namespaced under `openai/`.
14930
14980
  probePath: "openai/v1/models",
14931
14981
  examplePath: "openai/v1/chat/completions"
@@ -14935,6 +14985,12 @@ var PROVIDER_DESCRIPTORS = {
14935
14985
  directBaseUrl: "https://api.mistral.ai/",
14936
14986
  auth: { header: "authorization", scheme: "Bearer " },
14937
14987
  nativeClampStyle: "chat_completions",
14988
+ // Embeddings, fill-in-the-middle completions and speech.
14989
+ inferencePaths: [
14990
+ "v1/embeddings",
14991
+ { path: "v1/fim/completions", clamp: "chat_completions" },
14992
+ "v1/audio/speech"
14993
+ ],
14938
14994
  probePath: "v1/models",
14939
14995
  modelAuthor: "Mistral"
14940
14996
  },
@@ -14945,6 +15001,21 @@ var PROVIDER_DESCRIPTORS = {
14945
15001
  directBaseUrl: "https://api.together.ai/",
14946
15002
  auth: { header: "authorization", scheme: "Bearer " },
14947
15003
  nativeClampStyle: "chat_completions",
15004
+ // Its default `json` answer is the transcript alone; `verbose_json` adds the
15005
+ // duration it bills by, and the same `text` a client reads.
15006
+ transcriptionFormats: {
15007
+ metered: ["verbose_json"],
15008
+ default: "json",
15009
+ upgrades: { json: "verbose_json" }
15010
+ },
15011
+ // Legacy completions, images, speech and embeddings. Video is a job whose
15012
+ // result is polled for, so it is not here.
15013
+ inferencePaths: [
15014
+ { path: "v1/completions", clamp: "chat_completions" },
15015
+ "v1/images/generations",
15016
+ "v1/audio/speech",
15017
+ "v1/embeddings"
15018
+ ],
14948
15019
  probePath: "v1/models"
14949
15020
  },
14950
15021
  fireworks: {
@@ -14954,6 +15025,13 @@ var PROVIDER_DESCRIPTORS = {
14954
15025
  directBaseUrl: "https://api.fireworks.ai/",
14955
15026
  auth: { header: "authorization", scheme: "Bearer " },
14956
15027
  nativeClampStyle: "chat_completions",
15028
+ // Every format its inference plane speaks, and embeddings.
15029
+ inferencePaths: [
15030
+ { path: "inference/v1/completions", clamp: "chat_completions" },
15031
+ { path: "inference/v1/messages", clamp: "anthropic" },
15032
+ { path: "inference/v1/responses", clamp: "responses" },
15033
+ "inference/v1/embeddings"
15034
+ ],
14957
15035
  // No `probePath`: its list-models call is `v1/accounts/{account}/models`,
14958
15036
  // and the account id cannot be derived from the key. Nothing under
14959
15037
  // `inference/v1/` is documented as a GET.
@@ -14964,6 +15042,8 @@ var PROVIDER_DESCRIPTORS = {
14964
15042
  directBaseUrl: "https://api.cerebras.ai/",
14965
15043
  auth: { header: "authorization", scheme: "Bearer " },
14966
15044
  nativeClampStyle: "chat_completions",
15045
+ // Legacy completions.
15046
+ inferencePaths: [{ path: "v1/completions", clamp: "chat_completions" }],
14967
15047
  probePath: "v1/models"
14968
15048
  },
14969
15049
  moonshot: {
@@ -14973,6 +15053,8 @@ var PROVIDER_DESCRIPTORS = {
14973
15053
  directBaseUrl: "https://api.moonshot.ai/",
14974
15054
  auth: { header: "authorization", scheme: "Bearer " },
14975
15055
  nativeClampStyle: "chat_completions",
15056
+ // The Anthropic-format API.
15057
+ inferencePaths: [{ path: "anthropic/v1/messages", clamp: "anthropic" }],
14976
15058
  probePath: "v1/models",
14977
15059
  modelAuthor: "Moonshot AI"
14978
15060
  },
@@ -15010,6 +15092,13 @@ var PROVIDER_DESCRIPTORS = {
15010
15092
  directBaseUrl: "https://ark.ap-southeast.bytepluses.com/api/v3/",
15011
15093
  auth: { header: "authorization", scheme: "Bearer " },
15012
15094
  nativeClampStyle: "chat_completions",
15095
+ // Responses, Seedream images and multimodal embeddings, all under the base
15096
+ // URL's own `api/v3/`. Seedance video is a polled job, so it is not here.
15097
+ inferencePaths: [
15098
+ { path: "responses", clamp: "responses" },
15099
+ "images/generations",
15100
+ "embeddings/multimodal"
15101
+ ],
15013
15102
  // No `probePath`: ModelArk publishes no list-models call, and its own SDK
15014
15103
  // has no models resource. It also authenticates before it routes, so every
15015
15104
  // path answers the same 401 and a probe would prove nothing about the key.
@@ -16706,6 +16795,12 @@ var StateStore = class {
16706
16795
  function selectedProviderPolicies(routing) {
16707
16796
  return routing.providers.mode === "selected" ? routing.providers.selected : {};
16708
16797
  }
16798
+ var DEFAULT_INFERENCE_PATHS = new Map(
16799
+ PROVIDER_TYPES.map((type) => [
16800
+ type,
16801
+ (providerDescriptor(type).inferencePaths ?? []).map((entry) => typeof entry === "string" ? { path: entry, clamp: "none" } : { ...entry })
16802
+ ])
16803
+ );
16709
16804
 
16710
16805
  // ../src/shared/protocols.ts
16711
16806
  var PROTOCOLS = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maxceem/agw",
3
- "version": "0.7.1",
3
+ "version": "0.7.2",
4
4
  "type": "module",
5
5
  "description": "Manage App AI Gateway from a terminal or coding agent: providers, iOS and server apps, usage, and self-hosted deployment on Cloudflare",
6
6
  "keywords": [
@@ -26,6 +26,7 @@
26
26
  },
27
27
  "bugs": "https://github.com/maxceem/app-ai-gateway/issues",
28
28
  "upgradeFrom": [
29
+ "0.7.1",
29
30
  "0.7.0",
30
31
  "0.6.4",
31
32
  "0.6.3",