@juspay/neurolink 13.13.4 → 13.13.6
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 +392 -392
- package/dist/hitl/hitlManager.d.ts +1 -0
- package/dist/hitl/hitlManager.js +24 -0
- package/dist/hitl/toolCallConfirmation.d.ts +8 -0
- package/dist/hitl/toolCallConfirmation.js +12 -0
- package/dist/mcp/batching/requestBatcher.d.ts +1 -1
- package/dist/mcp/batching/requestBatcher.js +8 -4
- package/dist/mcp/toolRegistry.js +9 -4
- package/dist/neurolink.d.ts +7 -0
- package/dist/neurolink.js +26 -5
- package/dist/types/hitl.d.ts +8 -0
- package/dist/types/mcp.d.ts +3 -1
- package/docs-site/static/search-index.json +4 -4
- package/package.json +1 -1
package/dist/hitl/hitlManager.js
CHANGED
|
@@ -13,6 +13,20 @@ import { logger } from "../utils/logger.js";
|
|
|
13
13
|
const DEFAULT_TIMEOUT = 30000; // 30 seconds
|
|
14
14
|
// Shared with NeuroLink's HITL init logs so they report the policy applied here
|
|
15
15
|
export const DEFAULT_ALLOW_MODIFICATION = false;
|
|
16
|
+
// Record<keyof HITLConfig, true> makes adding a HITLConfig key without listing it here a compile error
|
|
17
|
+
const KNOWN_CONFIG_KEYS = new Set(Object.keys({
|
|
18
|
+
enabled: true,
|
|
19
|
+
dangerousActions: true,
|
|
20
|
+
timeout: true,
|
|
21
|
+
confirmationMethod: true,
|
|
22
|
+
allowArgumentModification: true,
|
|
23
|
+
autoApproveOnTimeout: true,
|
|
24
|
+
autoApproveExclusions: true,
|
|
25
|
+
auditLogging: true,
|
|
26
|
+
customRules: true,
|
|
27
|
+
confirmBuiltinTools: true,
|
|
28
|
+
confirmDirectToolCalls: true,
|
|
29
|
+
}));
|
|
16
30
|
/** The abort reason as text for `hitl:cancelled`, whatever the caller passed. */
|
|
17
31
|
export function describeAbortReason(signal) {
|
|
18
32
|
const reason = signal.reason;
|
|
@@ -53,10 +67,19 @@ export class HITLManager extends EventEmitter {
|
|
|
53
67
|
this.config = this.validateConfig(config);
|
|
54
68
|
this.setupEventHandlers();
|
|
55
69
|
}
|
|
70
|
+
warnedUnknownKeys = new Set();
|
|
56
71
|
/**
|
|
57
72
|
* Validate HITL configuration and apply defaults
|
|
58
73
|
*/
|
|
59
74
|
validateConfig(config) {
|
|
75
|
+
// Warn only: throwing here would break callers that pass planned-but-unsupported keys today.
|
|
76
|
+
// alwaysStderr, not logger.warn: warn is hidden unless NEUROLINK_DEBUG is set, and a typo'd key silently disables approval gates.
|
|
77
|
+
for (const key of Object.keys(config)) {
|
|
78
|
+
if (!KNOWN_CONFIG_KEYS.has(key) && !this.warnedUnknownKeys.has(key)) {
|
|
79
|
+
this.warnedUnknownKeys.add(key);
|
|
80
|
+
logger.alwaysStderr(`[HITL] Unknown config key "${key}" is ignored and has no effect. Supported keys: ${[...KNOWN_CONFIG_KEYS].join(", ")}. See docs/features/enterprise-hitl.md`);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
60
83
|
// Apply defaults for optional fields
|
|
61
84
|
const configWithDefaults = {
|
|
62
85
|
enabled: config.enabled,
|
|
@@ -71,6 +94,7 @@ export class HITLManager extends EventEmitter {
|
|
|
71
94
|
auditLogging: config.auditLogging ?? false, // Default: false
|
|
72
95
|
customRules: config.customRules ?? [], // Default: empty array
|
|
73
96
|
confirmBuiltinTools: config.confirmBuiltinTools ?? true, // Default: true (built-in write/bash tools prompt)
|
|
97
|
+
confirmDirectToolCalls: config.confirmDirectToolCalls ?? false, // Default: false (direct executeTool calls keep their existing behaviour)
|
|
74
98
|
};
|
|
75
99
|
if (!configWithDefaults.enabled) {
|
|
76
100
|
return configWithDefaults; // If disabled, don't validate other fields
|
|
@@ -20,6 +20,14 @@ export declare function createHITLExecutionState(): HITLExecutionState;
|
|
|
20
20
|
* machine unless the host set `hitl.confirmBuiltinTools: false`.
|
|
21
21
|
*/
|
|
22
22
|
export declare function builtInToolAlwaysConfirmed(hitl: HITLManager, toolName: string): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* `builtInToolAlwaysConfirmed` for a direct call to a tool resolved from the
|
|
25
|
+
* registry. It is opt-in (`hitl.confirmDirectToolCalls: true`) because direct
|
|
26
|
+
* callers were never prompted for these tools. Only a tool registered by
|
|
27
|
+
* NeuroLink itself (server `direct`) is a built-in, so a custom or external
|
|
28
|
+
* tool that reuses the name `writeFile` is not swept in.
|
|
29
|
+
*/
|
|
30
|
+
export declare function registeredToolAlwaysConfirmed(hitl: HITLManager, toolName: string, serverId: string | undefined): boolean;
|
|
23
31
|
/** Mark `result` as a HITL refusal and return it. */
|
|
24
32
|
export declare function markRefusalResult<T extends object>(result: T): T;
|
|
25
33
|
/** Whether `result` was marked as a HITL refusal (`markRefusalResult`). */
|
|
@@ -87,6 +87,18 @@ export function builtInToolAlwaysConfirmed(hitl, toolName) {
|
|
|
87
87
|
return (HITL_ALWAYS_CONFIRM_BUILT_IN_TOOLS.has(toolName) &&
|
|
88
88
|
hitl.getConfig().confirmBuiltinTools !== false);
|
|
89
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* `builtInToolAlwaysConfirmed` for a direct call to a tool resolved from the
|
|
92
|
+
* registry. It is opt-in (`hitl.confirmDirectToolCalls: true`) because direct
|
|
93
|
+
* callers were never prompted for these tools. Only a tool registered by
|
|
94
|
+
* NeuroLink itself (server `direct`) is a built-in, so a custom or external
|
|
95
|
+
* tool that reuses the name `writeFile` is not swept in.
|
|
96
|
+
*/
|
|
97
|
+
export function registeredToolAlwaysConfirmed(hitl, toolName, serverId) {
|
|
98
|
+
return (hitl.getConfig().confirmDirectToolCalls === true &&
|
|
99
|
+
serverId === "direct" &&
|
|
100
|
+
builtInToolAlwaysConfirmed(hitl, toolName));
|
|
101
|
+
}
|
|
90
102
|
/**
|
|
91
103
|
* Tool results that carry a HITL refusal. A cache of tool results must not
|
|
92
104
|
* keep one, the per-turn one of the Gemini loops (`DedupExecuteMap`)
|
|
@@ -98,7 +98,7 @@ export declare class ToolCallBatcher {
|
|
|
98
98
|
/**
|
|
99
99
|
* Set the tool executor function
|
|
100
100
|
*/
|
|
101
|
-
setToolExecutor(executor: (tool: string, args: unknown, serverId?: string) => Promise<unknown>): void;
|
|
101
|
+
setToolExecutor(executor: (tool: string, args: unknown, serverId?: string, signal?: AbortSignal) => Promise<unknown>): void;
|
|
102
102
|
/**
|
|
103
103
|
* Execute a tool call (will be batched automatically)
|
|
104
104
|
*/
|
|
@@ -238,15 +238,19 @@ export class RequestBatcher extends EventEmitter {
|
|
|
238
238
|
});
|
|
239
239
|
}
|
|
240
240
|
// Execute the batch with a timeout to prevent indefinite hangs
|
|
241
|
+
const batchAbort = new AbortController();
|
|
241
242
|
const executorPromise = this.executor(batchRequests.map((r) => ({
|
|
242
243
|
tool: r.tool,
|
|
243
244
|
args: r.args,
|
|
244
245
|
serverId: r.serverId,
|
|
245
|
-
})));
|
|
246
|
+
})), batchAbort.signal);
|
|
246
247
|
const timeoutMs = Math.max(5000, Number(process.env.MCP_TOOL_TIMEOUT) || 60000);
|
|
247
248
|
let timeoutHandle;
|
|
248
249
|
const timeoutPromise = new Promise((_, reject) => {
|
|
249
|
-
timeoutHandle = setTimeout(() =>
|
|
250
|
+
timeoutHandle = setTimeout(() => {
|
|
251
|
+
batchAbort.abort();
|
|
252
|
+
reject(ErrorFactory.toolTimeout("batchExecution", timeoutMs));
|
|
253
|
+
}, timeoutMs);
|
|
250
254
|
});
|
|
251
255
|
// Suppress unhandled rejection if executorPromise rejects after timeout wins
|
|
252
256
|
void executorPromise.catch((_e) => {
|
|
@@ -394,7 +398,7 @@ export class ToolCallBatcher {
|
|
|
394
398
|
...config,
|
|
395
399
|
});
|
|
396
400
|
// Set up internal executor that calls individual tool executions
|
|
397
|
-
this.batcher.setExecutor(async (requests) => {
|
|
401
|
+
this.batcher.setExecutor(async (requests, signal) => {
|
|
398
402
|
if (!this.toolExecutor) {
|
|
399
403
|
throw ErrorFactory.missingConfiguration("toolExecutor", {
|
|
400
404
|
hint: "Call setToolExecutor() before executing tool calls",
|
|
@@ -403,7 +407,7 @@ export class ToolCallBatcher {
|
|
|
403
407
|
const executor = this.toolExecutor;
|
|
404
408
|
const results = await Promise.all(requests.map(async (req) => {
|
|
405
409
|
try {
|
|
406
|
-
const result = await executor(req.tool, req.args, req.serverId);
|
|
410
|
+
const result = await executor(req.tool, req.args, req.serverId, signal);
|
|
407
411
|
return { success: true, result };
|
|
408
412
|
}
|
|
409
413
|
catch (error) {
|
package/dist/mcp/toolRegistry.js
CHANGED
|
@@ -13,7 +13,7 @@ import { detectCategory, createMCPServerInfo } from "../utils/mcpDefaults.js";
|
|
|
13
13
|
import { FlexibleToolValidator } from "./flexibleToolValidator.js";
|
|
14
14
|
import { ErrorFactory, isAbortError, throwIfSignalAborted, } from "../utils/errorHandling.js";
|
|
15
15
|
import { HITLError } from "../hitl/hitlErrors.js";
|
|
16
|
-
import { isRefusalResult, markRefusalResult, resolveToolCallConfirmation, } from "../hitl/toolCallConfirmation.js";
|
|
16
|
+
import { isRefusalResult, markRefusalResult, registeredToolAlwaysConfirmed, resolveToolCallConfirmation, } from "../hitl/toolCallConfirmation.js";
|
|
17
17
|
import { withSpan, tracers, ATTR } from "../telemetry/index.js";
|
|
18
18
|
import { SpanStatusCode } from "@opentelemetry/api";
|
|
19
19
|
import { getAuthContext } from "../auth/authContext.js";
|
|
@@ -364,7 +364,7 @@ export class MCPToolRegistry extends MCPRegistry {
|
|
|
364
364
|
// HITL Safety Check. A call that NeuroLink.executeTool already gated
|
|
365
365
|
// arrives with its decision recorded and is never asked again; a
|
|
366
366
|
// direct caller without one is asked here.
|
|
367
|
-
const finalArgs = await this.confirmToolCall(toolName, args, tool.serverId, execContext, span);
|
|
367
|
+
const finalArgs = await this.confirmToolCall(toolName, args, tool.serverId, execContext, span, tool.name);
|
|
368
368
|
// A call cancelled during its confirmation must not start.
|
|
369
369
|
throwIfSignalAborted(execContext.abortSignal);
|
|
370
370
|
// Execute the actual tool (with potentially modified arguments)
|
|
@@ -560,13 +560,18 @@ export class MCPToolRegistry extends MCPRegistry {
|
|
|
560
560
|
* must not run, which `executeTool` reports as `{ success: false }`;
|
|
561
561
|
* otherwise returns the arguments to run with.
|
|
562
562
|
*/
|
|
563
|
-
async confirmToolCall(toolName, args, serverId, execContext, span) {
|
|
563
|
+
async confirmToolCall(toolName, args, serverId, execContext, span, canonicalName) {
|
|
564
564
|
const action = await resolveToolCallConfirmation(this.hitlManager, toolName, args, execContext.hitlState, {
|
|
565
565
|
serverId,
|
|
566
566
|
sessionId: execContext.sessionId,
|
|
567
567
|
userId: execContext.userId,
|
|
568
568
|
signal: execContext.abortSignal,
|
|
569
|
-
}, {
|
|
569
|
+
}, {
|
|
570
|
+
log: (message) => registryLogger.info(message),
|
|
571
|
+
span,
|
|
572
|
+
alwaysConfirm: this.hitlManager !== undefined &&
|
|
573
|
+
registeredToolAlwaysConfirmed(this.hitlManager, canonicalName, serverId),
|
|
574
|
+
});
|
|
570
575
|
if (!action.run) {
|
|
571
576
|
throw action.error;
|
|
572
577
|
}
|
package/dist/neurolink.d.ts
CHANGED
|
@@ -1983,6 +1983,13 @@ export declare class NeuroLink {
|
|
|
1983
1983
|
* the external manager usually share the host's.
|
|
1984
1984
|
*/
|
|
1985
1985
|
private callNeedsConfirmation;
|
|
1986
|
+
/**
|
|
1987
|
+
* Whether a direct `executeTool` call to `toolName` resolves to a built-in
|
|
1988
|
+
* the host asked to have confirmed on every call (`confirmBuiltinTools`),
|
|
1989
|
+
* the same rule a model's call to it is held to. Opt-in through
|
|
1990
|
+
* `confirmDirectToolCalls`, so existing direct callers are not prompted.
|
|
1991
|
+
*/
|
|
1992
|
+
private isRegisteredBuiltInGated;
|
|
1986
1993
|
/**
|
|
1987
1994
|
* Bookkeeping for a call its confirmation refused: `tool:end` with
|
|
1988
1995
|
* `success: false`, the span marked as an error and a failed execution
|
package/dist/neurolink.js
CHANGED
|
@@ -54,7 +54,7 @@ import { FileReferenceRegistry } from "./files/fileReferenceRegistry.js";
|
|
|
54
54
|
import { resolveAttachmentPolicy } from "./utils/attachmentPolicy.js";
|
|
55
55
|
import { createFileTools } from "./files/fileTools.js";
|
|
56
56
|
import { HITLManager, DEFAULT_ALLOW_MODIFICATION } from "./hitl/hitlManager.js";
|
|
57
|
-
import { builtInToolAlwaysConfirmed, createHITLExecutionState, hitlStateRefused, isRefusalResult, markRefusalResult, resolveToolCallConfirmation, } from "./hitl/toolCallConfirmation.js";
|
|
57
|
+
import { builtInToolAlwaysConfirmed, createHITLExecutionState, hitlStateRefused, isRefusalResult, markRefusalResult, registeredToolAlwaysConfirmed, resolveToolCallConfirmation, } from "./hitl/toolCallConfirmation.js";
|
|
58
58
|
import { HITLError } from "./hitl/hitlErrors.js";
|
|
59
59
|
import { getAuthContext as getAmbientAuthContext } from "./auth/authContext.js";
|
|
60
60
|
import { ToolCallBatcher } from "./mcp/batching/index.js";
|
|
@@ -1712,7 +1712,10 @@ export class NeuroLink {
|
|
|
1712
1712
|
maxWaitMs: mcpConfig.batcher.maxWaitMs ?? 100,
|
|
1713
1713
|
});
|
|
1714
1714
|
// Wire batcher to execute tools via the internal execution path (bypass batcher itself)
|
|
1715
|
-
this.mcpToolBatcher.setToolExecutor(async (tool, args) => {
|
|
1715
|
+
this.mcpToolBatcher.setToolExecutor(async (tool, args, _serverId, batchSignal) => {
|
|
1716
|
+
// The batch's timeout aborts the call, so a confirmation card that
|
|
1717
|
+
// opened inside the batch (the setting changed after the call was
|
|
1718
|
+
// enqueued) is withdrawn and a late approval cannot run the call.
|
|
1716
1719
|
// A state of its own per call, so the safe-tool retry inside
|
|
1717
1720
|
// executeToolInternal reuses the first answer instead of asking again.
|
|
1718
1721
|
// A tool registered with no retries gets no safe-tool retry either.
|
|
@@ -1721,6 +1724,7 @@ export class NeuroLink {
|
|
|
1721
1724
|
maxRetries: this.toolRegistry.getToolInfo(tool)?.tool?.maxRetries ??
|
|
1722
1725
|
RETRY_ATTEMPTS.DEFAULT,
|
|
1723
1726
|
retryDelayMs: RETRY_DELAYS.BASE_MS,
|
|
1727
|
+
...(batchSignal ? { abortSignal: batchSignal } : {}),
|
|
1724
1728
|
}, createHITLExecutionState());
|
|
1725
1729
|
});
|
|
1726
1730
|
logger.debug("[NeuroLink] MCP tool call batcher initialized");
|
|
@@ -11877,7 +11881,11 @@ Current user's request: ${currentInput}`;
|
|
|
11877
11881
|
sessionId: sessionId ?? crypto.randomUUID(),
|
|
11878
11882
|
userId,
|
|
11879
11883
|
signal: options.abortSignal,
|
|
11880
|
-
}, {
|
|
11884
|
+
}, {
|
|
11885
|
+
span: ctx.span,
|
|
11886
|
+
pauseDeadline: options.pauseDeadline,
|
|
11887
|
+
alwaysConfirm: !ctx.external && this.isRegisteredBuiltInGated(hitl, toolName),
|
|
11888
|
+
});
|
|
11881
11889
|
if (action.run) {
|
|
11882
11890
|
return { params: action.args };
|
|
11883
11891
|
}
|
|
@@ -11966,8 +11974,9 @@ Current user's request: ${currentInput}`;
|
|
|
11966
11974
|
* the external manager usually share the host's.
|
|
11967
11975
|
*/
|
|
11968
11976
|
callNeedsConfirmation(toolName, params) {
|
|
11977
|
+
const registryManager = this.confirmationManagerFor(false);
|
|
11969
11978
|
const managers = new Set([
|
|
11970
|
-
|
|
11979
|
+
registryManager,
|
|
11971
11980
|
this.confirmationManagerFor(true),
|
|
11972
11981
|
]);
|
|
11973
11982
|
for (const manager of managers) {
|
|
@@ -11975,7 +11984,19 @@ Current user's request: ${currentInput}`;
|
|
|
11975
11984
|
return true;
|
|
11976
11985
|
}
|
|
11977
11986
|
}
|
|
11978
|
-
return
|
|
11987
|
+
return (registryManager?.isEnabled() === true &&
|
|
11988
|
+
this.isRegisteredBuiltInGated(registryManager, toolName));
|
|
11989
|
+
}
|
|
11990
|
+
/**
|
|
11991
|
+
* Whether a direct `executeTool` call to `toolName` resolves to a built-in
|
|
11992
|
+
* the host asked to have confirmed on every call (`confirmBuiltinTools`),
|
|
11993
|
+
* the same rule a model's call to it is held to. Opt-in through
|
|
11994
|
+
* `confirmDirectToolCalls`, so existing direct callers are not prompted.
|
|
11995
|
+
*/
|
|
11996
|
+
isRegisteredBuiltInGated(hitl, toolName) {
|
|
11997
|
+
const tool = this.toolRegistry.getToolInfo(toolName)?.tool;
|
|
11998
|
+
return (tool !== undefined &&
|
|
11999
|
+
registeredToolAlwaysConfirmed(hitl, tool.name, tool.serverId));
|
|
11979
12000
|
}
|
|
11980
12001
|
/**
|
|
11981
12002
|
* Bookkeeping for a call its confirmation refused: `tool:end` with
|
package/dist/types/hitl.d.ts
CHANGED
|
@@ -36,6 +36,14 @@ export type HITLConfig = {
|
|
|
36
36
|
* only, as every other tool is.
|
|
37
37
|
*/
|
|
38
38
|
confirmBuiltinTools?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Whether `confirmBuiltinTools` also applies to a direct
|
|
41
|
+
* `neurolink.executeTool("writeFile", ...)` call, which the host's own code
|
|
42
|
+
* makes rather than a model (default: false, so existing callers are not
|
|
43
|
+
* prompted). Applies only while `enabled` and `confirmBuiltinTools` are
|
|
44
|
+
* `true`; `dangerousActions` and `customRules` match direct calls either way.
|
|
45
|
+
*/
|
|
46
|
+
confirmDirectToolCalls?: boolean;
|
|
39
47
|
};
|
|
40
48
|
/**
|
|
41
49
|
* Custom rule for advanced HITL scenarios
|
package/dist/types/mcp.d.ts
CHANGED
|
@@ -1988,7 +1988,9 @@ export type BatchExecutor<T> = (requests: Array<{
|
|
|
1988
1988
|
tool: string;
|
|
1989
1989
|
args: unknown;
|
|
1990
1990
|
serverId?: string;
|
|
1991
|
-
}
|
|
1991
|
+
}>,
|
|
1992
|
+
/** Aborted when the batch times out, so a call still waiting can be withdrawn. */
|
|
1993
|
+
signal?: AbortSignal) => Promise<Array<{
|
|
1992
1994
|
success: boolean;
|
|
1993
1995
|
result?: T;
|
|
1994
1996
|
error?: Error;
|
|
@@ -2885,9 +2885,9 @@
|
|
|
2885
2885
|
{"objectID":"0de66cb24e860808d3967922706cb8f4c543cf24b9aa150e96a8b7d48788793f","title":"Environment Variables","url":"/docs/features/embeddings#environment-variables","content":"| Variable | Provider(s) | Description |\n| --------------------------- | ------------------------------- | ----------------------------------------------------------------------- |\n| OPENAI_EMBEDDING_MODEL | OpenAI | Override OpenAI default embedding model |\n| GOOGLE_AI_EMBEDDING_MODEL | Google AI Studio | Override AI Studio default embedding model |\n| VERTEX_EMBEDDING_MODEL | Google Vertex | Override Vertex default embedding model (default: text-embedding-004) |\n| GOOGLE_EMBEDDING_MODEL | Google AI Studio, Google Vertex | Shared fallback for Google providers |\n| BEDROCK_EMBEDDING_MODEL | Amazon Bedrock | Override Bedrock default embedding model |\n| AWS_EMBEDDING_MODEL | Amazon Bedrock | Alternative Bedrock env var |\n| VOYAGE_MODEL | Voyage | Override the provider's default embedding model |\n| JINA_MODEL | Jina | Override the provider's default embedding model |\n| OLLAMA_EMBEDDING_MODEL | Ollama | Locally available embedding model |\n| LITELLM_EMBEDDING_MODEL | LiteLLM | Embedding model or deployment served by the gateway |\n| NEUROLINK_EMBEDDING_MODEL | All (CLI RAG only) | Global override for RAG CLI commands |","hierarchy":{"lvl0":"Features","lvl1":"Embeddings","lvl2":"Environment Variables","lvl3":""}},
|
|
2886
2886
|
{"objectID":"2aeebbce7d7d32d83443815b6e956d40b7482158a0ad88582503606c264d8f69","title":"Key Files","url":"/docs/features/embeddings#key-files","content":"| File | Purpose |\n| -------------------------------------- | ------------------------------------------------------------------------------ |\n| src/lib/core/baseProvider.ts | Default embed() / embedMany() stubs |\n| src/lib/providers/openAI.ts | OpenAI embedding implementation |\n| src/lib/providers/googleAiStudio.ts | Google AI Studio embedding implementation |\n| src/lib/providers/googleVertex.ts | Google Vertex embedding implementation |\n| src/lib/providers/amazonBedrock.ts | Amazon Bedrock embedding implementation |\n| src/lib/server/routes/agentRoutes.ts | Server /embed and /embed-many routes |\n| src/lib/server/utils/validation.ts | EmbedRequestSchema, EmbedManyRequestSchema |\n| src/lib/server/types.ts | EmbedRequest, EmbedResponse, EmbedManyRequest, EmbedManyResponse types |\n| src/lib/types/providers.ts | AIProvider type with embedding methods |","hierarchy":{"lvl0":"Features","lvl1":"Embeddings","lvl2":"Key Files","lvl3":""}},
|
|
2887
2887
|
{"objectID":"7dc8cee91fc8da6885116ce742319dbaced7f61b1a073493131e7bcf566e43e7","title":"See Also","url":"/docs/features/embeddings#see-also","content":"RAG Document Processing Guide -- end-to-end RAG pipelines using embeddings\nSDK API Reference -- SDK API reference","hierarchy":{"lvl0":"Features","lvl1":"Embeddings","lvl2":"See Also","lvl3":""}},
|
|
2888
|
-
{"objectID":"d4f8720f9bb7fb3901fbd2263aabda49347af9cc64470e2596d0e244f6e21b71","title":"Enterprise Human-in-the-Loop System","url":"/docs/features/enterprise-hitl","content":"Enterprise Human-in-the-Loop System\n\nSince: v7.39.0 | Availability: SDK\n\nTreat every code sample below as the target API unless it appears in\n\"Currently available\" immediately after this box. A heading marked\n(Planned) has examples that use configuration keys or behaviour that do not\nexist, and (Planned) is not a promise of a date. The sections under \"Quick\nStart (5 Minutes)\" are covered by that heading's own label.\n\nNone of requireApproval, reviewCallback, statusCallback, mode,\nconfidenceThreshold, contentPatterns, escalationPolicy or the object form\nof auditLog exists in src/lib/types/hitl.ts or is handled by\nsrc/lib/hitl/hitlManager.ts. validateConfig does not reject unknown keys
|
|
2889
|
-
{"objectID":"f657e6a12a41f2e3e4154c625d37316b34b2b05fd8733d2319733d4f25707890","title":"Enterprise Human-in-the-Loop System","url":"/docs/features/enterprise-hitl#enterprise-human-in-the-loop-system","content":"Since: v7.39.0 | Availability: SDK\n\nTreat every code sample below as the target API unless it appears in\n\"Currently available\" immediately after this box. A heading marked\n(Planned) has examples that use configuration keys or behaviour that do not\nexist, and (Planned) is not a promise of a date. The sections under \"Quick\nStart (5 Minutes)\" are covered by that heading's own label.\n\nNone of requireApproval, reviewCallback, statusCallback, mode,\nconfidenceThreshold, contentPatterns, escalationPolicy or the object form\nof auditLog exists in src/lib/types/hitl.ts or is handled by\nsrc/lib/hitl/hitlManager.ts. validateConfig does not reject unknown keys
|
|
2890
|
-
{"objectID":"3e51c59f3c7b66d5d0827896808bc094566b2e937ca0e197111d8c4f73b8ea59","title":"Currently available","url":"/docs/features/enterprise-hitl#currently-available","content":"HITLConfig has exactly these
|
|
2888
|
+
{"objectID":"d4f8720f9bb7fb3901fbd2263aabda49347af9cc64470e2596d0e244f6e21b71","title":"Enterprise Human-in-the-Loop System","url":"/docs/features/enterprise-hitl","content":"Enterprise Human-in-the-Loop System\n\nSince: v7.39.0 | Availability: SDK\n\nTreat every code sample below as the target API unless it appears in\n\"Currently available\" immediately after this box. A heading marked\n(Planned) has examples that use configuration keys or behaviour that do not\nexist, and (Planned) is not a promise of a date. The sections under \"Quick\nStart (5 Minutes)\" are covered by that heading's own label.\n\nNone of requireApproval, reviewCallback, statusCallback, mode,\nconfidenceThreshold, contentPatterns, escalationPolicy or the object form\nof auditLog exists in src/lib/types/hitl.ts or is handled by\nsrc/lib/hitl/hitlManager.ts. validateConfig does not reject unknown keys:\na config copied from this page is accepted, every one of those keys is dropped,\nand the approval gates never fire. It writes one line per unknown key to stderr,\nvisible by default and without NEUROLINK_DEBUG\n([HITL] Unknown config key \"requireApproval\" is ignored ...), but does not\nthrow, so watch stderr when adapting an example.\n\nThat includes the compliance sections. The HIPAA / SOC2 / GDPR examples show an\nauditLog storage backend and an escalationPolicy that do not exist; do not\ncite them as evidence of a control.\n\nTracking: #752.\n\nCurrently available\n\nHITLConfig has exactly these eleven keys (see src/lib/types/hitl.ts).\nAnything else on this page is not implemented.\n\ndangerousActions is required whenever enabled is true; omitting it throws\nHITLConfigurationError from the NeuroLink constructor. auditLogging writes\neach request and decision to the NeuroLink logger at info level. Entries include\nthe full tool arguments, so redact secrets and personal data at the logger sink.\nallowArgumentModification is copied into the request event as\nallowModification for your approval UI; NeuroLink does not enforce it, and a\nhitl:confirmation-response that carries modifiedArguments is applied\neither way, so forward only the arguments you accept. The\nhitl:audit event is emitted on the internal HITLManager, and NeuroLink\nforwards only hitl:confirmation-request, hitl:timeout and\nhitl:cancelled to getEventEmitter(); listen for hitl:cancelled to retire\na card that was withdrawn.\n\nconfirmBuiltinTools (default true) applies only while enabled is true.\nWith it on, the built-in writeFile and executeBashCommand tools need\nconfirmation on every call the model makes during generate() or stream(),\nwhether or not dangerousActions matches them. Setting it to false removes\nonly that built-in rule: those tools are then gated like any other tool, so a\ndangerousActions keyword or a customRules match still requires approval.\nA direct neurolink.executeTool(\"writeFile\", ...) call is checked against\ndangerousActions and customRules only, not against this rule, unless the\nhost opts in with confirmDirectToolCalls: true (default false). With it on,\na direct call to writeFile or executeBashCommand (also as\ndirect.writeFile) needs confirmation like a model's call, and\nconfirmBuiltinTools: false removes that rule for direct calls too. A custom\nor external tool that reuses a built-in's name is never swept in. With HITL\ndisabled, no tool asks for confirmation.\n\nApproval is event-based, through the SDK emitter — there is no\nreviewCallback. The emitter is reached with getEventEmitter(); NeuroLink\ndoes not extend EventEmitter, so neurolink.on(...) and neurolink.emit(...)\ndo not exist:\n\nThis is the shape exercised by test/continuous-test-suite-hitl.ts. For\nproduction use today, refer to the Basic HITL Guide.\n\nExecutive Summary\n\nThis section describes the system the rest of this page is a design for. Today NeuroLink ships event-based tool approval and a log of each request and decision (see \"Currently available\"). It does not ship escalation, asynchronous review or an audit store, and it holds no HIPAA, SOC2 or GDPR certification or control.\n\nStrategic Value Proposition\nRisk Mitigation: Prevent costly AI mistakes through mandatory human checkpoints\nRegulatory Compliance (target): Produce the review records regulated industries ask for. Today auditLogging only writes a log line; compliance is the deployer's responsibility\nTrust & Transparency: Build stakeholder confidence with auditable AI decisions\nContinuous Improvement: Capture human expertise to improve AI accuracy over time\n\nWhen to Use HITL\n\nRequired for:\nMedical diagnosis and treatment recommendations\nFinancial transactions above risk thresholds\nLegal document generation and review\nCode execution in production environments\nPersonal data modification or deletion\nIrreversible operations (send email, post to social media)\n\nNot recommended for:\nRead-only operations (information retrieval)\nLow-stakes content generation\nDevelopment/testing environments\nHigh-volume, low-risk automation\n\nQuick Start (5 Minutes) — target API, not implemented\n\nThe configuration in this section is not implemented. Use\n\"Currently available\" above for a setup that works.\n\nInstallation\n\nHITL is built into NeuroLink SDK v7.39.0+. No additional packag","hierarchy":{"lvl0":"Features","lvl1":"Enterprise Human-in-the-Loop System","lvl2":"","lvl3":""}},
|
|
2889
|
+
{"objectID":"f657e6a12a41f2e3e4154c625d37316b34b2b05fd8733d2319733d4f25707890","title":"Enterprise Human-in-the-Loop System","url":"/docs/features/enterprise-hitl#enterprise-human-in-the-loop-system","content":"Since: v7.39.0 | Availability: SDK\n\nTreat every code sample below as the target API unless it appears in\n\"Currently available\" immediately after this box. A heading marked\n(Planned) has examples that use configuration keys or behaviour that do not\nexist, and (Planned) is not a promise of a date. The sections under \"Quick\nStart (5 Minutes)\" are covered by that heading's own label.\n\nNone of requireApproval, reviewCallback, statusCallback, mode,\nconfidenceThreshold, contentPatterns, escalationPolicy or the object form\nof auditLog exists in src/lib/types/hitl.ts or is handled by\nsrc/lib/hitl/hitlManager.ts. validateConfig does not reject unknown keys:\na config copied from this page is accepted, every one of those keys is dropped,\nand the approval gates never fire. It writes one line per unknown key to stderr,\nvisible by default and without NEUROLINK_DEBUG\n([HITL] Unknown config key \"requireApproval\" is ignored ...), but does not\nthrow, so watch stderr when adapting an example.\n\nThat includes the compliance sections. The HIPAA / SOC2 / GDPR examples show an\nauditLog storage backend and an escalationPolicy that do not exist; do not\ncite them as evidence of a control.\n\nTracking: #752.","hierarchy":{"lvl0":"Features","lvl1":"Enterprise Human-in-the-Loop System","lvl2":"Enterprise Human-in-the-Loop System","lvl3":""}},
|
|
2890
|
+
{"objectID":"3e51c59f3c7b66d5d0827896808bc094566b2e937ca0e197111d8c4f73b8ea59","title":"Currently available","url":"/docs/features/enterprise-hitl#currently-available","content":"HITLConfig has exactly these eleven keys (see src/lib/types/hitl.ts).\nAnything else on this page is not implemented.\n\ndangerousActions is required whenever enabled is true; omitting it throws\nHITLConfigurationError from the NeuroLink constructor. auditLogging writes\neach request and decision to the NeuroLink logger at info level. Entries include\nthe full tool arguments, so redact secrets and personal data at the logger sink.\nallowArgumentModification is copied into the request event as\nallowModification for your approval UI; NeuroLink does not enforce it, and a\nhitl:confirmation-response that carries modifiedArguments is applied\neither way, so forward only the arguments you accept. The\nhitl:audit event is emitted on the internal HITLManager, and NeuroLink\nforwards only hitl:confirmation-request, hitl:timeout and\nhitl:cancelled to getEventEmitter(); listen for hitl:cancelled to retire\na card that was withdrawn.\n\nconfirmBuiltinTools (default true) applies only while enabled is true.\nWith it on, the built-in writeFile and executeBashCommand tools need\nconfirmation on every call the model makes during generate() or stream(),\nwhether or not dangerousActions matches them. Setting it to false removes\nonly that built-in rule: those tools are then gated like any other tool, so a\ndangerousActions keyword or a customRules match still requires approval.\nA direct neurolink.executeTool(\"writeFile\", ...) call is checked against\ndangerousActions and customRules only, not against this rule, unless the\nhost opts in with confirmDirectToolCalls: true (default false). With it on,\na direct call to writeFile or executeBashCommand (also as\ndirect.writeFile) needs confirmation like a model's call, and\nconfirmBuiltinTools: false removes that rule for direct calls too. A custom\nor external tool that reuses a built-in's name is never swept in. With HITL\ndisabled, no tool asks for confirmation.\n\nApproval is event-based, through the SDK emitter — there is no\nreviewCallback.","hierarchy":{"lvl0":"Features","lvl1":"Enterprise Human-in-the-Loop System","lvl2":"Currently available","lvl3":""}},
|
|
2891
2891
|
{"objectID":"cdc9943cec3f7205dd828f820d0811c083a184041806fdec1ab59f96190d9520","title":"Executive Summary","url":"/docs/features/enterprise-hitl#executive-summary","content":"This section describes the system the rest of this page is a design for. Today NeuroLink ships event-based tool approval and a log of each request and decision (see \"Currently available\"). It does not ship escalation, asynchronous review or an audit store, and it holds no HIPAA, SOC2 or GDPR certification or control.","hierarchy":{"lvl0":"Features","lvl1":"Enterprise Human-in-the-Loop System","lvl2":"Executive Summary","lvl3":""}},
|
|
2892
2892
|
{"objectID":"93c851f60f7be9ce5fa8ad235b8ff9c30bc02df6b697a3d8067c863c0a09c316","title":"Strategic Value Proposition","url":"/docs/features/enterprise-hitl#strategic-value-proposition","content":"Risk Mitigation: Prevent costly AI mistakes through mandatory human checkpoints\nRegulatory Compliance (target): Produce the review records regulated industries ask for. Today auditLogging only writes a log line; compliance is the deployer's responsibility\nTrust & Transparency: Build stakeholder confidence with auditable AI decisions\nContinuous Improvement: Capture human expertise to improve AI accuracy over time","hierarchy":{"lvl0":"Features","lvl1":"Enterprise Human-in-the-Loop System","lvl2":"Strategic Value Proposition","lvl3":""}},
|
|
2893
2893
|
{"objectID":"2fde0188cc74ae4920ab9ba5ee8002de8276654a8c4ca8e8ff10ab3120e35b57","title":"When to Use HITL","url":"/docs/features/enterprise-hitl#when-to-use-hitl","content":"Required for:\nMedical diagnosis and treatment recommendations\nFinancial transactions above risk thresholds\nLegal document generation and review\nCode execution in production environments\nPersonal data modification or deletion\nIrreversible operations (send email, post to social media)\n\nNot recommended for:\nRead-only operations (information retrieval)\nLow-stakes content generation\nDevelopment/testing environments\nHigh-volume, low-risk automation","hierarchy":{"lvl0":"Features","lvl1":"Enterprise Human-in-the-Loop System","lvl2":"When to Use HITL","lvl3":""}},
|
|
@@ -3045,7 +3045,7 @@
|
|
|
3045
3045
|
{"objectID":"4d86f092ca7e6b372a961736d886b359fa75e092f709de1fc0632865629f0e19","title":"Security Features","url":"/docs/features/hitl#security-features","content":"One-time permissions: Each approval works for exactly one action\nNo reuse: AI cannot reuse old permissions for new actions\nAutomatic reset: Permission flag clears immediately after use\nFail-safe: Defaults to requiring permission when in doubt","hierarchy":{"lvl0":"Features","lvl1":"Human-in-the-Loop (HITL) Workflows","lvl2":"Security Features","lvl3":""}},
|
|
3046
3046
|
{"objectID":"a0bcb2831207c4628365c2a9a0c21588b0c9d3ccda0f793b63dd9bbff7d63467","title":"Built-in tools","url":"/docs/features/hitl#built-in-tools","content":"HITL applies to the built-in tools (readFile, writeFile, listDirectory,\nanalyzeCSV, calculateMath, getCurrentTime, websearchGrounding and the\nopt-in executeBashCommand) exactly as it applies to tools you register:\ndangerousActions keywords and customRules are matched against the tool\nname on every model-driven call. Before the 2026-10 security audit fix (finding\nC3) built-in tools bypassed HITL entirely — only tools executed through the\ntool registry were gated — so a\nprompt-injected model could write files or, with the bash tool enabled, run\nshell commands with no confirmation, while the bash tool's own description\nclaimed otherwise.\n\nTwo built-ins change the machine and are confirmed on every call while HITL\nis enabled, whatever dangerousActions lists: writeFile and\nexecuteBashCommand. To gate them by keywords only, like every other tool,\nset confirmBuiltinTools: false:\n\nA denied built-in call is reported to the model as a failed tool call\n(Built-in tool execution rejected by user: <reason>); the model sees the denial and\ncan continue without the side effect. A confirmation that returns\nmodifiedArguments runs the tool with those arguments. The confirmation\nrequest carries serverId: \"direct\" for a built-in tool.\n\nPer-call tools passed through generate({ tools }) are the host's own code\nand are not gated by HITL; wrap their execute yourself if they need it.","hierarchy":{"lvl0":"Features","lvl1":"Human-in-the-Loop (HITL) Workflows","lvl2":"Built-in tools","lvl3":""}},
|
|
3047
3047
|
{"objectID":"7854f3abc1202ff2f15b90ddfd8c29a88a2e6e71aa843e416f760a43ab570dfb","title":"Event Types","url":"/docs/features/hitl#event-types","content":"All HITL events ride the SDK emitter returned by\nneurolink.getEventEmitter(); emitter below is that object.\n\nConfirmation Request Event (hitl:confirmation-request):\n\nConfirmation Response (emit from your app):\n\nTimeout Event (hitl:timeout):\n\nCancelled Event (hitl:cancelled): a pending confirmation was withdrawn\nbecause the call that asked was cancelled (its abortSignal fired, for\nexample the turn was aborted). Retire the card in your UI; an answer sent for\nit is ignored.","hierarchy":{"lvl0":"Features","lvl1":"Human-in-the-Loop (HITL) Workflows","lvl2":"Event Types","lvl3":""}},
|
|
3048
|
-
{"objectID":"3e34634f989373951398483eb857081283b841ccc417e6db95768d3bd82649f9","title":"Confirmation and the call's limits","url":"/docs/features/hitl#confirmation-and-the-calls-limits","content":"A call that needs confirmation is confirmed once, before its attempt timeout,\nits retries and the circuit breaker start, and nothing runs until the human\napproves or the card times out under the rule below. A denial or a\ncancellation is final: the call returns a refusal and is not retried. A card\ntimeout is also final, unless autoApproveOnTimeout is enabled and the tool\nis not in autoApproveExclusions: then the timeout approves the call without\na human response, and it runs like any approved call. Once approved, a failed\nor timed-out attempt is retried without a new approval, so a tool with side\neffects can run more than once. A model loop's per-tool deadline does\nnot run while the card waits; approval resumes it with the time that was\nleft.\n\nThe rule applies to the tools of the instance and of its worker instances\n(createWorkerInstance, and so runIsolatedAgent, registerAgentTool and\ndelegate_task): registered tools, external MCP tools and NeuroLink's\nbuilt-in tools, matched by name (for example readFile by\ndangerousActions: [\"read\"]; writeFile and executeBashCommand are\nconfirmed on every call a model loop makes unless confirmBuiltinTools is\nfalse, see Built-in tools). Registered and built-in tools\nare confirmed by the HITL manager the tool registry holds: the instance's own,\nunless another manager was installed there\n(getToolRegistry().setHITLManager(), or a worker with HITL of its own, see\nbelow). External MCP tools are confirmed by the external server manager's: the\ninstance's own, or with none the registry's. A worker with no HITL of its own\nshares its host's registry, so its calls are confirmed by the manager that\nregistry holds, normally the host's, and their cards reach that manager\nowner's emitter. When an agent tool's call ends, through its attempt timeout\nor the caller's abort, its worker run is stopped and any card it raised is\nwithdrawn. Agent-tool calls are never batched.","hierarchy":{"lvl0":"Features","lvl1":"Human-in-the-Loop (HITL) Workflows","lvl2":"Confirmation and the call's limits","lvl3":""}},
|
|
3048
|
+
{"objectID":"3e34634f989373951398483eb857081283b841ccc417e6db95768d3bd82649f9","title":"Confirmation and the call's limits","url":"/docs/features/hitl#confirmation-and-the-calls-limits","content":"A call that needs confirmation is confirmed once, before its attempt timeout,\nits retries and the circuit breaker start, and nothing runs until the human\napproves or the card times out under the rule below. A denial or a\ncancellation is final: the call returns a refusal and is not retried. A card\ntimeout is also final, unless autoApproveOnTimeout is enabled and the tool\nis not in autoApproveExclusions: then the timeout approves the call without\na human response, and it runs like any approved call. Once approved, a failed\nor timed-out attempt is retried without a new approval, so a tool with side\neffects can run more than once. A model loop's per-tool deadline does\nnot run while the card waits; approval resumes it with the time that was\nleft.\n\nThe rule applies to the tools of the instance and of its worker instances\n(createWorkerInstance, and so runIsolatedAgent, registerAgentTool and\ndelegate_task): registered tools, external MCP tools and NeuroLink's\nbuilt-in tools, matched by name (for example readFile by\ndangerousActions: [\"read\"]; writeFile and executeBashCommand are\nconfirmed on every call a model loop makes unless confirmBuiltinTools is\nfalse, and on a direct executeTool() call only with confirmDirectToolCalls: true, see Built-in tools). Registered and built-in tools\nare confirmed by the HITL manager the tool registry holds: the instance's own,\nunless another manager was installed there\n(getToolRegistry().setHITLManager(), or a worker with HITL of its own, see\nbelow). External MCP tools are confirmed by the external server manager's: the\ninstance's own, or with none the registry's. A worker with no HITL of its own\nshares its host's registry, so its calls are confirmed by the manager that\nregistry holds, normally the host's, and their cards reach that manager\nowner's emitter. When an agent tool's call ends, through its attempt timeout\nor the caller's abort, its worker run is stopped and any card it raised is\nwithdrawn. Agent-tool calls are never batched.","hierarchy":{"lvl0":"Features","lvl1":"Human-in-the-Loop (HITL) Workflows","lvl2":"Confirmation and the call's limits","lvl3":""}},
|
|
3049
3049
|
{"objectID":"5068502ff92414daee273da8919813c835390458398854e7834845b1a9b7bdef","title":"Problem: Tool executes without asking for permission","url":"/docs/features/hitl#problem-tool-executes-without-asking-for-permission","content":"Cause: Tool not marked with requiresConfirmation: true\nSolution:\nAdd this boolean flag to any tool that performs risky operations","hierarchy":{"lvl0":"Features","lvl1":"Human-in-the-Loop (HITL) Workflows","lvl2":"Problem: Tool executes without asking for permission","lvl3":""}},
|
|
3050
3050
|
{"objectID":"385ab382fc18fbd69cc1e5d7da2909e9e5c70c897f97f372b61946a0273d456a","title":"Problem: AI keeps asking for confirmation repeatedly","url":"/docs/features/hitl#problem-ai-keeps-asking-for-confirmation-repeatedly","content":"Cause: Confirmation responses not being sent or sent with wrong confirmationId\nSolution:\nExtract confirmation ID from the request event\nAlways respond to every confirmation request\nCritical: Use the same confirmationId from the request","hierarchy":{"lvl0":"Features","lvl1":"Human-in-the-Loop (HITL) Workflows","lvl2":"Problem: AI keeps asking for confirmation repeatedly","lvl3":""}},
|
|
3051
3051
|
{"objectID":"09de33ea71681ebc227efede41ba43f241d943ed4b4628befc274d99b677b587","title":"Problem: Confirmation dialog doesn't show","url":"/docs/features/hitl#problem-confirmation-dialog-doesnt-show","content":"Cause: Not listening to hitl:confirmation-request event\nSolution:\nRegister the event handler early in your application startup\nAll subsequent tool executions will trigger confirmations when needed","hierarchy":{"lvl0":"Features","lvl1":"Human-in-the-Loop (HITL) Workflows","lvl2":"Problem: Confirmation dialog doesn't show","lvl3":""}},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juspay/neurolink",
|
|
3
|
-
"version": "13.13.
|
|
3
|
+
"version": "13.13.6",
|
|
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": {
|