agentdb 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/LICENSE +38 -0
- package/LICENSE-APACHE +190 -0
- package/LICENSE-MIT +21 -0
- package/README.md +953 -0
- package/bin/agentdb.js +485 -0
- package/bin/plugin-cli-wrapper.mjs +21 -0
- package/dist/cache/query-cache.d.ts +105 -0
- package/dist/cache/query-cache.d.ts.map +1 -0
- package/dist/cache/query-cache.js +224 -0
- package/dist/cache/query-cache.js.map +1 -0
- package/dist/cache/query-cache.mjs +219 -0
- package/dist/cli/cache/query-cache.d.ts +104 -0
- package/dist/cli/cache/query-cache.js +244 -0
- package/dist/cli/cli/db-commands.d.ts +48 -0
- package/dist/cli/cli/db-commands.js +613 -0
- package/dist/cli/commands.d.ts +7 -0
- package/dist/cli/commands.d.ts.map +1 -0
- package/dist/cli/commands.js +113 -0
- package/dist/cli/commands.js.map +1 -0
- package/dist/cli/commands.mjs +104 -0
- package/dist/cli/core/backend-interface.d.ts +70 -0
- package/dist/cli/core/backend-interface.js +15 -0
- package/dist/cli/core/native-backend.d.ts +140 -0
- package/dist/cli/core/native-backend.js +432 -0
- package/dist/cli/core/vector-db.d.ts +126 -0
- package/dist/cli/core/vector-db.js +338 -0
- package/dist/cli/core/wasm-backend.d.ts +95 -0
- package/dist/cli/core/wasm-backend.js +418 -0
- package/dist/cli/db-commands.d.ts +49 -0
- package/dist/cli/db-commands.d.ts.map +1 -0
- package/dist/cli/db-commands.js +533 -0
- package/dist/cli/db-commands.js.map +1 -0
- package/dist/cli/db-commands.mjs +522 -0
- package/dist/cli/generator.d.ts +11 -0
- package/dist/cli/generator.d.ts.map +1 -0
- package/dist/cli/generator.js +567 -0
- package/dist/cli/generator.js.map +1 -0
- package/dist/cli/generator.mjs +527 -0
- package/dist/cli/help.d.ts +18 -0
- package/dist/cli/help.d.ts.map +1 -0
- package/dist/cli/help.js +676 -0
- package/dist/cli/help.js.map +1 -0
- package/dist/cli/help.mjs +667 -0
- package/dist/cli/index/hnsw.d.ts +164 -0
- package/dist/cli/index/hnsw.js +558 -0
- package/dist/cli/plugin-cli.d.ts +7 -0
- package/dist/cli/plugin-cli.d.ts.map +1 -0
- package/dist/cli/plugin-cli.js +295 -0
- package/dist/cli/plugin-cli.js.map +1 -0
- package/dist/cli/plugin-cli.mjs +289 -0
- package/dist/cli/quantization/product-quantization.d.ts +108 -0
- package/dist/cli/quantization/product-quantization.js +350 -0
- package/dist/cli/query/query-builder.d.ts +322 -0
- package/dist/cli/query/query-builder.js +600 -0
- package/dist/cli/templates.d.ts +14 -0
- package/dist/cli/templates.d.ts.map +1 -0
- package/dist/cli/templates.js +182 -0
- package/dist/cli/templates.js.map +1 -0
- package/dist/cli/templates.mjs +176 -0
- package/dist/cli/types/index.d.ts +116 -0
- package/dist/cli/types/index.js +5 -0
- package/dist/cli/types.d.ts +91 -0
- package/dist/cli/types.d.ts.map +1 -0
- package/dist/cli/types.js +6 -0
- package/dist/cli/types.js.map +1 -0
- package/dist/cli/types.mjs +4 -0
- package/dist/cli/wizard/index.d.ts +6 -0
- package/dist/cli/wizard/index.d.ts.map +1 -0
- package/dist/cli/wizard/index.js +138 -0
- package/dist/cli/wizard/index.js.map +1 -0
- package/dist/cli/wizard/index.mjs +131 -0
- package/dist/cli/wizard/prompts.d.ts +11 -0
- package/dist/cli/wizard/prompts.d.ts.map +1 -0
- package/dist/cli/wizard/prompts.js +482 -0
- package/dist/cli/wizard/prompts.js.map +1 -0
- package/dist/cli/wizard/prompts.mjs +470 -0
- package/dist/cli/wizard/validator.d.ts +13 -0
- package/dist/cli/wizard/validator.d.ts.map +1 -0
- package/dist/cli/wizard/validator.js +234 -0
- package/dist/cli/wizard/validator.js.map +1 -0
- package/dist/cli/wizard/validator.mjs +224 -0
- package/dist/core/backend-interface.d.ts +71 -0
- package/dist/core/backend-interface.d.ts.map +1 -0
- package/dist/core/backend-interface.js +16 -0
- package/dist/core/backend-interface.js.map +1 -0
- package/dist/core/backend-interface.mjs +12 -0
- package/dist/core/native-backend.d.ts +141 -0
- package/dist/core/native-backend.d.ts.map +1 -0
- package/dist/core/native-backend.js +457 -0
- package/dist/core/native-backend.js.map +1 -0
- package/dist/core/native-backend.mjs +449 -0
- package/dist/core/vector-db.d.ts +127 -0
- package/dist/core/vector-db.d.ts.map +1 -0
- package/dist/core/vector-db.js +266 -0
- package/dist/core/vector-db.js.map +1 -0
- package/dist/core/vector-db.mjs +261 -0
- package/dist/core/wasm-backend.d.ts +96 -0
- package/dist/core/wasm-backend.d.ts.map +1 -0
- package/dist/core/wasm-backend.js +393 -0
- package/dist/core/wasm-backend.js.map +1 -0
- package/dist/core/wasm-backend.mjs +385 -0
- package/dist/index/hnsw-optimized.d.ts +75 -0
- package/dist/index/hnsw-optimized.d.ts.map +1 -0
- package/dist/index/hnsw-optimized.js +412 -0
- package/dist/index/hnsw-optimized.js.map +1 -0
- package/dist/index/hnsw-optimized.mjs +407 -0
- package/dist/index/hnsw.d.ts +165 -0
- package/dist/index/hnsw.d.ts.map +1 -0
- package/dist/index/hnsw.js +521 -0
- package/dist/index/hnsw.js.map +1 -0
- package/dist/index/hnsw.mjs +516 -0
- package/dist/index.d.ts +57 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +82 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +63 -0
- package/dist/mcp-server.d.ts +27 -0
- package/dist/mcp-server.d.ts.map +1 -0
- package/dist/mcp-server.js +789 -0
- package/dist/mcp-server.js.map +1 -0
- package/dist/mcp-server.mjs +784 -0
- package/dist/plugins/base-plugin.d.ts +114 -0
- package/dist/plugins/base-plugin.d.ts.map +1 -0
- package/dist/plugins/base-plugin.js +313 -0
- package/dist/plugins/base-plugin.js.map +1 -0
- package/dist/plugins/base-plugin.mjs +275 -0
- package/dist/plugins/implementations/active-learning.d.ts +135 -0
- package/dist/plugins/implementations/active-learning.d.ts.map +1 -0
- package/dist/plugins/implementations/active-learning.js +372 -0
- package/dist/plugins/implementations/active-learning.js.map +1 -0
- package/dist/plugins/implementations/active-learning.mjs +367 -0
- package/dist/plugins/implementations/actor-critic.d.ts +64 -0
- package/dist/plugins/implementations/actor-critic.d.ts.map +1 -0
- package/dist/plugins/implementations/actor-critic.js +363 -0
- package/dist/plugins/implementations/actor-critic.js.map +1 -0
- package/dist/plugins/implementations/actor-critic.mjs +358 -0
- package/dist/plugins/implementations/adversarial-training.d.ts +133 -0
- package/dist/plugins/implementations/adversarial-training.d.ts.map +1 -0
- package/dist/plugins/implementations/adversarial-training.js +409 -0
- package/dist/plugins/implementations/adversarial-training.js.map +1 -0
- package/dist/plugins/implementations/adversarial-training.mjs +404 -0
- package/dist/plugins/implementations/curriculum-learning.d.ts +132 -0
- package/dist/plugins/implementations/curriculum-learning.d.ts.map +1 -0
- package/dist/plugins/implementations/curriculum-learning.js +354 -0
- package/dist/plugins/implementations/curriculum-learning.js.map +1 -0
- package/dist/plugins/implementations/curriculum-learning.mjs +349 -0
- package/dist/plugins/implementations/decision-transformer.d.ts +77 -0
- package/dist/plugins/implementations/decision-transformer.d.ts.map +1 -0
- package/dist/plugins/implementations/decision-transformer.js +422 -0
- package/dist/plugins/implementations/decision-transformer.js.map +1 -0
- package/dist/plugins/implementations/decision-transformer.mjs +417 -0
- package/dist/plugins/implementations/federated-learning.d.ts +126 -0
- package/dist/plugins/implementations/federated-learning.d.ts.map +1 -0
- package/dist/plugins/implementations/federated-learning.js +436 -0
- package/dist/plugins/implementations/federated-learning.js.map +1 -0
- package/dist/plugins/implementations/federated-learning.mjs +431 -0
- package/dist/plugins/implementations/index.d.ts +30 -0
- package/dist/plugins/implementations/index.d.ts.map +1 -0
- package/dist/plugins/implementations/index.js +45 -0
- package/dist/plugins/implementations/index.js.map +1 -0
- package/dist/plugins/implementations/index.mjs +31 -0
- package/dist/plugins/implementations/multi-task-learning.d.ts +115 -0
- package/dist/plugins/implementations/multi-task-learning.d.ts.map +1 -0
- package/dist/plugins/implementations/multi-task-learning.js +369 -0
- package/dist/plugins/implementations/multi-task-learning.js.map +1 -0
- package/dist/plugins/implementations/multi-task-learning.mjs +364 -0
- package/dist/plugins/implementations/neural-architecture-search.d.ts +148 -0
- package/dist/plugins/implementations/neural-architecture-search.d.ts.map +1 -0
- package/dist/plugins/implementations/neural-architecture-search.js +379 -0
- package/dist/plugins/implementations/neural-architecture-search.js.map +1 -0
- package/dist/plugins/implementations/neural-architecture-search.mjs +374 -0
- package/dist/plugins/implementations/q-learning.d.ts +98 -0
- package/dist/plugins/implementations/q-learning.d.ts.map +1 -0
- package/dist/plugins/implementations/q-learning.js +435 -0
- package/dist/plugins/implementations/q-learning.js.map +1 -0
- package/dist/plugins/implementations/q-learning.mjs +430 -0
- package/dist/plugins/implementations/sarsa.d.ts +103 -0
- package/dist/plugins/implementations/sarsa.d.ts.map +1 -0
- package/dist/plugins/implementations/sarsa.js +347 -0
- package/dist/plugins/implementations/sarsa.js.map +1 -0
- package/dist/plugins/implementations/sarsa.mjs +342 -0
- package/dist/plugins/index.d.ts +107 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/index.js +179 -0
- package/dist/plugins/index.js.map +1 -0
- package/dist/plugins/index.mjs +168 -0
- package/dist/plugins/interface.d.ts +439 -0
- package/dist/plugins/interface.d.ts.map +1 -0
- package/dist/plugins/interface.js +12 -0
- package/dist/plugins/interface.js.map +1 -0
- package/dist/plugins/interface.mjs +10 -0
- package/dist/plugins/learning-plugin.interface.d.ts +257 -0
- package/dist/plugins/learning-plugin.interface.d.ts.map +1 -0
- package/dist/plugins/learning-plugin.interface.js +7 -0
- package/dist/plugins/learning-plugin.interface.js.map +1 -0
- package/dist/plugins/learning-plugin.interface.mjs +5 -0
- package/dist/plugins/plugin-exports.d.ts +71 -0
- package/dist/plugins/plugin-exports.d.ts.map +1 -0
- package/dist/plugins/plugin-exports.js +78 -0
- package/dist/plugins/plugin-exports.js.map +1 -0
- package/dist/plugins/plugin-exports.mjs +69 -0
- package/dist/plugins/registry.d.ts +206 -0
- package/dist/plugins/registry.d.ts.map +1 -0
- package/dist/plugins/registry.js +365 -0
- package/dist/plugins/registry.js.map +1 -0
- package/dist/plugins/registry.mjs +356 -0
- package/dist/plugins/validator.d.ts +63 -0
- package/dist/plugins/validator.d.ts.map +1 -0
- package/dist/plugins/validator.js +464 -0
- package/dist/plugins/validator.js.map +1 -0
- package/dist/plugins/validator.mjs +458 -0
- package/dist/quantization/binary-quantization.d.ts +104 -0
- package/dist/quantization/binary-quantization.d.ts.map +1 -0
- package/dist/quantization/binary-quantization.js +246 -0
- package/dist/quantization/binary-quantization.js.map +1 -0
- package/dist/quantization/binary-quantization.mjs +240 -0
- package/dist/quantization/optimized-pq.d.ts +138 -0
- package/dist/quantization/optimized-pq.d.ts.map +1 -0
- package/dist/quantization/optimized-pq.js +320 -0
- package/dist/quantization/optimized-pq.js.map +1 -0
- package/dist/quantization/optimized-pq.mjs +313 -0
- package/dist/quantization/product-quantization.d.ts +109 -0
- package/dist/quantization/product-quantization.d.ts.map +1 -0
- package/dist/quantization/product-quantization.js +287 -0
- package/dist/quantization/product-quantization.js.map +1 -0
- package/dist/quantization/product-quantization.mjs +282 -0
- package/dist/quantization/scalar-quantization.d.ts +100 -0
- package/dist/quantization/scalar-quantization.d.ts.map +1 -0
- package/dist/quantization/scalar-quantization.js +324 -0
- package/dist/quantization/scalar-quantization.js.map +1 -0
- package/dist/quantization/scalar-quantization.mjs +319 -0
- package/dist/query/index.d.ts +6 -0
- package/dist/query/index.d.ts.map +1 -0
- package/dist/query/index.js +9 -0
- package/dist/query/index.js.map +1 -0
- package/dist/query/index.mjs +4 -0
- package/dist/query/query-builder.d.ts +323 -0
- package/dist/query/query-builder.d.ts.map +1 -0
- package/dist/query/query-builder.js +524 -0
- package/dist/query/query-builder.js.map +1 -0
- package/dist/query/query-builder.mjs +519 -0
- package/dist/reasoning/context-synthesizer.d.ts +57 -0
- package/dist/reasoning/context-synthesizer.d.ts.map +1 -0
- package/dist/reasoning/context-synthesizer.js +224 -0
- package/dist/reasoning/context-synthesizer.js.map +1 -0
- package/dist/reasoning/context-synthesizer.mjs +219 -0
- package/dist/reasoning/experience-curator.d.ts +66 -0
- package/dist/reasoning/experience-curator.d.ts.map +1 -0
- package/dist/reasoning/experience-curator.js +288 -0
- package/dist/reasoning/experience-curator.js.map +1 -0
- package/dist/reasoning/experience-curator.mjs +283 -0
- package/dist/reasoning/memory-optimizer.d.ts +69 -0
- package/dist/reasoning/memory-optimizer.d.ts.map +1 -0
- package/dist/reasoning/memory-optimizer.js +331 -0
- package/dist/reasoning/memory-optimizer.js.map +1 -0
- package/dist/reasoning/memory-optimizer.mjs +326 -0
- package/dist/reasoning/pattern-matcher.d.ts +59 -0
- package/dist/reasoning/pattern-matcher.d.ts.map +1 -0
- package/dist/reasoning/pattern-matcher.js +229 -0
- package/dist/reasoning/pattern-matcher.js.map +1 -0
- package/dist/reasoning/pattern-matcher.mjs +224 -0
- package/dist/reasoningbank/adapter/agentdb-adapter.d.ts +118 -0
- package/dist/reasoningbank/adapter/agentdb-adapter.d.ts.map +1 -0
- package/dist/reasoningbank/adapter/agentdb-adapter.js +477 -0
- package/dist/reasoningbank/adapter/agentdb-adapter.js.map +1 -0
- package/dist/reasoningbank/adapter/types.d.ts +113 -0
- package/dist/reasoningbank/adapter/types.d.ts.map +1 -0
- package/dist/reasoningbank/adapter/types.js +9 -0
- package/dist/reasoningbank/adapter/types.js.map +1 -0
- package/dist/reasoningbank/cli/commands.d.ts +16 -0
- package/dist/reasoningbank/cli/commands.d.ts.map +1 -0
- package/dist/reasoningbank/cli/commands.js +272 -0
- package/dist/reasoningbank/cli/commands.js.map +1 -0
- package/dist/reasoningbank/mcp/agentdb-tools.d.ts +319 -0
- package/dist/reasoningbank/mcp/agentdb-tools.d.ts.map +1 -0
- package/dist/reasoningbank/mcp/agentdb-tools.js +301 -0
- package/dist/reasoningbank/mcp/agentdb-tools.js.map +1 -0
- package/dist/reasoningbank/migration/migrate.d.ts +25 -0
- package/dist/reasoningbank/migration/migrate.d.ts.map +1 -0
- package/dist/reasoningbank/migration/migrate.js +178 -0
- package/dist/reasoningbank/migration/migrate.js.map +1 -0
- package/dist/reasoningbank/reasoning/context-synthesizer.d.ts +37 -0
- package/dist/reasoningbank/reasoning/context-synthesizer.d.ts.map +1 -0
- package/dist/reasoningbank/reasoning/context-synthesizer.js +114 -0
- package/dist/reasoningbank/reasoning/context-synthesizer.js.map +1 -0
- package/dist/reasoningbank/reasoning/experience-curator.d.ts +39 -0
- package/dist/reasoningbank/reasoning/experience-curator.d.ts.map +1 -0
- package/dist/reasoningbank/reasoning/experience-curator.js +98 -0
- package/dist/reasoningbank/reasoning/experience-curator.js.map +1 -0
- package/dist/reasoningbank/reasoning/memory-optimizer.d.ts +44 -0
- package/dist/reasoningbank/reasoning/memory-optimizer.d.ts.map +1 -0
- package/dist/reasoningbank/reasoning/memory-optimizer.js +184 -0
- package/dist/reasoningbank/reasoning/memory-optimizer.js.map +1 -0
- package/dist/reasoningbank/reasoning/pattern-matcher.d.ts +40 -0
- package/dist/reasoningbank/reasoning/pattern-matcher.d.ts.map +1 -0
- package/dist/reasoningbank/reasoning/pattern-matcher.js +87 -0
- package/dist/reasoningbank/reasoning/pattern-matcher.js.map +1 -0
- package/dist/reasoningbank/sync/quic-sync.d.ts +77 -0
- package/dist/reasoningbank/sync/quic-sync.d.ts.map +1 -0
- package/dist/reasoningbank/sync/quic-sync.js +165 -0
- package/dist/reasoningbank/sync/quic-sync.js.map +1 -0
- package/dist/sync/conflict.d.ts +78 -0
- package/dist/sync/conflict.d.ts.map +1 -0
- package/dist/sync/conflict.js +202 -0
- package/dist/sync/conflict.js.map +1 -0
- package/dist/sync/conflict.mjs +196 -0
- package/dist/sync/coordinator.d.ts +111 -0
- package/dist/sync/coordinator.d.ts.map +1 -0
- package/dist/sync/coordinator.js +256 -0
- package/dist/sync/coordinator.js.map +1 -0
- package/dist/sync/coordinator.mjs +250 -0
- package/dist/sync/delta.d.ts +81 -0
- package/dist/sync/delta.d.ts.map +1 -0
- package/dist/sync/delta.js +245 -0
- package/dist/sync/delta.js.map +1 -0
- package/dist/sync/delta.mjs +238 -0
- package/dist/sync/index.d.ts +11 -0
- package/dist/sync/index.d.ts.map +1 -0
- package/dist/sync/index.js +22 -0
- package/dist/sync/index.js.map +1 -0
- package/dist/sync/index.mjs +9 -0
- package/dist/sync/quic-sync.d.ts +81 -0
- package/dist/sync/quic-sync.d.ts.map +1 -0
- package/dist/sync/quic-sync.js +329 -0
- package/dist/sync/quic-sync.js.map +1 -0
- package/dist/sync/quic-sync.mjs +323 -0
- package/dist/sync/types.d.ts +168 -0
- package/dist/sync/types.d.ts.map +1 -0
- package/dist/sync/types.js +8 -0
- package/dist/sync/types.js.map +1 -0
- package/dist/sync/types.mjs +6 -0
- package/dist/types/index.d.ts +117 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +6 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/index.mjs +4 -0
- package/dist/wasm-loader.d.ts +32 -0
- package/dist/wasm-loader.d.ts.map +1 -0
- package/dist/wasm-loader.js +75 -0
- package/dist/wasm-loader.js.map +1 -0
- package/dist/wasm-loader.mjs +64 -0
- package/examples/adaptive-learning.ts +284 -0
- package/examples/browser/README.md +732 -0
- package/examples/browser/adaptive-recommendations/index.html +427 -0
- package/examples/browser/collaborative-filtering/index.html +310 -0
- package/examples/browser/continual-learning/index.html +736 -0
- package/examples/browser/experience-replay/index.html +616 -0
- package/examples/browser/index.html +369 -0
- package/examples/browser/meta-learning/index.html +789 -0
- package/examples/browser/neuro-symbolic/index.html +692 -0
- package/examples/browser/pattern-learning/index.html +620 -0
- package/examples/browser/quantum-inspired/index.html +728 -0
- package/examples/browser/rag/index.html +624 -0
- package/examples/browser/swarm-intelligence/index.html +811 -0
- package/examples/browser-basic.html +170 -0
- package/examples/hnsw-example.ts +148 -0
- package/examples/node-basic.js +70 -0
- package/examples/quic-sync-example.ts +310 -0
- package/examples/quick-start.js +68 -0
- package/examples/wasm-example.ts +222 -0
- package/package.json +118 -0
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Configuration validation
|
|
4
|
+
*/
|
|
5
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
6
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.validateConfig = validateConfig;
|
|
10
|
+
exports.validatePluginName = validatePluginName;
|
|
11
|
+
exports.validateVersion = validateVersion;
|
|
12
|
+
exports.validateRewardFunction = validateRewardFunction;
|
|
13
|
+
const ajv_1 = __importDefault(require("ajv"));
|
|
14
|
+
const ajv = new ajv_1.default({ allErrors: true });
|
|
15
|
+
// JSON Schema for plugin configuration
|
|
16
|
+
const pluginConfigSchema = {
|
|
17
|
+
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
18
|
+
title: 'Learning Plugin Configuration',
|
|
19
|
+
type: 'object',
|
|
20
|
+
required: ['name', 'version', 'description', 'algorithm', 'storage', 'training'],
|
|
21
|
+
properties: {
|
|
22
|
+
name: {
|
|
23
|
+
type: 'string',
|
|
24
|
+
pattern: '^[a-z0-9-]+$',
|
|
25
|
+
minLength: 3,
|
|
26
|
+
maxLength: 50,
|
|
27
|
+
},
|
|
28
|
+
version: {
|
|
29
|
+
type: 'string',
|
|
30
|
+
pattern: '^\\d+\\.\\d+\\.\\d+$',
|
|
31
|
+
},
|
|
32
|
+
author: {
|
|
33
|
+
type: 'string',
|
|
34
|
+
},
|
|
35
|
+
description: {
|
|
36
|
+
type: 'string',
|
|
37
|
+
minLength: 10,
|
|
38
|
+
maxLength: 500,
|
|
39
|
+
},
|
|
40
|
+
algorithm: {
|
|
41
|
+
type: 'object',
|
|
42
|
+
required: ['type', 'base'],
|
|
43
|
+
properties: {
|
|
44
|
+
type: {
|
|
45
|
+
type: 'string',
|
|
46
|
+
},
|
|
47
|
+
base: {
|
|
48
|
+
type: 'string',
|
|
49
|
+
enum: ['decision_transformer', 'q_learning', 'sarsa', 'actor_critic', 'custom'],
|
|
50
|
+
},
|
|
51
|
+
learning_rate: {
|
|
52
|
+
type: 'number',
|
|
53
|
+
minimum: 0,
|
|
54
|
+
maximum: 1,
|
|
55
|
+
},
|
|
56
|
+
discount_factor: {
|
|
57
|
+
type: 'number',
|
|
58
|
+
minimum: 0,
|
|
59
|
+
maximum: 1,
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
reward: {
|
|
64
|
+
type: 'object',
|
|
65
|
+
required: ['type'],
|
|
66
|
+
properties: {
|
|
67
|
+
type: {
|
|
68
|
+
type: 'string',
|
|
69
|
+
// SECURITY FIX: Removed 'custom' to prevent code injection
|
|
70
|
+
enum: ['success_based', 'time_aware', 'token_aware'],
|
|
71
|
+
},
|
|
72
|
+
// SECURITY: function field removed
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
storage: {
|
|
76
|
+
type: 'object',
|
|
77
|
+
required: ['backend', 'path'],
|
|
78
|
+
properties: {
|
|
79
|
+
backend: {
|
|
80
|
+
type: 'string',
|
|
81
|
+
enum: ['agentdb'],
|
|
82
|
+
},
|
|
83
|
+
path: {
|
|
84
|
+
type: 'string',
|
|
85
|
+
},
|
|
86
|
+
hnsw: {
|
|
87
|
+
type: 'object',
|
|
88
|
+
properties: {
|
|
89
|
+
enabled: { type: 'boolean' },
|
|
90
|
+
M: { type: 'number', minimum: 2, maximum: 100 },
|
|
91
|
+
efConstruction: { type: 'number', minimum: 10, maximum: 1000 },
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
quantization: {
|
|
95
|
+
type: 'object',
|
|
96
|
+
properties: {
|
|
97
|
+
enabled: { type: 'boolean' },
|
|
98
|
+
bits: { type: 'number', enum: [8, 16] },
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
training: {
|
|
104
|
+
type: 'object',
|
|
105
|
+
required: ['min_experiences'],
|
|
106
|
+
properties: {
|
|
107
|
+
batch_size: {
|
|
108
|
+
type: 'number',
|
|
109
|
+
minimum: 1,
|
|
110
|
+
maximum: 1024,
|
|
111
|
+
},
|
|
112
|
+
epochs: {
|
|
113
|
+
type: 'number',
|
|
114
|
+
minimum: 1,
|
|
115
|
+
maximum: 1000,
|
|
116
|
+
},
|
|
117
|
+
min_experiences: {
|
|
118
|
+
type: 'number',
|
|
119
|
+
minimum: 10,
|
|
120
|
+
},
|
|
121
|
+
train_every: {
|
|
122
|
+
type: 'number',
|
|
123
|
+
minimum: 1,
|
|
124
|
+
},
|
|
125
|
+
validation_split: {
|
|
126
|
+
type: 'number',
|
|
127
|
+
minimum: 0,
|
|
128
|
+
maximum: 1,
|
|
129
|
+
},
|
|
130
|
+
online: {
|
|
131
|
+
type: 'boolean',
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
monitoring: {
|
|
136
|
+
type: 'object',
|
|
137
|
+
properties: {
|
|
138
|
+
track_metrics: {
|
|
139
|
+
type: 'array',
|
|
140
|
+
items: { type: 'string' },
|
|
141
|
+
},
|
|
142
|
+
log_interval: {
|
|
143
|
+
type: 'number',
|
|
144
|
+
minimum: 1,
|
|
145
|
+
},
|
|
146
|
+
save_checkpoints: {
|
|
147
|
+
type: 'boolean',
|
|
148
|
+
},
|
|
149
|
+
checkpoint_interval: {
|
|
150
|
+
type: 'number',
|
|
151
|
+
minimum: 1,
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
};
|
|
157
|
+
const validate = ajv.compile(pluginConfigSchema);
|
|
158
|
+
function validateConfig(config) {
|
|
159
|
+
const valid = validate(config);
|
|
160
|
+
if (valid) {
|
|
161
|
+
// Additional custom validation
|
|
162
|
+
const customErrors = performCustomValidation(config);
|
|
163
|
+
if (customErrors.length > 0) {
|
|
164
|
+
return {
|
|
165
|
+
valid: false,
|
|
166
|
+
errors: customErrors,
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
return {
|
|
170
|
+
valid: true,
|
|
171
|
+
errors: [],
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
const errors = validate.errors?.map((err) => {
|
|
175
|
+
return `${err.instancePath} ${err.message}`;
|
|
176
|
+
}) || ['Unknown validation error'];
|
|
177
|
+
return {
|
|
178
|
+
valid: false,
|
|
179
|
+
errors,
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
function performCustomValidation(config) {
|
|
183
|
+
const errors = [];
|
|
184
|
+
// SECURITY FIX: Custom reward functions completely removed from type system
|
|
185
|
+
// Type system now prevents 'custom' at compile time
|
|
186
|
+
// This check is kept for runtime validation of external JSON configs
|
|
187
|
+
// Validate algorithm-specific configuration
|
|
188
|
+
if (config.algorithm.base === 'q_learning') {
|
|
189
|
+
if (!config.algorithm.learning_rate) {
|
|
190
|
+
errors.push('Q-Learning requires learning_rate');
|
|
191
|
+
}
|
|
192
|
+
if (!config.algorithm.discount_factor) {
|
|
193
|
+
errors.push('Q-Learning requires discount_factor');
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
if (config.algorithm.base === 'decision_transformer') {
|
|
197
|
+
if (!config.algorithm.state_dim) {
|
|
198
|
+
errors.push('Decision Transformer requires state_dim');
|
|
199
|
+
}
|
|
200
|
+
if (!config.algorithm.action_dim) {
|
|
201
|
+
errors.push('Decision Transformer requires action_dim');
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
// Validate training configuration
|
|
205
|
+
if (!config.training.online && !config.training.batch_size) {
|
|
206
|
+
errors.push('Offline training requires batch_size');
|
|
207
|
+
}
|
|
208
|
+
// Validate HNSW configuration
|
|
209
|
+
if (config.storage.hnsw?.enabled) {
|
|
210
|
+
if (config.storage.hnsw.M && (config.storage.hnsw.M < 2 || config.storage.hnsw.M > 100)) {
|
|
211
|
+
errors.push('HNSW M parameter must be between 2 and 100');
|
|
212
|
+
}
|
|
213
|
+
if (config.storage.hnsw.efConstruction && config.storage.hnsw.efConstruction < 10) {
|
|
214
|
+
errors.push('HNSW efConstruction must be at least 10');
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
return errors;
|
|
218
|
+
}
|
|
219
|
+
function validatePluginName(name) {
|
|
220
|
+
return /^[a-z0-9-]+$/.test(name) && name.length >= 3 && name.length <= 50;
|
|
221
|
+
}
|
|
222
|
+
function validateVersion(version) {
|
|
223
|
+
return /^\d+\.\d+\.\d+$/.test(version);
|
|
224
|
+
}
|
|
225
|
+
function validateRewardFunction(func) {
|
|
226
|
+
try {
|
|
227
|
+
new Function('return ' + func);
|
|
228
|
+
return true;
|
|
229
|
+
}
|
|
230
|
+
catch {
|
|
231
|
+
return false;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
//# sourceMappingURL=validator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validator.js","sourceRoot":"","sources":["../../../src/cli/wizard/validator.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;AA6JH,wCA2BC;AA8CD,gDAEC;AAED,0CAEC;AAED,wDAOC;AAnPD,8CAAsB;AAGtB,MAAM,GAAG,GAAG,IAAI,aAAG,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;AAEzC,uCAAuC;AACvC,MAAM,kBAAkB,GAAG;IACzB,OAAO,EAAE,yCAAyC;IAClD,KAAK,EAAE,+BAA+B;IACtC,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,CAAC;IAChF,UAAU,EAAE;QACV,IAAI,EAAE;YACJ,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,cAAc;YACvB,SAAS,EAAE,CAAC;YACZ,SAAS,EAAE,EAAE;SACd;QACD,OAAO,EAAE;YACP,IAAI,EAAE,QAAQ;YACd,O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AAyC,CAAC,CAAC;QACzD,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAgB,kBAAkB,CAAC,IAAY;IAC7C,OAAO,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC;AAC5E,CAAC;AAED,SAAgB,eAAe,CAAC,OAAe;IAC7C,OAAO,iBAAiB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACzC,CAAC;AAED,SAAgB,sBAAsB,CAAC,IAAY;IACjD,IAAI,CAAC;QACH,IAAI,QAAQ,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC;QAC/B,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration validation
|
|
3
|
+
*/
|
|
4
|
+
import Ajv from 'ajv';
|
|
5
|
+
const ajv = new Ajv({ allErrors: true });
|
|
6
|
+
// JSON Schema for plugin configuration
|
|
7
|
+
const pluginConfigSchema = {
|
|
8
|
+
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
9
|
+
title: 'Learning Plugin Configuration',
|
|
10
|
+
type: 'object',
|
|
11
|
+
required: ['name', 'version', 'description', 'algorithm', 'storage', 'training'],
|
|
12
|
+
properties: {
|
|
13
|
+
name: {
|
|
14
|
+
type: 'string',
|
|
15
|
+
pattern: '^[a-z0-9-]+$',
|
|
16
|
+
minLength: 3,
|
|
17
|
+
maxLength: 50,
|
|
18
|
+
},
|
|
19
|
+
version: {
|
|
20
|
+
type: 'string',
|
|
21
|
+
pattern: '^\\d+\\.\\d+\\.\\d+$',
|
|
22
|
+
},
|
|
23
|
+
author: {
|
|
24
|
+
type: 'string',
|
|
25
|
+
},
|
|
26
|
+
description: {
|
|
27
|
+
type: 'string',
|
|
28
|
+
minLength: 10,
|
|
29
|
+
maxLength: 500,
|
|
30
|
+
},
|
|
31
|
+
algorithm: {
|
|
32
|
+
type: 'object',
|
|
33
|
+
required: ['type', 'base'],
|
|
34
|
+
properties: {
|
|
35
|
+
type: {
|
|
36
|
+
type: 'string',
|
|
37
|
+
},
|
|
38
|
+
base: {
|
|
39
|
+
type: 'string',
|
|
40
|
+
enum: ['decision_transformer', 'q_learning', 'sarsa', 'actor_critic', 'custom'],
|
|
41
|
+
},
|
|
42
|
+
learning_rate: {
|
|
43
|
+
type: 'number',
|
|
44
|
+
minimum: 0,
|
|
45
|
+
maximum: 1,
|
|
46
|
+
},
|
|
47
|
+
discount_factor: {
|
|
48
|
+
type: 'number',
|
|
49
|
+
minimum: 0,
|
|
50
|
+
maximum: 1,
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
reward: {
|
|
55
|
+
type: 'object',
|
|
56
|
+
required: ['type'],
|
|
57
|
+
properties: {
|
|
58
|
+
type: {
|
|
59
|
+
type: 'string',
|
|
60
|
+
// SECURITY FIX: Removed 'custom' to prevent code injection
|
|
61
|
+
enum: ['success_based', 'time_aware', 'token_aware'],
|
|
62
|
+
},
|
|
63
|
+
// SECURITY: function field removed
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
storage: {
|
|
67
|
+
type: 'object',
|
|
68
|
+
required: ['backend', 'path'],
|
|
69
|
+
properties: {
|
|
70
|
+
backend: {
|
|
71
|
+
type: 'string',
|
|
72
|
+
enum: ['agentdb'],
|
|
73
|
+
},
|
|
74
|
+
path: {
|
|
75
|
+
type: 'string',
|
|
76
|
+
},
|
|
77
|
+
hnsw: {
|
|
78
|
+
type: 'object',
|
|
79
|
+
properties: {
|
|
80
|
+
enabled: { type: 'boolean' },
|
|
81
|
+
M: { type: 'number', minimum: 2, maximum: 100 },
|
|
82
|
+
efConstruction: { type: 'number', minimum: 10, maximum: 1000 },
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
quantization: {
|
|
86
|
+
type: 'object',
|
|
87
|
+
properties: {
|
|
88
|
+
enabled: { type: 'boolean' },
|
|
89
|
+
bits: { type: 'number', enum: [8, 16] },
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
training: {
|
|
95
|
+
type: 'object',
|
|
96
|
+
required: ['min_experiences'],
|
|
97
|
+
properties: {
|
|
98
|
+
batch_size: {
|
|
99
|
+
type: 'number',
|
|
100
|
+
minimum: 1,
|
|
101
|
+
maximum: 1024,
|
|
102
|
+
},
|
|
103
|
+
epochs: {
|
|
104
|
+
type: 'number',
|
|
105
|
+
minimum: 1,
|
|
106
|
+
maximum: 1000,
|
|
107
|
+
},
|
|
108
|
+
min_experiences: {
|
|
109
|
+
type: 'number',
|
|
110
|
+
minimum: 10,
|
|
111
|
+
},
|
|
112
|
+
train_every: {
|
|
113
|
+
type: 'number',
|
|
114
|
+
minimum: 1,
|
|
115
|
+
},
|
|
116
|
+
validation_split: {
|
|
117
|
+
type: 'number',
|
|
118
|
+
minimum: 0,
|
|
119
|
+
maximum: 1,
|
|
120
|
+
},
|
|
121
|
+
online: {
|
|
122
|
+
type: 'boolean',
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
monitoring: {
|
|
127
|
+
type: 'object',
|
|
128
|
+
properties: {
|
|
129
|
+
track_metrics: {
|
|
130
|
+
type: 'array',
|
|
131
|
+
items: { type: 'string' },
|
|
132
|
+
},
|
|
133
|
+
log_interval: {
|
|
134
|
+
type: 'number',
|
|
135
|
+
minimum: 1,
|
|
136
|
+
},
|
|
137
|
+
save_checkpoints: {
|
|
138
|
+
type: 'boolean',
|
|
139
|
+
},
|
|
140
|
+
checkpoint_interval: {
|
|
141
|
+
type: 'number',
|
|
142
|
+
minimum: 1,
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
};
|
|
148
|
+
const validate = ajv.compile(pluginConfigSchema);
|
|
149
|
+
export function validateConfig(config) {
|
|
150
|
+
const valid = validate(config);
|
|
151
|
+
if (valid) {
|
|
152
|
+
// Additional custom validation
|
|
153
|
+
const customErrors = performCustomValidation(config);
|
|
154
|
+
if (customErrors.length > 0) {
|
|
155
|
+
return {
|
|
156
|
+
valid: false,
|
|
157
|
+
errors: customErrors,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
return {
|
|
161
|
+
valid: true,
|
|
162
|
+
errors: [],
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
const errors = validate.errors?.map((err) => {
|
|
166
|
+
return `${err.instancePath} ${err.message}`;
|
|
167
|
+
}) || ['Unknown validation error'];
|
|
168
|
+
return {
|
|
169
|
+
valid: false,
|
|
170
|
+
errors,
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
function performCustomValidation(config) {
|
|
174
|
+
const errors = [];
|
|
175
|
+
// SECURITY FIX: Custom reward functions completely removed from type system
|
|
176
|
+
// Type system now prevents 'custom' at compile time
|
|
177
|
+
// This check is kept for runtime validation of external JSON configs
|
|
178
|
+
// Validate algorithm-specific configuration
|
|
179
|
+
if (config.algorithm.base === 'q_learning') {
|
|
180
|
+
if (!config.algorithm.learning_rate) {
|
|
181
|
+
errors.push('Q-Learning requires learning_rate');
|
|
182
|
+
}
|
|
183
|
+
if (!config.algorithm.discount_factor) {
|
|
184
|
+
errors.push('Q-Learning requires discount_factor');
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
if (config.algorithm.base === 'decision_transformer') {
|
|
188
|
+
if (!config.algorithm.state_dim) {
|
|
189
|
+
errors.push('Decision Transformer requires state_dim');
|
|
190
|
+
}
|
|
191
|
+
if (!config.algorithm.action_dim) {
|
|
192
|
+
errors.push('Decision Transformer requires action_dim');
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
// Validate training configuration
|
|
196
|
+
if (!config.training.online && !config.training.batch_size) {
|
|
197
|
+
errors.push('Offline training requires batch_size');
|
|
198
|
+
}
|
|
199
|
+
// Validate HNSW configuration
|
|
200
|
+
if (config.storage.hnsw?.enabled) {
|
|
201
|
+
if (config.storage.hnsw.M && (config.storage.hnsw.M < 2 || config.storage.hnsw.M > 100)) {
|
|
202
|
+
errors.push('HNSW M parameter must be between 2 and 100');
|
|
203
|
+
}
|
|
204
|
+
if (config.storage.hnsw.efConstruction && config.storage.hnsw.efConstruction < 10) {
|
|
205
|
+
errors.push('HNSW efConstruction must be at least 10');
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return errors;
|
|
209
|
+
}
|
|
210
|
+
export function validatePluginName(name) {
|
|
211
|
+
return /^[a-z0-9-]+$/.test(name) && name.length >= 3 && name.length <= 50;
|
|
212
|
+
}
|
|
213
|
+
export function validateVersion(version) {
|
|
214
|
+
return /^\d+\.\d+\.\d+$/.test(version);
|
|
215
|
+
}
|
|
216
|
+
export function validateRewardFunction(func) {
|
|
217
|
+
try {
|
|
218
|
+
new Function('return ' + func);
|
|
219
|
+
return true;
|
|
220
|
+
}
|
|
221
|
+
catch {
|
|
222
|
+
return false;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Backend interface for vector database implementations
|
|
3
|
+
* Supports both native (better-sqlite3) and WASM (sql.js) backends
|
|
4
|
+
*/
|
|
5
|
+
import { Vector, SearchResult, SimilarityMetric, DatabaseConfig } from '../types';
|
|
6
|
+
/**
|
|
7
|
+
* Abstract interface for vector database backends
|
|
8
|
+
*/
|
|
9
|
+
export interface VectorBackend {
|
|
10
|
+
/**
|
|
11
|
+
* Initialize the database with given configuration
|
|
12
|
+
*/
|
|
13
|
+
initialize(config: DatabaseConfig): void;
|
|
14
|
+
/**
|
|
15
|
+
* Insert a single vector
|
|
16
|
+
* @returns The ID of the inserted vector
|
|
17
|
+
*/
|
|
18
|
+
insert(vector: Vector): string;
|
|
19
|
+
/**
|
|
20
|
+
* Insert multiple vectors in a transaction
|
|
21
|
+
* @returns Array of IDs of inserted vectors
|
|
22
|
+
*/
|
|
23
|
+
insertBatch(vectors: Vector[]): string[];
|
|
24
|
+
/**
|
|
25
|
+
* Search for k-nearest neighbors
|
|
26
|
+
*/
|
|
27
|
+
search(queryEmbedding: number[], k: number, metric: SimilarityMetric, threshold: number): SearchResult[];
|
|
28
|
+
/**
|
|
29
|
+
* Get vector by ID
|
|
30
|
+
*/
|
|
31
|
+
get(id: string): Vector | null;
|
|
32
|
+
/**
|
|
33
|
+
* Delete vector by ID
|
|
34
|
+
* @returns true if deleted, false if not found
|
|
35
|
+
*/
|
|
36
|
+
delete(id: string): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Get database statistics
|
|
39
|
+
*/
|
|
40
|
+
stats(): {
|
|
41
|
+
count: number;
|
|
42
|
+
size: number;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Close database connection and cleanup resources
|
|
46
|
+
*/
|
|
47
|
+
close(): void;
|
|
48
|
+
/**
|
|
49
|
+
* Export database to binary format (for WASM persistence)
|
|
50
|
+
*/
|
|
51
|
+
export?(): Uint8Array;
|
|
52
|
+
/**
|
|
53
|
+
* Import database from binary format (for WASM persistence)
|
|
54
|
+
*/
|
|
55
|
+
import?(data: Uint8Array): void;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Backend type enum
|
|
59
|
+
*/
|
|
60
|
+
export declare enum BackendType {
|
|
61
|
+
NATIVE = "native",
|
|
62
|
+
WASM = "wasm"
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Extended database configuration with backend selection
|
|
66
|
+
*/
|
|
67
|
+
export interface ExtendedDatabaseConfig extends DatabaseConfig {
|
|
68
|
+
backend?: BackendType;
|
|
69
|
+
wasmBinary?: Uint8Array;
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=backend-interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":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"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Backend interface for vector database implementations
|
|
4
|
+
* Supports both native (better-sqlite3) and WASM (sql.js) backends
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.BackendType = void 0;
|
|
8
|
+
/**
|
|
9
|
+
* Backend type enum
|
|
10
|
+
*/
|
|
11
|
+
var BackendType;
|
|
12
|
+
(function (BackendType) {
|
|
13
|
+
BackendType["NATIVE"] = "native";
|
|
14
|
+
BackendType["WASM"] = "wasm";
|
|
15
|
+
})(BackendType || (exports.BackendType = BackendType = {}));
|
|
16
|
+
//# sourceMappingURL=backend-interface.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"backend-interface.js","sourceRoot":"","sources":["../../src/core/backend-interface.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAmEH;;GAEG;AACH,IAAY,WAGX;AAHD,WAAY,WAAW;IACrB,gCAAiB,CAAA;IACjB,4BAAa,CAAA;AACf,CAAC,EAHW,WAAW,2BAAX,WAAW,QAGtB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Backend interface for vector database implementations
|
|
3
|
+
* Supports both native (better-sqlite3) and WASM (sql.js) backends
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Backend type enum
|
|
7
|
+
*/
|
|
8
|
+
export var BackendType;
|
|
9
|
+
(function (BackendType) {
|
|
10
|
+
BackendType["NATIVE"] = "native";
|
|
11
|
+
BackendType["WASM"] = "wasm";
|
|
12
|
+
})(BackendType || (BackendType = {}));
|