
Security News
/Research
Popular node-ipc npm Package Infected with Credential Stealer
Socket detected malicious node-ipc versions with obfuscated stealer/backdoor behavior in a developing npm supply chain attack.
@aegis-sdk/langchain
Advanced tools
LangChain.js callback handler and chain guard for prompt injection defense.
Part of the Aegis.js prompt injection defense toolkit.
npm install @aegis-sdk/langchain @aegis-sdk/core
import { ChatOpenAI } from '@langchain/openai';
import { Aegis } from '@aegis-sdk/core';
import { createAegisCallback } from '@aegis-sdk/langchain';
const aegis = new Aegis({ policy: 'strict' });
const model = new ChatOpenAI({
callbacks: [createAegisCallback(aegis)],
});
const result = await model.invoke('Hello!');
createAegisCallback(optionsOrAegis?)Creates a LangChain-compatible callback handler that intercepts LLM and tool lifecycle events:
handleLLMStart -- Scans input prompts for injection patternshandleLLMEnd -- Quarantines LLM output for safe downstream consumptionhandleToolStart -- Validates tool calls against the Aegis policyhandleToolEnd -- Quarantines tool outputAccepts an Aegis instance, AegisConfig, or AegisCallbackOptions:
| Option | Type | Default | Description |
|---|---|---|---|
aegis | AegisConfig | Aegis | {} | Aegis configuration or pre-constructed instance |
scanInput | boolean | true | Scan LLM input prompts |
scanOutput | boolean | true | Scan LLM output for violations |
validateTools | boolean | true | Validate tool calls against policy |
quarantineToolOutput | boolean | true | Quarantine tool outputs |
onBlocked | (error) => void | -- | Called when input is blocked |
onToolBlocked | (toolName, result) => void | -- | Called when a tool call is blocked |
AegisChainGuardWraps agentic chain/agent execution with step-level protection. Enforces a step budget, tracks cumulative risk across steps, and terminates the chain if risk exceeds the threshold.
import { AegisChainGuard } from '@aegis-sdk/langchain';
const guard = new AegisChainGuard({
aegis: new Aegis({ policy: 'strict' }),
maxSteps: 10,
riskThreshold: 0.7,
});
// In your agent loop:
const result = await guard.guardChainStep(currentMessages);
if (!result.allowed) {
console.error('Chain terminated:', result.reason);
break;
}
| Option | Type | Default | Description |
|---|---|---|---|
aegis | AegisConfig | Aegis | {} | Aegis configuration or pre-constructed instance |
maxSteps | number | 25 | Maximum chain steps before termination |
riskThreshold | number | 0.8 | Cumulative risk score threshold (0-1) |
scanStrategy | ScanStrategy | "last-user" | Which messages to scan per step |
onBudgetExceeded | (stepCount) => void | -- | Called when step budget is exceeded |
onRiskExceeded | (cumulativeRisk) => void | -- | Called when risk threshold is exceeded |
Methods: guardChainStep(messages), getStepCount(), getCumulativeRisk(), getAegisInstance(), reset().
guardMessages(aegis, messages, options?)Scans messages directly without using the callback handler. Throws AegisInputBlocked if input is blocked.
Aegis, AegisInputBlocked, AegisSessionQuarantined, AegisSessionTerminated, and all core types (including ActionValidationRequest, ActionValidationResult) are re-exported for convenience.
MIT
FAQs
LangChain.js adapter for Aegis prompt injection defense
The npm package @aegis-sdk/langchain receives a total of 6 weekly downloads. As such, @aegis-sdk/langchain popularity was classified as not popular.
We found that @aegis-sdk/langchain demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
/Research
Socket detected malicious node-ipc versions with obfuscated stealer/backdoor behavior in a developing npm supply chain attack.

Security News
TeamPCP and BreachForums are promoting a Shai-Hulud supply chain attack contest with a $1,000 prize for the biggest package compromise.

Security News
Packagist urges PHP projects to update Composer after a GitHub token format change exposed some GitHub Actions tokens in CI logs.