@juspay/neurolink 12.14.11 → 12.14.13
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 +2 -2
- package/dist/browser/neurolink.min.js +192 -192
- package/dist/providers/amazonBedrock/client.js +37 -4
- package/package.json +1 -1
|
@@ -4,6 +4,8 @@ import { createAnalytics } from "../../core/analytics.js";
|
|
|
4
4
|
import { BaseProvider } from "../../core/baseProvider.js";
|
|
5
5
|
import { DEFAULT_MAX_STEPS } from "../../core/constants.js";
|
|
6
6
|
import { runAgenticLoop } from "../../core/loopEngine.js";
|
|
7
|
+
import { resolveToolExecutionRecords } from "../../core/toolExecutionRecorder.js";
|
|
8
|
+
import { transformToolExecutions } from "../../utils/transformationUtils.js";
|
|
7
9
|
import { createBedrockLoopAdapter } from "./loopAdapter.js";
|
|
8
10
|
import { AuthenticationError, ProviderError, RateLimitError, } from "../../types/index.js";
|
|
9
11
|
import { classifyProviderError } from "../../utils/errorClassifier.js";
|
|
@@ -183,10 +185,19 @@ export class AmazonBedrockProvider extends BaseProvider {
|
|
|
183
185
|
}
|
|
184
186
|
else {
|
|
185
187
|
logger.debug(`[AmazonBedrockProvider] Text-only input in generate(), using simple message builder`);
|
|
186
|
-
// Add user message to conversation - simple text-only case
|
|
188
|
+
// Add user message to conversation - simple text-only case.
|
|
189
|
+
// The public generate contract accepts either `prompt` or `input.text`
|
|
190
|
+
// (see BaseProvider); reading only `prompt` here sent an empty user
|
|
191
|
+
// message whenever a caller used the `input.text` shape.
|
|
192
|
+
//
|
|
193
|
+
// `||`, not `??`, to match the canonical resolution in
|
|
194
|
+
// `Utilities.normalizeTextOptions`. This provider overrides `generate()`
|
|
195
|
+
// outright, so normalization never runs and the caller's raw options
|
|
196
|
+
// land here — an empty `prompt` must fall through to `input.text`
|
|
197
|
+
// rather than win by virtue of not being nullish.
|
|
187
198
|
const userMessage = {
|
|
188
199
|
role: "user",
|
|
189
|
-
content: [{ text: options.prompt }],
|
|
200
|
+
content: [{ text: options.prompt || input?.text || "" }],
|
|
190
201
|
};
|
|
191
202
|
this.conversationHistory.push(userMessage);
|
|
192
203
|
}
|
|
@@ -196,8 +207,9 @@ export class AmazonBedrockProvider extends BaseProvider {
|
|
|
196
207
|
let usage;
|
|
197
208
|
let finishReason;
|
|
198
209
|
let rawFinishReason;
|
|
210
|
+
let toolExecutions;
|
|
199
211
|
try {
|
|
200
|
-
({ text, usage, finishReason, rawFinishReason } =
|
|
212
|
+
({ text, usage, finishReason, rawFinishReason, toolExecutions } =
|
|
201
213
|
await this.conversationLoop(options));
|
|
202
214
|
}
|
|
203
215
|
catch (error) {
|
|
@@ -240,6 +252,11 @@ export class AmazonBedrockProvider extends BaseProvider {
|
|
|
240
252
|
success: true,
|
|
241
253
|
});
|
|
242
254
|
}
|
|
255
|
+
// Tool telemetry, mirroring the other `runAgenticLoop` consumers
|
|
256
|
+
// (anthropic, vertex, google-ai). Bedrock forwarded none of it, so
|
|
257
|
+
// `baseProvider` fell back to `result.toolsUsed || []` and every turn
|
|
258
|
+
// reported zero tools while running them correctly — leaving analytics,
|
|
259
|
+
// cost attribution and audit blind on this path.
|
|
243
260
|
return {
|
|
244
261
|
content: text, // CLI expects 'content' not 'text'
|
|
245
262
|
usage,
|
|
@@ -247,6 +264,14 @@ export class AmazonBedrockProvider extends BaseProvider {
|
|
|
247
264
|
provider: this.getProviderName(),
|
|
248
265
|
...(finishReason !== undefined && { finishReason }),
|
|
249
266
|
...(rawFinishReason !== undefined && { rawFinishReason }),
|
|
267
|
+
toolsUsed: toolExecutions.map((execution) => execution.name),
|
|
268
|
+
toolCalls: toolExecutions.map((execution) => ({
|
|
269
|
+
toolCallId: execution.id,
|
|
270
|
+
toolName: execution.name,
|
|
271
|
+
args: execution.input,
|
|
272
|
+
})),
|
|
273
|
+
toolExecutions: resolveToolExecutionRecords(options, transformToolExecutions(toolExecutions)),
|
|
274
|
+
enhancedWithTools: toolExecutions.length > 0,
|
|
250
275
|
};
|
|
251
276
|
}
|
|
252
277
|
async conversationLoop(options) {
|
|
@@ -317,6 +342,7 @@ export class AmazonBedrockProvider extends BaseProvider {
|
|
|
317
342
|
// kept alongside rather than dropped.
|
|
318
343
|
finishReason: result.finishReason,
|
|
319
344
|
rawFinishReason: result.rawStopReason,
|
|
345
|
+
toolExecutions: result.toolExecutions,
|
|
320
346
|
};
|
|
321
347
|
}
|
|
322
348
|
catch (error) {
|
|
@@ -951,7 +977,14 @@ export class AmazonBedrockProvider extends BaseProvider {
|
|
|
951
977
|
// body — and its finally block — never runs. Resolving twice is
|
|
952
978
|
// harmless; the first call wins.
|
|
953
979
|
void settled.then((outcome) => {
|
|
954
|
-
resolveAnalytics(createAnalytics(this.providerName, this.modelName || this.getDefaultModel(), {
|
|
980
|
+
resolveAnalytics(createAnalytics(this.providerName, this.modelName || this.getDefaultModel(), {
|
|
981
|
+
usage: usageFromOutcome(outcome.result?.usage),
|
|
982
|
+
// createAnalytics derives toolCallCount from these. Passing usage
|
|
983
|
+
// alone left every streamed Bedrock turn reporting no tool calls,
|
|
984
|
+
// however many it made.
|
|
985
|
+
toolExecutions: outcome.result?.toolExecutions ?? [],
|
|
986
|
+
toolsUsed: (outcome.result?.toolExecutions ?? []).map((execution) => execution.name),
|
|
987
|
+
}, Date.now() - startTime, {
|
|
955
988
|
requestId: `bedrock-stream-${Date.now()}`,
|
|
956
989
|
streamingMode: true,
|
|
957
990
|
}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juspay/neurolink",
|
|
3
|
-
"version": "12.14.
|
|
3
|
+
"version": "12.14.13",
|
|
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": {
|