@juspay/neurolink 12.28.0 → 12.28.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.
@@ -8,7 +8,7 @@ import { CONVERSATION_INSTRUCTIONS, STRUCTURED_OUTPUT_INSTRUCTIONS, } from "../c
8
8
  import { getAvailableInputTokens } from "../constants/contextWindows.js";
9
9
  import { PDF_LIMITS } from "../core/constants.js";
10
10
  import { enforceAggregateFileBudget, FILE_READ_BUDGET_PERCENT, } from "../context/fileTokenBudget.js";
11
- import { isCSVContent, SIZE_TIER_THRESHOLDS } from "../types/index.js";
11
+ import { isCSVContent, isTextContent, SIZE_TIER_THRESHOLDS, } from "../types/index.js";
12
12
  import { tracers, ATTR, withSpan } from "../telemetry/index.js";
13
13
  import { needsVisionTranscode, toVisionCompatibleImage, } from "../adapters/imageFormatSupport.js";
14
14
  import { FILE_TYPE_REGISTRY, lookupByExtension, } from "../processors/config/fileTypeRegistry.js";
@@ -1405,6 +1405,20 @@ export async function buildMultimodalMessagesArray(options, provider, model) {
1405
1405
  supportsNativeVideo(provider, model);
1406
1406
  // If no images, PDFs, audio or video, use standard message building and convert to MultimodalChatMessage[]
1407
1407
  if (!hasImages && !hasPDFs && !hasNativeAudio && !hasNativeVideo) {
1408
+ // A `content: [{type: "text", ...}]` item never reaches
1409
+ // convertContentToProviderFormat on this branch (that only runs for the
1410
+ // multimodal path below), and buildMessagesArray only ever reads
1411
+ // inp.text/options.prompt — so without this fold, every TextContent item
1412
+ // in `content[]` was silently dropped whenever the request carried no
1413
+ // image, PDF, native audio or native video. Fold them into inp.text first
1414
+ // (same append-and-preserve-order shape as the CSV fold immediately
1415
+ // below), so ordinary text-only requests behave the same as the
1416
+ // multimodal path, which already reads its (first) text item out of
1417
+ // `content[]`.
1418
+ const textContentItems = inp.content?.filter(isTextContent) ?? [];
1419
+ if (textContentItems.length > 0) {
1420
+ inp.text = appendTextContentToText(textContentItems, inp.text ?? "");
1421
+ }
1408
1422
  // #289: CSV content[] items don't need vision, so they never reach the
1409
1423
  // multimodal converter below — process them into the prompt text here
1410
1424
  // (otherwise a `content: [{type:"csv"}]`-only request silently drops it).
@@ -1562,6 +1576,23 @@ export async function buildMultimodalMessagesArray(options, provider, model) {
1562
1576
  throw error;
1563
1577
  }
1564
1578
  }
1579
+ /**
1580
+ * Fold TextContent `content[]` items into the prompt text, in the order they
1581
+ * appear, on the text-only path (no image/PDF/native-audio, so
1582
+ * convertContentToProviderFormat's own text handling never runs). Mirrors
1583
+ * appendCsvContentToText's append-after-base-text shape; unlike CSV this
1584
+ * needs no async decoding, just string concatenation.
1585
+ */
1586
+ function appendTextContentToText(textItems, baseText) {
1587
+ let text = baseText;
1588
+ for (const item of textItems) {
1589
+ if (!item.text) {
1590
+ continue;
1591
+ }
1592
+ text += `${text ? "\n\n" : ""}${item.text}`;
1593
+ }
1594
+ return text;
1595
+ }
1565
1596
  /**
1566
1597
  * Timeout for detecting/parsing an in-memory CSV `content[]` buffer (#325
1567
1598
  * review, round 2). Bounds a stalled detector rather than blocking the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juspay/neurolink",
3
- "version": "12.28.0",
3
+ "version": "12.28.1",
4
4
  "packageManager": "pnpm@10.15.1",
5
5
  "description": "The pipe layer of an AI nervous system: one interface connecting provider neurons to your application, across three inference types — generate, stream and decide. `decide` returns typed, calibrated judgements from a non-generative model (~400ms, ~$0.00002/call) for routing, tool selection and context budgeting. MCP-native (4 transports), voice TTS/STT/realtime, RAG, agents, memory, compaction, 9 observability exporters. OpenAI · Anthropic · Gemini · Bedrock · Azure · Ollama · TypeSafe Jev and more.",
6
6
  "author": {
@@ -96,6 +96,7 @@
96
96
  "test:media-registry-collisions": "pnpm exec tsx test/continuous-test-suite-media-registry-collisions.ts",
97
97
  "test:memory": "pnpm exec tsx test/continuous-test-suite-memory.ts",
98
98
  "test:multimodal-rag": "pnpm exec tsx test/continuous-test-suite-multimodal-rag.ts",
99
+ "test:multimodal-text-content-fold": "pnpm exec tsx test/continuous-test-suite-multimodal-text-content-fold.ts",
99
100
  "test:proxy-sharing": "pnpm run build && pnpm exec tsx test/continuous-test-suite-proxy-sharing.ts",
100
101
  "test:openai-compat-streaming-retry": "pnpm exec tsx test/continuous-test-suite-openai-compat-streaming-retry.ts",
101
102
  "test:anthropic-streaming-retry": "pnpm exec tsx test/continuous-test-suite-anthropic-streaming-retry.ts",