@juspay/neurolink 9.90.0 → 9.91.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.
Files changed (49) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/browser/neurolink.min.js +370 -361
  3. package/dist/core/baseProvider.d.ts +37 -3
  4. package/dist/core/baseProvider.js +167 -44
  5. package/dist/core/modules/GenerationHandler.js +7 -1
  6. package/dist/core/modules/ToolsManager.js +5 -0
  7. package/dist/core/toolDedup.js +4 -1
  8. package/dist/lib/core/baseProvider.d.ts +37 -3
  9. package/dist/lib/core/baseProvider.js +167 -44
  10. package/dist/lib/core/modules/GenerationHandler.js +7 -1
  11. package/dist/lib/core/modules/ToolsManager.js +5 -0
  12. package/dist/lib/core/toolDedup.js +4 -1
  13. package/dist/lib/mcp/toolRegistry.js +7 -2
  14. package/dist/lib/neurolink.d.ts +31 -1
  15. package/dist/lib/neurolink.js +151 -26
  16. package/dist/lib/providers/sagemaker/client.d.ts +9 -0
  17. package/dist/lib/providers/sagemaker/client.js +75 -30
  18. package/dist/lib/server/routes/agentRoutes.js +25 -2
  19. package/dist/lib/tools/toolDiscovery.d.ts +48 -0
  20. package/dist/lib/tools/toolDiscovery.js +231 -0
  21. package/dist/lib/tools/toolGate.d.ts +16 -0
  22. package/dist/lib/tools/toolGate.js +51 -0
  23. package/dist/lib/tools/toolPolicy.d.ts +40 -0
  24. package/dist/lib/tools/toolPolicy.js +194 -0
  25. package/dist/lib/types/config.d.ts +43 -3
  26. package/dist/lib/types/index.d.ts +1 -0
  27. package/dist/lib/types/index.js +1 -0
  28. package/dist/lib/types/providers.d.ts +8 -0
  29. package/dist/lib/types/toolResolution.d.ts +73 -0
  30. package/dist/lib/types/toolResolution.js +11 -0
  31. package/dist/mcp/toolRegistry.js +7 -2
  32. package/dist/neurolink.d.ts +31 -1
  33. package/dist/neurolink.js +151 -26
  34. package/dist/providers/sagemaker/client.d.ts +9 -0
  35. package/dist/providers/sagemaker/client.js +75 -30
  36. package/dist/server/routes/agentRoutes.js +25 -2
  37. package/dist/tools/toolDiscovery.d.ts +48 -0
  38. package/dist/tools/toolDiscovery.js +230 -0
  39. package/dist/tools/toolGate.d.ts +16 -0
  40. package/dist/tools/toolGate.js +50 -0
  41. package/dist/tools/toolPolicy.d.ts +40 -0
  42. package/dist/tools/toolPolicy.js +193 -0
  43. package/dist/types/config.d.ts +43 -3
  44. package/dist/types/index.d.ts +1 -0
  45. package/dist/types/index.js +1 -0
  46. package/dist/types/providers.d.ts +8 -0
  47. package/dist/types/toolResolution.d.ts +73 -0
  48. package/dist/types/toolResolution.js +10 -0
  49. package/package.json +3 -2
@@ -42,6 +42,12 @@ export type NeurolinkConstructorConfig = {
42
42
  conversationMemory?: Partial<ConversationMemoryConfig>;
43
43
  enableOrchestration?: boolean;
44
44
  hitl?: HITLConfig;
45
+ /**
46
+ * Instance-level tool policy: master switch, include/exclude lists
47
+ * (with `*` glob support), and on-demand MCP tool discovery.
48
+ * See {@link ToolConfig}.
49
+ */
50
+ tools?: ToolConfig;
45
51
  toolRegistry?: MCPToolRegistry;
46
52
  observability?: ObservabilityConfig;
47
53
  modelAliasConfig?: ModelAliasConfig;
@@ -329,14 +335,48 @@ export type AnalyticsConfig = {
329
335
  };
330
336
  };
331
337
  /**
332
- * Tool configuration
338
+ * Instance-level tool configuration (`new NeuroLink({ tools: {...} })`).
339
+ *
340
+ * The four primary keys (`enabled`, `include`, `exclude`, `discovery`) form
341
+ * the complete modern surface; per-call options (`toolFilter`,
342
+ * `excludeTools`, `enabledToolNames`, `disableTools`) keep working and are
343
+ * merged with this config by `resolveToolPolicy()`.
333
344
  */
334
345
  export type ToolConfig = {
335
- /** Whether built-in tools should be disabled */
346
+ /**
347
+ * Master switch. `false` disables all tools for every call from this
348
+ * instance (equivalent to passing `disableTools: true` on each call).
349
+ * Default: true.
350
+ */
351
+ enabled?: boolean;
352
+ /**
353
+ * Allowlist of tool names. Supports `*` globs (e.g. `"github*"`).
354
+ * Undefined = all tools; an EMPTY array means no tools (fail-closed).
355
+ * Per-call `toolFilter` is bounded by this list (a per-call filter can
356
+ * narrow it further but never widen past it).
357
+ */
358
+ include?: string[];
359
+ /** Denylist of tool names (supports `*` globs). Applied after `include`. */
360
+ exclude?: string[];
361
+ /**
362
+ * Defer external MCP tool schemas behind a `search_tools` meta-tool: the
363
+ * model sees a compact name+summary catalog instead of full schemas and
364
+ * loads a tool on demand by searching for it. Built-in tools, per-call
365
+ * tools, per-call whitelists (`toolFilter`/`enabledToolNames`), forced
366
+ * `toolChoice` tools, and already-discovered tools are always sent in
367
+ * full. Note: the instance-level `include` list deliberately does NOT
368
+ * force tools hot — it scopes the catalog, and discovery defers within
369
+ * that scope (a scoped-but-large catalog is exactly where deferral pays).
370
+ * Default: false.
371
+ */
372
+ discovery?: boolean;
373
+ /** Whether built-in tools should be disabled (equivalent to excluding all direct tools) */
336
374
  disableBuiltinTools?: boolean;
337
375
  /** Whether custom tools are allowed */
338
376
  allowCustomTools?: boolean;
339
- /** Maximum number of tools per provider */
377
+ /**
378
+ * @deprecated Never enforced; retained for compile compatibility only.
379
+ */
340
380
  maxToolsPerProvider?: number;
341
381
  /** Whether MCP tools should be enabled */
342
382
  enableMCPTools?: boolean;
@@ -52,6 +52,7 @@ export * from "./subscription.js";
52
52
  export * from "./task.js";
53
53
  export * from "./taskClassification.js";
54
54
  export * from "./toolDedup.js";
55
+ export * from "./toolResolution.js";
55
56
  export * from "./toolRouting.js";
56
57
  export * from "./tools.js";
57
58
  export * from "./vectorStoreChroma.js";
@@ -53,6 +53,7 @@ export * from "./subscription.js";
53
53
  export * from "./task.js";
54
54
  export * from "./taskClassification.js";
55
55
  export * from "./toolDedup.js";
56
+ export * from "./toolResolution.js";
56
57
  export * from "./toolRouting.js";
57
58
  export * from "./tools.js";
58
59
  export * from "./vectorStoreChroma.js";
@@ -593,6 +593,14 @@ export type AIProvider = {
593
593
  traceId: string;
594
594
  parentSpanId: string;
595
595
  } | null): void;
596
+ /**
597
+ * Whether this provider supports native tool/function calling for the
598
+ * current model. Implemented by BaseProvider (default true); overridden by
599
+ * providers with model-dependent or absent tool support (ollama,
600
+ * huggingface, image providers). Optional for compile compatibility with
601
+ * external AIProvider implementations — callers treat absence as `true`.
602
+ */
603
+ supportsTools?(): boolean;
596
604
  };
597
605
  /**
598
606
  * Provider attempt result for iteration tracking (converted from interface)
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Tool resolution types — the single tool-policy pipeline that decides which
3
+ * tools are sent to a provider for a given request.
4
+ *
5
+ * One policy object is resolved per request from (a) per-call legacy options
6
+ * (`toolFilter`, `excludeTools`, `enabledToolNames`, `disableTools`) and
7
+ * (b) the instance-level `tools` config, then applied at the single gate in
8
+ * `BaseProvider` that every generate/stream path passes through.
9
+ */
10
+ import type { ToolConfig } from "./config.js";
11
+ /**
12
+ * The resolved, merged tool policy for one request. Produced by
13
+ * `resolveToolPolicy()` (src/lib/tools/toolPolicy.ts) and consumed by
14
+ * `applyToolGate()` (src/lib/tools/toolGate.ts).
15
+ */
16
+ export type ResolvedToolPolicy = {
17
+ /** false = no tools at all for this request (drops caller-supplied tools too). */
18
+ enabled: boolean;
19
+ /**
20
+ * Allowlist of tool-name patterns (exact names or `*` globs).
21
+ * `undefined` = all tools pass. An empty array means "no tools" — it can
22
+ * only come from the new `tools.include` config surface; legacy
23
+ * `toolFilter: []` is normalized to `undefined` (fail-open, preserving
24
+ * historical behavior) before it reaches here.
25
+ */
26
+ include?: string[];
27
+ /**
28
+ * Secondary allowlist clause ANDed with `include` — set when both a
29
+ * legacy per-call allowlist and the instance `tools.include` are present.
30
+ * Kept as a separate clause because two glob pattern lists cannot be
31
+ * losslessly pre-intersected into a single pattern array (a name must
32
+ * match BOTH lists to pass).
33
+ */
34
+ includeBound?: string[];
35
+ /** Denylist of tool-name patterns (exact names or `*` globs), applied after include. */
36
+ exclude: string[];
37
+ /** Defer external MCP tool schemas behind the search_tools meta-tool. */
38
+ discovery: boolean;
39
+ /** Which option/config sources contributed to this policy (telemetry/debugging). */
40
+ sources: string[];
41
+ };
42
+ /**
43
+ * Inputs to `resolveToolPolicy()`. Kept as a named type so the mapping is
44
+ * unit-testable as a pure function.
45
+ */
46
+ export type ToolPolicyResolutionInput = {
47
+ /** Per-call options (the legacy per-call filtering surface). */
48
+ options: {
49
+ disableTools?: boolean;
50
+ toolFilter?: string[];
51
+ enabledToolNames?: string[];
52
+ excludeTools?: string[];
53
+ };
54
+ /** Instance-level `tools` config passed to the NeuroLink constructor. */
55
+ instanceConfig?: ToolConfig;
56
+ /**
57
+ * Names of the built-in (direct) tools of the calling provider — used to
58
+ * honor `tools.disableBuiltinTools` without this module importing the
59
+ * direct-tools registry.
60
+ */
61
+ builtinToolNames?: string[];
62
+ };
63
+ /**
64
+ * One entry in the deferred-tool catalog embedded in the `search_tools`
65
+ * meta-tool description when `tools.discovery` is enabled.
66
+ */
67
+ export type DeferredToolIndexEntry = {
68
+ name: string;
69
+ /** One-line description (truncated) shown in the search_tools catalog. */
70
+ summary: string;
71
+ /** Originating MCP server id, when known. */
72
+ serverId?: string;
73
+ };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Tool resolution types — the single tool-policy pipeline that decides which
3
+ * tools are sent to a provider for a given request.
4
+ *
5
+ * One policy object is resolved per request from (a) per-call legacy options
6
+ * (`toolFilter`, `excludeTools`, `enabledToolNames`, `disableTools`) and
7
+ * (b) the instance-level `tools` config, then applied at the single gate in
8
+ * `BaseProvider` that every generate/stream path passes through.
9
+ */
10
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juspay/neurolink",
3
- "version": "9.90.0",
3
+ "version": "9.91.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": {
@@ -74,6 +74,7 @@
74
74
  "test:cache": "npx tsx test/continuous-test-suite-cache-breakpoints.ts",
75
75
  "test:evaluation": "npx tsx test/continuous-test-suite-evaluation.ts",
76
76
  "test:mcp": "npx tsx test/continuous-test-suite-mcp-infra.ts",
77
+ "test:tool-resolution": "npx tsx test/continuous-test-suite-tool-resolution.ts",
77
78
  "test:mcp:http": "npx tsx test/continuous-test-suite-mcp-http.ts",
78
79
  "test:mcp:sdk": "npx tsx test/continuous-test-suite-mcp-sdk.ts",
79
80
  "test:mcp:cli": "npx tsx test/continuous-test-suite-mcp-cli.ts",
@@ -335,7 +336,6 @@
335
336
  "@ai-sdk/provider": "^3.0.8",
336
337
  "@anthropic-ai/sdk": "^0.102.0",
337
338
  "@anthropic-ai/vertex-sdk": "^0.16.0",
338
- "@aws-sdk/client-sagemaker-runtime": "^3.1000.0",
339
339
  "@aws-sdk/types": "^3.862.0",
340
340
  "@google/genai": "^1.43.0",
341
341
  "@modelcontextprotocol/sdk": "^1.27.1",
@@ -399,6 +399,7 @@
399
399
  "@aws-sdk/client-bedrock": "^3.1000.0",
400
400
  "@aws-sdk/client-bedrock-runtime": "^3.1000.0",
401
401
  "@aws-sdk/client-sagemaker": "^3.1000.0",
402
+ "@aws-sdk/client-sagemaker-runtime": "^3.1000.0",
402
403
  "@aws-sdk/credential-provider-node": "^3.886.0",
403
404
  "@fastify/cors": "^11.2.0",
404
405
  "@fastify/rate-limit": "^10.3.0",