This repository contains the NodeJS SDK.
Athena is a gRPC-based image classification service designed for CSAM (Child Sexual Abuse Material) detection by Crisp. The service provides real-time image classification through bidirectional streaming with session-based deployment management and multi-affiliate support.
- Real-time Classification: Bidirectional streaming for immediate image processing
- Session Management: Deployment-based grouping enables collaborative processing
- Multi-format Support: Supports JPEG, PNG, WebP, TIFF, and many other image formats
- Compression: Optional Brotli compression for bandwidth optimization
- Error Handling: Comprehensive error codes and detailed error messages
- Monitoring: Active deployment tracking and backlog monitoring
This project uses pre-commit hooks to ensure code quality and consistency. The hooks run linting, formatting, and type checking before each commit.
-
Install pre-commit (if not already installed):
uvx pre-commit --help
Or install globally:
uv tool install pre-commit
-
Install the hooks:
uvx pre-commit install
-
Run all quality checks manually:
npm run lint:all
- ESLint: Code quality and style issues
- Prettier: Code formatting consistency
- TypeScript: Type checking and compilation
- File checks: Trailing whitespace, file endings, large files, etc.
- Submodule status: Ensures submodules are properly tracked
You can run individual checks manually:
# Run ESLint
npm run lint
# Check Prettier formatting
npm run prettier:check
# Fix Prettier formatting
npm run prettier
# TypeScript type checking
npx tsc --noEmit
# Run all checks at once
npm run lint:allProtobufs are stored as a git submodule from the @crispthinking/athena-protobufs repository.
To update the protobuf definitions for client generation:
-
Update the submodule to the latest version:
git submodule update --remote athena-protobufs
-
Or update to a specific commit:
cd athena-protobufs git checkout <commit-sha> cd .. git add athena-protobufs git commit -m "Update protobuf definitions to <commit-sha>"
This project uses @protobuf-ts/plugin to generate TypeScript-native gRPC clients and message types for use with @grpc/grpc-js.
-
Ensure dependencies are installed:
npm install --save-dev @protobuf-ts/plugin npm install --save @grpc/grpc-js
-
Run the following command to regenerate the client and types:
npm run codegen
Or manually with:
npx protoc \ --plugin=protoc-gen-ts=./node_modules/.bin/protoc-gen-ts \ --ts_out=client_grpc1:./src/athena \ --proto_path=./athena-protobufs/athena \ ./athena-protobufs/athena/athena.proto
- This will generate
.tsfiles insrc/athena/including a gRPC client compatible with@grpc/grpc-js.
- This will generate
-
Update your imports in your code as needed:
- The main client will be in
src/athena/athena.grpc-client.ts. - Message types and enums are in
src/athena/athena.ts.
- The main client will be in
-
Format the generated code:
npm run prettier
- If you update proto files in the submodule, rerun
npm run codegento keep the TypeScript client in sync. - If you see TypeScript errors about missing modules, ensure your
tsconfig.jsonincludes thesrc/athenadirectory and restart your IDE/tsserver. - The generated files are automatically formatted by the pre-commit hooks, but you can run
npm run prettiermanually if needed.
Building Documentation To build the documentation:
curl -LsSf https://astral.sh/uv/install.sh | sh
uv sync cd docs make html The built documentation will be available in docs/build/html/index.html.