@juspay/neurolink 10.6.0 → 10.6.2
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 +8 -0
- package/dist/adapters/video/vertexVideoHandler.js +4 -1
- package/dist/agent/directTools.d.ts +2 -2
- package/dist/agent/orchestration/orchestrator.js +2 -0
- package/dist/auth/errors.d.ts +1 -1
- package/dist/auth/middleware/AuthMiddleware.d.ts +1 -1
- package/dist/auth/providers/BaseAuthProvider.d.ts +1 -1
- package/dist/auth/providers/auth0.js +1 -1
- package/dist/auth/providers/betterAuth.js +1 -1
- package/dist/auth/providers/clerk.js +1 -1
- package/dist/auth/providers/firebase.js +1 -1
- package/dist/auth/providers/jwt.js +1 -1
- package/dist/auth/providers/oauth2.js +1 -1
- package/dist/auth/providers/supabase.js +1 -1
- package/dist/auth/providers/workos.js +1 -1
- package/dist/browser/neurolink.min.js +338 -338
- package/dist/cli/commands/proxy.js +2 -0
- package/dist/cli/commands/rag.js +2 -4
- package/dist/cli/factories/commandFactory.js +3 -2
- package/dist/cli/loop/conversationSelector.js +4 -6
- package/dist/client/auth.js +2 -7
- package/dist/client/reactHooks.js +2 -2
- package/dist/client/reactHooks.tsx +5 -10
- package/dist/core/baseProvider.d.ts +1 -1
- package/dist/core/baseProvider.js +16 -6
- package/dist/core/factory.d.ts +4 -3
- package/dist/core/modules/GenerationHandler.d.ts +1 -1
- package/dist/core/modules/GenerationHandler.js +7 -5
- package/dist/core/modules/TelemetryHandler.js +2 -2
- package/dist/core/toolExecutionRecorder.d.ts +1 -1
- package/dist/core/toolExecutionRecorder.js +1 -2
- package/dist/evaluation/errors/EvaluationError.d.ts +1 -1
- package/dist/evaluation/scorers/rule/contentSimilarityScorer.js +2 -0
- package/dist/evaluation/scorers/rule/formatScorer.js +1 -1
- package/dist/factories/providerFactory.d.ts +4 -3
- package/dist/factories/providerRegistry.d.ts +9 -4
- package/dist/factories/providerRegistry.js +9 -4
- package/dist/features/ppt/slideGenerator.js +6 -5
- package/dist/features/ppt/utils.d.ts +2 -1
- package/dist/features/ppt/utils.js +1 -0
- package/dist/lib/adapters/video/vertexVideoHandler.js +4 -1
- package/dist/lib/agent/orchestration/orchestrator.js +2 -0
- package/dist/lib/auth/providers/auth0.js +1 -1
- package/dist/lib/auth/providers/betterAuth.js +1 -1
- package/dist/lib/auth/providers/clerk.js +1 -1
- package/dist/lib/auth/providers/firebase.js +1 -1
- package/dist/lib/auth/providers/jwt.js +1 -1
- package/dist/lib/auth/providers/oauth2.js +1 -1
- package/dist/lib/auth/providers/supabase.js +1 -1
- package/dist/lib/auth/providers/workos.js +1 -1
- package/dist/lib/client/auth.js +2 -7
- package/dist/lib/client/reactHooks.js +2 -2
- package/dist/lib/core/baseProvider.d.ts +1 -1
- package/dist/lib/core/baseProvider.js +16 -6
- package/dist/lib/core/factory.d.ts +4 -3
- package/dist/lib/core/modules/GenerationHandler.d.ts +1 -1
- package/dist/lib/core/modules/GenerationHandler.js +7 -5
- package/dist/lib/core/modules/TelemetryHandler.js +2 -2
- package/dist/lib/core/toolExecutionRecorder.d.ts +1 -1
- package/dist/lib/core/toolExecutionRecorder.js +1 -2
- package/dist/lib/evaluation/scorers/rule/contentSimilarityScorer.js +2 -0
- package/dist/lib/evaluation/scorers/rule/formatScorer.js +1 -1
- package/dist/lib/factories/providerFactory.d.ts +4 -3
- package/dist/lib/factories/providerRegistry.d.ts +9 -4
- package/dist/lib/factories/providerRegistry.js +9 -4
- package/dist/lib/features/ppt/slideGenerator.js +6 -5
- package/dist/lib/features/ppt/utils.d.ts +2 -1
- package/dist/lib/features/ppt/utils.js +1 -0
- package/dist/lib/mcp/elicitationProtocol.js +1 -1
- package/dist/lib/mcp/mcpRegistryClient.js +1 -1
- package/dist/lib/middleware/utils/guardrailsUtils.js +1 -1
- package/dist/lib/neurolink.js +15 -7
- package/dist/lib/processors/document/ExcelProcessor.js +5 -1
- package/dist/lib/processors/media/index.js +0 -10
- package/dist/lib/providers/amazonBedrock.js +4 -5
- package/dist/lib/providers/amazonSagemaker.d.ts +18 -0
- package/dist/lib/providers/amazonSagemaker.js +9 -3
- package/dist/lib/providers/anthropic.js +6 -1
- package/dist/lib/providers/googleAiStudio.js +5 -12
- package/dist/lib/providers/googleVertex.js +26 -5
- package/dist/lib/providers/openaiChatCompletionsBase.js +2 -0
- package/dist/lib/providers/sagemaker/errors.js +2 -1
- package/dist/lib/proxy/proxyFetch.js +6 -2
- package/dist/lib/rag/ChunkerFactory.js +1 -1
- package/dist/lib/rag/chunking/semanticChunker.js +1 -2
- package/dist/lib/rag/document/MDocument.js +1 -2
- package/dist/lib/rag/document/loaders.js +16 -3
- package/dist/lib/rag/pipeline/RAGPipeline.js +1 -2
- package/dist/lib/rag/retrieval/hybridSearch.js +1 -2
- package/dist/lib/rag/retrieval/vectorQueryTool.js +1 -2
- package/dist/lib/sdk/toolRegistration.js +6 -2
- package/dist/lib/server/middleware/cache.d.ts +4 -0
- package/dist/lib/server/middleware/cache.js +7 -3
- package/dist/lib/server/middleware/validation.js +2 -1
- package/dist/lib/server/utils/redaction.js +31 -39
- package/dist/lib/server/websocket/WebSocketHandler.js +3 -3
- package/dist/lib/services/server/ai/observability/instrumentation.js +8 -5
- package/dist/lib/types/classifierRouter.d.ts +2 -1
- package/dist/lib/types/providers.d.ts +22 -2
- package/dist/lib/utils/pdfProcessor.js +2 -0
- package/dist/lib/utils/safeFetch.js +20 -0
- package/dist/lib/utils/schemaConversion.d.ts +1 -1
- package/dist/lib/utils/schemaConversion.js +5 -1
- package/dist/lib/workflow/config.d.ts +1 -1
- package/dist/lib/workflow/config.js +1 -1
- package/dist/lib/workflow/core/workflowRegistry.js +1 -1
- package/dist/lib/workflow/core/workflowRunner.js +1 -1
- package/dist/lib/workflow/utils/workflowMetrics.d.ts +1 -1
- package/dist/lib/workflow/utils/workflowMetrics.js +1 -1
- package/dist/mcp/elicitationProtocol.js +1 -1
- package/dist/mcp/mcpRegistryClient.js +1 -1
- package/dist/middleware/utils/guardrailsUtils.js +1 -1
- package/dist/neurolink.js +15 -7
- package/dist/processors/document/ExcelProcessor.js +5 -1
- package/dist/processors/media/index.js +0 -10
- package/dist/providers/amazonBedrock.js +4 -5
- package/dist/providers/amazonSagemaker.d.ts +18 -0
- package/dist/providers/amazonSagemaker.js +9 -3
- package/dist/providers/anthropic.js +6 -1
- package/dist/providers/googleAiStudio.js +5 -12
- package/dist/providers/googleVertex.js +26 -5
- package/dist/providers/openaiChatCompletionsBase.js +2 -0
- package/dist/providers/sagemaker/errors.js +2 -1
- package/dist/proxy/proxyFetch.js +6 -2
- package/dist/rag/ChunkerFactory.js +1 -1
- package/dist/rag/chunking/semanticChunker.js +1 -2
- package/dist/rag/document/MDocument.js +1 -2
- package/dist/rag/document/loaders.js +16 -3
- package/dist/rag/pipeline/RAGPipeline.js +1 -2
- package/dist/rag/retrieval/hybridSearch.js +1 -2
- package/dist/rag/retrieval/vectorQueryTool.js +1 -2
- package/dist/sdk/toolRegistration.js +6 -2
- package/dist/server/middleware/cache.d.ts +4 -0
- package/dist/server/middleware/cache.js +7 -3
- package/dist/server/middleware/validation.js +2 -1
- package/dist/server/utils/redaction.js +31 -39
- package/dist/server/websocket/WebSocketHandler.js +3 -3
- package/dist/services/server/ai/observability/instrumentation.js +8 -5
- package/dist/types/classifierRouter.d.ts +2 -1
- package/dist/types/providers.d.ts +22 -2
- package/dist/utils/pdfProcessor.js +2 -0
- package/dist/utils/safeFetch.js +20 -0
- package/dist/utils/schemaConversion.d.ts +1 -1
- package/dist/utils/schemaConversion.js +5 -1
- package/dist/workflow/config.d.ts +2 -2
- package/dist/workflow/config.js +1 -1
- package/dist/workflow/core/workflowRegistry.js +1 -1
- package/dist/workflow/core/workflowRunner.js +1 -1
- package/dist/workflow/utils/workflowMetrics.d.ts +1 -1
- package/dist/workflow/utils/workflowMetrics.js +1 -1
- package/package.json +1 -1
|
@@ -80,13 +80,13 @@ function redactChunkByType(chunk, redactedFields, placeholder, config) {
|
|
|
80
80
|
const chunkType = typedChunk.type;
|
|
81
81
|
switch (chunkType) {
|
|
82
82
|
case "step-start":
|
|
83
|
-
return redactStepStart(
|
|
83
|
+
return redactStepStart(chunk, redactedFields, placeholder);
|
|
84
84
|
case "tool-call":
|
|
85
|
-
return redactToolCall(
|
|
85
|
+
return redactToolCall(chunk, redactedFields, placeholder, config);
|
|
86
86
|
case "tool-result":
|
|
87
|
-
return redactToolResult(
|
|
87
|
+
return redactToolResult(chunk, redactedFields, placeholder, config);
|
|
88
88
|
case "error":
|
|
89
|
-
return redactError(
|
|
89
|
+
return redactError(chunk, redactedFields, placeholder);
|
|
90
90
|
default:
|
|
91
91
|
return redactGenericChunk(typedChunk, redactedFields, placeholder);
|
|
92
92
|
}
|
|
@@ -99,13 +99,12 @@ function redactStepStart(chunk, redactedFields, placeholder) {
|
|
|
99
99
|
return chunk;
|
|
100
100
|
}
|
|
101
101
|
const { payload, ...rest } = chunk;
|
|
102
|
-
const
|
|
103
|
-
const
|
|
104
|
-
return {
|
|
102
|
+
const redactedPayload = redactObject(payload, redactedFields, placeholder, 0);
|
|
103
|
+
const redacted = {
|
|
105
104
|
...rest,
|
|
106
|
-
type: "step-start",
|
|
107
105
|
payload: redactedPayload,
|
|
108
106
|
};
|
|
107
|
+
return redacted;
|
|
109
108
|
}
|
|
110
109
|
/**
|
|
111
110
|
* Redact tool-call chunks
|
|
@@ -114,49 +113,45 @@ function redactToolCall(chunk, redactedFields, placeholder, config) {
|
|
|
114
113
|
// Handle chunks with payload structure
|
|
115
114
|
if (hasPayload(chunk)) {
|
|
116
115
|
const { payload, ...rest } = chunk;
|
|
117
|
-
const payloadObj = payload;
|
|
118
116
|
// Redact tool arguments if configured
|
|
119
|
-
if (
|
|
120
|
-
const toolCall =
|
|
117
|
+
if (payload.toolCall && typeof payload.toolCall === "object") {
|
|
118
|
+
const toolCall = payload.toolCall;
|
|
121
119
|
const redactArgs = config?.redactToolArgs !== false && redactedFields.has("args");
|
|
122
|
-
|
|
120
|
+
const redacted = {
|
|
123
121
|
...rest,
|
|
124
|
-
type: "tool-call",
|
|
125
122
|
payload: {
|
|
126
|
-
...
|
|
123
|
+
...payload,
|
|
127
124
|
toolCall: {
|
|
128
125
|
...toolCall,
|
|
129
126
|
args: redactArgs ? placeholder : toolCall.args,
|
|
130
127
|
},
|
|
131
128
|
},
|
|
132
129
|
};
|
|
130
|
+
return redacted;
|
|
133
131
|
}
|
|
134
|
-
|
|
132
|
+
const redacted = {
|
|
135
133
|
...rest,
|
|
136
|
-
|
|
137
|
-
payload: redactObject(payloadObj, redactedFields, placeholder, 0),
|
|
134
|
+
payload: redactObject(payload, redactedFields, placeholder, 0),
|
|
138
135
|
};
|
|
136
|
+
return redacted;
|
|
139
137
|
}
|
|
140
138
|
// Handle chunks with data structure (DataStreamEvent format)
|
|
141
139
|
if (hasData(chunk)) {
|
|
142
140
|
const { data, ...rest } = chunk;
|
|
143
|
-
const dataObj = data;
|
|
144
141
|
const redactArgs = config?.redactToolArgs !== false && redactedFields.has("args");
|
|
145
142
|
// Check for arguments field in data
|
|
146
|
-
if ("arguments" in
|
|
143
|
+
if ("arguments" in data && redactArgs) {
|
|
147
144
|
return {
|
|
148
145
|
...rest,
|
|
149
|
-
type: "tool-call",
|
|
150
146
|
data: {
|
|
151
|
-
...
|
|
147
|
+
...data,
|
|
152
148
|
arguments: placeholder,
|
|
153
149
|
},
|
|
154
150
|
};
|
|
155
151
|
}
|
|
156
152
|
return {
|
|
157
153
|
...rest,
|
|
158
|
-
|
|
159
|
-
data: redactObject(dataObj, redactedFields, placeholder, 0),
|
|
154
|
+
data: redactObject(data, redactedFields, placeholder, 0),
|
|
160
155
|
};
|
|
161
156
|
}
|
|
162
157
|
return chunk;
|
|
@@ -169,26 +164,23 @@ function redactToolResult(chunk, redactedFields, placeholder, config) {
|
|
|
169
164
|
// Handle chunks with payload structure
|
|
170
165
|
if (hasPayload(chunk)) {
|
|
171
166
|
const { payload, ...rest } = chunk;
|
|
172
|
-
const
|
|
173
|
-
return {
|
|
167
|
+
const redacted = {
|
|
174
168
|
...rest,
|
|
175
|
-
type: "tool-result",
|
|
176
169
|
payload: {
|
|
177
|
-
...
|
|
178
|
-
result: redactResult ? placeholder :
|
|
170
|
+
...payload,
|
|
171
|
+
result: redactResult ? placeholder : payload.result,
|
|
179
172
|
},
|
|
180
173
|
};
|
|
174
|
+
return redacted;
|
|
181
175
|
}
|
|
182
176
|
// Handle chunks with data structure (DataStreamEvent format)
|
|
183
177
|
if (hasData(chunk)) {
|
|
184
178
|
const { data, ...rest } = chunk;
|
|
185
|
-
const dataObj = data;
|
|
186
179
|
return {
|
|
187
180
|
...rest,
|
|
188
|
-
type: "tool-result",
|
|
189
181
|
data: {
|
|
190
|
-
...
|
|
191
|
-
result: redactResult ? placeholder :
|
|
182
|
+
...data,
|
|
183
|
+
result: redactResult ? placeholder : data.result,
|
|
192
184
|
},
|
|
193
185
|
};
|
|
194
186
|
}
|
|
@@ -202,11 +194,9 @@ function redactError(chunk, redactedFields, placeholder) {
|
|
|
202
194
|
// Handle chunks with data structure (DataStreamEvent format)
|
|
203
195
|
if (hasData(chunk)) {
|
|
204
196
|
const { data, ...rest } = chunk;
|
|
205
|
-
const
|
|
206
|
-
const { stack, ...dataRest } = dataObj;
|
|
197
|
+
const { stack, ...dataRest } = data;
|
|
207
198
|
return {
|
|
208
199
|
...rest,
|
|
209
|
-
type: "error",
|
|
210
200
|
data: {
|
|
211
201
|
...redactObject(dataRest, redactedFields, placeholder, 0),
|
|
212
202
|
...(isProduction ? {} : { stack }),
|
|
@@ -214,7 +204,8 @@ function redactError(chunk, redactedFields, placeholder) {
|
|
|
214
204
|
};
|
|
215
205
|
}
|
|
216
206
|
// Handle direct chunk with stack
|
|
217
|
-
const
|
|
207
|
+
const chunkRecord = chunk;
|
|
208
|
+
const { stack, ...restChunk } = chunkRecord;
|
|
218
209
|
const redactedRest = redactObject(restChunk, redactedFields, placeholder, 0);
|
|
219
210
|
return {
|
|
220
211
|
...redactedRest,
|
|
@@ -270,9 +261,10 @@ function redactObject(obj, redactedFields, placeholder, depth) {
|
|
|
270
261
|
* Type guard for chunks with payload
|
|
271
262
|
*/
|
|
272
263
|
function hasPayload(chunk) {
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
264
|
+
const record = chunk;
|
|
265
|
+
return ("payload" in record &&
|
|
266
|
+
record.payload !== null &&
|
|
267
|
+
typeof record.payload === "object");
|
|
276
268
|
}
|
|
277
269
|
/**
|
|
278
270
|
* Type guard for chunks with data (DataStreamEvent format)
|
|
@@ -334,17 +334,17 @@ export function createAgentWebSocketHandler(_neurolink) {
|
|
|
334
334
|
// Register message routes
|
|
335
335
|
router.route("generate", async (connection, payload) => {
|
|
336
336
|
const { prompt, options: _options } = payload;
|
|
337
|
-
// TODO: Implement generate using neurolink
|
|
337
|
+
// TODO(#1179): Implement generate using neurolink
|
|
338
338
|
return { type: "response", data: `Received: ${prompt}` };
|
|
339
339
|
});
|
|
340
340
|
router.route("stream", async (connection, payload) => {
|
|
341
341
|
const { prompt, options: _options } = payload;
|
|
342
|
-
// TODO: Implement streaming using neurolink
|
|
342
|
+
// TODO(#1179): Implement streaming using neurolink
|
|
343
343
|
return { type: "stream_start", data: { prompt } };
|
|
344
344
|
});
|
|
345
345
|
router.route("tool_call", async (connection, payload) => {
|
|
346
346
|
const { toolName, args: _args } = payload;
|
|
347
|
-
// TODO: Implement tool call using neurolink
|
|
347
|
+
// TODO(#1179): Implement tool call using neurolink
|
|
348
348
|
return { type: "tool_result", data: { toolName, result: null } };
|
|
349
349
|
});
|
|
350
350
|
return {
|
|
@@ -225,6 +225,7 @@ class ContextEnricher {
|
|
|
225
225
|
const userId = context?.userId ?? currentConfig?.userId ?? "guest";
|
|
226
226
|
const sessionId = context?.sessionId ?? currentConfig?.sessionId;
|
|
227
227
|
// Get span name for operation auto-detection
|
|
228
|
+
// (sdk-trace-base's Span type includes the ReadableSpan members)
|
|
228
229
|
const spanName = span.name;
|
|
229
230
|
// Determine if auto-detection is enabled for this context
|
|
230
231
|
const autoDetect = this.shouldAutoDetectOperationName(context);
|
|
@@ -386,9 +387,11 @@ class ContextEnricher {
|
|
|
386
387
|
*/
|
|
387
388
|
onEnd(span) {
|
|
388
389
|
try {
|
|
389
|
-
// Get span attributes (
|
|
390
|
-
|
|
391
|
-
|
|
390
|
+
// Get span attributes (sdk-trace-base's Span type includes the
|
|
391
|
+
// ReadableSpan members, so attributes/name/status are directly typed).
|
|
392
|
+
// Keep the {} fallback: this processor can be attached to an external
|
|
393
|
+
// app-owned TracerProvider whose span implementation may omit attributes.
|
|
394
|
+
const attributes = span.attributes ?? {};
|
|
392
395
|
// Handle wrapper/trace-root spans: update trace name with detected operation
|
|
393
396
|
// This supports host apps (like Curator) that create wrapper spans before AI calls
|
|
394
397
|
// This is optional - if spanContext fails, we skip wrapper span support
|
|
@@ -437,7 +440,7 @@ class ContextEnricher {
|
|
|
437
440
|
const provider = attributes["gen_ai.system"] ||
|
|
438
441
|
attributes["ai.model.provider"];
|
|
439
442
|
logger.debug(`${LOG_PREFIX} GenAI span detected`, {
|
|
440
|
-
spanName:
|
|
443
|
+
spanName: span.name,
|
|
441
444
|
model,
|
|
442
445
|
provider,
|
|
443
446
|
});
|
|
@@ -529,7 +532,7 @@ class ContextEnricher {
|
|
|
529
532
|
// *returns* { isError:true } (no exception thrown), so Langfuse sees
|
|
530
533
|
// level=DEFAULT and no status message. Parse the stringified result
|
|
531
534
|
// and surface the embedded error text.
|
|
532
|
-
if (
|
|
535
|
+
if (span.name === "ai.toolCall" &&
|
|
533
536
|
readableStatus?.code !== SpanStatusCode.ERROR) {
|
|
534
537
|
applyToolCallIsErrorStatus(mutableAttrs);
|
|
535
538
|
}
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* Type names are domain-prefixed `Classifier*` to stay globally unique across
|
|
14
14
|
* `src/lib/types/` (see CLAUDE.md rule 9).
|
|
15
15
|
*/
|
|
16
|
+
import type { ValidationSchema } from "./aliases.js";
|
|
16
17
|
/** Coarse difficulty buckets the classifier maps a request into. */
|
|
17
18
|
export type ClassifierDifficulty = "trivial" | "simple" | "moderate" | "hard" | "expert";
|
|
18
19
|
/** Which classification strategy to run. */
|
|
@@ -166,7 +167,7 @@ export type ClassifierGenerateOptions = {
|
|
|
166
167
|
temperature?: number;
|
|
167
168
|
maxTokens?: number;
|
|
168
169
|
disableTools?: boolean;
|
|
169
|
-
schema?:
|
|
170
|
+
schema?: ValidationSchema;
|
|
170
171
|
timeout?: number | string;
|
|
171
172
|
context?: Record<string, unknown>;
|
|
172
173
|
};
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Provider-specific type definitions for NeuroLink
|
|
3
3
|
*/
|
|
4
4
|
import type { UnknownRecord, JsonValue, StreamingCapability } from "./common.js";
|
|
5
|
+
import type { NeuroLink } from "../neurolink.js";
|
|
5
6
|
import { AIProviderName, AnthropicModels, BedrockModels, DeepSeekModels, GoogleAIModels, LlamaCppModels, LMStudioModels, NvidiaNimModels, OpenAIModels, VertexModels } from "../constants/enums.js";
|
|
6
7
|
import type { ValidationSchema } from "./aliases.js";
|
|
7
8
|
import type { EnhancedGenerateResult, GenerateResult, TextGenerationOptions } from "./generate.js";
|
|
@@ -1669,8 +1670,8 @@ export type ToolWithLegacyParams = {
|
|
|
1669
1670
|
* factory functions.
|
|
1670
1671
|
*/
|
|
1671
1672
|
export type ProviderConstructor = {
|
|
1672
|
-
new (modelName?: string, providerName?: string, sdk?:
|
|
1673
|
-
} | ((modelName?: string, providerName?: string, sdk?:
|
|
1673
|
+
new (modelName?: string, providerName?: string, sdk?: NeuroLink, region?: string, credentials?: UnknownRecord): AIProvider;
|
|
1674
|
+
} | ((modelName?: string, providerName?: string, sdk?: NeuroLink, region?: string, credentials?: UnknownRecord) => Promise<AIProvider>);
|
|
1674
1675
|
/** Provider registration entry held by ProviderFactory. */
|
|
1675
1676
|
export type ProviderRegistration = {
|
|
1676
1677
|
constructor: ProviderConstructor;
|
|
@@ -1779,6 +1780,25 @@ export type VertexNativePart = {
|
|
|
1779
1780
|
data: string;
|
|
1780
1781
|
};
|
|
1781
1782
|
};
|
|
1783
|
+
/**
|
|
1784
|
+
* Part variants that ride the native Gemini agentic tool loop in addition to
|
|
1785
|
+
* the plain `VertexNativePart` content shapes: model-issued function calls
|
|
1786
|
+
* replayed into history, and the function responses (plus wrap-up nudge text
|
|
1787
|
+
* parts) sent back on the next user turn. Mirrors the optional
|
|
1788
|
+
* `functionCall` / `functionResponse` members of the @google/genai SDK's
|
|
1789
|
+
* `Part` type, so loop contents stay directly assignable to the SDK payload.
|
|
1790
|
+
*/
|
|
1791
|
+
export type VertexNativeLoopPart = VertexNativePart | {
|
|
1792
|
+
functionCall: {
|
|
1793
|
+
name: string;
|
|
1794
|
+
args: Record<string, unknown>;
|
|
1795
|
+
};
|
|
1796
|
+
} | {
|
|
1797
|
+
functionResponse: {
|
|
1798
|
+
name: string;
|
|
1799
|
+
response: Record<string, unknown>;
|
|
1800
|
+
};
|
|
1801
|
+
};
|
|
1782
1802
|
/**
|
|
1783
1803
|
* Subset of `GenerateOptions["input"]` consumed by the shared Gemini-native
|
|
1784
1804
|
* multimodal-parts builder. Kept narrow so the helper doesn't depend on the
|
|
@@ -264,6 +264,8 @@ export class PDFProcessor {
|
|
|
264
264
|
clearTimeout(timeoutHandle);
|
|
265
265
|
}
|
|
266
266
|
try {
|
|
267
|
+
// Optional call: guards against a runtime pdf-parse version whose
|
|
268
|
+
// instances lack destroy(), while the typed v2 class declares it.
|
|
267
269
|
await pdf.destroy?.();
|
|
268
270
|
}
|
|
269
271
|
catch {
|
package/dist/utils/safeFetch.js
CHANGED
|
@@ -58,6 +58,23 @@ function buildPinnedAgent(hostname, addresses) {
|
|
|
58
58
|
},
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* Runtime-validating narrow across the undici → DOM `Response` type boundary.
|
|
63
|
+
* `readBoundedBuffer` only touches `headers.get()` and `arrayBuffer()`; the
|
|
64
|
+
* two libraries' `Response` declarations disagree on unrelated members
|
|
65
|
+
* (headers iterator shapes), so validate the members actually used instead
|
|
66
|
+
* of blindly asserting.
|
|
67
|
+
*/
|
|
68
|
+
function isBoundedBufferResponse(value) {
|
|
69
|
+
if (typeof value !== "object" || value === null) {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
const candidate = value;
|
|
73
|
+
return (typeof candidate.arrayBuffer === "function" &&
|
|
74
|
+
typeof candidate.headers === "object" &&
|
|
75
|
+
candidate.headers !== null &&
|
|
76
|
+
typeof candidate.headers.get === "function");
|
|
77
|
+
}
|
|
61
78
|
/**
|
|
62
79
|
* Safely download a binary asset from an external URL.
|
|
63
80
|
*
|
|
@@ -96,5 +113,8 @@ export async function safeDownload(url, options) {
|
|
|
96
113
|
}
|
|
97
114
|
// readBoundedBuffer expects a Response that exposes Content-Length and
|
|
98
115
|
// arrayBuffer(). undici Response satisfies both.
|
|
116
|
+
if (!isBoundedBufferResponse(response)) {
|
|
117
|
+
throw new Error(`safeDownload(${options.label}): response is missing headers.get()/arrayBuffer()`);
|
|
118
|
+
}
|
|
99
119
|
return readBoundedBuffer(response, options.maxBytes, options.label);
|
|
100
120
|
}
|
|
@@ -27,7 +27,7 @@ export declare function ensureNestedSchemaTypes(schema: Record<string, unknown>)
|
|
|
27
27
|
* 2. AI SDK `jsonSchema()` wrappers (have `.jsonSchema` property) -- extracted directly
|
|
28
28
|
* 3. Plain JSON Schema objects (have `type`/`properties` but no `_def`) -- returned as-is
|
|
29
29
|
*/
|
|
30
|
-
export declare function convertZodToJsonSchema(zodSchema: ZodUnknownSchema, target?: "jsonSchema7" | "openApi3"): object;
|
|
30
|
+
export declare function convertZodToJsonSchema(zodSchema: ZodUnknownSchema | Record<string, unknown>, target?: "jsonSchema7" | "openApi3"): object;
|
|
31
31
|
export declare function normalizeJsonSchemaObject(schema: Record<string, unknown> | undefined | null): Record<string, unknown>;
|
|
32
32
|
/**
|
|
33
33
|
* Normalize a JSON Schema for the OpenAI chat-completions `tools` wire
|
|
@@ -308,7 +308,10 @@ export function ensureNestedSchemaTypes(schema) {
|
|
|
308
308
|
* 2. AI SDK `jsonSchema()` wrappers (have `.jsonSchema` property) -- extracted directly
|
|
309
309
|
* 3. Plain JSON Schema objects (have `type`/`properties` but no `_def`) -- returned as-is
|
|
310
310
|
*/
|
|
311
|
-
export function convertZodToJsonSchema(
|
|
311
|
+
export function convertZodToJsonSchema(
|
|
312
|
+
// The union mirrors the three documented input shapes: Zod schemas plus
|
|
313
|
+
// plain-object forms (AI SDK `jsonSchema()` wrappers and raw JSON Schema).
|
|
314
|
+
zodSchema,
|
|
312
315
|
// Default to JSON Schema draft-07 so non-Vertex consumers (Bedrock, MCP
|
|
313
316
|
// tool registration, etc.) keep their pre-migration dialect. Vertex/Gemini
|
|
314
317
|
// callers opt into "openApi3" explicitly to get `nullable: true` instead
|
|
@@ -360,6 +363,7 @@ target = "jsonSchema7") {
|
|
|
360
363
|
try {
|
|
361
364
|
// Zod 4→3 boundary: zodToJsonSchema types reference Zod 3's ZodSchema via zod/v3.
|
|
362
365
|
// Runtime compatible — cast through unknown at this third-party boundary only.
|
|
366
|
+
// eslint-disable-next-line no-restricted-syntax -- genuine third-party type-system boundary: zod-to-json-schema's input type is zod/v3's ZodType, structurally incompatible with the Zod 4 schema held here (no overlap, single assertion cannot compile); runtime-compatible fallback contract documented above.
|
|
363
367
|
const zodV3Schema = zodSchema;
|
|
364
368
|
const jsonSchema = zodToJsonSchema(zodV3Schema, {
|
|
365
369
|
name: "ToolParameters",
|
|
@@ -140,8 +140,8 @@ export declare const WorkflowConfigSchema: z.ZodObject<{
|
|
|
140
140
|
type: z.ZodEnum<{
|
|
141
141
|
custom: "custom";
|
|
142
142
|
chain: "chain";
|
|
143
|
-
adaptive: "adaptive";
|
|
144
143
|
ensemble: "ensemble";
|
|
144
|
+
adaptive: "adaptive";
|
|
145
145
|
}>;
|
|
146
146
|
models: z.ZodArray<z.ZodObject<{
|
|
147
147
|
provider: z.ZodType<AIProviderName, unknown, z.core.$ZodTypeInternals<AIProviderName, unknown>>;
|
|
@@ -368,7 +368,7 @@ export declare function hasJudge(config: WorkflowConfig): boolean;
|
|
|
368
368
|
export declare function getAllJudges(config: WorkflowConfig): JudgeConfig[];
|
|
369
369
|
/**
|
|
370
370
|
* Calculate estimated workflow cost (placeholder)
|
|
371
|
-
* TODO: Implement actual provider-specific pricing
|
|
371
|
+
* TODO(#1179): Implement actual provider-specific pricing
|
|
372
372
|
* @param config - Workflow configuration
|
|
373
373
|
* @param estimatedTokens - Estimated number of tokens for the request
|
|
374
374
|
* @returns Estimated cost in USD
|
package/dist/workflow/config.js
CHANGED
|
@@ -383,7 +383,7 @@ export function getAllJudges(config) {
|
|
|
383
383
|
}
|
|
384
384
|
/**
|
|
385
385
|
* Calculate estimated workflow cost (placeholder)
|
|
386
|
-
* TODO: Implement actual provider-specific pricing
|
|
386
|
+
* TODO(#1179): Implement actual provider-specific pricing
|
|
387
387
|
* @param config - Workflow configuration
|
|
388
388
|
* @param estimatedTokens - Estimated number of tokens for the request
|
|
389
389
|
* @returns Estimated cost in USD
|
|
@@ -10,7 +10,7 @@ const functionTag = "WorkflowRegistry";
|
|
|
10
10
|
// ============================================================================
|
|
11
11
|
/**
|
|
12
12
|
* In-memory workflow registry
|
|
13
|
-
* TODO: Consider persistent storage in future phases
|
|
13
|
+
* TODO(#1179): Consider persistent storage in future phases
|
|
14
14
|
*/
|
|
15
15
|
const workflowRegistry = new Map();
|
|
16
16
|
// ============================================================================
|
|
@@ -158,7 +158,7 @@ export async function runWorkflow(config, options) {
|
|
|
158
158
|
totalInputTokens: calculateInputTokens(ensembleResult.responses),
|
|
159
159
|
totalOutputTokens: calculateOutputTokens(ensembleResult.responses),
|
|
160
160
|
totalTokens: calculateTotalTokens(ensembleResult.responses),
|
|
161
|
-
byModel: [], // TODO: Populate per-model breakdown
|
|
161
|
+
byModel: [], // TODO(#1179): Populate per-model breakdown
|
|
162
162
|
},
|
|
163
163
|
// Additional metadata
|
|
164
164
|
metadata: options.metadata,
|
|
@@ -46,7 +46,7 @@ export declare function calculateModelMetrics(responses: EnsembleResponse[]): Re
|
|
|
46
46
|
/**
|
|
47
47
|
* Calculate consensus level between responses
|
|
48
48
|
* NOTE: Placeholder implementation - uses response length similarity
|
|
49
|
-
* TODO: Implement semantic similarity in Phase 2
|
|
49
|
+
* TODO(#1179): Implement semantic similarity in Phase 2
|
|
50
50
|
*/
|
|
51
51
|
export declare function calculateConsensus(responses: EnsembleResponse[]): number;
|
|
52
52
|
/**
|
|
@@ -159,7 +159,7 @@ export function calculateModelMetrics(responses) {
|
|
|
159
159
|
/**
|
|
160
160
|
* Calculate consensus level between responses
|
|
161
161
|
* NOTE: Placeholder implementation - uses response length similarity
|
|
162
|
-
* TODO: Implement semantic similarity in Phase 2
|
|
162
|
+
* TODO(#1179): Implement semantic similarity in Phase 2
|
|
163
163
|
*/
|
|
164
164
|
export function calculateConsensus(responses) {
|
|
165
165
|
const successful = responses.filter((r) => r.status === "success");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juspay/neurolink",
|
|
3
|
-
"version": "10.6.
|
|
3
|
+
"version": "10.6.2",
|
|
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": {
|