@juspay/neurolink 12.12.14 → 12.12.16

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.
@@ -139,7 +139,67 @@ export class AmazonSageMakerProvider extends BaseProvider {
139
139
  if (!hasNativeDoGenerate(model)) {
140
140
  throw this.handleProviderError(new Error("sagemaker: model handle exposes no doGenerate()"));
141
141
  }
142
- const doGenerate = model.doGenerate.bind(model);
142
+ const doGenerate = async (call) => {
143
+ const format = call.responseFormat;
144
+ const result = await model.doGenerate({
145
+ ...call,
146
+ ...(call.maxOutputTokens !== undefined
147
+ ? { maxTokens: call.maxOutputTokens }
148
+ : {}),
149
+ ...(format?.type === "json"
150
+ ? {
151
+ responseFormat: format.schema
152
+ ? {
153
+ type: "json_schema",
154
+ json_schema: { name: "response", schema: format.schema },
155
+ }
156
+ : { type: "json_object" },
157
+ }
158
+ : {}),
159
+ });
160
+ // SageMaker's low-level model retains its legacy result for streaming
161
+ // and direct consumers. The shared loop consumes V3 content and usage.
162
+ if (Array.isArray(result.content)) {
163
+ return result;
164
+ }
165
+ const content = [];
166
+ if (typeof result.text === "string" && result.text) {
167
+ content.push({ type: "text", text: result.text });
168
+ }
169
+ if (typeof result.reasoning === "string" && result.reasoning) {
170
+ content.push({ type: "reasoning", text: result.reasoning });
171
+ }
172
+ for (const call of Array.isArray(result.toolCalls)
173
+ ? result.toolCalls
174
+ : []) {
175
+ if (typeof call !== "object" || call === null) {
176
+ continue;
177
+ }
178
+ const item = call;
179
+ const fn = item.function;
180
+ if (typeof item.id === "string" && typeof fn?.name === "string") {
181
+ content.push({
182
+ type: "tool-call",
183
+ toolCallId: item.id,
184
+ toolName: fn.name,
185
+ input: fn.arguments ?? "{}",
186
+ });
187
+ }
188
+ }
189
+ const usage = result.usage;
190
+ return {
191
+ ...result,
192
+ content,
193
+ usage: {
194
+ inputTokens: {
195
+ total: typeof usage?.inputTokens === "number" ? usage.inputTokens : 0,
196
+ },
197
+ outputTokens: {
198
+ total: typeof usage?.outputTokens === "number" ? usage.outputTokens : 0,
199
+ },
200
+ },
201
+ };
202
+ };
143
203
  const shouldUseTools = !options.disableTools && this.supportsTools();
144
204
  const toolsRecord = shouldUseTools
145
205
  ? options.tools || {}
@@ -399,8 +399,8 @@ export class SageMakerLanguageModel {
399
399
  ...(options.maxTokens !== undefined
400
400
  ? { max_new_tokens: options.maxTokens }
401
401
  : {}),
402
- temperature: options.temperature || 0.7,
403
- top_p: options.topP || 0.9,
402
+ temperature: options.temperature ?? 0.7,
403
+ top_p: options.topP ?? 0.9,
404
404
  stop: options.stopSequences || [],
405
405
  },
406
406
  };
@@ -582,9 +582,14 @@ export class SageMakerLanguageModel {
582
582
  // Handle response with tool calls
583
583
  if (responseBody.choices && Array.isArray(responseBody.choices)) {
584
584
  const choice = responseBody.choices[0];
585
- if (choice?.message?.content) {
585
+ if (typeof choice?.message?.content === "string") {
586
586
  return choice.message.content;
587
587
  }
588
+ // A tool-only assistant turn has no text. Serializing the entire
589
+ // endpoint response here would replay its envelope as assistant prose.
590
+ if (choice?.message?.tool_calls?.length) {
591
+ return "";
592
+ }
588
593
  }
589
594
  // Fallback: stringify the entire response
590
595
  return JSON.stringify(responseBody);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juspay/neurolink",
3
- "version": "12.12.14",
3
+ "version": "12.12.16",
4
4
  "packageManager": "pnpm@10.15.1",
5
5
  "description": "TypeScript AI SDK with 24+ LLM providers behind one consistent API. MCP-native (connect any MCP server), voice TTS/STT/realtime, RAG, agents, memory, context compaction. OpenAI · Anthropic · Gemini · Bedrock · Azure · Ollama · DeepSeek · NVIDIA NIM and more.",
6
6
  "author": {
@@ -394,11 +394,11 @@
394
394
  "eventsource-parser": "^3.0.8",
395
395
  "fast-xml-parser": "^5.7.0",
396
396
  "google-auth-library": "^10.6.1",
397
- "hono": "^4.12.34",
397
+ "hono": "^4.13.5",
398
398
  "iconv-lite": "0.7.2",
399
399
  "inquirer": "^13.3.0",
400
400
  "jose": "^6.1.3",
401
- "js-yaml": "^4.3.1",
401
+ "js-yaml": "^4.3.2",
402
402
  "json-schema-to-zod": "^2.7.0",
403
403
  "jsonrepair": "^3.14.0",
404
404
  "minisearch": "^7.2.0",
@@ -621,8 +621,8 @@
621
621
  "undici@>=7.0.0 <7.24.0": ">=7.24.0 <8.0.0",
622
622
  "undici@>=6.0.0 <6.23.0": ">=6.23.0",
623
623
  "undici@<5.29.0": ">=5.29.0",
624
- "js-yaml@>=4.0.0 <4.1.1": ">=4.1.1",
625
- "js-yaml@>=3.0.0 <3.14.2": ">=3.14.2",
624
+ "js-yaml@>=4.0.0 <4.3.2": ">=4.3.2",
625
+ "js-yaml@>=3.0.0 <3.15.2": ">=3.15.2",
626
626
  "ajv@>=8.0.0 <8.18.0": ">=8.18.0",
627
627
  "@grpc/grpc-js@<1.14.4": ">=1.14.4",
628
628
  "@protobufjs/utf8@<1.1.1": ">=1.1.1",