@intutic/shared-types 2.3.0 → 2.5.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.
Files changed (83) hide show
  1. package/README.md +1 -1
  2. package/dist/anomaly.d.ts +0 -19
  3. package/dist/anomaly.d.ts.map +1 -1
  4. package/dist/attenuation.d.ts +4 -3
  5. package/dist/attenuation.d.ts.map +1 -1
  6. package/dist/attenuation.js +4 -3
  7. package/dist/attenuation.js.map +1 -1
  8. package/dist/auth.d.ts +106 -0
  9. package/dist/auth.d.ts.map +1 -1
  10. package/dist/auth.js +17 -1
  11. package/dist/auth.js.map +1 -1
  12. package/dist/chaos.d.ts +2225 -0
  13. package/dist/chaos.d.ts.map +1 -0
  14. package/dist/chaos.js +358 -0
  15. package/dist/chaos.js.map +1 -0
  16. package/dist/chaosGate.d.ts +166 -0
  17. package/dist/chaosGate.d.ts.map +1 -0
  18. package/dist/chaosGate.js +383 -0
  19. package/dist/chaosGate.js.map +1 -0
  20. package/dist/cloudProbe.d.ts +54 -0
  21. package/dist/cloudProbe.d.ts.map +1 -0
  22. package/dist/cloudProbe.js +254 -0
  23. package/dist/cloudProbe.js.map +1 -0
  24. package/dist/enums.d.ts +48 -0
  25. package/dist/enums.d.ts.map +1 -1
  26. package/dist/enums.js +31 -3
  27. package/dist/enums.js.map +1 -1
  28. package/dist/finops.d.ts +38 -18
  29. package/dist/finops.d.ts.map +1 -1
  30. package/dist/guardrailIr.d.ts +4 -4
  31. package/dist/index.d.ts +18 -9
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js +68 -9
  34. package/dist/index.js.map +1 -1
  35. package/dist/intelligence.d.ts +3 -100
  36. package/dist/intelligence.d.ts.map +1 -1
  37. package/dist/intelligence.js +3 -3
  38. package/dist/intelligence.js.map +1 -1
  39. package/dist/mcpBudgets.d.ts +32 -32
  40. package/dist/notifications.d.ts +17 -2
  41. package/dist/notifications.d.ts.map +1 -1
  42. package/dist/notifications.js +35 -5
  43. package/dist/notifications.js.map +1 -1
  44. package/dist/observability.d.ts +0 -31
  45. package/dist/observability.d.ts.map +1 -1
  46. package/dist/observability.js +0 -7
  47. package/dist/observability.js.map +1 -1
  48. package/dist/opaqueRefusal.d.ts +40 -0
  49. package/dist/opaqueRefusal.d.ts.map +1 -0
  50. package/dist/opaqueRefusal.js +53 -0
  51. package/dist/opaqueRefusal.js.map +1 -0
  52. package/dist/policyGuardrails.d.ts +5 -5
  53. package/dist/providerVerification.d.ts +35 -9
  54. package/dist/providerVerification.d.ts.map +1 -1
  55. package/dist/providerVerification.js +79 -19
  56. package/dist/providerVerification.js.map +1 -1
  57. package/dist/providers.d.ts +50 -13
  58. package/dist/providers.d.ts.map +1 -1
  59. package/dist/providers.js +131 -27
  60. package/dist/providers.js.map +1 -1
  61. package/dist/spendBudgets.d.ts +122 -0
  62. package/dist/spendBudgets.d.ts.map +1 -0
  63. package/dist/spendBudgets.js +92 -0
  64. package/dist/spendBudgets.js.map +1 -0
  65. package/dist/taskManagement.d.ts +34 -82
  66. package/dist/taskManagement.d.ts.map +1 -1
  67. package/dist/taskManagement.js +4 -4
  68. package/dist/toolPoison.d.ts +15 -2
  69. package/dist/toolPoison.d.ts.map +1 -1
  70. package/dist/toolPoison.js +14 -4
  71. package/dist/toolPoison.js.map +1 -1
  72. package/dist/upstreamRetry.d.ts +121 -0
  73. package/dist/upstreamRetry.d.ts.map +1 -0
  74. package/dist/upstreamRetry.js +90 -0
  75. package/dist/upstreamRetry.js.map +1 -0
  76. package/dist/wasmRuleDescriptor.d.ts +43 -0
  77. package/dist/wasmRuleDescriptor.d.ts.map +1 -0
  78. package/dist/wasmRuleDescriptor.js +65 -0
  79. package/dist/wasmRuleDescriptor.js.map +1 -0
  80. package/dist/workspaceSettings.d.ts +42 -4
  81. package/dist/workspaceSettings.d.ts.map +1 -1
  82. package/dist/workspaceSettings.js.map +1 -1
  83. package/package.json +2 -2
@@ -28,7 +28,11 @@
28
28
  */
29
29
  Object.defineProperty(exports, "__esModule", { value: true });
30
30
  exports.buildVerificationProbe = buildVerificationProbe;
31
+ exports.parseProviderModels = parseProviderModels;
32
+ exports.buildVerificationProbeAsync = buildVerificationProbeAsync;
33
+ exports.classifyProbe = classifyProbe;
31
34
  exports.classifyProbeResponse = classifyProbeResponse;
35
+ const cloudProbe_js_1 = require("./cloudProbe.js");
32
36
  /**
33
37
  * Strip trailing `/` characters, without a regex. `endpoint`/`apiBase` are
34
38
  * workspace-provisioned credential fields — CodeQL correctly flagged the
@@ -50,15 +54,14 @@ function stripTrailingSlashes(s) {
50
54
  *
51
55
  * `fields` is the provider's credential field map exactly as stored — the
52
56
  * same shape `PROVIDER_REGISTRY`'s `ProviderCredentialField.key`s describe
53
- * (`providers.ts`), e.g. `{ apiKey: '...' }` for Anthropic, `{ apiKey, endpoint,
54
- * deploymentName }` for Azure OpenAI.
57
+ * (`providers.ts`), e.g. `{ apiKey: '...' }` for Anthropic, `{ apiKey, endpoint }`
58
+ * for Azure OpenAI.
55
59
  *
56
- * Bedrock and Vertex AI return `null`: verifying them means SigV4 request
57
- * signing or a GCP OAuth2/JWT exchange, neither of which exists anywhere in
58
- * this codebase yet (the same "real per-provider engineering, not a config
59
- * change" boundary that also keeps routing those two providers out). A
60
- * caller seeing `null` should say "cannot verify automatically," not fail
61
- * the credential.
60
+ * Bedrock and Vertex AI return `null` here: their probe is signed per
61
+ * request, which takes WebCrypto and is asynchronous — see
62
+ * `buildVerificationProbeAsync`, which every executor calls. A caller seeing
63
+ * `null` from that should say "cannot verify automatically," not fail the
64
+ * credential.
62
65
  */
63
66
  function buildVerificationProbe(provider, fields) {
64
67
  switch (provider) {
@@ -66,21 +69,16 @@ function buildVerificationProbe(provider, fields) {
66
69
  const apiKey = fields.apiKey;
67
70
  if (!apiKey)
68
71
  return null;
69
- // Anthropic's API has no /v1/models endpoint to probe cheaply, so the
70
- // cheapest real call is a 1-max-token message — costs about one token.
72
+ // Listing models is the cheapest authenticated call Anthropic has: it
73
+ // spends no tokens, and the answer says which models the key reaches.
74
+ // 1000 is the page-size ceiling, enough for the whole catalog in one call.
71
75
  return {
72
- url: 'https://api.anthropic.com/v1/messages',
73
- method: 'POST',
76
+ url: 'https://api.anthropic.com/v1/models?limit=1000',
77
+ method: 'GET',
74
78
  headers: {
75
79
  'x-api-key': apiKey,
76
80
  'anthropic-version': '2023-06-01',
77
- 'content-type': 'application/json',
78
81
  },
79
- body: JSON.stringify({
80
- model: 'claude-haiku-4-5',
81
- max_tokens: 1,
82
- messages: [{ role: 'user', content: 'hi' }],
83
- }),
84
82
  };
85
83
  }
86
84
  case 'openai': {
@@ -138,7 +136,7 @@ function buildVerificationProbe(provider, fields) {
138
136
  if (!apiKey)
139
137
  return null;
140
138
  return {
141
- url: `https://generativelanguage.googleapis.com/v1beta/models?key=${encodeURIComponent(apiKey)}`,
139
+ url: `https://generativelanguage.googleapis.com/v1beta/models?pageSize=1000&key=${encodeURIComponent(apiKey)}`,
142
140
  method: 'GET',
143
141
  headers: {},
144
142
  };
@@ -174,6 +172,68 @@ function buildVerificationProbe(provider, fields) {
174
172
  return null;
175
173
  }
176
174
  }
175
+ /** `body[listKey][].{idKey}` values that are non-empty strings. */
176
+ function pluck(body, listKey, idKey) {
177
+ if (typeof body !== 'object' || body === null)
178
+ return null;
179
+ const list = body[listKey];
180
+ if (!Array.isArray(list))
181
+ return null;
182
+ const ids = [];
183
+ for (const entry of list) {
184
+ const id = typeof entry === 'object' && entry !== null ? entry[idKey] : undefined;
185
+ if (typeof id === 'string' && id.length > 0)
186
+ ids.push(id);
187
+ }
188
+ return ids;
189
+ }
190
+ /**
191
+ * The model ids in a provider's list-models answer (the body a `valid`
192
+ * verification probe got back), deduplicated and sorted; `null` when this
193
+ * provider's probe does not list the models a request can name, or the body
194
+ * is not the expected shape.
195
+ *
196
+ * Azure OpenAI's probe lists base models, while a request names a deployment,
197
+ * so its list would mislead; Bedrock and Vertex AI probe identity, not models.
198
+ */
199
+ function parseProviderModels(provider, body) {
200
+ let ids;
201
+ switch (provider) {
202
+ case 'anthropic':
203
+ case 'openai':
204
+ case 'mistral':
205
+ case 'openrouter':
206
+ case 'deepseek':
207
+ ids = pluck(body, 'data', 'id');
208
+ break;
209
+ case 'gemini':
210
+ // Gemini names a model `models/gemini-2.5-pro`; requests use the bare id.
211
+ ids = pluck(body, 'models', 'name')?.map((n) => (n.startsWith('models/') ? n.slice('models/'.length) : n)) ?? null;
212
+ break;
213
+ case 'cohere':
214
+ case 'ollama':
215
+ ids = pluck(body, 'models', 'name');
216
+ break;
217
+ default:
218
+ return null;
219
+ }
220
+ if (!ids)
221
+ return null;
222
+ return [...new Set(ids.filter((id) => id.length > 0))].sort();
223
+ }
224
+ /**
225
+ * The probe for any provider: a signed cloud probe for Bedrock and Vertex AI
226
+ * (`cloudProbe.ts`), the plain request description otherwise.
227
+ */
228
+ async function buildVerificationProbeAsync(provider, fields, now = new Date()) {
229
+ return (await (0, cloudProbe_js_1.buildCloudVerificationProbe)(provider, fields, now)) ?? buildVerificationProbe(provider, fields);
230
+ }
231
+ /** The verdict for a probe's answer: the probe's own reading when it has one. */
232
+ function classifyProbe(probe, status, headers) {
233
+ return probe.classify
234
+ ? probe.classify(status, headers ?? { get: () => null })
235
+ : classifyProbeResponse(status);
236
+ }
177
237
  /**
178
238
  * Classify a probe's HTTP response. Deliberately narrow about what counts as
179
239
  * "invalid": only 401/403 mean the credential itself is wrong. A 429
@@ -1 +1 @@
1
- {"version":3,"file":"providerVerification.js","sourceRoot":"","sources":["../src/providerVerification.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;;AAyCH,wDAqHC;AAcD,sDAIC;AA9KD;;;;;;;;GAQG;AACH,SAAS,oBAAoB,CAAC,CAAS;IACrC,IAAI,GAAG,GAAG,CAAC,CAAC,MAAM,CAAA;IAClB,OAAO,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,KAAK,GAAG;QAAE,GAAG,E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;YACE,OAAO,IAAI,CAAA;IACf,CAAC;IACD,IAAI,CAAC,GAAG;QAAE,OAAO,IAAI,CAAA;IACrB,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAA;AAC/D,CAAC;AAED;;;GAGG;AACI,KAAK,UAAU,2BAA2B,CAC/C,QAAgB,EAChB,MAA8B,EAC9B,MAAY,IAAI,IAAI,EAAE;IAEtB,OAAO,CAAC,MAAM,IAAA,2CAA2B,EAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,sBAAsB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;AAC/G,CAAC;AAED,iFAAiF;AACjF,SAAgB,aAAa,CAC3B,KAA2B,EAC3B,MAAc,EACd,OAA8C;IAE9C,OAAO,KAAK,CAAC,QAAQ;QACnB,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC;QACxD,CAAC,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAA;AACnC,CAAC;AAED;;;;;;;;;GASG;AACH,SAAgB,qBAAqB,CAAC,UAAkB;IACtD,IAAI,UAAU,IAAI,GAAG,IAAI,UAAU,GAAG,GAAG;QAAE,OAAO,OAAO,CAAA;IACzD,IAAI,UAAU,KAAK,GAAG,IAAI,UAAU,KAAK,GAAG;QAAE,OAAO,SAAS,CAAA;IAC9D,OAAO,SAAS,CAAA;AAClB,CAAC"}
@@ -11,6 +11,11 @@
11
11
  * new provider's *field layout* is a data change here, not new code in
12
12
  * every place that touches credentials.
13
13
  *
14
+ * AWS Bedrock, Google Vertex AI and Azure OpenAI are routed by the proxy's
15
+ * `src/cloud` module: requests name them as `bedrock/<model id>`,
16
+ * `vertex/<model>` and `azure/<deployment>`, and the stored blob is the
17
+ * region/endpoint plus credential that module signs or authenticates with.
18
+ *
14
19
  * Deliberately NOT exhaustive — LiteLLM supports 100+ providers. This is a
15
20
  * representative slice spanning the shapes that actually differ (single
16
21
  * key, multi-field cloud credential, self-hosted endpoint, structured
@@ -19,13 +24,16 @@
19
24
  * of these shapes is adding one entry, not new plumbing.
20
25
  *
21
26
  * `routingLive: true` means `packages/proxy` actually forwards requests to
22
- * this provider today (`fetch_provider_credential` in `proxy.rs` knows its
23
- * field name). `routingLive: false` means the credential can be
24
- * pre-provisioned here, but nothing in the proxy calls it yet — routing
25
- * support is separate, real per-provider engineering (a new `Provider`
26
- * enum variant, `get_model_provider`, pricing in `pricing.rs`), not a
27
- * config change. The dashboard wizard must say so, not imply the key is
28
- * live the moment it's saved.
27
+ * this provider today: it has an upstream for it (`provider_from_wire_id` in
28
+ * `proxy.rs`, which a proxy test holds this flag to). Gemini models are served
29
+ * on the Messages, Chat Completions and Responses routes, through the
30
+ * Gemini API translation; the proxy refuses the native `/v1beta/models/…`
31
+ * route, whose model is named in the URL. `routingLive: false` means the
32
+ * credential can be pre-provisioned here, but nothing in the proxy calls it
33
+ * yet — routing support is separate, real per-provider engineering (a new
34
+ * `Provider` enum variant, `get_model_provider`, pricing in `pricing.rs`),
35
+ * not a config change. The dashboard wizard must say so, not imply the key
36
+ * is live the moment it's saved.
29
37
  *
30
38
  * @module
31
39
  */
@@ -47,6 +55,15 @@ export interface ProviderDefinition {
47
55
  /** Link to the provider's own API-key docs, shown in the wizard. */
48
56
  docsUrl?: string;
49
57
  fields: ProviderCredentialField[];
58
+ /**
59
+ * Alternative credential sets, at least one of which must be complete —
60
+ * e.g. Bedrock takes an access key pair OR a Bedrock API key. Each inner
61
+ * list names field keys that are required together. Fields named here
62
+ * are `required: false` individually.
63
+ */
64
+ requiresOneOf?: string[][];
65
+ /** Shown above the fields: how requests name this provider's models. */
66
+ usageHint?: string;
50
67
  /** See module doc — whether packages/proxy currently routes to this provider. */
51
68
  routingLive: boolean;
52
69
  }
@@ -93,11 +110,31 @@ export declare const DEEPSEEK_API_MODEL_IDS: readonly ["deepseek-chat", "deepsee
93
110
  * against the Rust source; if the heuristic changes there, change it here in
94
111
  * the same commit.
95
112
  *
96
- * Order matters and matches the Rust exactly: claude → gemini → '/'
97
- * (OpenRouter's vendor/model namespacing — checked before the mistral
98
- * prefixes so "mistralai/..." routes to OpenRouter) → an exact DeepSeek API
99
- * id ({@link DEEPSEEK_API_MODEL_IDS}) → mistral prefixes → OpenAI as the
100
- * default arm.
113
+ * Order matters and matches the Rust exactly: a cloud prefix
114
+ * ({@link cloudProviderForModel}) → claude → gemini → '/' (OpenRouter's
115
+ * vendor/model namespacing — checked before the mistral prefixes so
116
+ * "mistralai/..." routes to OpenRouter) → an exact DeepSeek API id
117
+ * ({@link DEEPSEEK_API_MODEL_IDS}) → mistral prefixes → OpenAI as the
118
+ * default arm. A `config.yaml` model alias is not visible here: it lives in
119
+ * the proxy's own configuration.
120
+ */
121
+ export declare function inferProviderForModel(model: string): CloudProviderId | 'anthropic' | 'gemini' | 'openrouter' | 'deepseek' | 'mistral' | 'openai';
122
+ /** Registry ids of the providers the proxy reaches through its cloud adapters. */
123
+ export type CloudProviderId = 'bedrock' | 'vertex_ai' | 'azure_openai';
124
+ /**
125
+ * The cloud provider a `bedrock/`, `vertex/` (or `vertex_ai/`) or `azure/`
126
+ * model name routes to — `crate::cloud::parse_prefixed` in the proxy.
127
+ */
128
+ export declare function cloudProviderForModel(model: string): CloudProviderId | undefined;
129
+ /** Host suffixes a workspace's Azure endpoint may use — `AZURE_HOST_SUFFIXES` in the proxy. */
130
+ export declare const AZURE_ENDPOINT_HOST_SUFFIXES: readonly [".openai.azure.com", ".services.ai.azure.com", ".cognitiveservices.azure.com"];
131
+ /**
132
+ * The same checks the proxy applies when it reads a stored cloud credential
133
+ * (`cloud::config::from_workspace`), so a credential the proxy would refuse
134
+ * is refused when it is saved instead. Returns the reason, or `null`.
135
+ * Regions, locations and project ids become part of a hostname or URL path;
136
+ * the Azure endpoint is a host the gateway sends the key to, so it must be
137
+ * an Azure resource over TLS.
101
138
  */
102
- export declare function inferProviderForModel(model: string): 'anthropic' | 'gemini' | 'openrouter' | 'deepseek' | 'mistral' | 'openai';
139
+ export declare function checkCloudCredentialFields(providerId: string, values: Record<string, string>): string | null;
103
140
  //# sourceMappingURL=providers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../src/providers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,6DAA6D;AAC7D,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,UAAU,GAAG,UAAU,CAAA;AAEhE,MAAM,WAAW,uBAAuB;IACtC,iFAAiF;IACjF,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,iBAAiB,CAAA;IACvB,QAAQ,EAAE,OAAO,CAAA;IACjB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,kBAAkB;IACjC,yDAAyD;IACzD,EAAE,EAAE,MAAM,CAAA;IACV,WAAW,EAAE,MAAM,CAAA;IACnB,oEAAoE;IACpE,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,uBAAuB,EAAE,CAAA;IACjC,iFAAiF;IACjF,WAAW,EAAE,OAAO,CAAA;CACrB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,yBAAyB,4CAA6C,CAAA;AAEnF,eAAO,MAAM,iBAAiB,EAAE,kBAAkB,EAgGjD,CAAA;AAED,wBAAgB,qBAAqB,CAAC,EAAE,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS,CAEhF;AAED,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAErD;AAED;;;;;;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AgB,iBAAiB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAErD;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB,mEAAoE,CAAA;AAEvG;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,MAAM,GAEX,eAAe,GACf,WAAW,GACX,QAAQ,GACR,YAAY,GACZ,UAAU,GACV,SAAS,GACT,QAAQ,CAYX;AAED,kFAAkF;AAClF,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,WAAW,GAAG,cAAc,CAAA;AAEtE;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS,CAchF;AAED,+FAA+F;AAC/F,eAAO,MAAM,4BAA4B,0FAI/B,CAAA;AAIV;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,GAAG,IAAI,CAuC5G"}
package/dist/providers.js CHANGED
@@ -12,6 +12,11 @@
12
12
  * new provider's *field layout* is a data change here, not new code in
13
13
  * every place that touches credentials.
14
14
  *
15
+ * AWS Bedrock, Google Vertex AI and Azure OpenAI are routed by the proxy's
16
+ * `src/cloud` module: requests name them as `bedrock/<model id>`,
17
+ * `vertex/<model>` and `azure/<deployment>`, and the stored blob is the
18
+ * region/endpoint plus credential that module signs or authenticates with.
19
+ *
15
20
  * Deliberately NOT exhaustive — LiteLLM supports 100+ providers. This is a
16
21
  * representative slice spanning the shapes that actually differ (single
17
22
  * key, multi-field cloud credential, self-hosted endpoint, structured
@@ -20,21 +25,26 @@
20
25
  * of these shapes is adding one entry, not new plumbing.
21
26
  *
22
27
  * `routingLive: true` means `packages/proxy` actually forwards requests to
23
- * this provider today (`fetch_provider_credential` in `proxy.rs` knows its
24
- * field name). `routingLive: false` means the credential can be
25
- * pre-provisioned here, but nothing in the proxy calls it yet — routing
26
- * support is separate, real per-provider engineering (a new `Provider`
27
- * enum variant, `get_model_provider`, pricing in `pricing.rs`), not a
28
- * config change. The dashboard wizard must say so, not imply the key is
29
- * live the moment it's saved.
28
+ * this provider today: it has an upstream for it (`provider_from_wire_id` in
29
+ * `proxy.rs`, which a proxy test holds this flag to). Gemini models are served
30
+ * on the Messages, Chat Completions and Responses routes, through the
31
+ * Gemini API translation; the proxy refuses the native `/v1beta/models/…`
32
+ * route, whose model is named in the URL. `routingLive: false` means the
33
+ * credential can be pre-provisioned here, but nothing in the proxy calls it
34
+ * yet — routing support is separate, real per-provider engineering (a new
35
+ * `Provider` enum variant, `get_model_provider`, pricing in `pricing.rs`),
36
+ * not a config change. The dashboard wizard must say so, not imply the key
37
+ * is live the moment it's saved.
30
38
  *
31
39
  * @module
32
40
  */
33
41
  Object.defineProperty(exports, "__esModule", { value: true });
34
- exports.DEEPSEEK_API_MODEL_IDS = exports.PROVIDER_REGISTRY = exports.LIVE_ROUTING_PROVIDER_IDS = void 0;
42
+ exports.AZURE_ENDPOINT_HOST_SUFFIXES = exports.DEEPSEEK_API_MODEL_IDS = exports.PROVIDER_REGISTRY = exports.LIVE_ROUTING_PROVIDER_IDS = void 0;
35
43
  exports.getProviderDefinition = getProviderDefinition;
36
44
  exports.isKnownProviderId = isKnownProviderId;
37
45
  exports.inferProviderForModel = inferProviderForModel;
46
+ exports.cloudProviderForModel = cloudProviderForModel;
47
+ exports.checkCloudCredentialFields = checkCloudCredentialFields;
38
48
  /**
39
49
  * The 3 providers this system supported before this registry existed —
40
50
  * their storage format (`{provider}_api_key`, a flat string field) is
@@ -75,34 +85,45 @@ exports.PROVIDER_REGISTRY = [
75
85
  displayName: 'Google Gemini',
76
86
  docsUrl: 'https://aistudio.google.com/app/apikey',
77
87
  fields: [{ key: 'apiKey', label: 'API Key', type: 'password', required: true }],
78
- // The proxy resolves gemini-* models but forwards the request without
79
- // translating it to Gemini's generateContent format, so no request
80
- // succeeds. The key keeps its flat-field storage
81
- // (LIVE_ROUTING_PROVIDER_IDS), so a key saved now is the one the proxy
82
- // reads once Gemini routing ships.
83
- routingLive: false,
88
+ routingLive: true,
84
89
  },
85
90
  {
86
91
  id: 'azure_openai',
87
92
  displayName: 'Azure OpenAI',
88
- docsUrl: 'https://learn.microsoft.com/azure/ai-services/openai/how-to/create-resource',
93
+ docsUrl: 'https://learn.microsoft.com/azure/ai-foundry/openai/how-to/create-resource',
89
94
  fields: [
95
+ {
96
+ key: 'endpoint',
97
+ label: 'Resource Endpoint',
98
+ type: 'text',
99
+ required: true,
100
+ placeholder: 'https://your-resource.openai.azure.com',
101
+ helpText: 'An *.openai.azure.com, *.services.ai.azure.com or *.cognitiveservices.azure.com resource URL.',
102
+ },
90
103
  { key: 'apiKey', label: 'API Key', type: 'password', required: true },
91
- { key: 'endpoint', label: 'Resource Endpoint', type: 'text', required: true, placeholder: 'https://your-resource.openai.azure.com' },
92
- { key: 'deploymentName', label: 'Deployment Name', type: 'text', required: true },
93
104
  ],
94
- routingLive: false,
105
+ usageHint: 'Name a deployment as azure/<deployment> in the model field.',
106
+ routingLive: true,
95
107
  },
96
108
  {
97
109
  id: 'bedrock',
98
110
  displayName: 'AWS Bedrock',
99
111
  docsUrl: 'https://docs.aws.amazon.com/bedrock/latest/userguide/getting-started.html',
100
112
  fields: [
101
- { key: 'awsAccessKeyId', label: 'AWS Access Key ID', type: 'password', required: true },
102
- { key: 'awsSecretAccessKey', label: 'AWS Secret Access Key', type: 'password', required: true },
103
113
  { key: 'awsRegion', label: 'AWS Region', type: 'text', required: true, placeholder: 'us-east-1' },
114
+ { key: 'awsAccessKeyId', label: 'AWS Access Key ID', type: 'password', required: false },
115
+ { key: 'awsSecretAccessKey', label: 'AWS Secret Access Key', type: 'password', required: false },
116
+ {
117
+ key: 'apiKey',
118
+ label: 'Bedrock API Key',
119
+ type: 'password',
120
+ required: false,
121
+ helpText: 'Instead of an access key pair.',
122
+ },
104
123
  ],
105
- routingLive: false,
124
+ requiresOneOf: [['awsAccessKeyId', 'awsSecretAccessKey'], ['apiKey']],
125
+ usageHint: 'Name a model as bedrock/<model id>, e.g. bedrock/anthropic.claude-opus-4-7.',
126
+ routingLive: true,
106
127
  },
107
128
  {
108
129
  id: 'vertex_ai',
@@ -110,9 +131,11 @@ exports.PROVIDER_REGISTRY = [
110
131
  docsUrl: 'https://cloud.google.com/vertex-ai/docs/authentication',
111
132
  fields: [
112
133
  { key: 'projectId', label: 'GCP Project ID', type: 'text', required: true },
134
+ { key: 'location', label: 'Location', type: 'text', required: false, placeholder: 'global' },
113
135
  { key: 'serviceAccountJson', label: 'Service Account JSON', type: 'textarea', required: true, helpText: 'The full JSON key file contents for a service account with Vertex AI access.' },
114
136
  ],
115
- routingLive: false,
137
+ usageHint: 'Name a model as vertex/<model>, e.g. vertex/claude-sonnet-4-5@20250929 or vertex/gemini-2.5-pro.',
138
+ routingLive: true,
116
139
  },
117
140
  {
118
141
  id: 'cohere',
@@ -178,13 +201,18 @@ exports.DEEPSEEK_API_MODEL_IDS = ['deepseek-chat', 'deepseek-reasoner', 'deepsee
178
201
  * against the Rust source; if the heuristic changes there, change it here in
179
202
  * the same commit.
180
203
  *
181
- * Order matters and matches the Rust exactly: claude → gemini → '/'
182
- * (OpenRouter's vendor/model namespacing — checked before the mistral
183
- * prefixes so "mistralai/..." routes to OpenRouter) → an exact DeepSeek API
184
- * id ({@link DEEPSEEK_API_MODEL_IDS}) → mistral prefixes → OpenAI as the
185
- * default arm.
204
+ * Order matters and matches the Rust exactly: a cloud prefix
205
+ * ({@link cloudProviderForModel}) → claude → gemini → '/' (OpenRouter's
206
+ * vendor/model namespacing — checked before the mistral prefixes so
207
+ * "mistralai/..." routes to OpenRouter) → an exact DeepSeek API id
208
+ * ({@link DEEPSEEK_API_MODEL_IDS}) → mistral prefixes → OpenAI as the
209
+ * default arm. A `config.yaml` model alias is not visible here: it lives in
210
+ * the proxy's own configuration.
186
211
  */
187
212
  function inferProviderForModel(model) {
213
+ const cloud = cloudProviderForModel(model);
214
+ if (cloud)
215
+ return cloud;
188
216
  const m = model.toLowerCase();
189
217
  if (m.includes('claude'))
190
218
  return 'anthropic';
@@ -199,4 +227,80 @@ function inferProviderForModel(model) {
199
227
  }
200
228
  return 'openai';
201
229
  }
230
+ /**
231
+ * The cloud provider a `bedrock/`, `vertex/` (or `vertex_ai/`) or `azure/`
232
+ * model name routes to — `crate::cloud::parse_prefixed` in the proxy.
233
+ */
234
+ function cloudProviderForModel(model) {
235
+ const slash = model.indexOf('/');
236
+ if (slash <= 0 || model.slice(slash + 1).trim() === '')
237
+ return undefined;
238
+ switch (model.slice(0, slash).toLowerCase()) {
239
+ case 'bedrock':
240
+ return 'bedrock';
241
+ case 'vertex':
242
+ case 'vertex_ai':
243
+ return 'vertex_ai';
244
+ case 'azure':
245
+ return 'azure_openai';
246
+ default:
247
+ return undefined;
248
+ }
249
+ }
250
+ /** Host suffixes a workspace's Azure endpoint may use — `AZURE_HOST_SUFFIXES` in the proxy. */
251
+ exports.AZURE_ENDPOINT_HOST_SUFFIXES = [
252
+ '.openai.azure.com',
253
+ '.services.ai.azure.com',
254
+ '.cognitiveservices.azure.com',
255
+ ];
256
+ const CLOUD_NAME = /^[a-z0-9][a-z0-9-]{0,31}$/;
257
+ /**
258
+ * The same checks the proxy applies when it reads a stored cloud credential
259
+ * (`cloud::config::from_workspace`), so a credential the proxy would refuse
260
+ * is refused when it is saved instead. Returns the reason, or `null`.
261
+ * Regions, locations and project ids become part of a hostname or URL path;
262
+ * the Azure endpoint is a host the gateway sends the key to, so it must be
263
+ * an Azure resource over TLS.
264
+ */
265
+ function checkCloudCredentialFields(providerId, values) {
266
+ switch (providerId) {
267
+ case 'bedrock':
268
+ return CLOUD_NAME.test(values.awsRegion ?? '') ? null : 'AWS Region must be a region name such as us-east-1';
269
+ case 'vertex_ai': {
270
+ if (!/^[a-z0-9-]{1,64}$/.test(values.projectId ?? ''))
271
+ return 'GCP Project ID must be a project id or number';
272
+ if (values.location !== undefined && !CLOUD_NAME.test(values.location)) {
273
+ return 'Location must be a location name such as us-east5 or global';
274
+ }
275
+ let doc;
276
+ try {
277
+ doc = JSON.parse(values.serviceAccountJson ?? '');
278
+ }
279
+ catch {
280
+ return 'Service Account JSON is not valid JSON';
281
+ }
282
+ const type = doc?.type;
283
+ return type === 'service_account' || type === 'authorized_user'
284
+ ? null
285
+ : 'Service Account JSON must be a service_account (or authorized_user) credential file';
286
+ }
287
+ case 'azure_openai': {
288
+ let url;
289
+ try {
290
+ url = new URL(values.endpoint ?? '');
291
+ }
292
+ catch {
293
+ return 'Resource Endpoint must be a URL';
294
+ }
295
+ const host = url.hostname.toLowerCase();
296
+ const label = exports.AZURE_ENDPOINT_HOST_SUFFIXES.map((sfx) => (host.endsWith(sfx) ? host.slice(0, -sfx.length) : null)).find((l) => l !== null);
297
+ const ok = url.protocol === 'https:' && url.port === '' && url.username === '' && !!label && /^[a-z0-9-]+$/.test(label);
298
+ return ok
299
+ ? null
300
+ : 'Resource Endpoint must be https://<resource>.openai.azure.com, .services.ai.azure.com or .cognitiveservices.azure.com';
301
+ }
302
+ default:
303
+ return null;
304
+ }
305
+ }
202
306
  //# sourceMappingURL=providers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"providers.js","sourceRoot":"","sources":["../src/providers.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;;;AAiJH,sDAEC;AAED,8CAEC;AA6BD,sDAYC;AAtKD;;;;;;;;;;;;;;;;;;GAkBG;AACU,QAAA,yBAAyB,GAAG,CAAC,WAAW,EAAE,QAAQ,EAAE,QAAQ,CAAU,CAAA;AAEtE,QAAA,iBAAiB,GAAyB;IACrD;QACE,EAAE,EAAE,WAAW;QACf,WAAW,EAAE,WAAW;QACxB,OAAO,EAAE,6CAA6C;QACtD,MAAM,EAAE,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,UAAU,EAAE,Q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 * virtual key or one member may run up per day or per month, and how many
4
+ * requests and tokens a virtual key may send per minute.
5
+ *
6
+ * A budget is `hard` or `soft`. The LLM proxy refuses a request that a hard
7
+ * budget's remainder does not cover (`BUDGET_EXCEEDED`, 429, before the
8
+ * request leaves); a soft budget never refuses. Both raise the workspace's
9
+ * budget alerts — once at the alert threshold and once at the limit, per
10
+ * period — as `finops.budget.threshold` / `finops.budget.exceeded`.
11
+ *
12
+ * Periods are fixed UTC windows, like MCP call budgets (`mcpBudgets.ts`): a
13
+ * day starts at 00:00 UTC, a month on the 1st at 00:00 UTC. The window id is
14
+ * part of every per-key and per-member spend counter's Valkey key, so a new
15
+ * day or month starts from zero and an old counter expires on its own.
16
+ *
17
+ * Spend is what the control plane records per completed call
18
+ * (`finopsService.incrementSpend`), so a request's own cost lands after it
19
+ * finishes: the proxy checks a hard budget against the spend recorded so far
20
+ * plus the request's estimated cost, with the same 20% margin the workspace
21
+ * cap has always used.
22
+ *
23
+ * @module
24
+ */
25
+ import { z } from 'zod';
26
+ /** A budget's period: a UTC calendar day or a UTC calendar month. */
27
+ export type SpendBudgetPeriod = 'day' | 'month';
28
+ /** `hard` refuses requests the remainder does not cover; `soft` only alerts. */
29
+ export type SpendBudgetEnforcement = 'hard' | 'soft';
30
+ /**
31
+ * Whose spend a budget limits:
32
+ * - `workspace` every call in the workspace (Settings › Billing › Budget Limits);
33
+ * - `key` the calls one virtual key makes;
34
+ * - `member` the calls made with the virtual keys one member owns.
35
+ */
36
+ export type SpendBudgetScope = 'workspace' | 'key' | 'member';
37
+ export interface SpendBudget {
38
+ period: SpendBudgetPeriod;
39
+ limitUsd: number;
40
+ enforcement: SpendBudgetEnforcement;
41
+ }
42
+ export declare const SPEND_BUDGET_PERIODS: readonly SpendBudgetPeriod[];
43
+ export declare const SPEND_BUDGET_SCOPES: readonly SpendBudgetScope[];
44
+ export declare const MAX_SPEND_BUDGET_USD = 1000000;
45
+ /**
46
+ * The member budget that applies to every member without one of their own,
47
+ * period by period. A member's own day budget replaces the default day
48
+ * budget; the default month budget still applies to them unless they have a
49
+ * month budget too.
50
+ */
51
+ export declare const MEMBER_BUDGET_DEFAULT = "default";
52
+ export declare const SpendBudgetSchema: z.ZodObject<{
53
+ period: z.ZodEnum<["day", "month"]>;
54
+ limitUsd: z.ZodNumber;
55
+ enforcement: z.ZodDefault<z.ZodEnum<["hard", "soft"]>>;
56
+ }, "strict", z.ZodTypeAny, {
57
+ period: "day" | "month";
58
+ limitUsd: number;
59
+ enforcement: "hard" | "soft";
60
+ }, {
61
+ period: "day" | "month";
62
+ limitUsd: number;
63
+ enforcement?: "hard" | "soft" | undefined;
64
+ }>;
65
+ /** One budget per period at most: a key or member has a day budget, a month budget, both or neither. */
66
+ export declare const SpendBudgetListSchema: z.ZodEffects<z.ZodArray<z.ZodObject<{
67
+ period: z.ZodEnum<["day", "month"]>;
68
+ limitUsd: z.ZodNumber;
69
+ enforcement: z.ZodDefault<z.ZodEnum<["hard", "soft"]>>;
70
+ }, "strict", z.ZodTypeAny, {
71
+ period: "day" | "month";
72
+ limitUsd: number;
73
+ enforcement: "hard" | "soft";
74
+ }, {
75
+ period: "day" | "month";
76
+ limitUsd: number;
77
+ enforcement?: "hard" | "soft" | undefined;
78
+ }>, "many">, {
79
+ period: "day" | "month";
80
+ limitUsd: number;
81
+ enforcement: "hard" | "soft";
82
+ }[], {
83
+ period: "day" | "month";
84
+ limitUsd: number;
85
+ enforcement?: "hard" | "soft" | undefined;
86
+ }[]>;
87
+ /** Requests and tokens one virtual key may send per minute; `null` (or absent) means no limit. */
88
+ export interface KeyRateLimit {
89
+ rpm: number | null;
90
+ tpm: number | null;
91
+ }
92
+ export declare const MAX_KEY_RPM = 100000;
93
+ export declare const MAX_KEY_TPM = 100000000;
94
+ export declare const KeyRateLimitSchema: z.ZodObject<{
95
+ rpm: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
96
+ tpm: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
97
+ }, "strict", z.ZodTypeAny, {
98
+ rpm?: number | null | undefined;
99
+ tpm?: number | null | undefined;
100
+ }, {
101
+ rpm?: number | null | undefined;
102
+ tpm?: number | null | undefined;
103
+ }>;
104
+ /**
105
+ * One hard budget as the proxy reads it from a virtual key's cached auth
106
+ * entry (`hardBudgets`) and from `GET /api/v1/auth/key-context`. Soft budgets
107
+ * are not sent: the proxy never refuses on one.
108
+ */
109
+ export interface HardBudgetWire {
110
+ scope: SpendBudgetScope;
111
+ period: SpendBudgetPeriod;
112
+ limitUsd: number;
113
+ }
114
+ /** The UTC window a moment falls in: its id (part of the counter key), when it began and when it resets. */
115
+ export declare function spendBudgetWindow(period: SpendBudgetPeriod, nowMs: number): {
116
+ id: string;
117
+ startMs: number;
118
+ resetAtMs: number;
119
+ };
120
+ /** A budget in words, for alerts, refusals and the dashboard. */
121
+ export declare function describeSpendBudget(scope: SpendBudgetScope, budget: SpendBudget, subjectLabel?: string): string;
122
+ //# sourceMappingURL=spendBudgets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spendBudgets.d.ts","sourceRoot":"","sources":["../src/spendBudgets.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,qEAAqE;AACrE,MAAM,MAAM,iBAAiB,GAAG,KAAK,GAAG,OAAO,CAAA;AAE/C,gFAAgF;AAChF,MAAM,MAAM,sBAAsB,GAAG,MAAM,GAAG,MAAM,CAAA;AAEpD;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GAAG,WAAW,GAAG,KAAK,GAAG,QAAQ,CAAA;AAE7D,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,iBAAiB,CAAA;IACzB,QAAQ,EAAE,MAAM,CAAA;IAChB,WAAW,EAAE,sBAAsB,CAAA;CACpC;AAED,eAAO,MAAM,oBAAoB,EAAE,SAAS,iBAAiB,EAAqB,CAAA;AAClF,eAAO,MAAM,mBA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