@juspay/neurolink 13.10.1 → 13.10.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.
@@ -180,8 +180,11 @@ export class MCPToolRegistry extends MCPRegistry {
180
180
  tools: toolsObject,
181
181
  configuration: {},
182
182
  };
183
- // Call the parent register method
184
- this.register(plugin);
183
+ // Key by the server id, the same key unregisterServer() removes by.
184
+ // metadata.name is display text: two servers may share it, and the
185
+ // parent register() would let the second silently replace the first.
186
+ this.plugins.set(serverId, plugin);
187
+ registryLogger.debug(`Registered plugin: ${plugin.metadata.name}`);
185
188
  // Use MCPServerInfo.tools array directly - ZERO conversions!
186
189
  const tools = serverInfo.tools;
187
190
  for (const tool of tools) {
package/dist/neurolink.js CHANGED
@@ -11669,6 +11669,8 @@ Current user's request: ${currentInput}`;
11669
11669
  }
11670
11670
  structuredError = new NeuroLinkError({
11671
11671
  ...structuredError,
11672
+ // Error#message is non-enumerable, so the spread above drops it.
11673
+ message: structuredError.message,
11672
11674
  context: {
11673
11675
  ...structuredError.context,
11674
11676
  executionTime,
@@ -2,7 +2,7 @@
2
2
  * Comprehensive Type Alias Library
3
3
  * Centralizes commonly used complex types to improve readability and maintainability
4
4
  */
5
- import type { ZodTypeAny } from "zod";
5
+ import type { ZodTypeAny, core as ZodCore } from "zod";
6
6
  import type { JsonValue, Result, AsyncFunction } from "./common.js";
7
7
  import { zodToJsonSchema } from "zod-to-json-schema";
8
8
  import type { Schema } from "./tools.js";
@@ -32,6 +32,22 @@ export type Zod4NativeTarget = "draft-07" | "openapi-3.0";
32
32
  */
33
33
  export type Zod4NativeParams = {
34
34
  target?: Zod4NativeTarget;
35
+ io?: "input" | "output";
36
+ unrepresentable?: "throw" | "any";
37
+ override?: (context: Zod4OverrideContext) => void;
38
+ };
39
+ /** The definition of a Zod 4 object schema, as `override` reads it. */
40
+ export type Zod4ObjectDefinition = ZodCore.$ZodObjectDef;
41
+ /** The definition of a Zod 4 discriminated union, as `override` reads it. */
42
+ export type Zod4DiscriminatedUnionDefinition = ZodCore.$ZodDiscriminatedUnionDef;
43
+ /**
44
+ * What Zod 4's `override` hook is handed for each node it converts: the
45
+ * schema node, and the JSON Schema it produced for it, which the hook edits
46
+ * in place.
47
+ */
48
+ export type Zod4OverrideContext = {
49
+ zodSchema: ZodCore.$ZodType;
50
+ jsonSchema: Record<string, unknown>;
35
51
  };
36
52
  /**
37
53
  * Union type for schema validation (Zod or AI SDK schema)
@@ -368,6 +368,122 @@ export function ensureNestedSchemaTypes(schema) {
368
368
  }
369
369
  return result;
370
370
  }
371
+ // Zod 4's converter reads the output side of a schema by default and throws on
372
+ // `.transform()`, dates and `z.instanceof()`, which sent a whole tool to the
373
+ // provider as one with no parameters. Convert the input side instead (that is
374
+ // what a model has to supply) and give the result the shape zod-to-json-schema
375
+ // gave the Zod 3 equivalent, so the schemas providers receive do not change
376
+ // with the Zod major.
377
+ //
378
+ // String formats zod-to-json-schema emitted as a bare `format`. Zod 4 adds the
379
+ // regex it validates with beside them, and emits includes / startsWith /
380
+ // endsWith as non-standard formats next to their pattern.
381
+ const STANDARD_STRING_FORMATS = new Set([
382
+ "email",
383
+ "uri",
384
+ "uuid",
385
+ "date-time",
386
+ "date",
387
+ "time",
388
+ "duration",
389
+ "ipv4",
390
+ "ipv6",
391
+ ]);
392
+ // A key is required exactly when Zod rejects the object without it
393
+ // (handlePropertyResult in zod/v4/core). Zod's own converter marks `.catch()`
394
+ // and some `.preprocess()` keys required although parsing accepts them
395
+ // missing. Deciding that parses `undefined`, so a callback on that path
396
+ // (`.preprocess()`, `.transform()`, a `.default()` thunk) runs once per
397
+ // conversion, with the value Zod would give it for a missing key at call time.
398
+ function acceptsMissingKey(field) {
399
+ if (field._zod.optin === undefined) {
400
+ return false;
401
+ }
402
+ if (field._zod.optout === "optional") {
403
+ return true;
404
+ }
405
+ // `.catch()` replaces every failure, so a missing key always passes. Zod's
406
+ // own converter already calls a catch callback once, to read its default;
407
+ // saying so here keeps this check from calling it a second time.
408
+ if (field._zod.def.type === "catch") {
409
+ return true;
410
+ }
411
+ try {
412
+ return zodModule.safeParse(field, undefined).success;
413
+ }
414
+ catch {
415
+ // An async preprocess or transform cannot be parsed synchronously, so
416
+ // whether it accepts a missing key is not known. Required is the safe side:
417
+ // a model that supplies a key the schema would have defaulted loses
418
+ // nothing, while one that omits a key the schema rejects fails the call.
419
+ return false;
420
+ }
421
+ }
422
+ function isPlainRecord(value) {
423
+ return !!value && typeof value === "object" && !Array.isArray(value);
424
+ }
425
+ function isObjectDefinition(definition) {
426
+ return definition.type === "object";
427
+ }
428
+ // `z.xor()` is also an exclusive union that Zod 4 writes as `oneOf`, but it is
429
+ // not a discriminated union: only a discriminator marks the one that
430
+ // `zod-to-json-schema` wrote as `anyOf`.
431
+ function isDiscriminatedUnionDefinition(definition) {
432
+ return (definition.type === "union" &&
433
+ "discriminator" in definition &&
434
+ typeof definition.discriminator === "string");
435
+ }
436
+ function shapeLikeZodToJsonSchema({ zodSchema, jsonSchema, }) {
437
+ const definition = zodSchema._zod.def;
438
+ if (isObjectDefinition(definition)) {
439
+ if (definition.catchall === undefined) {
440
+ jsonSchema.additionalProperties = false;
441
+ }
442
+ else if (isPlainRecord(jsonSchema.additionalProperties) &&
443
+ Object.keys(jsonSchema.additionalProperties).length === 0) {
444
+ jsonSchema.additionalProperties = true;
445
+ }
446
+ const required = Object.entries(definition.shape)
447
+ .filter(([, field]) => !acceptsMissingKey(field))
448
+ .map(([key]) => key);
449
+ if (required.length > 0) {
450
+ jsonSchema.required = required;
451
+ }
452
+ else {
453
+ delete jsonSchema.required;
454
+ }
455
+ }
456
+ if (isDiscriminatedUnionDefinition(definition) &&
457
+ Array.isArray(jsonSchema.oneOf)) {
458
+ jsonSchema.anyOf = jsonSchema.oneOf;
459
+ delete jsonSchema.oneOf;
460
+ }
461
+ if (typeof jsonSchema.format === "string") {
462
+ if (STANDARD_STRING_FORMATS.has(jsonSchema.format)) {
463
+ delete jsonSchema.pattern;
464
+ }
465
+ else {
466
+ delete jsonSchema.format;
467
+ }
468
+ }
469
+ if (definition.type === "catch") {
470
+ delete jsonSchema.default;
471
+ }
472
+ if (definition.type === "record" &&
473
+ isPlainRecord(jsonSchema.propertyNames) &&
474
+ Object.keys(jsonSchema.propertyNames).length === 1 &&
475
+ jsonSchema.propertyNames.type === "string") {
476
+ delete jsonSchema.propertyNames;
477
+ }
478
+ if (definition.type === "date") {
479
+ // JSON carries no Date, so a model can only send a date-time string, which
480
+ // is how zod-to-json-schema described z.date() for Zod 3. A plain z.date()
481
+ // then rejects that string when the call is validated; z.coerce.date()
482
+ // accepts it. Dropping the field instead would hide a date the tool needs.
483
+ jsonSchema.type = "string";
484
+ jsonSchema.format = "date-time";
485
+ }
486
+ }
371
487
  /**
372
488
  * Convert Zod schema to JSON Schema format for provider APIs.
373
489
  *
@@ -413,6 +529,9 @@ target = "jsonSchema7") {
413
529
  try {
414
530
  const native = zodToJsonSchemaV4(zodSchema, {
415
531
  target: nativeTarget,
532
+ io: "input",
533
+ unrepresentable: "any",
534
+ override: shapeLikeZodToJsonSchema,
416
535
  });
417
536
  // Drop the $schema metadata Vertex/Gemini doesn't need, then walk to
418
537
  // backfill any missing nested types (Zod 4's output is already flat
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juspay/neurolink",
3
- "version": "13.10.1",
3
+ "version": "13.10.2",
4
4
  "packageManager": "pnpm@10.34.9+sha512.f49b5a8ea0fdedb44bb3c0c1d6575092a53c2950d95b7ad15df11f17974877a2de3a01c07e934e9b28ce716e51c09a94962c7306d09be2e1e4b18a8c8762fd32",
5
5
  "description": "The pipe layer of an AI nervous system: one interface connecting provider neurons to your application, across three inference types — generate, stream and decide. `decide` returns typed, calibrated judgements from a non-generative model (~400ms, ~$0.00002/call) for routing, tool selection and context budgeting. MCP-native (4 transports), voice TTS/STT/realtime, RAG, agents, memory, compaction, 9 observability exporters. OpenAI · Anthropic · Gemini · Bedrock · Azure · Ollama · TypeSafe Jev and more.",
6
6
  "author": {
@@ -116,6 +116,8 @@
116
116
  "test:adjust-body-after-400": "pnpm exec tsx test/continuous-test-suite-adjust-body-after-400.ts",
117
117
  "test:zod3-schema-native-path": "pnpm exec tsx test/continuous-test-suite-zod3-schema-native-path.ts",
118
118
  "test:zod-wire-schemas": "pnpm exec tsx test/continuous-test-suite-zod-wire-schemas.ts",
119
+ "test:zod4-tool-schema-shape": "pnpm exec tsx test/continuous-test-suite-zod4-tool-schema-shape.ts",
120
+ "test:mcp-server-id-and-tool-error": "pnpm exec tsx test/continuous-test-suite-mcp-server-id-and-tool-error.ts",
119
121
  "test:forced-tool-declared": "pnpm exec tsx test/continuous-test-suite-forced-tool-declared.ts",
120
122
  "test:span-content-redaction": "pnpm exec tsx test/continuous-test-suite-span-content-redaction.ts",
121
123
  "test:voice-turn-memory": "pnpm exec tsx test/continuous-test-suite-voice-turn-memory.ts",