@juspay/neurolink 9.58.0 → 9.59.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/CHANGELOG.md +6 -0
- package/dist/browser/neurolink.min.js +314 -314
- package/dist/lib/neurolink.d.ts +34 -0
- package/dist/lib/neurolink.js +89 -1
- package/dist/lib/providers/litellm.js +12 -1
- package/dist/lib/providers/openAI.js +19 -2
- package/dist/lib/types/errors.d.ts +42 -0
- package/dist/lib/types/errors.js +94 -0
- package/dist/neurolink.d.ts +34 -0
- package/dist/neurolink.js +89 -1
- package/dist/providers/litellm.js +12 -1
- package/dist/providers/openAI.js +19 -2
- package/dist/types/errors.d.ts +42 -0
- package/dist/types/errors.js +94 -0
- package/package.json +1 -1
package/dist/types/errors.js
CHANGED
|
@@ -165,3 +165,97 @@ export class ModelAccessError extends BaseError {
|
|
|
165
165
|
this.requiredTier = requiredTier;
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
|
+
/**
|
|
169
|
+
* Curator P1-1: thrown when a provider rejects a request because the
|
|
170
|
+
* caller's team / API key is not whitelisted for the requested model.
|
|
171
|
+
*
|
|
172
|
+
* LiteLLM's `team not allowed to access model. This team can only access
|
|
173
|
+
* models=['glm-latest', 'kimi-latest', ...]` is the canonical example —
|
|
174
|
+
* the list is parsed off the error body so callers / fallback orchestrators
|
|
175
|
+
* can choose a whitelisted alternative without scraping strings.
|
|
176
|
+
*/
|
|
177
|
+
export class ModelAccessDeniedError extends ProviderError {
|
|
178
|
+
requestedModel;
|
|
179
|
+
allowedModels;
|
|
180
|
+
code = "MODEL_ACCESS_DENIED";
|
|
181
|
+
constructor(message, options = {}) {
|
|
182
|
+
super(message, options.provider);
|
|
183
|
+
this.name = "ModelAccessDeniedError";
|
|
184
|
+
this.requestedModel = options.requestedModel;
|
|
185
|
+
this.allowedModels = options.allowedModels;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
/** Maximum body length we'll attempt to parse. Real provider error
|
|
189
|
+
* bodies are well under 10 KB; longer inputs are either truncated
|
|
190
|
+
* log output or a deliberate ReDoS attempt. */
|
|
191
|
+
const MAX_ALLOWED_MODELS_INPUT = 10_000;
|
|
192
|
+
/**
|
|
193
|
+
* Parse the `allowed_models` array out of a provider error message body.
|
|
194
|
+
* Currently targets the LiteLLM team-whitelist response shape:
|
|
195
|
+
*
|
|
196
|
+
* "team not allowed to access model. This team can only access
|
|
197
|
+
* models=['glm-latest', 'kimi-latest', 'open-large']"
|
|
198
|
+
*
|
|
199
|
+
* Implementation note: deliberately uses `indexOf`/`slice` instead of a
|
|
200
|
+
* single `/models\s*=\s*\[([^\]]*)\]/` regex. CodeQL flagged the latter
|
|
201
|
+
* as `js/polynomial-redos` because the `[^\]]*` greedy quantifier on
|
|
202
|
+
* library-supplied input can be exploited by a crafted long string. The
|
|
203
|
+
* indexOf/slice path is O(n) with no backtracking and we additionally
|
|
204
|
+
* cap the input length.
|
|
205
|
+
*
|
|
206
|
+
* Returns undefined when no list is found.
|
|
207
|
+
*/
|
|
208
|
+
export function parseAllowedModels(message) {
|
|
209
|
+
if (typeof message !== "string" || message.length === 0) {
|
|
210
|
+
return undefined;
|
|
211
|
+
}
|
|
212
|
+
if (message.length > MAX_ALLOWED_MODELS_INPUT) {
|
|
213
|
+
return undefined;
|
|
214
|
+
}
|
|
215
|
+
// Locate `models` keyword case-insensitively, then walk forward to
|
|
216
|
+
// confirm `=` and `[` markers — no regex backtracking.
|
|
217
|
+
const lower = message.toLowerCase();
|
|
218
|
+
let idx = lower.indexOf("models", 0);
|
|
219
|
+
while (idx !== -1) {
|
|
220
|
+
let cursor = idx + "models".length;
|
|
221
|
+
// Skip whitespace
|
|
222
|
+
while (cursor < message.length && /\s/.test(message[cursor])) {
|
|
223
|
+
cursor++;
|
|
224
|
+
}
|
|
225
|
+
if (message[cursor] !== "=") {
|
|
226
|
+
idx = lower.indexOf("models", idx + 1);
|
|
227
|
+
continue;
|
|
228
|
+
}
|
|
229
|
+
cursor++;
|
|
230
|
+
while (cursor < message.length && /\s/.test(message[cursor])) {
|
|
231
|
+
cursor++;
|
|
232
|
+
}
|
|
233
|
+
if (message[cursor] !== "[") {
|
|
234
|
+
idx = lower.indexOf("models", idx + 1);
|
|
235
|
+
continue;
|
|
236
|
+
}
|
|
237
|
+
const open = cursor;
|
|
238
|
+
const close = message.indexOf("]", open + 1);
|
|
239
|
+
if (close === -1) {
|
|
240
|
+
return undefined;
|
|
241
|
+
}
|
|
242
|
+
const inside = message.slice(open + 1, close);
|
|
243
|
+
const items = inside
|
|
244
|
+
.split(",")
|
|
245
|
+
.map((s) => s.trim().replace(/^['"]|['"]$/g, ""))
|
|
246
|
+
.filter((s) => s.length > 0);
|
|
247
|
+
return items.length > 0 ? items : undefined;
|
|
248
|
+
}
|
|
249
|
+
return undefined;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Returns true when `message` looks like a model-access-denied response
|
|
253
|
+
* (LiteLLM "team not allowed", generic "not allowed to access model",
|
|
254
|
+
* or "team can only access models=[...]").
|
|
255
|
+
*/
|
|
256
|
+
export function isModelAccessDeniedMessage(message) {
|
|
257
|
+
const lower = message.toLowerCase();
|
|
258
|
+
return ((lower.includes("team") && lower.includes("not allowed")) ||
|
|
259
|
+
lower.includes("team can only access") ||
|
|
260
|
+
/not\s+allowed\s+to\s+access\s+(this\s+)?model/i.test(message));
|
|
261
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juspay/neurolink",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.59.0",
|
|
4
4
|
"packageManager": "pnpm@10.15.1",
|
|
5
5
|
"description": "Universal AI Development Platform with working MCP integration, multi-provider support, and professional CLI. Built-in tools operational, 58+ external MCP servers discoverable. Connect to filesystem, GitHub, database operations, and more. Build, test, and deploy AI applications with 13 providers: OpenAI, Anthropic, Google AI, AWS Bedrock, Azure, Hugging Face, Ollama, and Mistral AI.",
|
|
6
6
|
"author": {
|