@denizsvnc/ai-rag-engine 0.0.0-stage → 2.2.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 +36 -0
- package/LICENSE +21 -0
- package/README.md +115 -2
- package/dist/adapters/cache/index.d.ts +1 -0
- package/dist/adapters/cache/redis-cache.adapter.d.ts +49 -0
- package/dist/adapters/faq/local-faq.adapter.d.ts +29 -0
- package/dist/adapters/faq/url-faq.adapter.d.ts +14 -0
- package/dist/adapters/llm/custom.adapter.d.ts +42 -0
- package/dist/adapters/llm/fallback.adapter.d.ts +10 -0
- package/dist/adapters/llm/gemini.adapter.d.ts +9 -0
- package/dist/adapters/llm/ollama.adapter.d.ts +30 -0
- package/dist/adapters/llm/openai.adapter.d.ts +10 -0
- package/dist/adapters/llm/openrouter.adapter.d.ts +6 -0
- package/dist/adapters/llm/tiered.adapter.d.ts +22 -0
- package/dist/adapters/rules/static-rules.adapter.d.ts +6 -0
- package/dist/adapters/vector/memory-vector.adapter.d.ts +33 -0
- package/dist/adapters/vector/postgres-vector.adapter.d.ts +51 -0
- package/dist/api/auth.d.ts +47 -0
- package/dist/api/middleware.d.ts +3 -0
- package/dist/api/rate-limit.d.ts +8 -0
- package/dist/api/routes.d.ts +9 -0
- package/dist/api/server.d.ts +1 -0
- package/dist/api/server.js +4433 -0
- package/dist/config/default.d.ts +22 -0
- package/dist/config/ingestion-runtime.d.ts +11 -0
- package/dist/core/cache-manager.d.ts +29 -0
- package/dist/core/engine.d.ts +75 -0
- package/dist/core/ingestion/ingestion-worker.d.ts +19 -0
- package/dist/core/ingestion/postgres-ingestion-store.d.ts +56 -0
- package/dist/core/ingestion/queued-ingestion.service.d.ts +35 -0
- package/dist/core/metrics/prometheus-exporter.d.ts +12 -0
- package/dist/core/metrics/rag-evaluator.d.ts +63 -0
- package/dist/core/metrics/token-tracker.d.ts +69 -0
- package/dist/core/prompt-builder.d.ts +20 -0
- package/dist/core/queue/bullmq-queue.d.ts +39 -0
- package/dist/core/queue/in-memory-queue.d.ts +24 -0
- package/dist/core/queue/job-queue.interface.d.ts +22 -0
- package/dist/core/queue/queue-factory.d.ts +12 -0
- package/dist/core/security/confirmation.d.ts +64 -0
- package/dist/core/security/injection-detector.d.ts +25 -0
- package/dist/core/security/nonce-store.d.ts +21 -0
- package/dist/core/security/pii-guard.d.ts +38 -0
- package/dist/core/security/sanitizer.d.ts +23 -0
- package/dist/core/security/secrets.d.ts +2 -0
- package/dist/core/security/security-guard.d.ts +18 -0
- package/dist/core/security/security.types.d.ts +38 -0
- package/dist/core/sml-engine.d.ts +65 -0
- package/dist/core/tool-registry.d.ts +17 -0
- package/dist/core/vector/bm25.d.ts +44 -0
- package/dist/core/vector/hybrid-search.d.ts +15 -0
- package/dist/index.d.ts +51 -0
- package/dist/index.js +4509 -0
- package/dist/interfaces/cache.interface.d.ts +8 -0
- package/dist/interfaces/engine-config.interface.d.ts +73 -0
- package/dist/interfaces/faq.interface.d.ts +17 -0
- package/dist/interfaces/ingestion.interface.d.ts +14 -0
- package/dist/interfaces/llm.interface.d.ts +22 -0
- package/dist/interfaces/query-context.interface.d.ts +33 -0
- package/dist/interfaces/rules.interface.d.ts +3 -0
- package/dist/interfaces/tool.interface.d.ts +50 -0
- package/dist/interfaces/vector.interface.d.ts +15 -0
- package/dist/scripts/migrate-vector.d.ts +1 -0
- package/dist/scripts/migrate-vector.js +627 -0
- package/dist/services/document-ingestion.service.d.ts +116 -0
- package/dist/utils/http.d.ts +2 -0
- package/dist/utils/math.d.ts +3 -0
- package/dist/worker.d.ts +1 -0
- package/dist/worker.js +1787 -0
- package/docs/RELEASING.md +55 -0
- package/docs/USAGE.md +148 -0
- package/package.json +95 -4
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Versioning and Release Checklist
|
|
2
|
+
|
|
3
|
+
## Policy
|
|
4
|
+
|
|
5
|
+
The recommended first public version is **2.2.0**: the repository already identifies its preceding API as 2.1.0, and the new distribution includes durable ingestion and persistence. No public npm history or tag was found during preparation. This recommendation does not assert that any version was published. The maintainer must approve the version before publication. If API stabilization is still desired, use a deliberate `2.2.0-rc.1` prerelease and a non-latest dist-tag.
|
|
6
|
+
|
|
7
|
+
After the first public release, use patch releases for compatible fixes, minor releases for compatible features, and major releases for incompatible public API, security-contract or supported-runtime changes. Document security-driven breaks and migration paths. Never reuse a published version; do not silently modify artifacts after review.
|
|
8
|
+
|
|
9
|
+
## Required local gates
|
|
10
|
+
|
|
11
|
+
1. Verify scope ownership and registry state while authenticated as the intended maintainer. A public 404 does not prove an available or owned scope.
|
|
12
|
+
2. Review `CHANGELOG.md`, package name/version, ESM/Node requirements and compatibility notes.
|
|
13
|
+
3. Run `npm ci`, typecheck, full tests with disposable pgvector/Redis, security regressions, build, package verification, dependency audit and independent consumer installation.
|
|
14
|
+
4. Run real-model consumer integration when model/provisioning changes warrant it. Keep it distinct from the deterministic package gate.
|
|
15
|
+
5. Inspect packed files and ensure no credentials, demo fixtures, model weights, absolute workstation paths, caches or install-time SDK hooks are shipped.
|
|
16
|
+
6. Inspect transitive native dependency scripts/permissions; `npm audit` does not prove absence of malicious code or unpublished vulnerabilities. Models have separate licenses.
|
|
17
|
+
7. Approve the exact tarball hash, package version and dist-tag. Review CI results on Node 22/24.
|
|
18
|
+
8. Only after explicit authorization, publish the reviewed tarball. Tags, pushes and GitHub releases require their own authorization.
|
|
19
|
+
|
|
20
|
+
## Manual commands for the owner
|
|
21
|
+
|
|
22
|
+
Preparation (no publication):
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
npm ci
|
|
26
|
+
npm run typecheck
|
|
27
|
+
PG_TEST_URL=postgresql://postgres:test@localhost/rag_test \
|
|
28
|
+
REDIS_TEST_URL=redis://localhost:6379 npm test
|
|
29
|
+
REDIS_TEST_URL=redis://localhost:6379 npm run test:security
|
|
30
|
+
npm run test:package
|
|
31
|
+
npm run test:consumer
|
|
32
|
+
npm audit --audit-level=high
|
|
33
|
+
npm pack --dry-run
|
|
34
|
+
npm pack
|
|
35
|
+
shasum -a 256 denizsvnc-ai-rag-engine-2.2.0.tgz
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Only when the repository owner is ready to authenticate and publish:
|
|
39
|
+
|
|
40
|
+
```sh
|
|
41
|
+
npm login --registry=https://registry.npmjs.org/
|
|
42
|
+
npm whoami --registry=https://registry.npmjs.org/
|
|
43
|
+
npm view @denizsvnc/ai-rag-engine versions --json --registry=https://registry.npmjs.org/
|
|
44
|
+
# Confirm namespace rights, intended version and reviewed tarball hash before proceeding.
|
|
45
|
+
npm publish ./denizsvnc-ai-rag-engine-2.2.0.tgz --access public --tag latest --registry=https://registry.npmjs.org/
|
|
46
|
+
npm view @denizsvnc/ai-rag-engine@2.2.0 dist.integrity --registry=https://registry.npmjs.org/
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
A 404 from `npm view` is expected for a genuinely new name but is not an authorization check. `npm login`/`npm publish` were not executed by the preparation agent. Do not store tokens in the repository, `.npmrc`, logs or CI artifacts. Prefer owner-approved short-lived authentication and enforced account security.
|
|
50
|
+
|
|
51
|
+
## Trusted Publishing (optional, not configured)
|
|
52
|
+
|
|
53
|
+
No automatic publication workflow is installed. For later owner-approved CI publication, npm supports OIDC Trusted Publishing with matching repository/workflow/environment settings, npm CLI 11.5.1+ and Node.js 22.14+. Configure it in the npm package settings, use an approved environment and `id-token: write`, and keep all validation gates. Trusted publication automatically attaches provenance. First-publication and package-ownership prerequisites must be resolved by the owner. Do not add token secrets as a fallback.
|
|
54
|
+
|
|
55
|
+
References: [npm Trusted Publishing](https://docs.npmjs.com/trusted-publishers/), [npm provenance](https://docs.npmjs.com/generating-provenance-statements/), [Node.js release schedule](https://github.com/nodejs/Release).
|
package/docs/USAGE.md
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# SDK Usage and Operations
|
|
2
|
+
|
|
3
|
+
## Runtime and module contract
|
|
4
|
+
|
|
5
|
+
Install `@denizsvnc/ai-rag-engine` after publication, or its local `.tgz` before publication. Use ESM (`"type": "module"` in the application). CommonJS `require()` is not a supported contract; CommonJS applications can use asynchronous `import()`. Node.js 22.14+ is required; Node 22/24 are the explicit test matrix. TypeScript 5.8+ is recommended; NodeNext and Bundler resolution are validated with strict checking. `skipLibCheck` is not required. Supported exports are the root API and `./package.json`; internal `dist/` paths are private. CLI commands are separate entry points.
|
|
6
|
+
|
|
7
|
+
The library never automatically loads `.env`. Applications may call `dotenv.config()` themselves. The server/worker/migration CLIs explicitly load `.env`. Importing the root library creates no server, connection, model download, or background worker. Native Transformers is imported lazily on the first embedding initialization.
|
|
8
|
+
|
|
9
|
+
## Lifecycle and defaults
|
|
10
|
+
|
|
11
|
+
Construct `RAGEngine` with `llmProvider` and `inputs`. `init()` is idempotent and shares concurrent initialization; `query()` also initializes automatically. Default SML initialization loads MiniLM, so set `smlConfig: { enabled: false }` for adapters that do not use local routing. A vector adapter or FAQ can still explicitly load its own embedding model. Default cache uses `./data/query-cache.json` relative to the application working directory; disable it or supply an adapter/path explicitly. New cache files are OS-user private (`0600` on POSIX); existing cache files should be reviewed separately. Cache/registry paths are trusted host configuration, never HTTP/user input.
|
|
12
|
+
|
|
13
|
+
`LocalFaqAdapter()` is initially empty. Call `setFaqs()` with application data or pass an explicit `filePath`. No sample business policies are loaded or shipped. This changes the old checkout-only default `./src/utils/faq-embeddings.json`.
|
|
14
|
+
|
|
15
|
+
The engine does not own externally supplied pools/clients. Close PostgreSQL adapters, queues and Redis clients when the host shuts down. Durable worker `close()` drains active tasks. The HTTP and worker CLIs install SIGTERM/SIGINT handlers with a shutdown deadline. Explicit SDK callers own their lifecycle.
|
|
16
|
+
|
|
17
|
+
## Provider configuration
|
|
18
|
+
|
|
19
|
+
```js
|
|
20
|
+
import { RAGEngine, CustomLLMAdapter } from '@denizsvnc/ai-rag-engine';
|
|
21
|
+
const provider = new CustomLLMAdapter({
|
|
22
|
+
endpoint: 'http://127.0.0.1:8000/v1/chat/completions',
|
|
23
|
+
model: 'your-deployed-model'
|
|
24
|
+
});
|
|
25
|
+
const engine = new RAGEngine({
|
|
26
|
+
llmProvider: provider, inputs: {},
|
|
27
|
+
smlConfig: { enabled: false }, cache: { enabled: false }
|
|
28
|
+
});
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
The private endpoint is an explicit data destination; review it before sending proprietary data. API keys belong in secret management, not source control. Other constructors: `new OpenAIAdapter(apiKey, model)`, `new GeminiAdapter(apiKey, model)`, `new OllamaAdapter({ host, model })`. `FallbackLLMProvider` accepts providers in order; `TieredLLMProvider.createFromEnv()` builds configured fast/smart chains. Configure `LLM_TIMEOUT_MS` (1–300000; default 30000) to bound HTTP calls. Providers can still fail; catch errors and return an application-appropriate failure without disclosing credentials or raw upstream responses. The SDK does not implement a provider-wide distributed token budget.
|
|
32
|
+
|
|
33
|
+
OpenRouter fallback from `createFromEnv()` requires `ALLOW_PUBLIC_OPENSOURCE_LLM=true`. Set this flag to `false` in restricted environments. Review all explicitly supplied endpoints/providers independently. PII filtering is pattern/algorithm based and cannot guarantee every sensitive field is detected.
|
|
34
|
+
|
|
35
|
+
## Local embeddings, FAQ and routing
|
|
36
|
+
|
|
37
|
+
```js
|
|
38
|
+
import { SMLEngine, LocalFaqAdapter } from '@denizsvnc/ai-rag-engine';
|
|
39
|
+
const embeddings = new SMLEngine({
|
|
40
|
+
modelName: 'Xenova/all-MiniLM-L6-v2',
|
|
41
|
+
cacheDir: './models',
|
|
42
|
+
localFilesOnly: false // true after provisioning a local cache for offline use
|
|
43
|
+
});
|
|
44
|
+
const faq = new LocalFaqAdapter({ smlEngine: embeddings });
|
|
45
|
+
await faq.setFaqs([
|
|
46
|
+
{ id: 'support', question: 'When is support available?', answer: 'Weekdays.', tenantId: 'acme' }
|
|
47
|
+
]);
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
FAQ entries without `tenantId` are deliberately global. Model weights are separate downloads with their own licenses and storage requirements. The SDK includes Transformers/ONNX as a direct dependency to preserve default local embedding behavior; these native dependencies increase installation size. `RAG_MODEL_CACHE_DIR` supplies the default per-instance cache directory without mutating Transformers global state. Two SMLEngine instances can have different cache settings. Tools use descriptions for local routing; provide precise descriptions and persist their registry at a trusted writable path.
|
|
51
|
+
|
|
52
|
+
## Vector adapters and retrieval
|
|
53
|
+
|
|
54
|
+
`MemoryVectorAdapter` supports tenant/ID upsert and in-memory dense/sparse/hybrid retrieval. Its `search()` also supports context-free data; only use tenant-tagged documents and trusted filters in multi-tenant applications. Restart loses state. SDK users can implement `IVectorStoreAdapter` for other stores without Express.
|
|
55
|
+
|
|
56
|
+
```js
|
|
57
|
+
import { PostgresVectorAdapter, RAGEngine } from '@denizsvnc/ai-rag-engine';
|
|
58
|
+
const vectors = new PostgresVectorAdapter({
|
|
59
|
+
connectionString: process.env.DATABASE_URL,
|
|
60
|
+
tableName: 'rag_documents', modelName: 'Xenova/all-MiniLM-L6-v2',
|
|
61
|
+
dimensions: 384, autoMigrate: false
|
|
62
|
+
});
|
|
63
|
+
await vectors.init();
|
|
64
|
+
await vectors.addDocuments([{ id: 'policy', content: 'Returns: 14 days.', metadata: { tenantId: 'acme' } }]);
|
|
65
|
+
const engine = new RAGEngine({
|
|
66
|
+
llmProvider: provider, inputs: { vectorStore: vectors },
|
|
67
|
+
smlConfig: { enabled: false }, cache: { enabled: false },
|
|
68
|
+
retrieval: { strategy: 'hybrid', topK: 3 }
|
|
69
|
+
});
|
|
70
|
+
// Authenticate the caller before producing this context.
|
|
71
|
+
const answer = await engine.query('What is the return policy?', { tenantId: 'acme', userId: 'u1', roles: ['viewer'] });
|
|
72
|
+
// Close when the host finishes all requests:
|
|
73
|
+
await vectors.close();
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
This snippet assumes `provider` is configured as above. Run `ai-rag-migrate` with an owner role first. Runtime needs table DML and schema USAGE; use a separate restricted role. Model/dimension mismatches reject initialization. New model configurations need new tables and reindexing. PostgreSQL hybrid retrieval combines dense vectors and the `simple` full-text dictionary using reciprocal rank fusion; it is not BM25 or Turkish morphological analysis. Exact search is the default; optional HNSW requires recall evaluation with actual tenant filters. Direct DB access is not protected by tenant RLS.
|
|
77
|
+
|
|
78
|
+
## Secure tools and tenant context
|
|
79
|
+
|
|
80
|
+
Import `IAgentTool` for types and use Zod schemas for validation:
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
import { z } from 'zod';
|
|
84
|
+
import type { IAgentTool } from '@denizsvnc/ai-rag-engine';
|
|
85
|
+
const reserve: IAgentTool<{ sku: string }> = {
|
|
86
|
+
name: 'reserve_item', description: 'Reserve inventory for an authenticated customer',
|
|
87
|
+
parameters: { type: 'object', properties: { sku: { type: 'string', description: 'Inventory SKU' } }, required: ['sku'] },
|
|
88
|
+
zodSchema: z.object({ sku: z.string().min(1) }),
|
|
89
|
+
requiredRoles: ['editor'], isMutating: true,
|
|
90
|
+
async execute(args, context) {
|
|
91
|
+
// Enforce ownership/tenant constraints again in the application's transaction.
|
|
92
|
+
return { sku: args.sku, tenantId: context?.tenantId };
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
The example demonstrates the tool contract, not an inventory database implementation. A returned `confirmationRequests` proposal must be shown to the authenticated user; only after approval should the application resubmit the same action with `context.confirmationTicket`. Boolean confirmation is not authorization. Tickets bind tool, exact arguments, tenant and user, expire and are atomically consumed once. Production requires a 32+ byte independent `CONFIRMATION_SECRET` and `RedisConfirmationNonceStore`; use a shared Redis namespace with no eviction. Do not silently use memory on Redis failures. Tool handlers are trusted application code; the SDK is not a sandbox and cannot make arbitrary callbacks safe.
|
|
98
|
+
|
|
99
|
+
Direct SDK callers must authenticate context themselves. Never accept tenant/user/roles directly from untrusted JSON. Express integrations should use `createApiRoutes` or authenticated middleware so only verified `req.auth` supplies identity. Production rejects anonymous development auth and missing/known/weak secrets. JWT identity is HMAC signed; rotate keys operationally and keep issuer/audience configuration consistent. Read-only viewer and mutating editor/admin policies must match the application's own authorization rules.
|
|
100
|
+
|
|
101
|
+
## Standalone API, worker and migrations
|
|
102
|
+
|
|
103
|
+
Installed commands: `ai-rag-server`, `ai-rag-worker`, `ai-rag-migrate`. Do not import CLI files into an application. Production mode defaults to BullMQ ingestion and a shared PostgreSQL vector store. Development memory mode is single-process and not durable.
|
|
104
|
+
|
|
105
|
+
| Setting | Default / purpose |
|
|
106
|
+
| --- | --- |
|
|
107
|
+
| `NODE_ENV` | Host environment; production enforces strict secrets |
|
|
108
|
+
| `JWT_SECRET`, `CONFIRMATION_SECRET` | Independent random secrets, 32+ bytes in production |
|
|
109
|
+
| `DATABASE_URL` | PostgreSQL runtime connection; pgvector migrations required |
|
|
110
|
+
| `REDIS_URL` | Shared queue/cache/rate-limit connection |
|
|
111
|
+
| `CONFIRMATION_REDIS_URL` | Optional separate shared nonce Redis connection |
|
|
112
|
+
| `VECTOR_STORE` | `postgres` with durable queue; otherwise `memory` |
|
|
113
|
+
| `VECTOR_TABLE_NAME` | `rag_documents` |
|
|
114
|
+
| `VECTOR_AUTO_MIGRATE` | `false`; DDL should run separately |
|
|
115
|
+
| `EMBEDDING_MODEL`, `EMBEDDING_DIMENSIONS` | MiniLM, 384; migration/runtime must match |
|
|
116
|
+
| `INGESTION_QUEUE` | Production `bullmq`, development `memory` |
|
|
117
|
+
| `INGESTION_QUEUE_NAME`, `INGESTION_TABLE_NAME` | `rag-ingestion-queue`, `rag_ingestion` |
|
|
118
|
+
| `INGESTION_CONCURRENCY`, `INGESTION_GLOBAL_CONCURRENCY` | 2 per worker, 4 shared |
|
|
119
|
+
| `INGESTION_ATTEMPTS` | 3, exponential backoff |
|
|
120
|
+
| `INGESTION_MAX_UPLOAD_BYTES` | 5242880 |
|
|
121
|
+
| `INGESTION_MAX_PENDING_PER_TENANT` | 100 |
|
|
122
|
+
| `INGESTION_MAX_STORED_BYTES_PER_TENANT` | 52428800 |
|
|
123
|
+
| `API_RATE_LIMIT` | 120 authenticated requests/tenant/minute |
|
|
124
|
+
| `SHUTDOWN_TIMEOUT_MS` | 30000 |
|
|
125
|
+
| `PRIVATE_LLM_ENDPOINT`, `PRIVATE_LLM_MODEL_FAST/SMART` | Explicit OpenAI-compatible private destination/model |
|
|
126
|
+
| `OPENAI_API_KEY`, `GEMINI_API_KEY`, `OLLAMA_HOST` | Enable corresponding configured provider |
|
|
127
|
+
| `ALLOW_PUBLIC_OPENSOURCE_LLM` | Public router fallback disabled unless explicitly true |
|
|
128
|
+
| `RAG_MODEL_CACHE_DIR` | `./data/models`; writable trusted model cache |
|
|
129
|
+
| `FAQ_FILE_PATH` | No FAQ file by default |
|
|
130
|
+
| `CACHE_KEY_PREFIX`, `API_RATE_KEY_PREFIX` | Table-specific default namespaces |
|
|
131
|
+
|
|
132
|
+
Keep DB/table/model/queue settings identical across API and workers. Migration can provision `RUNTIME_DB_USER/PASSWORD`; existing role passwords are not reset. Redis persistence, noeviction, backups and capacity monitoring are deployment requirements. Upload content is stored in PostgreSQL before dispatch. Outbox polling recovers missing queue entries. Successful raw content is removed; failed raw content expires after 7 days, while result/idempotency ledgers persist. Archive growing ledgers operationally. `Idempotency-Key` conflicts return 409, quota/rate-limit failures 429, limiter outages 503. Failed retained jobs can be retried with `POST /api/ingest/status/:jobId/retry` under their tenant's authorization.
|
|
133
|
+
|
|
134
|
+
Worker delivery is at least once. Transactional document version manifests prevent old/repeated work from replacing newer data, remove stale chunks and bump a cache revision. The SDK does not claim exactly-once message delivery. SIGKILL recovery uses BullMQ stalled-job detection. The limited PDF parser does not include OCR and rejects PDFs without extractable text.
|
|
135
|
+
|
|
136
|
+
## Errors and troubleshooting
|
|
137
|
+
|
|
138
|
+
- Import errors: use ESM and a supported Node version; install the `.tgz`, not a symlink to unbuilt source.
|
|
139
|
+
- Type errors: use NodeNext/Bundler and a current TypeScript compiler. Consumer fixtures verify strict declaration resolution without `skipLibCheck`.
|
|
140
|
+
- Unexpected model download: disable SML when unused; FAQ/vector adapters can still need embeddings. Preload models and use `SMLEngine.localFilesOnly` where appropriate.
|
|
141
|
+
- No FAQ answer: provide actual FAQ data explicitly; tune thresholds on a representative labeled dataset.
|
|
142
|
+
- Queue stays pending: run the separate worker, verify shared Redis/DB settings and migration permissions.
|
|
143
|
+
- Schema/model mismatch: run matching migrations; do not force reuse of incompatible embedding tables.
|
|
144
|
+
- Authentication rejection: provision independent secrets and consistent issuer/audience; never relax production checks to resolve deployment errors.
|
|
145
|
+
- Permission denied on cache: select an explicit writable directory owned by the runtime user. Do not make credential/cache files world-writable.
|
|
146
|
+
- Provider failures: validate endpoint, model and timeout without logging secrets. Local small-model checks do not establish general answer quality.
|
|
147
|
+
|
|
148
|
+
No production throughput, universal PII masking, complete prompt-injection prevention, full OCR, or broad multilingual answer-quality guarantee is made.
|
package/package.json
CHANGED
|
@@ -1,6 +1,97 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@denizsvnc/ai-rag-engine",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "2.2.0",
|
|
4
|
+
"description": "TypeScript RAG engine with pluggable providers, local semantic routing, tenant-aware retrieval, and durable document ingestion.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.js"
|
|
11
|
+
},
|
|
12
|
+
"./package.json": "./package.json"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist/**/*.js",
|
|
16
|
+
"dist/**/*.d.ts",
|
|
17
|
+
"README.md",
|
|
18
|
+
"LICENSE",
|
|
19
|
+
"CHANGELOG.md",
|
|
20
|
+
"docs/USAGE.md",
|
|
21
|
+
"docs/RELEASING.md"
|
|
22
|
+
],
|
|
23
|
+
"scripts": {
|
|
24
|
+
"dev": "tsx watch src/api/server.ts",
|
|
25
|
+
"build:types": "tsc -p tsconfig.build.json",
|
|
26
|
+
"build:js": "node tools/build.mjs",
|
|
27
|
+
"build": "npm run clean && npm run build:types && npm run build:js",
|
|
28
|
+
"typecheck": "tsc --noEmit",
|
|
29
|
+
"start": "node dist/api/server.js",
|
|
30
|
+
"test": "tsx test/run-all.ts",
|
|
31
|
+
"benchmark": "tsx test/performance/smoke-benchmark.ts",
|
|
32
|
+
"example:ecommerce": "tsx src/examples/02-ecommerce-with-tools/index.ts",
|
|
33
|
+
"example:minimal": "tsx src/examples/01-minimal-express/index.ts",
|
|
34
|
+
"test:security": "node --import tsx --test test/security/*.test.ts test/unit/security/*.test.ts test/integration/security-boundaries.test.ts test/integration/distributed-confirmation.test.ts test/unit/governed-tools.test.ts",
|
|
35
|
+
"db:migrate": "node dist/scripts/migrate-vector.js",
|
|
36
|
+
"start:worker": "node dist/worker.js",
|
|
37
|
+
"prepack": "npm run build",
|
|
38
|
+
"test:consumer": "node test/package/run.mjs",
|
|
39
|
+
"clean": "node tools/clean.mjs",
|
|
40
|
+
"test:consumer:integration": "node test/consumer/run.mjs",
|
|
41
|
+
"test:package": "npm run build && node tools/verify-package.mjs"
|
|
42
|
+
},
|
|
43
|
+
"keywords": [
|
|
44
|
+
"rag",
|
|
45
|
+
"agentic-rag",
|
|
46
|
+
"sml",
|
|
47
|
+
"semantic-routing",
|
|
48
|
+
"vector-search",
|
|
49
|
+
"prompt-injection",
|
|
50
|
+
"ollama",
|
|
51
|
+
"vllm",
|
|
52
|
+
"openai",
|
|
53
|
+
"gemini",
|
|
54
|
+
"openrouter"
|
|
55
|
+
],
|
|
56
|
+
"author": "Denizsvnc (https://github.com/Denizsvnc)",
|
|
57
|
+
"license": "MIT",
|
|
58
|
+
"type": "module",
|
|
59
|
+
"dependencies": {
|
|
60
|
+
"@huggingface/transformers": "4.3.1",
|
|
61
|
+
"bullmq": "6.7.2",
|
|
62
|
+
"dotenv": "16.6.1",
|
|
63
|
+
"express": "5.3.0",
|
|
64
|
+
"ioredis": "6.0.0",
|
|
65
|
+
"lru-cache": "10.4.3",
|
|
66
|
+
"pg": "8.23.1",
|
|
67
|
+
"zod": "4.6.7",
|
|
68
|
+
"@types/pg": "8.23.1",
|
|
69
|
+
"@types/express": "5.0.6",
|
|
70
|
+
"@types/node": "26.6.5"
|
|
71
|
+
},
|
|
72
|
+
"devDependencies": {
|
|
73
|
+
"esbuild": "0.28.2",
|
|
74
|
+
"tsx": "4.23.15",
|
|
75
|
+
"typescript": "7.0.2"
|
|
76
|
+
},
|
|
77
|
+
"bin": {
|
|
78
|
+
"ai-rag-server": "dist/api/server.js",
|
|
79
|
+
"ai-rag-worker": "dist/worker.js",
|
|
80
|
+
"ai-rag-migrate": "dist/scripts/migrate-vector.js"
|
|
81
|
+
},
|
|
82
|
+
"repository": {
|
|
83
|
+
"type": "git",
|
|
84
|
+
"url": "git+https://github.com/Denizsvnc/ai-rag-engine.git"
|
|
85
|
+
},
|
|
86
|
+
"homepage": "https://github.com/Denizsvnc/ai-rag-engine#readme",
|
|
87
|
+
"bugs": {
|
|
88
|
+
"url": "https://github.com/Denizsvnc/ai-rag-engine/issues"
|
|
89
|
+
},
|
|
90
|
+
"engines": {
|
|
91
|
+
"node": ">=22.14.0"
|
|
92
|
+
},
|
|
93
|
+
"publishConfig": {
|
|
94
|
+
"access": "public",
|
|
95
|
+
"registry": "https://registry.npmjs.org/"
|
|
96
|
+
}
|
|
97
|
+
}
|