@juspay/neurolink 9.67.3 → 9.68.1

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.
@@ -318,6 +318,45 @@ export const mapNeuroLinkToolChoice = (choice) => {
318
318
  }
319
319
  return undefined;
320
320
  };
321
+ // OpenAI-compatible endpoints (OpenAI, DeepSeek, …) reject
322
+ // `response_format: { type: "json_object" }` unless the literal word "json"
323
+ // appears somewhere in the messages. The `@ai-sdk/openai-compatible` wrapper
324
+ // this client replaced injected that instruction for us; the native client
325
+ // must do the same or json_object requests 400.
326
+ export const messagesContainJsonWord = (messages) => messages.some((m) => {
327
+ const c = m.content;
328
+ if (typeof c === "string") {
329
+ return /\bjson\b/i.test(c);
330
+ }
331
+ if (Array.isArray(c)) {
332
+ return c.some((part) => typeof part?.text === "string" &&
333
+ /\bjson\b/i.test(part.text));
334
+ }
335
+ return false;
336
+ });
337
+ // Prepends a minimal JSON-instruction system message to the FINAL wire body
338
+ // when json_object mode is requested and its messages don't already mention
339
+ // "json". Operates on the post-`adjustRequestBody` body so the guard reflects
340
+ // whatever a subclass left on the wire (response_format/messages it may have
341
+ // rewritten), not an intermediate state. No-op otherwise.
342
+ export const ensureJsonWordInBody = (body) => body.response_format?.type === "json_object" &&
343
+ !messagesContainJsonWord(body.messages)
344
+ ? {
345
+ ...body,
346
+ messages: [
347
+ {
348
+ role: "system",
349
+ content: "Respond with valid JSON only — no prose, no markdown fencing.",
350
+ },
351
+ ...body.messages,
352
+ ],
353
+ }
354
+ : body;
355
+ // Reasoning-class OpenAI models (o-series, gpt-5+) reject `max_tokens` and
356
+ // require `max_completion_tokens`. The OpenAI + Azure providers use this to
357
+ // rename the field on the wire body; third-party OpenAI-compatible endpoints
358
+ // keep `max_tokens`, so it is opt-in per provider, never applied by default.
359
+ export const requiresMaxCompletionTokens = (modelId) => /^(o\d|gpt-5)/i.test(modelId.replace(/^.*\//, ""));
321
360
  export const buildBody = (args) => {
322
361
  const { modelId, messages, options, tools, toolChoice, streaming, responseFormat, } = args;
323
362
  const body = {
@@ -212,7 +212,6 @@ export type StreamLoopArgs = {
212
212
  maxSteps: number;
213
213
  modelId: string;
214
214
  url: string;
215
- apiKey: string;
216
215
  fetchImpl: typeof fetch;
217
216
  abortSignal: AbortSignal | undefined;
218
217
  options: StreamOptions;
@@ -125,6 +125,7 @@ export type NeurolinkCredentials = {
125
125
  resourceName?: string;
126
126
  deploymentName?: string;
127
127
  apiVersion?: string;
128
+ useMaxCompletionTokens?: boolean;
128
129
  };
129
130
  mistral?: {
130
131
  apiKey?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juspay/neurolink",
3
- "version": "9.67.3",
3
+ "version": "9.68.1",
4
4
  "packageManager": "pnpm@10.15.1",
5
5
  "description": "Universal AI Development Platform with working MCP integration, multi-provider support, voice (TTS/STT/realtime), and professional CLI. 58+ external MCP servers discoverable, multimodal file processing, RAG pipelines. Build, test, and deploy AI applications with 21+ providers: OpenAI, Anthropic, Google AI Studio, Google Vertex, AWS Bedrock, Azure OpenAI, Mistral, LiteLLM, SageMaker, Hugging Face, Ollama, OpenAI-compatible, OpenRouter, DeepSeek, NVIDIA NIM, LM Studio, llama.cpp, plus voice (OpenAI TTS, ElevenLabs, Deepgram, Azure Speech).",
6
6
  "author": {