@juspay/neurolink 11.16.3 → 11.17.1
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 +428 -426
- package/dist/core/loopEngine.js +2 -0
- package/dist/providers/anthropic/client.js +5 -2
- package/dist/providers/anthropic/loopAdapter.d.ts +1 -1
- package/dist/providers/anthropic/loopAdapter.js +48 -6
- package/dist/providers/googleNativeGemini3/utils.js +5 -1
- package/dist/providers/googleVertex/client.js +543 -848
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.js +6 -1
- package/dist/server/routes/index.d.ts +1 -0
- package/dist/server/routes/index.js +9 -1
- package/dist/types/loopEngine.d.ts +63 -4
- package/dist/types/server.d.ts +9 -1
- package/package.json +3 -1
package/dist/server/index.d.ts
CHANGED
|
@@ -38,7 +38,7 @@ export { createMCPBodyAttachmentMiddleware, fastifyMCPBodyHook, } from "./middle
|
|
|
38
38
|
export { createRateLimitMiddleware, createSlidingWindowRateLimitMiddleware, InMemoryRateLimitStore, } from "./middleware/rateLimit.js";
|
|
39
39
|
export { CommonSchemas, createFieldValidator, createRequestValidationMiddleware, ValidationError, } from "./middleware/validation.js";
|
|
40
40
|
export { AgentExecuteRequestSchema as OpenAPIAgentExecuteRequestSchema, AgentExecuteResponseSchema, AgentInputSchema, ApiKeySecurityScheme, BasicSecurityScheme, BearerSecurityScheme, CommonParameters, ConversationMessageSchema, createApiInfo, createDeleteOperation, createErrorResponse as createOpenAPIErrorResponse, createGetOperation, createHeaderParameter, createOpenAPIGenerator, createPathParameter, createPostOperation, createQueryParameter, createServer as createOpenAPIServer, createStreamingPostOperation, createStreamingResponse, createSuccessResponse, DefaultServers, ErrorResponseSchema, generateOpenAPIFromConfig, generateOpenAPISpec, HealthResponseSchema, MCPServerStatusSchema, MCPServersListResponseSchema, MCPServerToolSchema, MetricsResponseSchema, NeuroLinkApiInfo, OpenAPIGenerator, OpenAPISchemas, ProviderInfoSchema, ReadyResponseSchema, SessionSchema, SessionsListResponseSchema, StandardErrorResponses, StandardTags, TokenUsageSchema, ToolCallSchema, ToolDefinitionSchema, ToolExecuteRequestSchema as OpenAPIToolExecuteRequestSchema, ToolExecuteResponseSchema, ToolListResponseSchema, ToolParameterSchema, } from "./openapi/index.js";
|
|
41
|
-
export { createAgentRoutes, createAllRoutes, createHealthRoutes, createMCPRoutes, createMemoryRoutes, createOpenApiRoutes, createToolRoutes, registerAllRoutes, } from "./routes/index.js";
|
|
41
|
+
export { createAgentRoutes, createAllRoutes, createHealthRoutes, createMCPRoutes, createMemoryRoutes, createOpenApiRoutes, createToolRoutes, registerAllRoutes, createClaudeProxyRoutes, createOpenAIProxyRoutes, createCodexProxyRoutes, } from "./routes/index.js";
|
|
42
42
|
export { BaseDataStreamWriter, createDataStreamResponse, createDataStreamWriter, createNDJSONHeaders, createSSEHeaders, DataStreamResponse, formatSSEEvent, pipeAsyncIterableToDataStream, WebStreamWriter, } from "./streaming/index.js";
|
|
43
43
|
export { ErrorCategory, ErrorSeverity, ServerAdapterErrorCode, } from "../types/index.js";
|
|
44
44
|
export { createStreamRedactor, redactStreamChunk } from "./utils/redaction.js";
|
package/dist/server/index.js
CHANGED
|
@@ -93,7 +93,12 @@ OpenAPIGenerator, OpenAPISchemas, ProviderInfoSchema, ReadyResponseSchema, Sessi
|
|
|
93
93
|
// ============================================
|
|
94
94
|
// Routes
|
|
95
95
|
// ============================================
|
|
96
|
-
export { createAgentRoutes, createAllRoutes, createHealthRoutes, createMCPRoutes, createMemoryRoutes, createOpenApiRoutes, createToolRoutes, registerAllRoutes,
|
|
96
|
+
export { createAgentRoutes, createAllRoutes, createHealthRoutes, createMCPRoutes, createMemoryRoutes, createOpenApiRoutes, createToolRoutes, registerAllRoutes,
|
|
97
|
+
// The proxy doors. All three were reachable only from the deep path
|
|
98
|
+
// ./routes/index.js, which is not a package export — so a consumer of
|
|
99
|
+
// "@juspay/neurolink/server" could reach them only indirectly through
|
|
100
|
+
// createAllRoutes' flags, never to mount one on its own.
|
|
101
|
+
createClaudeProxyRoutes, createOpenAIProxyRoutes, createCodexProxyRoutes, } from "./routes/index.js";
|
|
97
102
|
// ============================================
|
|
98
103
|
// Streaming
|
|
99
104
|
// ============================================
|
|
@@ -7,6 +7,7 @@ export { createAgentRoutes } from "./agentRoutes.js";
|
|
|
7
7
|
export { createClaudeProxyRoutes } from "./claudeProxyRoutes.js";
|
|
8
8
|
export { createHealthRoutes } from "./healthRoutes.js";
|
|
9
9
|
export { createOpenAIProxyRoutes } from "./openaiProxyRoutes.js";
|
|
10
|
+
export { createCodexProxyRoutes } from "./codexProxyRoutes.js";
|
|
10
11
|
export { createMCPRoutes } from "./mcpRoutes.js";
|
|
11
12
|
export { createMemoryRoutes } from "./memoryRoutes.js";
|
|
12
13
|
export { createOpenApiRoutes } from "./openApiRoutes.js";
|
|
@@ -7,6 +7,7 @@ import { createClaudeProxyRoutes } from "./claudeProxyRoutes.js";
|
|
|
7
7
|
// ClaudeProxyDeps removed
|
|
8
8
|
import { createHealthRoutes } from "./healthRoutes.js";
|
|
9
9
|
import { createOpenAIProxyRoutes } from "./openaiProxyRoutes.js";
|
|
10
|
+
import { createCodexProxyRoutes } from "./codexProxyRoutes.js";
|
|
10
11
|
import { createMCPRoutes } from "./mcpRoutes.js";
|
|
11
12
|
import { createMemoryRoutes } from "./memoryRoutes.js";
|
|
12
13
|
import { createOpenApiRoutes } from "./openApiRoutes.js";
|
|
@@ -17,6 +18,7 @@ export { createClaudeProxyRoutes } from "./claudeProxyRoutes.js";
|
|
|
17
18
|
// ClaudeProxyDeps removed
|
|
18
19
|
export { createHealthRoutes } from "./healthRoutes.js";
|
|
19
20
|
export { createOpenAIProxyRoutes } from "./openaiProxyRoutes.js";
|
|
21
|
+
export { createCodexProxyRoutes } from "./codexProxyRoutes.js";
|
|
20
22
|
export { createMCPRoutes } from "./mcpRoutes.js";
|
|
21
23
|
export { createMemoryRoutes } from "./memoryRoutes.js";
|
|
22
24
|
export { createOpenApiRoutes } from "./openApiRoutes.js";
|
|
@@ -37,16 +39,22 @@ export function createAllRoutes(basePath = "/api", options) {
|
|
|
37
39
|
if (options?.enableSwagger) {
|
|
38
40
|
routes.push(createOpenApiRoutes(basePath, options.getRoutes));
|
|
39
41
|
}
|
|
40
|
-
// Unified proxy flag enables
|
|
42
|
+
// Unified proxy flag enables every door. Codex was omitted here for long
|
|
43
|
+
// enough that it became reachable only from `neurolink proxy start`; a
|
|
44
|
+
// consumer opting into proxying means all of it, not a subset.
|
|
41
45
|
// Legacy per-format flags are still supported for backward compatibility.
|
|
42
46
|
const enableClaudeProxy = options?.proxy || options?.claudeProxy;
|
|
43
47
|
const enableOpenAIProxy = options?.proxy || options?.openaiProxy;
|
|
48
|
+
const enableCodexProxy = options?.proxy || options?.codexProxy;
|
|
44
49
|
if (enableClaudeProxy) {
|
|
45
50
|
routes.push(createClaudeProxyRoutes(undefined, basePath));
|
|
46
51
|
}
|
|
47
52
|
if (enableOpenAIProxy) {
|
|
48
53
|
routes.push(createOpenAIProxyRoutes(undefined, basePath));
|
|
49
54
|
}
|
|
55
|
+
if (enableCodexProxy) {
|
|
56
|
+
routes.push(createCodexProxyRoutes(basePath));
|
|
57
|
+
}
|
|
50
58
|
return routes;
|
|
51
59
|
}
|
|
52
60
|
/**
|
|
@@ -27,6 +27,19 @@ export type AgenticLoopUsage = {
|
|
|
27
27
|
cacheReadTokens?: number;
|
|
28
28
|
cacheWriteTokens?: number;
|
|
29
29
|
reasoningTokens?: number;
|
|
30
|
+
/**
|
|
31
|
+
* Cache writes split by time-to-live, which Anthropic reports separately
|
|
32
|
+
* from the total under `cache_creation.ephemeral_5m_input_tokens` and
|
|
33
|
+
* `ephemeral_1h_input_tokens`.
|
|
34
|
+
*
|
|
35
|
+
* Carried because the Claude-on-Vertex turn span reports both as
|
|
36
|
+
* `input_cache_creation_5m` / `_1h`, and `cacheWriteTokens` alone cannot
|
|
37
|
+
* reconstruct them — the two tiers are priced differently, so collapsing
|
|
38
|
+
* them loses the only signal that says which one a turn actually bought.
|
|
39
|
+
* Undefined for providers that never report the split.
|
|
40
|
+
*/
|
|
41
|
+
cacheWrite5mTokens?: number;
|
|
42
|
+
cacheWrite1hTokens?: number;
|
|
30
43
|
};
|
|
31
44
|
export type AgenticLoopStepResult<TRaw = unknown> = {
|
|
32
45
|
text: string;
|
|
@@ -191,15 +204,46 @@ export type AgenticLoopAdapter<TConversation = unknown, TRaw = unknown> = {
|
|
|
191
204
|
* Anthropic has never had one, and setting it for both would change native
|
|
192
205
|
* Anthropic's behaviour under the guise of a shared refactor.
|
|
193
206
|
*/
|
|
194
|
-
|
|
195
|
-
|
|
207
|
+
/**
|
|
208
|
+
* Construction input for `createAnthropicLoopAdapter`, shared by direct
|
|
209
|
+
* Anthropic and Claude-on-Vertex.
|
|
210
|
+
*
|
|
211
|
+
* Parameterized on the message shape because the two do NOT agree on it.
|
|
212
|
+
* Direct Anthropic uses the SDK's `MessageParam`; Claude-on-Vertex carries its
|
|
213
|
+
* own `VertexAnthropicMessage`, whose role union is narrower
|
|
214
|
+
* ("user" | "assistant", no "system") and whose image `media_type` is a plain
|
|
215
|
+
* string rather than the SDK's four-way union. Neither is assignable to the
|
|
216
|
+
* other, so pinning the adapter to one of them locked the other out entirely.
|
|
217
|
+
* The engine has been generic over its conversation type all along; this makes
|
|
218
|
+
* the adapter config match.
|
|
219
|
+
*/
|
|
220
|
+
export type AnthropicLoopAdapterConfig<TMessage = Anthropic.Messages.MessageParam> = {
|
|
221
|
+
/**
|
|
222
|
+
* Only `messages.create` is ever called, so only that is required.
|
|
223
|
+
*
|
|
224
|
+
* `Pick<Anthropic, "messages">` looked equivalent and is not: it demands the
|
|
225
|
+
* FULL `Messages` resource, including `batches` and the private `_client`.
|
|
226
|
+
* That excludes `AnthropicVertex`, whose `MessagesResource` is structurally
|
|
227
|
+
* smaller but has the one method this adapter uses — a client the adapter
|
|
228
|
+
* can drive perfectly, rejected for members it never touches.
|
|
229
|
+
*/
|
|
230
|
+
client: {
|
|
231
|
+
messages: Pick<Anthropic["messages"], "create">;
|
|
232
|
+
};
|
|
196
233
|
maxSteps: number;
|
|
197
234
|
/**
|
|
198
235
|
* Build one step's request. A closure so the per-turn work the caller
|
|
199
236
|
* already does — system prompt, tool declarations, sampling, thinking
|
|
200
237
|
* config, cache breakpoints — stays where it is rather than moving here.
|
|
201
238
|
*/
|
|
202
|
-
|
|
239
|
+
/**
|
|
240
|
+
* Returns the NON-streaming params. The adapter adds `stream: true` itself,
|
|
241
|
+
* so requiring the streaming variant here would force every caller to
|
|
242
|
+
* declare a literal `true` it does not control — and a caller whose params
|
|
243
|
+
* type carries `stream?: boolean` fails to match `stream: true` for a field
|
|
244
|
+
* the adapter is about to overwrite.
|
|
245
|
+
*/
|
|
246
|
+
buildParams: (conversation: TMessage[], step: number) => Anthropic.Messages.MessageCreateParamsNonStreaming;
|
|
203
247
|
/** The turn's live tool record, used for deferred-catalog resolution. */
|
|
204
248
|
toolsRecord: Record<string, Tool>;
|
|
205
249
|
/**
|
|
@@ -234,7 +278,7 @@ export type AnthropicLoopAdapterConfig = {
|
|
|
234
278
|
* both every step with nothing else bounding growth, so a migration that
|
|
235
279
|
* drops this overflows the window mid-turn.
|
|
236
280
|
*/
|
|
237
|
-
planReclaim?: (conversation:
|
|
281
|
+
planReclaim?: (conversation: TMessage[], step: number) => AgenticLoopReclaimResult<TMessage[]> | undefined;
|
|
238
282
|
/**
|
|
239
283
|
* Calibration feedback for the provider's reclaim guard: the FULL prompt
|
|
240
284
|
* size for the step just made — uncached input plus both cache tiers.
|
|
@@ -268,6 +312,21 @@ export type GeminiToolExecutionGuards = {
|
|
|
268
312
|
* legitimately slow tool reads as a stalled turn without this.
|
|
269
313
|
*/
|
|
270
314
|
onProgress?: () => void;
|
|
315
|
+
/**
|
|
316
|
+
* Wrap one tool call in the provider's own observability.
|
|
317
|
+
*
|
|
318
|
+
* A function rather than a pair of start/end callbacks, because the caller
|
|
319
|
+
* needs the execution to happen INSIDE its span's context — spans opened by
|
|
320
|
+
* the tool itself must nest under the tool call, not dangle as siblings of
|
|
321
|
+
* the turn. Handing over the whole invocation is the only shape that lets a
|
|
322
|
+
* caller do `context.with(span, run)`.
|
|
323
|
+
*
|
|
324
|
+
* The caller awaits `run()` itself, so it sees the settled result and can
|
|
325
|
+
* mark a FAILURE THAT WAS RETURNED rather than thrown: MCP tools report
|
|
326
|
+
* errors in their payload, and an observation that only watches for
|
|
327
|
+
* exceptions records those calls as successful.
|
|
328
|
+
*/
|
|
329
|
+
withToolSpan?: <T>(name: string, run: () => Promise<T>) => Promise<T>;
|
|
271
330
|
};
|
|
272
331
|
/** What one Gemini step produced, carried to `buildToolResultMessages`. */
|
|
273
332
|
export type GeminiStepRaw = {
|
package/dist/types/server.d.ts
CHANGED
|
@@ -1058,10 +1058,18 @@ export type OpenAPISpec = {
|
|
|
1058
1058
|
export type CreateRoutesOptions = {
|
|
1059
1059
|
enableSwagger?: boolean;
|
|
1060
1060
|
getRoutes?: () => RouteDefinition[];
|
|
1061
|
-
/** Enable
|
|
1061
|
+
/** Enable every proxy door: Claude, OpenAI and Codex. */
|
|
1062
1062
|
proxy?: boolean;
|
|
1063
1063
|
claudeProxy?: boolean;
|
|
1064
1064
|
openaiProxy?: boolean;
|
|
1065
|
+
/**
|
|
1066
|
+
* Enable the Codex door on its own.
|
|
1067
|
+
*
|
|
1068
|
+
* Codex was reachable only from `neurolink proxy start` until this existed —
|
|
1069
|
+
* `createAllRoutes` mounted two of the three doors, so an SDK consumer could
|
|
1070
|
+
* not expose it even deliberately.
|
|
1071
|
+
*/
|
|
1072
|
+
codexProxy?: boolean;
|
|
1065
1073
|
};
|
|
1066
1074
|
/** Data stream finish event. */
|
|
1067
1075
|
export type FinishEvent = DataStreamEvent & {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juspay/neurolink",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.17.1",
|
|
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": {
|
|
@@ -40,6 +40,8 @@
|
|
|
40
40
|
"prepack": "svelte-kit sync && svelte-package && pnpm run build:react-hooks && pnpm run build:cli && pnpm run build:browser && publint",
|
|
41
41
|
"build:react-hooks": "npx tsc --jsx react-jsx --module nodenext --moduleResolution nodenext --target esnext --esModuleInterop --skipLibCheck --outDir dist --declaration false src/lib/client/reactHooks.tsx",
|
|
42
42
|
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json && tsc --noEmit --strict",
|
|
43
|
+
"check:ci-scripts": "svelte-kit sync && tsc -p tsconfig.ci-scripts.json",
|
|
44
|
+
"check:test-parse": "node scripts/parse-check-tests.mjs",
|
|
43
45
|
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
|
44
46
|
"typecheck": "tsc --noEmit",
|
|
45
47
|
"modelServer": "tsx scripts/modelServer.ts",
|