@juspay/neurolink 12.49.18 → 12.49.19
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/agent/agent.js +59 -4
- package/dist/browser/neurolink.min.js +330 -330
- package/dist/neurolink.d.ts +5 -0
- package/dist/neurolink.js +115 -10
- package/dist/types/agentNetwork.d.ts +21 -1
- package/dist/types/common.d.ts +5 -0
- package/dist/types/generate.d.ts +3 -1
- package/dist/types/toolRouting.d.ts +6 -0
- package/dist/utils/conversationMemory.js +1 -1
- package/package.json +3 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
## [12.49.
|
|
1
|
+
## [12.49.19](https://github.com/juspay/neurolink/compare/v12.49.18...v12.49.19) (2026-10-10)
|
|
2
2
|
|
|
3
3
|
### Bug Fixes
|
|
4
4
|
|
|
5
|
-
- **(BZ-
|
|
5
|
+
- **(BZ-6757):** preserve agent sessions and host-owned turn state ([c4bf59d](https://github.com/juspay/neurolink/commit/c4bf59d3928fe0cccedf2bb0418bb2face362be9))
|
|
6
6
|
|
|
7
7
|
## [11.2.3](https://github.com/juspay/neurolink/compare/v11.2.2...v11.2.3) (2026-08-19)
|
|
8
8
|
|
package/dist/agent/agent.js
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
import { EventEmitter } from "events";
|
|
9
9
|
import { ErrorFactory } from "../utils/errorHandling.js";
|
|
10
10
|
import { logger } from "../utils/logger.js";
|
|
11
|
+
import { toToolExecutionRecords } from "../core/toolExecutionRecorder.js";
|
|
11
12
|
/**
|
|
12
13
|
* Agent - Wraps a NeuroLink instance with specialized behavior
|
|
13
14
|
*
|
|
@@ -209,6 +210,8 @@ export class Agent {
|
|
|
209
210
|
async *stream(input, options) {
|
|
210
211
|
const startTime = Date.now();
|
|
211
212
|
const traceId = options?.traceId ?? `agent-${this.id}-${Date.now()}`;
|
|
213
|
+
let streamResult;
|
|
214
|
+
let fullContent = "";
|
|
212
215
|
this.emitter.emit("agent:start", {
|
|
213
216
|
agentId: this.id,
|
|
214
217
|
traceId,
|
|
@@ -235,8 +238,7 @@ export class Agent {
|
|
|
235
238
|
const prompt = this.buildPrompt(input, options?.context);
|
|
236
239
|
const streamOptions = this.buildStreamOptions(prompt, options, traceId);
|
|
237
240
|
// Execute via NeuroLink
|
|
238
|
-
|
|
239
|
-
let fullContent = "";
|
|
241
|
+
streamResult = await this.neurolink.stream(streamOptions);
|
|
240
242
|
for await (const chunk of streamResult.stream) {
|
|
241
243
|
// Handle different chunk types from the stream
|
|
242
244
|
if ("content" in chunk && typeof chunk.content === "string") {
|
|
@@ -289,11 +291,19 @@ export class Agent {
|
|
|
289
291
|
catch {
|
|
290
292
|
logger.warn(`[Agent:${this.id}] Stream cost analytics unavailable`);
|
|
291
293
|
}
|
|
294
|
+
const stopReason = streamResult.metadata?.stopReason ?? streamResult.stopReason;
|
|
295
|
+
const error = streamResult.metadata?.error;
|
|
296
|
+
const status = error || stopReason === "provider-error" ? "error" : "success";
|
|
297
|
+
const toolExecutions = toToolExecutionRecords(streamResult.toolExecutions, options?.toolExecutionCapture);
|
|
292
298
|
this.emitter.emit("agent:complete", {
|
|
293
299
|
agentId: this.id,
|
|
294
300
|
traceId,
|
|
295
301
|
duration,
|
|
296
302
|
content: fullContent,
|
|
303
|
+
status,
|
|
304
|
+
toolExecutions,
|
|
305
|
+
stopReason,
|
|
306
|
+
error,
|
|
297
307
|
});
|
|
298
308
|
yield {
|
|
299
309
|
type: "agent-complete",
|
|
@@ -301,6 +311,10 @@ export class Agent {
|
|
|
301
311
|
content: fullContent,
|
|
302
312
|
usage: streamResult.usage,
|
|
303
313
|
cost,
|
|
314
|
+
status,
|
|
315
|
+
toolExecutions,
|
|
316
|
+
stopReason,
|
|
317
|
+
error,
|
|
304
318
|
duration,
|
|
305
319
|
timestamp: Date.now(),
|
|
306
320
|
traceId,
|
|
@@ -314,6 +328,10 @@ export class Agent {
|
|
|
314
328
|
});
|
|
315
329
|
yield {
|
|
316
330
|
type: "agent-error",
|
|
331
|
+
status: "error",
|
|
332
|
+
content: fullContent,
|
|
333
|
+
toolExecutions: toToolExecutionRecords(streamResult?.toolExecutions, options?.toolExecutionCapture),
|
|
334
|
+
stopReason: streamResult?.metadata?.stopReason ?? streamResult?.stopReason,
|
|
317
335
|
agentId: this.id,
|
|
318
336
|
error: error instanceof Error ? error.message : String(error),
|
|
319
337
|
timestamp: Date.now(),
|
|
@@ -359,8 +377,11 @@ export class Agent {
|
|
|
359
377
|
*/
|
|
360
378
|
buildPrompt(input, context) {
|
|
361
379
|
let prompt = typeof input === "string" ? input : JSON.stringify(input);
|
|
362
|
-
|
|
363
|
-
|
|
380
|
+
const promptContext = context
|
|
381
|
+
? Object.fromEntries(Object.entries(context).filter(([key]) => key !== "sessionId"))
|
|
382
|
+
: undefined;
|
|
383
|
+
if (promptContext && Object.keys(promptContext).length > 0) {
|
|
384
|
+
prompt = `Context: ${JSON.stringify(promptContext)}\n\nTask: ${prompt}`;
|
|
364
385
|
}
|
|
365
386
|
return prompt;
|
|
366
387
|
}
|
|
@@ -376,6 +397,11 @@ export class Agent {
|
|
|
376
397
|
provider: this.provider,
|
|
377
398
|
model: this.model,
|
|
378
399
|
temperature: this.temperature,
|
|
400
|
+
...(options?.region !== undefined && { region: options.region }),
|
|
401
|
+
...(options?.maxTokens !== undefined && { maxTokens: options.maxTokens }),
|
|
402
|
+
...(options?.disableTools !== undefined && {
|
|
403
|
+
disableTools: options.disableTools,
|
|
404
|
+
}),
|
|
379
405
|
systemPrompt: this.instructions,
|
|
380
406
|
// toolFilter delegates to BaseProvider.applyToolFiltering() natively
|
|
381
407
|
...(this.tools && this.tools.length > 0 && { toolFilter: this.tools }),
|
|
@@ -386,6 +412,12 @@ export class Agent {
|
|
|
386
412
|
...(options?.maxBudgetUsd !== undefined && {
|
|
387
413
|
maxBudgetUsd: options.maxBudgetUsd,
|
|
388
414
|
}),
|
|
415
|
+
...(options?.disableInternalFallback !== undefined && {
|
|
416
|
+
disableInternalFallback: options.disableInternalFallback,
|
|
417
|
+
}),
|
|
418
|
+
...(options?.toolExecutionCapture && {
|
|
419
|
+
toolExecutionCapture: options.toolExecutionCapture,
|
|
420
|
+
}),
|
|
389
421
|
requestId: traceId,
|
|
390
422
|
// Turn budget + cancellation, forwarded verbatim to generate() — the
|
|
391
423
|
// machinery (wrap-up nudge, stall watchdog, honest stopReason) lives
|
|
@@ -401,10 +433,16 @@ export class Agent {
|
|
|
401
433
|
...(options?.stallTimeoutMs !== undefined && {
|
|
402
434
|
stallTimeoutMs: options.stallTimeoutMs,
|
|
403
435
|
}),
|
|
436
|
+
...(options?.useMemory === false && { memory: { enabled: false } }),
|
|
404
437
|
context: {
|
|
405
438
|
agentId: this.id,
|
|
406
439
|
agentName: this.name,
|
|
407
440
|
...options?.context,
|
|
441
|
+
...(options?.useMemory === false
|
|
442
|
+
? { sessionId: undefined }
|
|
443
|
+
: options?.sessionId !== undefined
|
|
444
|
+
? { sessionId: options.sessionId }
|
|
445
|
+
: {}),
|
|
408
446
|
},
|
|
409
447
|
};
|
|
410
448
|
}
|
|
@@ -420,6 +458,11 @@ export class Agent {
|
|
|
420
458
|
provider: this.provider,
|
|
421
459
|
model: this.model,
|
|
422
460
|
temperature: this.temperature,
|
|
461
|
+
...(options?.region !== undefined && { region: options.region }),
|
|
462
|
+
...(options?.maxTokens !== undefined && { maxTokens: options.maxTokens }),
|
|
463
|
+
...(options?.disableTools !== undefined && {
|
|
464
|
+
disableTools: options.disableTools,
|
|
465
|
+
}),
|
|
423
466
|
systemPrompt: this.instructions,
|
|
424
467
|
// toolFilter delegates to BaseProvider.applyToolFiltering() natively
|
|
425
468
|
...(this.tools && this.tools.length > 0 && { toolFilter: this.tools }),
|
|
@@ -430,6 +473,12 @@ export class Agent {
|
|
|
430
473
|
...(options?.maxBudgetUsd !== undefined && {
|
|
431
474
|
maxBudgetUsd: options.maxBudgetUsd,
|
|
432
475
|
}),
|
|
476
|
+
...(options?.disableInternalFallback !== undefined && {
|
|
477
|
+
disableInternalFallback: options.disableInternalFallback,
|
|
478
|
+
}),
|
|
479
|
+
...(options?.toolExecutionCapture && {
|
|
480
|
+
toolExecutionCapture: options.toolExecutionCapture,
|
|
481
|
+
}),
|
|
433
482
|
// Turn budget + cancellation, forwarded verbatim to stream()
|
|
434
483
|
...(options?.abortSignal && { abortSignal: options.abortSignal }),
|
|
435
484
|
...(options?.timeout !== undefined && { timeout: options.timeout }),
|
|
@@ -442,11 +491,17 @@ export class Agent {
|
|
|
442
491
|
...(options?.stallTimeoutMs !== undefined && {
|
|
443
492
|
stallTimeoutMs: options.stallTimeoutMs,
|
|
444
493
|
}),
|
|
494
|
+
...(options?.useMemory === false && { memory: { enabled: false } }),
|
|
445
495
|
context: {
|
|
446
496
|
agentId: this.id,
|
|
447
497
|
agentName: this.name,
|
|
448
498
|
traceId,
|
|
449
499
|
...options?.context,
|
|
500
|
+
...(options?.useMemory === false
|
|
501
|
+
? { sessionId: undefined }
|
|
502
|
+
: options?.sessionId !== undefined
|
|
503
|
+
? { sessionId: options.sessionId }
|
|
504
|
+
: {}),
|
|
450
505
|
},
|
|
451
506
|
};
|
|
452
507
|
}
|