
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
llm-bridge-loader
Advanced tools
A powerful and flexible dependency-based bridge loader for LLM Bridge packages. Automatically discover, validate, and load LLM bridges from your project dependencies.
# pnpm (κΆμ₯)
pnpm add llm-bridge-loader llm-bridge-spec zod
# npm
npm install llm-bridge-loader llm-bridge-spec zod
# yarn
yarn add llm-bridge-loader llm-bridge-spec zod
import { DependencyBridgeLoader } from 'llm-bridge-loader';
// Create a loader instance
const loader = new DependencyBridgeLoader();
// Load a bridge by package name
const bridge = await loader.loadBridge('ollama-llm-bridge', {
host: 'http://localhost:11434',
model: 'llama3.2',
temperature: 0.7,
});
// Use the bridge
const response = await bridge.invoke({
messages: [{ role: 'user', content: [{ type: 'text', text: 'Hello!' }] }],
});
console.log(response.choices[0].message.content[0].text);
Import guidelines
- Use the package root import:
import { DependencyBridgeLoader } from 'llm-bridge-loader'
- Do not deep-import internal paths like
llm-bridge-loader/src/...
as they are not part of the public API and are blocked bypackage.json.exports
.
import { DependencyBridgeLoader } from 'llm-bridge-loader';
const loader = new DependencyBridgeLoader();
// Load multiple bridges from configuration
const bridges = await loader.loadBridgesFromConfig([
{
name: 'ollama',
package: 'ollama-llm-bridge',
config: {
host: 'http://localhost:11434',
model: 'llama3.2',
temperature: 0.7,
},
},
{
name: 'openai',
package: 'openai-llm-bridge',
config: {
apiKey: process.env.OPENAI_API_KEY,
model: 'gpt-4',
temperature: 0.8,
},
},
]);
// Use specific bridge
const ollamaBridge = bridges.get('ollama');
const openAIBridge = bridges.get('openai');
The loader automatically discovers LLM bridge packages by:
-llm-bridge
manifest()
exportLlmBridge
// 1. Discover available bridges
const availableBridges = await loader.discoverBridges();
// 2. Get bridge information
const bridgeInfo = await loader.getBridgeInfo('ollama-llm-bridge');
console.log(bridgeInfo.manifest.capabilities);
// 3. Load and configure bridge
const bridge = await loader.loadBridge('ollama-llm-bridge', config);
DependencyBridgeLoader
Main class for loading LLM bridges from dependencies.
loadBridge(packageName: string, config: unknown): Promise<LlmBridge>
Loads a specific bridge with configuration.
const bridge = await loader.loadBridge('ollama-llm-bridge', {
model: 'llama3.2',
temperature: 0.7,
});
discoverBridges(): Promise<string[]>
Discovers all available LLM bridge packages.
const packages = await loader.discoverBridges();
console.log(packages); // ['ollama-llm-bridge', 'openai-llm-bridge', ...]
getBridgeInfo(packageName: string): Promise<BridgePackageInfo>
Gets detailed information about a bridge package.
const info = await loader.getBridgeInfo('ollama-llm-bridge');
console.log(info.manifest.name);
console.log(info.manifest.capabilities);
loadBridgesFromConfig(configs: BridgeConfig[]): Promise<Map<string, LlmBridge>>
Loads multiple bridges from configuration array.
const bridges = await loader.loadBridgesFromConfig([
{ name: 'ollama', package: 'ollama-llm-bridge', config: { model: 'llama3.2' } },
{ name: 'openai', package: 'openai-llm-bridge', config: { model: 'gpt-4' } },
]);
BridgeConfig
Configuration for loading a bridge.
interface BridgeConfig {
name: string; // Unique identifier for the bridge
package: string; // Package name (e.g., 'ollama-llm-bridge')
config: unknown; // Bridge-specific configuration
}
BridgePackageInfo
Information about a bridge package.
interface BridgePackageInfo {
packageName: string;
manifest: LlmManifest;
bridgeClass: new (config: unknown) => LlmBridge;
}
The loader automatically scans your node_modules
for packages that:
-llm-bridge
manifest()
functionLlmBridge
// Register a custom bridge
loader.registerBridge('my-custom-bridge', {
packageName: 'my-custom-bridge',
manifest: myCustomManifest,
bridgeClass: MyCustomBridge,
});
The loader uses Zod schemas to validate bridge configurations:
// Each bridge defines its own configuration schema
const ollamaSchema = z.object({
host: z.string().url().optional(),
model: z.string(),
temperature: z.number().min(0).max(1).optional(),
});
// Loader validates config against the schema
const bridge = await loader.loadBridge('ollama-llm-bridge', {
model: 'llama3.2',
temperature: 0.7, // Validated against schema
});
The loader provides detailed error information:
import { BridgeLoadError, BridgeNotFoundError, ConfigurationError } from 'llm-bridge-loader';
try {
const bridge = await loader.loadBridge('unknown-bridge', {});
} catch (error) {
if (error instanceof BridgeNotFoundError) {
console.error('Bridge not found:', error.packageName);
console.log('Available bridges:', error.availableBridges);
} else if (error instanceof ConfigurationError) {
console.error('Invalid configuration:', error.message);
console.log('Validation errors:', error.validationErrors);
}
}
# Run unit tests
pnpm test
# Run tests with coverage
pnpm test:coverage
# Run in watch mode
pnpm test:watch
llm-bridge-loader/
βββ src/
β βββ dependency/
β β βββ dependency-bridge.loader.ts # Main loader implementation
β β βββ __tests__/
β βββ types.ts # Type definitions
β βββ index.ts # Entry point
βββ package.json
βββ README.md
llm-bridge-spec
- Core interfaces and typesollama-llm-bridge
- Ollama bridge implementationopenai-llm-bridge
- OpenAI bridge implementationbedrock-llm-bridge
- AWS Bedrock bridge implementationμ΄ νλ‘μ νΈλ Git Workflow Guideλ₯Ό λ°λ¦ λλ€.
git checkout -b feature/core-new-feature
git commit -m "β
[TODO 1/3] Add new loader functionality"
pnpm lint && pnpm test:ci && pnpm build
μ΄ νλ‘μ νΈλ MIT λΌμ΄μ μ€ νμ μμ΅λλ€.
Made with β€οΈ by the LLM Bridge Team
FAQs
LLM Bridge Loader - load bridges from dependencies
The npm package llm-bridge-loader receives a total of 180 weekly downloads. As such, llm-bridge-loader popularity was classified as not popular.
We found that llm-bridge-loader 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
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socketβs AI scanner detected the supply chain attack and flagged the malware.