@juspay/neurolink 9.42.1 → 9.43.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 +6 -0
- package/dist/browser/neurolink.min.js +300 -300
- package/dist/cli/commands/mcp.js +15 -3
- package/dist/cli/commands/proxy.js +29 -6
- package/dist/core/baseProvider.js +12 -3
- package/dist/core/factory.js +4 -4
- package/dist/core/modules/ToolsManager.d.ts +1 -0
- package/dist/core/modules/ToolsManager.js +40 -42
- package/dist/core/toolEvents.d.ts +3 -0
- package/dist/core/toolEvents.js +7 -0
- package/dist/evaluation/scorers/scorerRegistry.js +3 -2
- package/dist/lib/core/baseProvider.js +12 -3
- package/dist/lib/core/factory.js +4 -4
- package/dist/lib/core/modules/ToolsManager.d.ts +1 -0
- package/dist/lib/core/modules/ToolsManager.js +40 -42
- package/dist/lib/core/toolEvents.d.ts +3 -0
- package/dist/lib/core/toolEvents.js +8 -0
- package/dist/lib/evaluation/scorers/scorerRegistry.js +3 -2
- package/dist/lib/neurolink.js +33 -19
- package/dist/lib/providers/googleNativeGemini3.d.ts +4 -0
- package/dist/lib/providers/googleNativeGemini3.js +39 -1
- package/dist/lib/providers/googleVertex.js +10 -2
- package/dist/lib/proxy/claudeFormat.js +2 -1
- package/dist/lib/proxy/proxyHealth.d.ts +17 -0
- package/dist/lib/proxy/proxyHealth.js +55 -0
- package/dist/lib/proxy/requestLogger.js +8 -3
- package/dist/lib/proxy/routingPolicy.d.ts +33 -0
- package/dist/lib/proxy/routingPolicy.js +255 -0
- package/dist/lib/proxy/snapshotPersistence.d.ts +2 -0
- package/dist/lib/proxy/snapshotPersistence.js +41 -0
- package/dist/lib/server/routes/claudeProxyRoutes.d.ts +1 -9
- package/dist/lib/server/routes/claudeProxyRoutes.js +304 -219
- package/dist/lib/tasks/store/redisTaskStore.js +34 -16
- package/dist/lib/types/cli.d.ts +4 -0
- package/dist/lib/types/proxyTypes.d.ts +87 -0
- package/dist/lib/types/tools.d.ts +18 -0
- package/dist/lib/utils/schemaConversion.d.ts +1 -0
- package/dist/lib/utils/schemaConversion.js +3 -0
- package/dist/neurolink.js +33 -19
- package/dist/providers/googleNativeGemini3.d.ts +4 -0
- package/dist/providers/googleNativeGemini3.js +39 -1
- package/dist/providers/googleVertex.js +10 -2
- package/dist/proxy/claudeFormat.js +2 -1
- package/dist/proxy/proxyHealth.d.ts +17 -0
- package/dist/proxy/proxyHealth.js +54 -0
- package/dist/proxy/requestLogger.js +8 -3
- package/dist/proxy/routingPolicy.d.ts +33 -0
- package/dist/proxy/routingPolicy.js +254 -0
- package/dist/proxy/snapshotPersistence.d.ts +2 -0
- package/dist/proxy/snapshotPersistence.js +40 -0
- package/dist/server/routes/claudeProxyRoutes.d.ts +1 -9
- package/dist/server/routes/claudeProxyRoutes.js +304 -219
- package/dist/tasks/store/redisTaskStore.js +34 -16
- package/dist/types/cli.d.ts +4 -0
- package/dist/types/proxyTypes.d.ts +87 -0
- package/dist/types/tools.d.ts +18 -0
- package/dist/utils/schemaConversion.d.ts +1 -0
- package/dist/utils/schemaConversion.js +3 -0
- package/package.json +1 -1
|
@@ -183,21 +183,39 @@ export class RedisTaskStore {
|
|
|
183
183
|
const ttlSeconds = Math.ceil(ttlMs / 1000);
|
|
184
184
|
// Set TTL on associated keys best-effort. A successful task write should not
|
|
185
185
|
// be surfaced as a failure just because the retention metadata could not be updated.
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
186
|
+
void (async () => {
|
|
187
|
+
const runsKey = taskRunsKey(task.id);
|
|
188
|
+
for (let attempt = 1; attempt <= 3; attempt++) {
|
|
189
|
+
try {
|
|
190
|
+
await client.expire(runsKey, ttlSeconds);
|
|
191
|
+
break;
|
|
192
|
+
}
|
|
193
|
+
catch (err) {
|
|
194
|
+
if (attempt === 3) {
|
|
195
|
+
logger.warn("[TaskStore:Redis] expire failed after 3 attempts on task runs key — task data may outlive retention window", { taskId: task.id, key: runsKey, ttlSeconds, err: String(err) });
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
await new Promise((r) => setTimeout(r, 100 * attempt));
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
})();
|
|
203
|
+
void (async () => {
|
|
204
|
+
const histKey = taskHistoryKey(task.id);
|
|
205
|
+
for (let attempt = 1; attempt <= 3; attempt++) {
|
|
206
|
+
try {
|
|
207
|
+
await client.expire(histKey, ttlSeconds);
|
|
208
|
+
break;
|
|
209
|
+
}
|
|
210
|
+
catch (err) {
|
|
211
|
+
if (attempt === 3) {
|
|
212
|
+
logger.warn("[TaskStore:Redis] expire failed after 3 attempts on task history key — task data may outlive retention window", { taskId: task.id, key: histKey, ttlSeconds, err: String(err) });
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
await new Promise((r) => setTimeout(r, 100 * attempt));
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
})();
|
|
202
220
|
}
|
|
203
221
|
}
|
package/dist/types/cli.d.ts
CHANGED
|
@@ -798,6 +798,10 @@ export type ProxyState = {
|
|
|
798
798
|
host: string;
|
|
799
799
|
strategy: string;
|
|
800
800
|
startTime: string;
|
|
801
|
+
ready?: boolean;
|
|
802
|
+
readyAt?: string;
|
|
803
|
+
healthPath?: string;
|
|
804
|
+
statusPath?: string;
|
|
801
805
|
envFile?: string;
|
|
802
806
|
/** Fallback chain from proxy config (persisted at start time) */
|
|
803
807
|
fallbackChain?: FallbackInfo[];
|
|
@@ -548,6 +548,7 @@ export type AnthropicAuthRetryResult = {
|
|
|
548
548
|
export type AnthropicNonOkResult = {
|
|
549
549
|
response?: Response | unknown;
|
|
550
550
|
continueLoop: boolean;
|
|
551
|
+
retrySameAccount?: boolean;
|
|
551
552
|
lastError: unknown;
|
|
552
553
|
authFailureMessage: string | null;
|
|
553
554
|
sawTransientFailure: boolean;
|
|
@@ -570,6 +571,7 @@ export type PreparedAnthropicAccountAttempt = {
|
|
|
570
571
|
};
|
|
571
572
|
export type AnthropicUpstreamFetchResult = {
|
|
572
573
|
continueLoop: boolean;
|
|
574
|
+
retrySameAccount?: boolean;
|
|
573
575
|
response?: Response;
|
|
574
576
|
lastError: unknown;
|
|
575
577
|
sawRateLimit: boolean;
|
|
@@ -639,6 +641,10 @@ export type RuntimeAccountState = {
|
|
|
639
641
|
backoffLevel: number;
|
|
640
642
|
consecutiveRefreshFailures: number;
|
|
641
643
|
permanentlyDisabled: boolean;
|
|
644
|
+
requestClassCooldowns?: Record<string, number>;
|
|
645
|
+
modelTierCooldowns?: Record<string, number>;
|
|
646
|
+
requestClassBackoffLevels?: Record<string, number>;
|
|
647
|
+
modelTierBackoffLevels?: Record<string, number>;
|
|
642
648
|
lastToken?: string;
|
|
643
649
|
lastRefreshToken?: string;
|
|
644
650
|
};
|
|
@@ -689,3 +695,84 @@ export type CachedSession = {
|
|
|
689
695
|
userId: string;
|
|
690
696
|
expiresAt: number;
|
|
691
697
|
};
|
|
698
|
+
/** Model tier classification for proxy routing decisions. */
|
|
699
|
+
export type ClaudeProxyModelTier = "opus" | "sonnet" | "haiku" | "other";
|
|
700
|
+
/** Request class for proxy routing policy. */
|
|
701
|
+
export type ClaudeProxyRequestClass = "multimodal" | "high-tool-count-non-stream-structured" | "strong-tool-fidelity" | "streaming-conversational" | "standard";
|
|
702
|
+
/** Full classification profile for a proxy request. */
|
|
703
|
+
export type ClaudeProxyRequestProfile = {
|
|
704
|
+
requestedModel: string;
|
|
705
|
+
modelTier: ClaudeProxyModelTier;
|
|
706
|
+
primaryClass: ClaudeProxyRequestClass;
|
|
707
|
+
classes: ClaudeProxyRequestClass[];
|
|
708
|
+
stream: boolean;
|
|
709
|
+
toolCount: number;
|
|
710
|
+
hasImages: boolean;
|
|
711
|
+
hasThinking: boolean;
|
|
712
|
+
hasToolHistory: boolean;
|
|
713
|
+
requiresToolUse: boolean;
|
|
714
|
+
requiresSpecificTool: boolean;
|
|
715
|
+
requiresStrongToolFidelity: boolean;
|
|
716
|
+
isHighToolCountNonStream: boolean;
|
|
717
|
+
isStreamingConversational: boolean;
|
|
718
|
+
isMultimodal: boolean;
|
|
719
|
+
};
|
|
720
|
+
/** Outcome of evaluating a single fallback candidate. */
|
|
721
|
+
export type FallbackEligibilityDecision = {
|
|
722
|
+
provider?: string;
|
|
723
|
+
model?: string;
|
|
724
|
+
eligible: boolean;
|
|
725
|
+
reason: string;
|
|
726
|
+
};
|
|
727
|
+
/** A single provider attempt in the proxy translation plan. */
|
|
728
|
+
export type ProxyTranslationAttempt = {
|
|
729
|
+
provider?: string;
|
|
730
|
+
model?: string;
|
|
731
|
+
label: string;
|
|
732
|
+
};
|
|
733
|
+
/** Ordered plan of provider attempts and skipped candidates. */
|
|
734
|
+
export type ProxyTranslationPlan = {
|
|
735
|
+
profile: ClaudeProxyRequestProfile;
|
|
736
|
+
attempts: ProxyTranslationAttempt[];
|
|
737
|
+
skipped: FallbackEligibilityDecision[];
|
|
738
|
+
};
|
|
739
|
+
/** Discriminated union describing why a cooldown is active. */
|
|
740
|
+
export type CooldownScope = {
|
|
741
|
+
scope: "request_class";
|
|
742
|
+
key: string;
|
|
743
|
+
until: number;
|
|
744
|
+
} | {
|
|
745
|
+
scope: "model_tier";
|
|
746
|
+
key: string;
|
|
747
|
+
until: number;
|
|
748
|
+
} | {
|
|
749
|
+
scope: "generic";
|
|
750
|
+
key: "generic";
|
|
751
|
+
until: number;
|
|
752
|
+
};
|
|
753
|
+
/** An account skipped during partitioning, with the cooldown that caused it. */
|
|
754
|
+
export type CooldownSkippedAccount<T> = {
|
|
755
|
+
account: T;
|
|
756
|
+
cooldown: CooldownScope;
|
|
757
|
+
};
|
|
758
|
+
/** Mutable readiness state tracked by the proxy process. */
|
|
759
|
+
export type ProxyReadinessState = {
|
|
760
|
+
startTimeMs: number;
|
|
761
|
+
acceptingConnections: boolean;
|
|
762
|
+
ready: boolean;
|
|
763
|
+
readyAtMs?: number;
|
|
764
|
+
};
|
|
765
|
+
/** Structured response returned by the proxy /health endpoint. */
|
|
766
|
+
export type ProxyHealthResponse = {
|
|
767
|
+
status: "ok" | "starting";
|
|
768
|
+
ready: boolean;
|
|
769
|
+
acceptingConnections: boolean;
|
|
770
|
+
strategy: string;
|
|
771
|
+
passthrough: boolean;
|
|
772
|
+
version: string;
|
|
773
|
+
startedAt: string;
|
|
774
|
+
readyAt: string | null;
|
|
775
|
+
uptime: number;
|
|
776
|
+
healthPath: "/health";
|
|
777
|
+
statusPath: "/status";
|
|
778
|
+
};
|
package/dist/types/tools.d.ts
CHANGED
|
@@ -294,6 +294,8 @@ export type ToolExecutionContext = {
|
|
|
294
294
|
export type ToolExecutionEvent = {
|
|
295
295
|
type: "tool:start" | "tool:end";
|
|
296
296
|
tool: string;
|
|
297
|
+
/** Compatibility alias for older consumers that expect `toolName`. */
|
|
298
|
+
toolName?: string;
|
|
297
299
|
input?: unknown;
|
|
298
300
|
result?: unknown;
|
|
299
301
|
error?: string;
|
|
@@ -301,6 +303,22 @@ export type ToolExecutionEvent = {
|
|
|
301
303
|
duration?: number;
|
|
302
304
|
executionId: string;
|
|
303
305
|
};
|
|
306
|
+
/**
|
|
307
|
+
* Payload emitted for tool:start and tool:end events.
|
|
308
|
+
* Always includes both `tool` and `toolName` for backward compatibility.
|
|
309
|
+
*/
|
|
310
|
+
export type ToolEventPayload = {
|
|
311
|
+
tool: string;
|
|
312
|
+
toolName: string;
|
|
313
|
+
input?: unknown;
|
|
314
|
+
result?: unknown;
|
|
315
|
+
error?: string;
|
|
316
|
+
success?: boolean;
|
|
317
|
+
responseTime?: number;
|
|
318
|
+
timestamp?: number;
|
|
319
|
+
duration?: number;
|
|
320
|
+
executionId?: string;
|
|
321
|
+
};
|
|
304
322
|
/**
|
|
305
323
|
* Tool execution summary for completed executions
|
|
306
324
|
*/
|
|
@@ -20,6 +20,7 @@ export declare function inlineJsonSchema(schema: Record<string, unknown>, defini
|
|
|
20
20
|
* 3. Plain JSON Schema objects (have `type`/`properties` but no `_def`) — returned as-is
|
|
21
21
|
*/
|
|
22
22
|
export declare function convertZodToJsonSchema(zodSchema: ZodUnknownSchema): object;
|
|
23
|
+
export declare function normalizeJsonSchemaObject(schema: Record<string, unknown> | undefined | null): Record<string, unknown>;
|
|
23
24
|
/**
|
|
24
25
|
* Check if a value is a Zod schema
|
|
25
26
|
*/
|
|
@@ -138,6 +138,9 @@ export function convertZodToJsonSchema(zodSchema) {
|
|
|
138
138
|
return { type: "object", properties: {} };
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
|
+
export function normalizeJsonSchemaObject(schema) {
|
|
142
|
+
return ensureTypeField(inlineJsonSchema(schema ? { ...schema } : { type: "object", properties: {} }));
|
|
143
|
+
}
|
|
141
144
|
/**
|
|
142
145
|
* Ensure a JSON Schema object has a `type` field (required by Vertex/Gemini).
|
|
143
146
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juspay/neurolink",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.43.0",
|
|
4
4
|
"packageManager": "pnpm@10.15.1",
|
|
5
5
|
"description": "Universal AI Development Platform with working MCP integration, multi-provider support, and professional CLI. Built-in tools operational, 58+ external MCP servers discoverable. Connect to filesystem, GitHub, database operations, and more. Build, test, and deploy AI applications with 13 providers: OpenAI, Anthropic, Google AI, AWS Bedrock, Azure, Hugging Face, Ollama, and Mistral AI.",
|
|
6
6
|
"author": {
|