@juspay/neurolink 9.26.2 → 9.28.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.
Files changed (125) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +59 -9
  3. package/dist/cli/commands/config.d.ts +4 -4
  4. package/dist/cli/commands/mcp.d.ts +87 -0
  5. package/dist/cli/commands/mcp.js +1524 -0
  6. package/dist/cli/loop/optionsSchema.js +4 -0
  7. package/dist/core/modules/ToolsManager.js +29 -2
  8. package/dist/index.d.ts +2 -1
  9. package/dist/index.js +27 -1
  10. package/dist/lib/core/modules/ToolsManager.js +29 -2
  11. package/dist/lib/index.d.ts +2 -1
  12. package/dist/lib/index.js +27 -1
  13. package/dist/lib/mcp/agentExposure.d.ts +228 -0
  14. package/dist/lib/mcp/agentExposure.js +357 -0
  15. package/dist/lib/mcp/batching/index.d.ts +11 -0
  16. package/dist/lib/mcp/batching/index.js +11 -0
  17. package/dist/lib/mcp/batching/requestBatcher.d.ts +202 -0
  18. package/dist/lib/mcp/batching/requestBatcher.js +442 -0
  19. package/dist/lib/mcp/caching/index.d.ts +11 -0
  20. package/dist/lib/mcp/caching/index.js +11 -0
  21. package/dist/lib/mcp/caching/toolCache.d.ts +221 -0
  22. package/dist/lib/mcp/caching/toolCache.js +434 -0
  23. package/dist/lib/mcp/elicitation/elicitationManager.d.ts +169 -0
  24. package/dist/lib/mcp/elicitation/elicitationManager.js +377 -0
  25. package/dist/lib/mcp/elicitation/index.d.ts +11 -0
  26. package/dist/lib/mcp/elicitation/index.js +12 -0
  27. package/dist/lib/mcp/elicitation/types.d.ts +278 -0
  28. package/dist/lib/mcp/elicitation/types.js +11 -0
  29. package/dist/lib/mcp/elicitationProtocol.d.ts +228 -0
  30. package/dist/lib/mcp/elicitationProtocol.js +376 -0
  31. package/dist/lib/mcp/enhancedToolDiscovery.d.ts +205 -0
  32. package/dist/lib/mcp/enhancedToolDiscovery.js +482 -0
  33. package/dist/lib/mcp/index.d.ts +38 -1
  34. package/dist/lib/mcp/index.js +36 -3
  35. package/dist/lib/mcp/mcpRegistryClient.d.ts +332 -0
  36. package/dist/lib/mcp/mcpRegistryClient.js +489 -0
  37. package/dist/lib/mcp/mcpServerBase.d.ts +227 -0
  38. package/dist/lib/mcp/mcpServerBase.js +374 -0
  39. package/dist/lib/mcp/multiServerManager.d.ts +310 -0
  40. package/dist/lib/mcp/multiServerManager.js +580 -0
  41. package/dist/lib/mcp/routing/index.d.ts +11 -0
  42. package/dist/lib/mcp/routing/index.js +11 -0
  43. package/dist/lib/mcp/routing/toolRouter.d.ts +219 -0
  44. package/dist/lib/mcp/routing/toolRouter.js +417 -0
  45. package/dist/lib/mcp/serverCapabilities.d.ts +341 -0
  46. package/dist/lib/mcp/serverCapabilities.js +503 -0
  47. package/dist/lib/mcp/toolAnnotations.d.ts +154 -0
  48. package/dist/lib/mcp/toolAnnotations.js +240 -0
  49. package/dist/lib/mcp/toolConverter.d.ts +178 -0
  50. package/dist/lib/mcp/toolConverter.js +259 -0
  51. package/dist/lib/mcp/toolIntegration.d.ts +136 -0
  52. package/dist/lib/mcp/toolIntegration.js +335 -0
  53. package/dist/lib/memory/hippocampusInitializer.d.ts +2 -2
  54. package/dist/lib/memory/hippocampusInitializer.js +1 -1
  55. package/dist/lib/neurolink.d.ts +275 -2
  56. package/dist/lib/neurolink.js +596 -56
  57. package/dist/lib/providers/litellm.d.ts +10 -0
  58. package/dist/lib/providers/litellm.js +104 -2
  59. package/dist/lib/types/configTypes.d.ts +56 -0
  60. package/dist/lib/types/conversation.d.ts +2 -2
  61. package/dist/lib/types/generateTypes.d.ts +4 -0
  62. package/dist/lib/types/index.d.ts +2 -1
  63. package/dist/lib/types/modelTypes.d.ts +6 -6
  64. package/dist/lib/types/streamTypes.d.ts +2 -0
  65. package/dist/lib/types/tools.d.ts +2 -0
  66. package/dist/lib/utils/pricing.js +177 -17
  67. package/dist/lib/utils/schemaConversion.d.ts +6 -1
  68. package/dist/lib/utils/schemaConversion.js +50 -28
  69. package/dist/lib/workflow/config.d.ts +16 -16
  70. package/dist/mcp/agentExposure.d.ts +228 -0
  71. package/dist/mcp/agentExposure.js +356 -0
  72. package/dist/mcp/batching/index.d.ts +11 -0
  73. package/dist/mcp/batching/index.js +10 -0
  74. package/dist/mcp/batching/requestBatcher.d.ts +202 -0
  75. package/dist/mcp/batching/requestBatcher.js +441 -0
  76. package/dist/mcp/caching/index.d.ts +11 -0
  77. package/dist/mcp/caching/index.js +10 -0
  78. package/dist/mcp/caching/toolCache.d.ts +221 -0
  79. package/dist/mcp/caching/toolCache.js +433 -0
  80. package/dist/mcp/elicitation/elicitationManager.d.ts +169 -0
  81. package/dist/mcp/elicitation/elicitationManager.js +376 -0
  82. package/dist/mcp/elicitation/index.d.ts +11 -0
  83. package/dist/mcp/elicitation/index.js +11 -0
  84. package/dist/mcp/elicitation/types.d.ts +278 -0
  85. package/dist/mcp/elicitation/types.js +10 -0
  86. package/dist/mcp/elicitationProtocol.d.ts +228 -0
  87. package/dist/mcp/elicitationProtocol.js +375 -0
  88. package/dist/mcp/enhancedToolDiscovery.d.ts +205 -0
  89. package/dist/mcp/enhancedToolDiscovery.js +481 -0
  90. package/dist/mcp/index.d.ts +38 -1
  91. package/dist/mcp/index.js +36 -3
  92. package/dist/mcp/mcpRegistryClient.d.ts +332 -0
  93. package/dist/mcp/mcpRegistryClient.js +488 -0
  94. package/dist/mcp/mcpServerBase.d.ts +227 -0
  95. package/dist/mcp/mcpServerBase.js +373 -0
  96. package/dist/mcp/multiServerManager.d.ts +310 -0
  97. package/dist/mcp/multiServerManager.js +579 -0
  98. package/dist/mcp/routing/index.d.ts +11 -0
  99. package/dist/mcp/routing/index.js +10 -0
  100. package/dist/mcp/routing/toolRouter.d.ts +219 -0
  101. package/dist/mcp/routing/toolRouter.js +416 -0
  102. package/dist/mcp/serverCapabilities.d.ts +341 -0
  103. package/dist/mcp/serverCapabilities.js +502 -0
  104. package/dist/mcp/toolAnnotations.d.ts +154 -0
  105. package/dist/mcp/toolAnnotations.js +239 -0
  106. package/dist/mcp/toolConverter.d.ts +178 -0
  107. package/dist/mcp/toolConverter.js +258 -0
  108. package/dist/mcp/toolIntegration.d.ts +136 -0
  109. package/dist/mcp/toolIntegration.js +334 -0
  110. package/dist/memory/hippocampusInitializer.d.ts +2 -2
  111. package/dist/memory/hippocampusInitializer.js +1 -1
  112. package/dist/neurolink.d.ts +275 -2
  113. package/dist/neurolink.js +596 -56
  114. package/dist/providers/litellm.d.ts +10 -0
  115. package/dist/providers/litellm.js +104 -2
  116. package/dist/types/configTypes.d.ts +56 -0
  117. package/dist/types/conversation.d.ts +2 -2
  118. package/dist/types/generateTypes.d.ts +4 -0
  119. package/dist/types/index.d.ts +2 -1
  120. package/dist/types/streamTypes.d.ts +2 -0
  121. package/dist/types/tools.d.ts +2 -0
  122. package/dist/utils/pricing.js +177 -17
  123. package/dist/utils/schemaConversion.d.ts +6 -1
  124. package/dist/utils/schemaConversion.js +50 -28
  125. package/package.json +2 -2
@@ -93,50 +93,72 @@ export function inlineJsonSchema(schema, definitions, visited = new Set()) {
93
93
  return result;
94
94
  }
95
95
  /**
96
- * Convert Zod schema to JSON Schema format for Claude AI
96
+ * Convert Zod schema to JSON Schema format for provider APIs.
97
+ *
98
+ * Handles three input types:
99
+ * 1. Zod schemas (have `_def.typeName`) — converted via zod-to-json-schema
100
+ * 2. AI SDK `jsonSchema()` wrappers (have `.jsonSchema` property) — extracted directly
101
+ * 3. Plain JSON Schema objects (have `type`/`properties` but no `_def`) — returned as-is
97
102
  */
98
103
  export function convertZodToJsonSchema(zodSchema) {
104
+ const schema = zodSchema;
105
+ if (!schema || typeof schema !== "object") {
106
+ return { type: "object", properties: {} };
107
+ }
108
+ // AI SDK jsonSchema() wrapper — extract the inner JSON Schema directly
109
+ if ("jsonSchema" in schema &&
110
+ schema.jsonSchema !== null &&
111
+ typeof schema.jsonSchema === "object") {
112
+ const extracted = schema.jsonSchema;
113
+ return ensureTypeField(extracted);
114
+ }
115
+ // Plain JSON Schema object (from external MCP tools) — no Zod internals
116
+ if (!isZodSchema(schema)) {
117
+ return ensureTypeField(schema);
118
+ }
119
+ // Actual Zod schema — convert via zod-to-json-schema
99
120
  try {
100
- // Use a type assertion that bypasses the infinite recursion check
101
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
102
121
  const jsonSchema = zodToJsonSchema(zodSchema, {
103
122
  name: "ToolParameters",
104
123
  target: "jsonSchema7",
105
124
  errorMessages: true,
106
125
  });
107
- // CRITICAL FIX: Ensure schema always has a proper type field for Google Vertex AI
108
- if (!jsonSchema.type) {
109
- // Default to "object" type if not specified, as most tool schemas are objects
110
- jsonSchema.type = "object";
111
- // If no properties, ensure it's at least an empty object schema
112
- if (!jsonSchema.properties) {
113
- jsonSchema.properties = {};
114
- }
115
- logger.info(`[SCHEMA-TYPE-FIX] Added missing type field to JSON Schema`, {
116
- originalType: undefined,
117
- fixedType: jsonSchema.type,
118
- hasProperties: !!jsonSchema.properties,
119
- addedEmptyProperties: !jsonSchema.properties,
120
- });
121
- }
122
- logger.debug("Converted Zod schema to JSON Schema", {
123
- hasProperties: !!jsonSchema.properties,
124
- propertiesCount: Object.keys(jsonSchema.properties || {}).length,
125
- schemaType: jsonSchema.type,
126
- hasTypeField: !!jsonSchema.type,
127
- });
128
- return jsonSchema;
126
+ // zodToJsonSchema with 'name' produces { $ref: "#/definitions/ToolParameters", definitions: {...} }
127
+ // Inline the $ref to produce a flat schema before passing to ensureTypeField
128
+ const inlined = inlineJsonSchema(jsonSchema);
129
+ return ensureTypeField(inlined);
129
130
  }
130
131
  catch (error) {
131
132
  logger.warn("Failed to convert Zod schema to JSON Schema", {
132
133
  error: error instanceof Error ? error.message : String(error),
133
134
  });
134
- // Return a valid empty object schema instead of empty object
135
- return {
135
+ return { type: "object", properties: {} };
136
+ }
137
+ }
138
+ /**
139
+ * Ensure a JSON Schema object has a `type` field (required by Vertex/Gemini).
140
+ */
141
+ function ensureTypeField(schema) {
142
+ if (!schema.type) {
143
+ // Schemas using composition keywords (anyOf/oneOf/allOf) deliberately omit type
144
+ if (schema.anyOf || schema.oneOf || schema.allOf) {
145
+ return schema;
146
+ }
147
+ const hadProperties = !!schema.properties;
148
+ const result = {
149
+ ...schema,
136
150
  type: "object",
137
- properties: {},
138
151
  };
152
+ if (!result.properties) {
153
+ result.properties = {};
154
+ }
155
+ logger.debug("[SCHEMA-TYPE-FIX] Added missing type field to JSON Schema", {
156
+ fixedType: "object",
157
+ addedProperties: !hadProperties,
158
+ });
159
+ return result;
139
160
  }
161
+ return schema;
140
162
  }
141
163
  /**
142
164
  * Check if a value is a Zod schema
@@ -236,6 +236,7 @@ export declare const ModelGroupSchema: z.ZodObject<{
236
236
  timeout: z.ZodOptional<z.ZodNumber>;
237
237
  metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<JsonValue, z.ZodTypeDef, JsonValue>>>;
238
238
  }, "strip", z.ZodTypeAny, {
239
+ id: string;
239
240
  models: {
240
241
  provider: AIProviderName;
241
242
  model: string;
@@ -251,7 +252,6 @@ export declare const ModelGroupSchema: z.ZodObject<{
251
252
  frequencyPenalty?: number | undefined;
252
253
  label?: string | undefined;
253
254
  }[];
254
- id: string;
255
255
  executionStrategy: "parallel" | "sequential";
256
256
  continueOnFailure: boolean;
257
257
  minSuccessful: number;
@@ -261,6 +261,7 @@ export declare const ModelGroupSchema: z.ZodObject<{
261
261
  description?: string | undefined;
262
262
  parallelism?: number | undefined;
263
263
  }, {
264
+ id: string;
264
265
  models: {
265
266
  provider: string;
266
267
  model: string;
@@ -276,7 +277,6 @@ export declare const ModelGroupSchema: z.ZodObject<{
276
277
  frequencyPenalty?: number | undefined;
277
278
  label?: string | undefined;
278
279
  }[];
279
- id: string;
280
280
  executionStrategy: "parallel" | "sequential";
281
281
  timeout?: number | undefined;
282
282
  metadata?: Record<string, JsonValue> | undefined;
@@ -438,6 +438,7 @@ export declare const WorkflowConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodObject
438
438
  timeout: z.ZodOptional<z.ZodNumber>;
439
439
  metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<JsonValue, z.ZodTypeDef, JsonValue>>>;
440
440
  }, "strip", z.ZodTypeAny, {
441
+ id: string;
441
442
  models: {
442
443
  provider: AIProviderName;
443
444
  model: string;
@@ -453,7 +454,6 @@ export declare const WorkflowConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodObject
453
454
  frequencyPenalty?: number | undefined;
454
455
  label?: string | undefined;
455
456
  }[];
456
- id: string;
457
457
  executionStrategy: "parallel" | "sequential";
458
458
  continueOnFailure: boolean;
459
459
  minSuccessful: number;
@@ -463,6 +463,7 @@ export declare const WorkflowConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodObject
463
463
  description?: string | undefined;
464
464
  parallelism?: number | undefined;
465
465
  }, {
466
+ id: string;
466
467
  models: {
467
468
  provider: string;
468
469
  model: string;
@@ -478,7 +479,6 @@ export declare const WorkflowConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodObject
478
479
  frequencyPenalty?: number | undefined;
479
480
  label?: string | undefined;
480
481
  }[];
481
- id: string;
482
482
  executionStrategy: "parallel" | "sequential";
483
483
  timeout?: number | undefined;
484
484
  metadata?: Record<string, JsonValue> | undefined;
@@ -716,6 +716,7 @@ export declare const WorkflowConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodObject
716
716
  }, "strip", z.ZodTypeAny, {
717
717
  type: "custom" | "chain" | "ensemble" | "adaptive";
718
718
  name: string;
719
+ id: string;
719
720
  models: {
720
721
  provider: AIProviderName;
721
722
  model: string;
@@ -731,7 +732,6 @@ export declare const WorkflowConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodObject
731
732
  frequencyPenalty?: number | undefined;
732
733
  label?: string | undefined;
733
734
  }[];
734
- id: string;
735
735
  execution?: {
736
736
  timeout?: number | undefined;
737
737
  metadata?: Record<string, JsonValue> | undefined;
@@ -789,6 +789,7 @@ export declare const WorkflowConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodObject
789
789
  createdAt?: string | undefined;
790
790
  updatedAt?: string | undefined;
791
791
  modelGroups?: {
792
+ id: string;
792
793
  models: {
793
794
  provider: AIProviderName;
794
795
  model: string;
@@ -804,7 +805,6 @@ export declare const WorkflowConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodObject
804
805
  frequencyPenalty?: number | undefined;
805
806
  label?: string | undefined;
806
807
  }[];
807
- id: string;
808
808
  executionStrategy: "parallel" | "sequential";
809
809
  continueOnFailure: boolean;
810
810
  minSuccessful: number;
@@ -838,6 +838,7 @@ export declare const WorkflowConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodObject
838
838
  }, {
839
839
  type: "custom" | "chain" | "ensemble" | "adaptive";
840
840
  name: string;
841
+ id: string;
841
842
  models: {
842
843
  provider: string;
843
844
  model: string;
@@ -853,7 +854,6 @@ export declare const WorkflowConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodObject
853
854
  frequencyPenalty?: number | undefined;
854
855
  label?: string | undefined;
855
856
  }[];
856
- id: string;
857
857
  execution?: {
858
858
  timeout?: number | undefined;
859
859
  metadata?: Record<string, JsonValue> | undefined;
@@ -911,6 +911,7 @@ export declare const WorkflowConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodObject
911
911
  createdAt?: string | undefined;
912
912
  updatedAt?: string | undefined;
913
913
  modelGroups?: {
914
+ id: string;
914
915
  models: {
915
916
  provider: string;
916
917
  model: string;
@@ -926,7 +927,6 @@ export declare const WorkflowConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodObject
926
927
  frequencyPenalty?: number | undefined;
927
928
  label?: string | undefined;
928
929
  }[];
929
- id: string;
930
930
  executionStrategy: "parallel" | "sequential";
931
931
  timeout?: number | undefined;
932
932
  metadata?: Record<string, JsonValue> | undefined;
@@ -960,6 +960,7 @@ export declare const WorkflowConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodObject
960
960
  }>, {
961
961
  type: "custom" | "chain" | "ensemble" | "adaptive";
962
962
  name: string;
963
+ id: string;
963
964
  models: {
964
965
  provider: AIProviderName;
965
966
  model: string;
@@ -975,7 +976,6 @@ export declare const WorkflowConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodObject
975
976
  frequencyPenalty?: number | undefined;
976
977
  label?: string | undefined;
977
978
  }[];
978
- id: string;
979
979
  execution?: {
980
980
  timeout?: number | undefined;
981
981
  metadata?: Record<string, JsonValue> | undefined;
@@ -1033,6 +1033,7 @@ export declare const WorkflowConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodObject
1033
1033
  createdAt?: string | undefined;
1034
1034
  updatedAt?: string | undefined;
1035
1035
  modelGroups?: {
1036
+ id: string;
1036
1037
  models: {
1037
1038
  provider: AIProviderName;
1038
1039
  model: string;
@@ -1048,7 +1049,6 @@ export declare const WorkflowConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodObject
1048
1049
  frequencyPenalty?: number | undefined;
1049
1050
  label?: string | undefined;
1050
1051
  }[];
1051
- id: string;
1052
1052
  executionStrategy: "parallel" | "sequential";
1053
1053
  continueOnFailure: boolean;
1054
1054
  minSuccessful: number;
@@ -1082,6 +1082,7 @@ export declare const WorkflowConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodObject
1082
1082
  }, {
1083
1083
  type: "custom" | "chain" | "ensemble" | "adaptive";
1084
1084
  name: string;
1085
+ id: string;
1085
1086
  models: {
1086
1087
  provider: string;
1087
1088
  model: string;
@@ -1097,7 +1098,6 @@ export declare const WorkflowConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodObject
1097
1098
  frequencyPenalty?: number | undefined;
1098
1099
  label?: string | undefined;
1099
1100
  }[];
1100
- id: string;
1101
1101
  execution?: {
1102
1102
  timeout?: number | undefined;
1103
1103
  metadata?: Record<string, JsonValue> | undefined;
@@ -1155,6 +1155,7 @@ export declare const WorkflowConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodObject
1155
1155
  createdAt?: string | undefined;
1156
1156
  updatedAt?: string | undefined;
1157
1157
  modelGroups?: {
1158
+ id: string;
1158
1159
  models: {
1159
1160
  provider: string;
1160
1161
  model: string;
@@ -1170,7 +1171,6 @@ export declare const WorkflowConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodObject
1170
1171
  frequencyPenalty?: number | undefined;
1171
1172
  label?: string | undefined;
1172
1173
  }[];
1173
- id: string;
1174
1174
  executionStrategy: "parallel" | "sequential";
1175
1175
  timeout?: number | undefined;
1176
1176
  metadata?: Record<string, JsonValue> | undefined;
@@ -1204,6 +1204,7 @@ export declare const WorkflowConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodObject
1204
1204
  }>, {
1205
1205
  type: "custom" | "chain" | "ensemble" | "adaptive";
1206
1206
  name: string;
1207
+ id: string;
1207
1208
  models: {
1208
1209
  provider: AIProviderName;
1209
1210
  model: string;
@@ -1219,7 +1220,6 @@ export declare const WorkflowConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodObject
1219
1220
  frequencyPenalty?: number | undefined;
1220
1221
  label?: string | undefined;
1221
1222
  }[];
1222
- id: string;
1223
1223
  execution?: {
1224
1224
  timeout?: number | undefined;
1225
1225
  metadata?: Record<string, JsonValue> | undefined;
@@ -1277,6 +1277,7 @@ export declare const WorkflowConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodObject
1277
1277
  createdAt?: string | undefined;
1278
1278
  updatedAt?: string | undefined;
1279
1279
  modelGroups?: {
1280
+ id: string;
1280
1281
  models: {
1281
1282
  provider: AIProviderName;
1282
1283
  model: string;
@@ -1292,7 +1293,6 @@ export declare const WorkflowConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodObject
1292
1293
  frequencyPenalty?: number | undefined;
1293
1294
  label?: string | undefined;
1294
1295
  }[];
1295
- id: string;
1296
1296
  executionStrategy: "parallel" | "sequential";
1297
1297
  continueOnFailure: boolean;
1298
1298
  minSuccessful: number;
@@ -1326,6 +1326,7 @@ export declare const WorkflowConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodObject
1326
1326
  }, {
1327
1327
  type: "custom" | "chain" | "ensemble" | "adaptive";
1328
1328
  name: string;
1329
+ id: string;
1329
1330
  models: {
1330
1331
  provider: string;
1331
1332
  model: string;
@@ -1341,7 +1342,6 @@ export declare const WorkflowConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodObject
1341
1342
  frequencyPenalty?: number | undefined;
1342
1343
  label?: string | undefined;
1343
1344
  }[];
1344
- id: string;
1345
1345
  execution?: {
1346
1346
  timeout?: number | undefined;
1347
1347
  metadata?: Record<string, JsonValue> | undefined;
@@ -1399,6 +1399,7 @@ export declare const WorkflowConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodObject
1399
1399
  createdAt?: string | undefined;
1400
1400
  updatedAt?: string | undefined;
1401
1401
  modelGroups?: {
1402
+ id: string;
1402
1403
  models: {
1403
1404
  provider: string;
1404
1405
  model: string;
@@ -1414,7 +1415,6 @@ export declare const WorkflowConfigSchema: z.ZodEffects<z.ZodEffects<z.ZodObject
1414
1415
  frequencyPenalty?: number | undefined;
1415
1416
  label?: string | undefined;
1416
1417
  }[];
1417
- id: string;
1418
1418
  executionStrategy: "parallel" | "sequential";
1419
1419
  timeout?: number | undefined;
1420
1420
  metadata?: Record<string, JsonValue> | undefined;
@@ -0,0 +1,228 @@
1
+ /**
2
+ * Agent and Workflow Exposure as MCP Tools
3
+ *
4
+ * Enables exposing NeuroLink agents and workflows as MCP tools,
5
+ * allowing external MCP clients to invoke complex AI operations
6
+ * through the standardized MCP protocol.
7
+ *
8
+ * @module mcp/agentExposure
9
+ * @since 8.39.0
10
+ */
11
+ import type { JsonObject } from "../types/common.js";
12
+ import type { NeuroLinkExecutionContext } from "../types/mcpTypes.js";
13
+ import type { MCPServerTool, MCPToolAnnotations } from "./toolAnnotations.js";
14
+ /**
15
+ * Agent definition for MCP exposure
16
+ */
17
+ export type ExposableAgent = {
18
+ /**
19
+ * Unique agent identifier
20
+ */
21
+ id: string;
22
+ /**
23
+ * Human-readable agent name
24
+ */
25
+ name: string;
26
+ /**
27
+ * Agent description for AI models
28
+ */
29
+ description: string;
30
+ /**
31
+ * Input schema for the agent
32
+ */
33
+ inputSchema?: JsonObject;
34
+ /**
35
+ * Output schema for the agent
36
+ */
37
+ outputSchema?: JsonObject;
38
+ /**
39
+ * Agent execution function
40
+ */
41
+ execute: (input: unknown, context?: NeuroLinkExecutionContext) => Promise<unknown>;
42
+ /**
43
+ * Additional agent metadata
44
+ */
45
+ metadata?: {
46
+ version?: string;
47
+ author?: string;
48
+ category?: string;
49
+ tags?: string[];
50
+ estimatedDuration?: number;
51
+ costHint?: number;
52
+ };
53
+ };
54
+ /**
55
+ * Workflow definition for MCP exposure
56
+ */
57
+ export type ExposableWorkflow = {
58
+ /**
59
+ * Unique workflow identifier
60
+ */
61
+ id: string;
62
+ /**
63
+ * Human-readable workflow name
64
+ */
65
+ name: string;
66
+ /**
67
+ * Workflow description
68
+ */
69
+ description: string;
70
+ /**
71
+ * Workflow steps (for documentation)
72
+ */
73
+ steps?: Array<{
74
+ id: string;
75
+ name: string;
76
+ description?: string;
77
+ }>;
78
+ /**
79
+ * Input schema for the workflow
80
+ */
81
+ inputSchema?: JsonObject;
82
+ /**
83
+ * Output schema for the workflow
84
+ */
85
+ outputSchema?: JsonObject;
86
+ /**
87
+ * Workflow execution function
88
+ */
89
+ execute: (input: unknown, context?: NeuroLinkExecutionContext) => Promise<unknown>;
90
+ /**
91
+ * Workflow metadata
92
+ */
93
+ metadata?: {
94
+ version?: string;
95
+ author?: string;
96
+ category?: string;
97
+ tags?: string[];
98
+ estimatedDuration?: number;
99
+ retriable?: boolean;
100
+ idempotent?: boolean;
101
+ };
102
+ };
103
+ /**
104
+ * Options for exposing agents/workflows as MCP tools
105
+ */
106
+ export type ExposureOptions = {
107
+ /**
108
+ * Prefix for tool names
109
+ */
110
+ prefix?: string;
111
+ /**
112
+ * Default annotations for all exposed tools
113
+ */
114
+ defaultAnnotations?: MCPToolAnnotations;
115
+ /**
116
+ * Whether to include metadata in tool description
117
+ */
118
+ includeMetadataInDescription?: boolean;
119
+ /**
120
+ * Custom name transformer
121
+ */
122
+ nameTransformer?: (name: string) => string;
123
+ /**
124
+ * Add execution context wrapper
125
+ */
126
+ wrapWithContext?: boolean;
127
+ /**
128
+ * Timeout for agent/workflow execution (ms)
129
+ */
130
+ executionTimeout?: number;
131
+ /**
132
+ * Enable execution logging
133
+ */
134
+ enableLogging?: boolean;
135
+ };
136
+ /**
137
+ * Exposure result
138
+ */
139
+ export type ExposureResult = {
140
+ /**
141
+ * Generated MCP tool
142
+ */
143
+ tool: MCPServerTool;
144
+ /**
145
+ * Original source type
146
+ */
147
+ sourceType: "agent" | "workflow";
148
+ /**
149
+ * Original source ID
150
+ */
151
+ sourceId: string;
152
+ /**
153
+ * Generated tool name
154
+ */
155
+ toolName: string;
156
+ };
157
+ /**
158
+ * Expose an agent as an MCP tool
159
+ */
160
+ export declare function exposeAgentAsTool(agent: ExposableAgent, options?: ExposureOptions): ExposureResult;
161
+ /**
162
+ * Expose a workflow as an MCP tool
163
+ */
164
+ export declare function exposeWorkflowAsTool(workflow: ExposableWorkflow, options?: ExposureOptions): ExposureResult;
165
+ /**
166
+ * Batch expose agents as MCP tools
167
+ */
168
+ export declare function exposeAgentsAsTools(agents: ExposableAgent[], options?: ExposureOptions): ExposureResult[];
169
+ /**
170
+ * Batch expose workflows as MCP tools
171
+ */
172
+ export declare function exposeWorkflowsAsTools(workflows: ExposableWorkflow[], options?: ExposureOptions): ExposureResult[];
173
+ /**
174
+ * Agent Exposure Manager
175
+ *
176
+ * Manages the lifecycle of exposed agents and workflows,
177
+ * providing registration, lookup, and invocation capabilities.
178
+ */
179
+ export declare class AgentExposureManager {
180
+ private exposedTools;
181
+ private options;
182
+ constructor(options?: ExposureOptions);
183
+ /**
184
+ * Expose an agent and register it
185
+ */
186
+ exposeAgent(agent: ExposableAgent): MCPServerTool;
187
+ /**
188
+ * Expose a workflow and register it
189
+ */
190
+ exposeWorkflow(workflow: ExposableWorkflow): MCPServerTool;
191
+ /**
192
+ * Get all exposed tools
193
+ */
194
+ getExposedTools(): MCPServerTool[];
195
+ /**
196
+ * Get exposed tool by name
197
+ */
198
+ getExposedTool(toolName: string): MCPServerTool | undefined;
199
+ /**
200
+ * Get exposure result by tool name
201
+ */
202
+ getExposureResult(toolName: string): ExposureResult | undefined;
203
+ /**
204
+ * Get tools by source type
205
+ */
206
+ getToolsBySourceType(sourceType: "agent" | "workflow"): MCPServerTool[];
207
+ /**
208
+ * Remove exposed tool
209
+ */
210
+ unexpose(toolName: string): boolean;
211
+ /**
212
+ * Clear all exposed tools
213
+ */
214
+ clear(): void;
215
+ /**
216
+ * Get statistics
217
+ */
218
+ getStatistics(): {
219
+ totalExposed: number;
220
+ exposedAgents: number;
221
+ exposedWorkflows: number;
222
+ toolNames: string[];
223
+ };
224
+ }
225
+ /**
226
+ * Global agent exposure manager instance
227
+ */
228
+ export declare const globalAgentExposureManager: AgentExposureManager;