@juspay/neurolink 9.82.0 → 9.84.0
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 +18 -0
- package/dist/agent/agent.d.ts +104 -0
- package/dist/agent/agent.js +401 -0
- package/dist/agent/agentNetwork.d.ts +87 -0
- package/dist/agent/agentNetwork.js +458 -0
- package/dist/agent/communication/index.d.ts +9 -0
- package/dist/agent/communication/index.js +9 -0
- package/dist/agent/communication/message-bus.d.ts +113 -0
- package/dist/agent/communication/message-bus.js +406 -0
- package/dist/agent/coordination/coordinator.d.ts +83 -0
- package/dist/agent/coordination/coordinator.js +598 -0
- package/dist/agent/coordination/index.d.ts +10 -0
- package/dist/agent/coordination/index.js +10 -0
- package/dist/agent/coordination/task-distributor.d.ts +113 -0
- package/dist/agent/coordination/task-distributor.js +585 -0
- package/dist/agent/index.d.ts +38 -0
- package/dist/agent/index.js +44 -0
- package/dist/agent/orchestration/index.d.ts +10 -0
- package/dist/agent/orchestration/index.js +10 -0
- package/dist/agent/orchestration/orchestrator.d.ts +114 -0
- package/dist/agent/orchestration/orchestrator.js +476 -0
- package/dist/agent/orchestration/topology.d.ts +164 -0
- package/dist/agent/orchestration/topology.js +520 -0
- package/dist/agent/prompts/routingPrompts.d.ts +63 -0
- package/dist/agent/prompts/routingPrompts.js +201 -0
- package/dist/browser/neurolink.min.js +377 -358
- package/dist/cli/commands/agent.d.ts +37 -0
- package/dist/cli/commands/agent.js +718 -0
- package/dist/cli/factories/commandFactory.d.ts +8 -0
- package/dist/cli/factories/commandFactory.js +116 -0
- package/dist/cli/loop/optionsSchema.d.ts +1 -1
- package/dist/cli/parser.js +4 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +19 -0
- package/dist/lib/agent/agent.d.ts +104 -0
- package/dist/lib/agent/agent.js +402 -0
- package/dist/lib/agent/agentNetwork.d.ts +87 -0
- package/dist/lib/agent/agentNetwork.js +459 -0
- package/dist/lib/agent/communication/index.d.ts +9 -0
- package/dist/lib/agent/communication/index.js +10 -0
- package/dist/lib/agent/communication/message-bus.d.ts +113 -0
- package/dist/lib/agent/communication/message-bus.js +407 -0
- package/dist/lib/agent/coordination/coordinator.d.ts +83 -0
- package/dist/lib/agent/coordination/coordinator.js +599 -0
- package/dist/lib/agent/coordination/index.d.ts +10 -0
- package/dist/lib/agent/coordination/index.js +11 -0
- package/dist/lib/agent/coordination/task-distributor.d.ts +113 -0
- package/dist/lib/agent/coordination/task-distributor.js +586 -0
- package/dist/lib/agent/index.d.ts +38 -0
- package/dist/lib/agent/index.js +45 -0
- package/dist/lib/agent/orchestration/index.d.ts +10 -0
- package/dist/lib/agent/orchestration/index.js +11 -0
- package/dist/lib/agent/orchestration/orchestrator.d.ts +114 -0
- package/dist/lib/agent/orchestration/orchestrator.js +477 -0
- package/dist/lib/agent/orchestration/topology.d.ts +164 -0
- package/dist/lib/agent/orchestration/topology.js +521 -0
- package/dist/lib/agent/prompts/routingPrompts.d.ts +63 -0
- package/dist/lib/agent/prompts/routingPrompts.js +202 -0
- package/dist/lib/index.d.ts +6 -0
- package/dist/lib/index.js +19 -0
- package/dist/lib/neurolink.d.ts +129 -0
- package/dist/lib/neurolink.js +276 -0
- package/dist/lib/processors/config/{fileTypes.js → fileExtensions.js} +1 -1
- package/dist/lib/processors/config/index.d.ts +2 -2
- package/dist/lib/processors/config/index.js +2 -2
- package/dist/lib/processors/config/{mimeTypes.js → mimeConstants.js} +1 -1
- package/dist/lib/processors/index.js +8 -0
- package/dist/lib/providers/googleAiStudio.js +28 -7
- package/dist/lib/providers/googleNativeGemini3.d.ts +18 -0
- package/dist/lib/providers/googleNativeGemini3.js +69 -3
- package/dist/lib/providers/googleVertex.js +33 -9
- package/dist/lib/types/agentNetwork.d.ts +1184 -0
- package/dist/lib/types/agentNetwork.js +8 -0
- package/dist/lib/types/cli.d.ts +66 -0
- package/dist/lib/types/common.d.ts +3 -0
- package/dist/lib/types/generate.d.ts +53 -0
- package/dist/lib/types/index.d.ts +2 -0
- package/dist/lib/types/index.js +3 -0
- package/dist/lib/types/ioProcessor.d.ts +119 -0
- package/dist/lib/types/ioProcessor.js +10 -0
- package/dist/lib/types/providers.d.ts +8 -0
- package/dist/lib/types/stream.d.ts +36 -0
- package/dist/lib/utils/piiDetector.d.ts +24 -0
- package/dist/lib/utils/piiDetector.js +221 -0
- package/dist/lib/utils/pricing.js +144 -26
- package/dist/lib/utils/responseValidator.d.ts +21 -0
- package/dist/lib/utils/responseValidator.js +354 -0
- package/dist/lib/utils/tokenUtils.d.ts +11 -0
- package/dist/lib/utils/tokenUtils.js +33 -2
- package/dist/lib/utils/tripwireEvaluator.d.ts +73 -0
- package/dist/lib/utils/tripwireEvaluator.js +285 -0
- package/dist/neurolink.d.ts +129 -0
- package/dist/neurolink.js +276 -0
- package/dist/processors/config/index.d.ts +2 -2
- package/dist/processors/config/index.js +2 -2
- package/dist/processors/index.js +8 -0
- package/dist/providers/googleAiStudio.js +28 -7
- package/dist/providers/googleNativeGemini3.d.ts +18 -0
- package/dist/providers/googleNativeGemini3.js +69 -3
- package/dist/providers/googleVertex.js +33 -9
- package/dist/types/agentNetwork.d.ts +1184 -0
- package/dist/types/agentNetwork.js +7 -0
- package/dist/types/cli.d.ts +66 -0
- package/dist/types/common.d.ts +3 -0
- package/dist/types/generate.d.ts +53 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.js +3 -0
- package/dist/types/ioProcessor.d.ts +119 -0
- package/dist/types/ioProcessor.js +9 -0
- package/dist/types/providers.d.ts +8 -0
- package/dist/types/stream.d.ts +36 -0
- package/dist/utils/piiDetector.d.ts +24 -0
- package/dist/utils/piiDetector.js +220 -0
- package/dist/utils/pricing.js +144 -26
- package/dist/utils/responseValidator.d.ts +21 -0
- package/dist/utils/responseValidator.js +353 -0
- package/dist/utils/tokenUtils.d.ts +11 -0
- package/dist/utils/tokenUtils.js +33 -2
- package/dist/utils/tripwireEvaluator.d.ts +73 -0
- package/dist/utils/tripwireEvaluator.js +284 -0
- package/package.json +1 -1
- /package/dist/lib/processors/config/{fileTypes.d.ts → fileExtensions.d.ts} +0 -0
- /package/dist/lib/processors/config/{mimeTypes.d.ts → mimeConstants.d.ts} +0 -0
- /package/dist/processors/config/{fileTypes.d.ts → fileExtensions.d.ts} +0 -0
- /package/dist/processors/config/{fileTypes.js → fileExtensions.js} +0 -0
- /package/dist/processors/config/{mimeTypes.d.ts → mimeConstants.d.ts} +0 -0
- /package/dist/processors/config/{mimeTypes.js → mimeConstants.js} +0 -0
|
@@ -24,7 +24,7 @@ import { convertZodToJsonSchema, inlineJsonSchema, ensureNestedSchemaTypes, } fr
|
|
|
24
24
|
import { createNativeThinkingConfig } from "../utils/thinkingConfig.js";
|
|
25
25
|
import { TimeoutError, raceWithAbort, withTimeout, } from "../utils/async/index.js";
|
|
26
26
|
import { parseTimeout } from "../utils/timeout.js";
|
|
27
|
-
import { appendStepText, buildAbortedTurnMessage, buildContextCapMessage, buildToolLoopCapMessage, buildTurnStalledMessage, buildTurnTimeoutMessage, buildWrapupNudgeText, createContextGuard, createTextChannel, createTurnClock, extractThoughtSignature, isAbortError, mapGeminiFinishReason, prependConversationMessages, resolveTurnStopReason, } from "./googleNativeGemini3.js";
|
|
27
|
+
import { appendStepText, buildAbortedTurnMessage, buildContextCapMessage, buildToolLoopCapMessage, buildTurnStalledMessage, buildTurnTimeoutMessage, buildWrapupNudgeText, createContextGuard, createTextChannel, createTurnClock, extractThoughtSignature, isAbortError, mapGeminiFinishReason, prependConversationMessages, resolveTurnStopReason, DedupExecuteMap, } from "./googleNativeGemini3.js";
|
|
28
28
|
import { getContextWindowSize } from "../constants/contextWindows.js";
|
|
29
29
|
import { ATTR, LANGFUSE_ATTR, spanJsonAttribute, tracers, withClientSpan, withClientStreamSpan, withSpan, } from "../telemetry/index.js";
|
|
30
30
|
import { SpanKind, SpanStatusCode, context as otelContext, trace as otelTrace, } from "@opentelemetry/api";
|
|
@@ -1138,7 +1138,7 @@ export class GoogleVertexProvider extends BaseProvider {
|
|
|
1138
1138
|
});
|
|
1139
1139
|
// Convert Vercel AI SDK tools to @google/genai FunctionDeclarations
|
|
1140
1140
|
let tools;
|
|
1141
|
-
const executeMap = new
|
|
1141
|
+
const executeMap = new DedupExecuteMap();
|
|
1142
1142
|
if (options.tools &&
|
|
1143
1143
|
Object.keys(options.tools).length > 0 &&
|
|
1144
1144
|
!options.disableTools) {
|
|
@@ -1325,6 +1325,7 @@ export class GoogleVertexProvider extends BaseProvider {
|
|
|
1325
1325
|
// promptTokenCount is typically in the final chunk, candidatesTokenCount accumulates
|
|
1326
1326
|
let totalInputTokens = 0;
|
|
1327
1327
|
let totalOutputTokens = 0;
|
|
1328
|
+
let totalCacheReadTokens = 0;
|
|
1328
1329
|
// Track text parts as they arrive from the SDK so the returned async
|
|
1329
1330
|
// iterable yields multiple chunks instead of a single buffered chunk.
|
|
1330
1331
|
// The CLI's chunk-count smoke test asserts > 1 stream chunks for any
|
|
@@ -1440,6 +1441,10 @@ export class GoogleVertexProvider extends BaseProvider {
|
|
|
1440
1441
|
totalInputTokens = usageMetadata.promptTokenCount;
|
|
1441
1442
|
// Feed the context guard the REAL prompt size of this call.
|
|
1442
1443
|
contextGuard.noteUsage(usageMetadata.promptTokenCount, usageMetadata.candidatesTokenCount ?? 0);
|
|
1444
|
+
// cachedContentTokenCount is OVERLAPPING (a subset already inside
|
|
1445
|
+
// promptTokenCount). Clamp to the prompt count so a later uncached
|
|
1446
|
+
// step resets it to 0 instead of leaving a stale cached value.
|
|
1447
|
+
totalCacheReadTokens = Math.min(usageMetadata.cachedContentTokenCount ?? 0, usageMetadata.promptTokenCount);
|
|
1443
1448
|
}
|
|
1444
1449
|
// Take the latest candidatesTokenCount (accumulates through chunks)
|
|
1445
1450
|
if (usageMetadata.candidatesTokenCount !== undefined &&
|
|
@@ -1891,6 +1896,10 @@ export class GoogleVertexProvider extends BaseProvider {
|
|
|
1891
1896
|
// Filter out final_result from tool calls as it's an internal pattern
|
|
1892
1897
|
const externalToolCalls = allToolCalls.filter((tc) => tc.toolName !== "final_result");
|
|
1893
1898
|
const externalToolExecutions = toolExecutions.filter((te) => te.name !== "final_result");
|
|
1899
|
+
// Gemini promptTokenCount is OVERLAPPING (already includes
|
|
1900
|
+
// cachedContentTokenCount). Subtract once so the cached portion is billed at
|
|
1901
|
+
// the cheaper cacheRead rate without double-counting; total is conserved.
|
|
1902
|
+
const adjustedInputTokens = Math.max(0, totalInputTokens - totalCacheReadTokens);
|
|
1894
1903
|
const result = {
|
|
1895
1904
|
stream: createTextStream(),
|
|
1896
1905
|
provider: this.providerName,
|
|
@@ -1899,9 +1908,12 @@ export class GoogleVertexProvider extends BaseProvider {
|
|
|
1899
1908
|
stopReason,
|
|
1900
1909
|
rawFinishReason: lastFinishReason,
|
|
1901
1910
|
usage: {
|
|
1902
|
-
input:
|
|
1911
|
+
input: adjustedInputTokens,
|
|
1903
1912
|
output: totalOutputTokens,
|
|
1904
|
-
total:
|
|
1913
|
+
total: adjustedInputTokens + totalCacheReadTokens + totalOutputTokens,
|
|
1914
|
+
...(totalCacheReadTokens > 0 && {
|
|
1915
|
+
cacheReadTokens: totalCacheReadTokens,
|
|
1916
|
+
}),
|
|
1905
1917
|
},
|
|
1906
1918
|
toolCalls: externalToolCalls.map((tc) => ({
|
|
1907
1919
|
toolName: tc.toolName,
|
|
@@ -2073,7 +2085,7 @@ export class GoogleVertexProvider extends BaseProvider {
|
|
|
2073
2085
|
const combinedTools = !options.disableTools ? options.tools || {} : {};
|
|
2074
2086
|
// Convert Vercel AI SDK tools to @google/genai FunctionDeclarations
|
|
2075
2087
|
let tools;
|
|
2076
|
-
const executeMap = new
|
|
2088
|
+
const executeMap = new DedupExecuteMap();
|
|
2077
2089
|
if (Object.keys(combinedTools).length > 0) {
|
|
2078
2090
|
const functionDeclarations = [];
|
|
2079
2091
|
for (const [name, tool] of Object.entries(combinedTools)) {
|
|
@@ -2254,6 +2266,7 @@ export class GoogleVertexProvider extends BaseProvider {
|
|
|
2254
2266
|
// promptTokenCount is typically in the final chunk, candidatesTokenCount accumulates
|
|
2255
2267
|
let totalInputTokens = 0;
|
|
2256
2268
|
let totalOutputTokens = 0;
|
|
2269
|
+
let totalCacheReadTokens = 0;
|
|
2257
2270
|
// Abort scaffolding (mirrors executeNativeAnthropicStream). The native
|
|
2258
2271
|
// Gemini SDK cancels via config.abortSignal, so drive an internal
|
|
2259
2272
|
// AbortController: the caller's signal and the turn clock's watchdogs
|
|
@@ -2359,6 +2372,10 @@ export class GoogleVertexProvider extends BaseProvider {
|
|
|
2359
2372
|
totalInputTokens = usageMetadata.promptTokenCount;
|
|
2360
2373
|
// Feed the context guard the REAL prompt size of this call.
|
|
2361
2374
|
contextGuard.noteUsage(usageMetadata.promptTokenCount, usageMetadata.candidatesTokenCount ?? 0);
|
|
2375
|
+
// cachedContentTokenCount is OVERLAPPING (a subset already inside
|
|
2376
|
+
// promptTokenCount). Clamp to the prompt count so a later uncached
|
|
2377
|
+
// step resets it to 0 instead of leaving a stale cached value.
|
|
2378
|
+
totalCacheReadTokens = Math.min(usageMetadata.cachedContentTokenCount ?? 0, usageMetadata.promptTokenCount);
|
|
2362
2379
|
}
|
|
2363
2380
|
// Take the latest candidatesTokenCount (accumulates through chunks)
|
|
2364
2381
|
if (usageMetadata.candidatesTokenCount !== undefined &&
|
|
@@ -2789,6 +2806,10 @@ export class GoogleVertexProvider extends BaseProvider {
|
|
|
2789
2806
|
const externalToolCalls = allToolCalls.filter((tc) => tc.toolName !== "final_result");
|
|
2790
2807
|
const externalToolExecutions = toolExecutions.filter((te) => te.name !== "final_result");
|
|
2791
2808
|
// Build EnhancedGenerateResult
|
|
2809
|
+
// Gemini promptTokenCount is OVERLAPPING (already includes
|
|
2810
|
+
// cachedContentTokenCount). Subtract once so the cached portion is billed at
|
|
2811
|
+
// the cheaper cacheRead rate without double-counting; total is conserved.
|
|
2812
|
+
const adjustedInputTokens = Math.max(0, totalInputTokens - totalCacheReadTokens);
|
|
2792
2813
|
const result = {
|
|
2793
2814
|
content: finalText,
|
|
2794
2815
|
provider: this.providerName,
|
|
@@ -2798,9 +2819,12 @@ export class GoogleVertexProvider extends BaseProvider {
|
|
|
2798
2819
|
rawFinishReason: lastFinishReason,
|
|
2799
2820
|
stepsUsed: step,
|
|
2800
2821
|
usage: {
|
|
2801
|
-
input:
|
|
2822
|
+
input: adjustedInputTokens,
|
|
2802
2823
|
output: totalOutputTokens,
|
|
2803
|
-
total:
|
|
2824
|
+
total: adjustedInputTokens + totalCacheReadTokens + totalOutputTokens,
|
|
2825
|
+
...(totalCacheReadTokens > 0 && {
|
|
2826
|
+
cacheReadTokens: totalCacheReadTokens,
|
|
2827
|
+
}),
|
|
2804
2828
|
},
|
|
2805
2829
|
responseTime,
|
|
2806
2830
|
toolsUsed: externalToolCalls.map((tc) => tc.toolName),
|
|
@@ -3092,7 +3116,7 @@ export class GoogleVertexProvider extends BaseProvider {
|
|
|
3092
3116
|
: userContentParts);
|
|
3093
3117
|
// Convert tools to Anthropic format if present
|
|
3094
3118
|
let tools;
|
|
3095
|
-
const executeMap = new
|
|
3119
|
+
const executeMap = new DedupExecuteMap();
|
|
3096
3120
|
if (options.tools &&
|
|
3097
3121
|
Object.keys(options.tools).length > 0 &&
|
|
3098
3122
|
!options.disableTools) {
|
|
@@ -4401,7 +4425,7 @@ export class GoogleVertexProvider extends BaseProvider {
|
|
|
4401
4425
|
: userContentParts);
|
|
4402
4426
|
// Convert tools to Anthropic format if present
|
|
4403
4427
|
let tools;
|
|
4404
|
-
const executeMap = new
|
|
4428
|
+
const executeMap = new DedupExecuteMap();
|
|
4405
4429
|
const toolExecutions = [];
|
|
4406
4430
|
// Defensive guard: Vertex generate() bypasses BaseProvider.generate(), so
|
|
4407
4431
|
// disableTools must be checked here before native tool declarations are
|