@lockllm/sdk 1.0.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.
- package/CHANGELOG.md +81 -0
- package/CODE_OF_CONDUCT.md +130 -0
- package/CONTRIBUTING.md +259 -0
- package/LICENSE +21 -0
- package/README.md +928 -0
- package/SECURITY.md +261 -0
- package/dist/client.d.ts +39 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +65 -0
- package/dist/client.js.map +1 -0
- package/dist/client.mjs +61 -0
- package/dist/errors.d.ts +60 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +175 -0
- package/dist/errors.js.map +1 -0
- package/dist/errors.mjs +164 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +49 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +17 -0
- package/dist/scan.d.ts +32 -0
- package/dist/scan.d.ts.map +1 -0
- package/dist/scan.js +40 -0
- package/dist/scan.js.map +1 -0
- package/dist/scan.mjs +36 -0
- package/dist/types/common.d.ts +31 -0
- package/dist/types/common.d.ts.map +1 -0
- package/dist/types/common.js +6 -0
- package/dist/types/common.js.map +1 -0
- package/dist/types/common.mjs +5 -0
- package/dist/types/errors.d.ts +22 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/errors.js +6 -0
- package/dist/types/errors.js.map +1 -0
- package/dist/types/errors.mjs +5 -0
- package/dist/types/providers.d.ts +24 -0
- package/dist/types/providers.d.ts.map +1 -0
- package/dist/types/providers.js +26 -0
- package/dist/types/providers.js.map +1 -0
- package/dist/types/providers.mjs +23 -0
- package/dist/types/scan.d.ts +36 -0
- package/dist/types/scan.d.ts.map +1 -0
- package/dist/types/scan.js +6 -0
- package/dist/types/scan.js.map +1 -0
- package/dist/types/scan.mjs +5 -0
- package/dist/utils.d.ts +84 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +225 -0
- package/dist/utils.js.map +1 -0
- package/dist/utils.mjs +215 -0
- package/dist/wrappers/anthropic-wrapper.d.ts +72 -0
- package/dist/wrappers/anthropic-wrapper.d.ts.map +1 -0
- package/dist/wrappers/anthropic-wrapper.js +78 -0
- package/dist/wrappers/anthropic-wrapper.js.map +1 -0
- package/dist/wrappers/anthropic-wrapper.mjs +74 -0
- package/dist/wrappers/generic-wrapper.d.ts +180 -0
- package/dist/wrappers/generic-wrapper.d.ts.map +1 -0
- package/dist/wrappers/generic-wrapper.js +246 -0
- package/dist/wrappers/generic-wrapper.js.map +1 -0
- package/dist/wrappers/generic-wrapper.mjs +225 -0
- package/dist/wrappers/index.d.ts +27 -0
- package/dist/wrappers/index.d.ts.map +1 -0
- package/dist/wrappers/index.js +48 -0
- package/dist/wrappers/index.js.map +1 -0
- package/dist/wrappers/index.mjs +26 -0
- package/dist/wrappers/openai-wrapper.d.ts +70 -0
- package/dist/wrappers/openai-wrapper.d.ts.map +1 -0
- package/dist/wrappers/openai-wrapper.js +76 -0
- package/dist/wrappers/openai-wrapper.js.map +1 -0
- package/dist/wrappers/openai-wrapper.mjs +72 -0
- package/package.json +106 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [1.1.0] - 2026-01-16
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
#### Universal Provider Support
|
|
8
|
+
- **Generic Wrapper Factory**: Added `createClient()` function to create clients for any LLM provider using their official SDK
|
|
9
|
+
- **OpenAI-Compatible Helper**: Added `createOpenAICompatible()` for easy integration with OpenAI-compatible providers
|
|
10
|
+
- **15 New Provider Wrappers**: Pre-configured factory functions for all remaining providers:
|
|
11
|
+
- `createGroq()` - Groq (fast inference)
|
|
12
|
+
- `createDeepSeek()` - DeepSeek (reasoning models)
|
|
13
|
+
- `createPerplexity()` - Perplexity (online models with search)
|
|
14
|
+
- `createMistral()` - Mistral AI
|
|
15
|
+
- `createOpenRouter()` - OpenRouter (access to 200+ models)
|
|
16
|
+
- `createTogether()` - Together AI
|
|
17
|
+
- `createXAI()` - xAI (Grok)
|
|
18
|
+
- `createFireworks()` - Fireworks AI
|
|
19
|
+
- `createAnyscale()` - Anyscale
|
|
20
|
+
- `createHuggingFace()` - Hugging Face
|
|
21
|
+
- `createGemini()` - Google Gemini
|
|
22
|
+
- `createCohere()` - Cohere
|
|
23
|
+
- `createAzure()` - Azure OpenAI
|
|
24
|
+
- `createBedrock()` - AWS Bedrock
|
|
25
|
+
- `createVertexAI()` - Google Vertex AI
|
|
26
|
+
|
|
27
|
+
#### Utility Functions
|
|
28
|
+
- **`getProxyURL(provider)`**: Get the LockLLM proxy URL for any specific provider
|
|
29
|
+
- **`getAllProxyURLs()`**: Get all available proxy URLs for all 17 providers
|
|
30
|
+
- **Type Export**: Added `ProviderName` type export for better TypeScript support
|
|
31
|
+
|
|
32
|
+
#### Examples
|
|
33
|
+
- **`examples/wrapper-generic.ts`**: Comprehensive example showing three ways to integrate with any provider
|
|
34
|
+
- **`examples/wrapper-all-providers.ts`**: Complete example demonstrating all 17 providers
|
|
35
|
+
|
|
36
|
+
#### Documentation
|
|
37
|
+
- Updated README with provider comparison table showing wrapper functions and compatibility
|
|
38
|
+
- Added three integration methods with examples (provider-specific, generic, official SDKs)
|
|
39
|
+
- Expanded "Supported Providers" section with detailed integration patterns
|
|
40
|
+
- Added examples for Groq, DeepSeek, Mistral, Perplexity, OpenRouter, and Azure
|
|
41
|
+
- Updated API Reference with all new wrapper functions and utilities
|
|
42
|
+
- Enhanced examples README with new example descriptions
|
|
43
|
+
|
|
44
|
+
### Changed
|
|
45
|
+
- Build system updated to properly generate both CommonJS (`.js`) and ESM (`.mjs`) outputs
|
|
46
|
+
- Fixed `tsconfig.esm.json` to work with TypeScript 5.9.3
|
|
47
|
+
- Improved documentation structure and clarity
|
|
48
|
+
|
|
49
|
+
### Technical Details
|
|
50
|
+
|
|
51
|
+
#### Integration Methods
|
|
52
|
+
|
|
53
|
+
**Method 1: Provider-Specific Wrappers (Easiest)**
|
|
54
|
+
```typescript
|
|
55
|
+
import { createOpenAI, createGroq, createAnthropic } from '@lockllm/sdk';
|
|
56
|
+
const client = createGroq({ apiKey: process.env.LOCKLLM_API_KEY });
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
**Method 2: Generic Wrappers (Flexible)**
|
|
60
|
+
```typescript
|
|
61
|
+
import { createClient, createOpenAICompatible } from '@lockllm/sdk';
|
|
62
|
+
// For OpenAI-compatible providers
|
|
63
|
+
const client = createOpenAICompatible('deepseek', { apiKey });
|
|
64
|
+
// For custom SDKs
|
|
65
|
+
const cohere = createClient('cohere', CohereClient, { apiKey });
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
**Method 3: Official SDKs Directly (Most Control)**
|
|
69
|
+
```typescript
|
|
70
|
+
import OpenAI from 'openai';
|
|
71
|
+
import { getProxyURL } from '@lockllm/sdk';
|
|
72
|
+
const client = new OpenAI({
|
|
73
|
+
apiKey: process.env.LOCKLLM_API_KEY,
|
|
74
|
+
baseURL: getProxyURL('mistral')
|
|
75
|
+
});
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Notes
|
|
79
|
+
- All 15+ providers are now fully supported with multiple integration options
|
|
80
|
+
- Zero breaking changes - existing code continues to work
|
|
81
|
+
- Backward compatible with v1.0.0
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, or sexual identity and orientation.
|
|
6
|
+
|
|
7
|
+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
|
8
|
+
|
|
9
|
+
## Our Standards
|
|
10
|
+
|
|
11
|
+
### Positive Behavior
|
|
12
|
+
|
|
13
|
+
Examples of behavior that contributes to a positive environment:
|
|
14
|
+
|
|
15
|
+
- Using welcoming and inclusive language
|
|
16
|
+
- Being respectful of differing viewpoints and experiences
|
|
17
|
+
- Gracefully accepting constructive criticism
|
|
18
|
+
- Focusing on what is best for the community
|
|
19
|
+
- Showing empathy towards other community members
|
|
20
|
+
- Giving and gracefully accepting constructive feedback
|
|
21
|
+
- Accepting responsibility and apologizing to those affected by our mistakes
|
|
22
|
+
- Learning from mistakes and improving our behavior
|
|
23
|
+
|
|
24
|
+
### Unacceptable Behavior
|
|
25
|
+
|
|
26
|
+
Examples of unacceptable behavior include:
|
|
27
|
+
|
|
28
|
+
- The use of sexualized language or imagery
|
|
29
|
+
- Trolling, insulting or derogatory comments, and personal or political attacks
|
|
30
|
+
- Public or private harassment
|
|
31
|
+
- Publishing others' private information without explicit permission
|
|
32
|
+
- Violent threats or language directed against another person
|
|
33
|
+
- Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language
|
|
34
|
+
- Advocating for, or encouraging, any of the above behavior
|
|
35
|
+
- Other conduct which could reasonably be considered inappropriate in a professional setting
|
|
36
|
+
|
|
37
|
+
## Scope
|
|
38
|
+
|
|
39
|
+
This Code of Conduct applies within all community spaces, including but not limited to:
|
|
40
|
+
|
|
41
|
+
- GitHub repositories (issues, pull requests, discussions)
|
|
42
|
+
- Project communication channels (email, chat, forums)
|
|
43
|
+
- Social media accounts representing the project
|
|
44
|
+
- Project events (conferences, meetups, online events)
|
|
45
|
+
|
|
46
|
+
This Code of Conduct also applies when an individual is officially representing the community in public spaces.
|
|
47
|
+
|
|
48
|
+
## Enforcement Responsibilities
|
|
49
|
+
|
|
50
|
+
Project maintainers are responsible for clarifying and enforcing our standards of acceptable behavior. They will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
|
51
|
+
|
|
52
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned with this Code of Conduct. They will communicate reasons for moderation decisions when appropriate.
|
|
53
|
+
|
|
54
|
+
## Reporting Issues
|
|
55
|
+
|
|
56
|
+
If you experience or witness unacceptable behavior, or have any other concerns, please report it by contacting the project team at:
|
|
57
|
+
|
|
58
|
+
**support@lockllm.com**
|
|
59
|
+
|
|
60
|
+
All reports will be handled with discretion and confidentiality.
|
|
61
|
+
|
|
62
|
+
### What to Include in Your Report
|
|
63
|
+
|
|
64
|
+
To help us address the issue effectively, please include:
|
|
65
|
+
|
|
66
|
+
- Your contact information
|
|
67
|
+
- Names (real, nicknames, or pseudonyms) of individuals involved
|
|
68
|
+
- Description of the incident, including specific behavior
|
|
69
|
+
- Date and time of the incident
|
|
70
|
+
- Location/platform where the incident occurred
|
|
71
|
+
- Whether the incident is ongoing
|
|
72
|
+
- Any additional context or information
|
|
73
|
+
- If you believe any other individuals witnessed the incident
|
|
74
|
+
|
|
75
|
+
### Confidentiality
|
|
76
|
+
|
|
77
|
+
All reports will be reviewed and investigated. We respect the privacy and security of the reporter of any incident.
|
|
78
|
+
|
|
79
|
+
## Enforcement Guidelines
|
|
80
|
+
|
|
81
|
+
Project maintainers will follow these Community Impact Guidelines in determining consequences for any action deemed in violation of this Code of Conduct:
|
|
82
|
+
|
|
83
|
+
### 1. Correction
|
|
84
|
+
|
|
85
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome.
|
|
86
|
+
|
|
87
|
+
**Consequence**: A private, written warning from project maintainers, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
|
88
|
+
|
|
89
|
+
### 2. Warning
|
|
90
|
+
|
|
91
|
+
**Community Impact**: A violation through a single incident or series of actions.
|
|
92
|
+
|
|
93
|
+
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period. This includes avoiding interactions in community spaces as well as external channels. Violating these terms may lead to a temporary or permanent ban.
|
|
94
|
+
|
|
95
|
+
### 3. Temporary Ban
|
|
96
|
+
|
|
97
|
+
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
|
98
|
+
|
|
99
|
+
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
|
100
|
+
|
|
101
|
+
### 4. Permanent Ban
|
|
102
|
+
|
|
103
|
+
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
|
104
|
+
|
|
105
|
+
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
|
106
|
+
|
|
107
|
+
## Attribution
|
|
108
|
+
|
|
109
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.1, available at
|
|
110
|
+
https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
|
|
111
|
+
|
|
112
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
|
|
113
|
+
|
|
114
|
+
[homepage]: https://www.contributor-covenant.org
|
|
115
|
+
|
|
116
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
|
117
|
+
https://www.contributor-covenant.org/faq. Translations are available at
|
|
118
|
+
https://www.contributor-covenant.org/translations.
|
|
119
|
+
|
|
120
|
+
## Contact
|
|
121
|
+
|
|
122
|
+
- **Security Issues**: support@lockllm.com (see [SECURITY.md](SECURITY.md))
|
|
123
|
+
|
|
124
|
+
## Acknowledgment
|
|
125
|
+
|
|
126
|
+
By participating in this community, you agree to abide by this Code of Conduct. We are committed to providing a welcoming and inspiring community for all.
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
**Last Updated**: January 2026
|
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
# Contributing to LockLLM JavaScript/TypeScript SDK
|
|
2
|
+
|
|
3
|
+
Thank you for your interest in contributing to LockLLM! We welcome contributions from the community to help make AI security more accessible and effective.
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
|
|
7
|
+
- [Code of Conduct](#code-of-conduct)
|
|
8
|
+
- [How Can I Contribute?](#how-can-i-contribute)
|
|
9
|
+
- [Development Setup](#development-setup)
|
|
10
|
+
- [Pull Request Process](#pull-request-process)
|
|
11
|
+
- [Coding Standards](#coding-standards)
|
|
12
|
+
- [Testing Guidelines](#testing-guidelines)
|
|
13
|
+
- [Reporting Bugs](#reporting-bugs)
|
|
14
|
+
- [Suggesting Enhancements](#suggesting-enhancements)
|
|
15
|
+
|
|
16
|
+
## Code of Conduct
|
|
17
|
+
|
|
18
|
+
This project adheres to a Code of Conduct that all contributors are expected to follow. Please read [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) before contributing.
|
|
19
|
+
|
|
20
|
+
## How Can I Contribute?
|
|
21
|
+
|
|
22
|
+
### Reporting Bugs
|
|
23
|
+
|
|
24
|
+
Before creating bug reports, please check the existing issues to avoid duplicates. When creating a bug report, include:
|
|
25
|
+
|
|
26
|
+
- A clear and descriptive title
|
|
27
|
+
- Detailed steps to reproduce the issue
|
|
28
|
+
- Expected behavior vs actual behavior
|
|
29
|
+
- Code samples demonstrating the issue
|
|
30
|
+
- Your environment (Node.js version, OS, SDK version)
|
|
31
|
+
- Error messages and stack traces
|
|
32
|
+
|
|
33
|
+
### Suggesting Enhancements
|
|
34
|
+
|
|
35
|
+
Enhancement suggestions are tracked as GitHub issues. When suggesting an enhancement:
|
|
36
|
+
|
|
37
|
+
- Use a clear and descriptive title
|
|
38
|
+
- Provide a detailed description of the proposed functionality
|
|
39
|
+
- Explain why this enhancement would be useful
|
|
40
|
+
- Include code examples if applicable
|
|
41
|
+
|
|
42
|
+
### Code Contributions
|
|
43
|
+
|
|
44
|
+
1. **Fork the repository** and create your branch from `main`
|
|
45
|
+
2. **Make your changes** following our coding standards
|
|
46
|
+
3. **Add tests** for any new functionality
|
|
47
|
+
4. **Update documentation** as needed
|
|
48
|
+
5. **Submit a pull request**
|
|
49
|
+
|
|
50
|
+
## Development Setup
|
|
51
|
+
|
|
52
|
+
### Prerequisites
|
|
53
|
+
|
|
54
|
+
- Node.js 18+ and npm
|
|
55
|
+
- TypeScript knowledge
|
|
56
|
+
- Git
|
|
57
|
+
|
|
58
|
+
### Setup Steps
|
|
59
|
+
|
|
60
|
+
1. Fork and clone the repository:
|
|
61
|
+
```bash
|
|
62
|
+
git clone https://github.com/YOUR-USERNAME/lockllm-npm.git
|
|
63
|
+
cd lockllm-npm
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
2. Install dependencies:
|
|
67
|
+
```bash
|
|
68
|
+
npm install
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
3. Install peer dependencies for testing:
|
|
72
|
+
```bash
|
|
73
|
+
npm install openai @anthropic-ai/sdk
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
4. Run tests to ensure everything works:
|
|
77
|
+
```bash
|
|
78
|
+
npm test
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
5. Build the project:
|
|
82
|
+
```bash
|
|
83
|
+
npm run build
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Available Scripts
|
|
87
|
+
|
|
88
|
+
- `npm run build` - Build both CommonJS and ESM versions
|
|
89
|
+
- `npm test` - Run the test suite
|
|
90
|
+
- `npm run test:watch` - Run tests in watch mode
|
|
91
|
+
- `npm run test:coverage` - Generate coverage report
|
|
92
|
+
- `npm run lint` - Lint the codebase
|
|
93
|
+
- `npm run format` - Format code with Prettier
|
|
94
|
+
- `npm run typecheck` - Run TypeScript type checking
|
|
95
|
+
|
|
96
|
+
## Pull Request Process
|
|
97
|
+
|
|
98
|
+
1. **Update Documentation**: Ensure README.md and relevant documentation reflect your changes
|
|
99
|
+
|
|
100
|
+
2. **Add Tests**: All new features and bug fixes must include tests
|
|
101
|
+
|
|
102
|
+
3. **Run the Full Test Suite**:
|
|
103
|
+
```bash
|
|
104
|
+
npm run typecheck
|
|
105
|
+
npm test
|
|
106
|
+
npm run lint
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
4. **Update CHANGELOG**: Add your changes to the Unreleased section
|
|
110
|
+
|
|
111
|
+
5. **Write Clear Commit Messages**:
|
|
112
|
+
- Use present tense ("Add feature" not "Added feature")
|
|
113
|
+
- Use imperative mood ("Move cursor to..." not "Moves cursor to...")
|
|
114
|
+
- Reference issues and pull requests when relevant
|
|
115
|
+
|
|
116
|
+
6. **Submit PR**:
|
|
117
|
+
- Fill out the PR template completely
|
|
118
|
+
- Link related issues
|
|
119
|
+
- Request review from maintainers
|
|
120
|
+
|
|
121
|
+
7. **Address Review Feedback**: Be responsive to review comments and make requested changes
|
|
122
|
+
|
|
123
|
+
## Coding Standards
|
|
124
|
+
|
|
125
|
+
### TypeScript Style
|
|
126
|
+
|
|
127
|
+
- Use TypeScript for all source code
|
|
128
|
+
- Enable strict mode in `tsconfig.json`
|
|
129
|
+
- Provide type definitions for all public APIs
|
|
130
|
+
- Avoid using `any` - use `unknown` or proper types
|
|
131
|
+
|
|
132
|
+
### Code Style
|
|
133
|
+
|
|
134
|
+
We use ESLint and Prettier for consistent code style:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
# Format code
|
|
138
|
+
npm run format
|
|
139
|
+
|
|
140
|
+
# Check linting
|
|
141
|
+
npm run lint
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Naming Conventions
|
|
145
|
+
|
|
146
|
+
- **Classes**: PascalCase (e.g., `LockLLM`, `PromptInjectionError`)
|
|
147
|
+
- **Functions/Methods**: camelCase (e.g., `createOpenAI`, `scanPrompt`)
|
|
148
|
+
- **Constants**: UPPER_SNAKE_CASE (e.g., `DEFAULT_TIMEOUT`)
|
|
149
|
+
- **Interfaces/Types**: PascalCase (e.g., `ScanRequest`, `ClientConfig`)
|
|
150
|
+
- **Private members**: Prefix with underscore (e.g., `_processRequest`)
|
|
151
|
+
|
|
152
|
+
### File Organization
|
|
153
|
+
|
|
154
|
+
- Place source code in `src/`
|
|
155
|
+
- Place tests alongside source files with `.test.ts` extension
|
|
156
|
+
- Export public API through `src/index.ts`
|
|
157
|
+
- Keep files focused and single-purpose
|
|
158
|
+
|
|
159
|
+
## Testing Guidelines
|
|
160
|
+
|
|
161
|
+
### Test Requirements
|
|
162
|
+
|
|
163
|
+
- All new features must include tests
|
|
164
|
+
- Bug fixes should include regression tests
|
|
165
|
+
- Aim for >90% code coverage
|
|
166
|
+
- Tests should be isolated and deterministic
|
|
167
|
+
|
|
168
|
+
### Writing Tests
|
|
169
|
+
|
|
170
|
+
We use Vitest for testing:
|
|
171
|
+
|
|
172
|
+
```typescript
|
|
173
|
+
import { describe, it, expect } from 'vitest';
|
|
174
|
+
import { LockLLM } from '../index';
|
|
175
|
+
|
|
176
|
+
describe('LockLLM', () => {
|
|
177
|
+
it('should scan input successfully', async () => {
|
|
178
|
+
const client = new LockLLM({ apiKey: 'test-key' });
|
|
179
|
+
const result = await client.scan({ input: 'Hello world' });
|
|
180
|
+
expect(result.safe).toBe(true);
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### Test Categories
|
|
186
|
+
|
|
187
|
+
- **Unit Tests**: Test individual functions and classes
|
|
188
|
+
- **Integration Tests**: Test wrapper functions with provider SDKs
|
|
189
|
+
- **Error Handling Tests**: Verify proper error handling
|
|
190
|
+
|
|
191
|
+
### Running Tests
|
|
192
|
+
|
|
193
|
+
```bash
|
|
194
|
+
# Run all tests
|
|
195
|
+
npm test
|
|
196
|
+
|
|
197
|
+
# Run specific test file
|
|
198
|
+
npm test -- scan.test.ts
|
|
199
|
+
|
|
200
|
+
# Run with coverage
|
|
201
|
+
npm run test:coverage
|
|
202
|
+
|
|
203
|
+
# Run in watch mode during development
|
|
204
|
+
npm run test:watch
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## Documentation
|
|
208
|
+
|
|
209
|
+
### Code Documentation
|
|
210
|
+
|
|
211
|
+
- Add JSDoc comments for all public APIs
|
|
212
|
+
- Include parameter descriptions and return types
|
|
213
|
+
- Provide usage examples in comments
|
|
214
|
+
|
|
215
|
+
Example:
|
|
216
|
+
```typescript
|
|
217
|
+
/**
|
|
218
|
+
* Scans input text for security threats
|
|
219
|
+
* @param request - The scan request containing input text and options
|
|
220
|
+
* @returns Promise resolving to scan results with safety classification
|
|
221
|
+
* @throws {AuthenticationError} If API key is invalid
|
|
222
|
+
* @example
|
|
223
|
+
* ```typescript
|
|
224
|
+
* const result = await client.scan({
|
|
225
|
+
* input: 'User input here',
|
|
226
|
+
* sensitivity: 'medium'
|
|
227
|
+
* });
|
|
228
|
+
* ```
|
|
229
|
+
*/
|
|
230
|
+
async scan(request: ScanRequest): Promise<ScanResponse>
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
### README Updates
|
|
234
|
+
|
|
235
|
+
- Update feature lists when adding capabilities
|
|
236
|
+
- Add examples for new functionality
|
|
237
|
+
- Keep API reference section current
|
|
238
|
+
- Update performance metrics if applicable
|
|
239
|
+
|
|
240
|
+
## Security Considerations
|
|
241
|
+
|
|
242
|
+
- Never commit API keys or secrets
|
|
243
|
+
- Be cautious with user input in examples
|
|
244
|
+
- Follow security best practices
|
|
245
|
+
- Report security vulnerabilities privately (see [SECURITY.md](SECURITY.md))
|
|
246
|
+
|
|
247
|
+
## Questions?
|
|
248
|
+
|
|
249
|
+
- Open an issue for questions about contributing
|
|
250
|
+
- Email support@lockllm.com for private inquiries
|
|
251
|
+
- Check existing issues and pull requests for similar discussions
|
|
252
|
+
|
|
253
|
+
## License
|
|
254
|
+
|
|
255
|
+
By contributing to LockLLM, you agree that your contributions will be licensed under the MIT License.
|
|
256
|
+
|
|
257
|
+
---
|
|
258
|
+
|
|
259
|
+
Thank you for contributing to LockLLM! Your efforts help make AI applications more secure for everyone.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 LockLLM
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|