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,527 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin code generator
|
|
3
|
+
* Generates complete plugin structure from configuration
|
|
4
|
+
*/
|
|
5
|
+
import fs from 'fs/promises';
|
|
6
|
+
import path from 'path';
|
|
7
|
+
import chalk from 'chalk';
|
|
8
|
+
import YAML from 'yaml';
|
|
9
|
+
import { getTemplateConfig } from './templates.mjs';
|
|
10
|
+
export async function generatePlugin(config, options = {}) {
|
|
11
|
+
let pluginConfig;
|
|
12
|
+
// Handle quick template creation
|
|
13
|
+
if ('template' in config && 'useDefaults' in config) {
|
|
14
|
+
const templateConfig = await getTemplateConfig(config.template);
|
|
15
|
+
const template = await import('./templates.js').then(m => m.getTemplate(config.template));
|
|
16
|
+
pluginConfig = {
|
|
17
|
+
...templateConfig,
|
|
18
|
+
name: config.name,
|
|
19
|
+
description: template ? (await template).description : 'AI learning plugin',
|
|
20
|
+
version: '1.0.0',
|
|
21
|
+
author: 'Unknown',
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
pluginConfig = config;
|
|
26
|
+
}
|
|
27
|
+
// SECURITY FIXES: Enhanced path validation
|
|
28
|
+
const pluginName = pluginConfig.name;
|
|
29
|
+
// 1. Validate format (already enforced by schema, but double-check)
|
|
30
|
+
if (!/^[a-z0-9-]+$/.test(pluginName)) {
|
|
31
|
+
throw new Error('Invalid plugin name format. Use only lowercase letters, numbers, and hyphens.');
|
|
32
|
+
}
|
|
33
|
+
// 2. Validate length
|
|
34
|
+
if (pluginName.length < 3 || pluginName.length > 50) {
|
|
35
|
+
throw new Error('Plugin name must be between 3 and 50 characters');
|
|
36
|
+
}
|
|
37
|
+
// 3. Check for reserved OS names
|
|
38
|
+
const RESERVED_NAMES = [
|
|
39
|
+
'con', 'prn', 'aux', 'nul', 'com1', 'com2', 'com3', 'com4', 'com5',
|
|
40
|
+
'com6', 'com7', 'com8', 'com9', 'lpt1', 'lpt2', 'lpt3', 'lpt4',
|
|
41
|
+
'lpt5', 'lpt6', 'lpt7', 'lpt8', 'lpt9', 'clock$'
|
|
42
|
+
];
|
|
43
|
+
if (RESERVED_NAMES.includes(pluginName.toLowerCase())) {
|
|
44
|
+
throw new Error(`Plugin name '${pluginName}' is reserved by the operating system`);
|
|
45
|
+
}
|
|
46
|
+
// 4. Construct paths safely
|
|
47
|
+
const pluginsBaseDir = path.resolve(process.cwd(), 'plugins');
|
|
48
|
+
const pluginDir = path.join(pluginsBaseDir, pluginName);
|
|
49
|
+
// 5. Verify resolved path is within plugins directory (prevent traversal via symlinks)
|
|
50
|
+
const resolvedPluginDir = path.resolve(pluginDir);
|
|
51
|
+
if (!resolvedPluginDir.startsWith(pluginsBaseDir + path.sep) && resolvedPluginDir !== pluginsBaseDir) {
|
|
52
|
+
throw new Error('Invalid plugin directory path (security violation)');
|
|
53
|
+
}
|
|
54
|
+
// 6. Check if path exists and is not a symlink
|
|
55
|
+
try {
|
|
56
|
+
const stats = await fs.lstat(pluginDir);
|
|
57
|
+
if (stats.isSymbolicLink()) {
|
|
58
|
+
throw new Error('Plugin directory cannot be a symlink (security violation)');
|
|
59
|
+
}
|
|
60
|
+
// Directory exists and is not a symlink - check if we should overwrite
|
|
61
|
+
if (!options.force) {
|
|
62
|
+
throw new Error(`Plugin directory already exists: ${pluginDir}. Use --force to overwrite.`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
catch (err) {
|
|
66
|
+
// ENOENT is expected (directory doesn't exist yet)
|
|
67
|
+
if (err.code !== 'ENOENT') {
|
|
68
|
+
throw err;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
try {
|
|
72
|
+
// Create directory structure
|
|
73
|
+
await createDirectoryStructure(pluginDir);
|
|
74
|
+
if (options.configOnly) {
|
|
75
|
+
// Save configuration only
|
|
76
|
+
await saveConfiguration(pluginDir, pluginConfig);
|
|
77
|
+
console.log(chalk.green(`✓ Configuration saved to ${pluginDir}/plugin.yaml`));
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
// Generate all files
|
|
81
|
+
await Promise.all([
|
|
82
|
+
saveConfiguration(pluginDir, pluginConfig),
|
|
83
|
+
generateIndexFile(pluginDir, pluginConfig),
|
|
84
|
+
generateAgentFile(pluginDir, pluginConfig),
|
|
85
|
+
generateRewardFile(pluginDir, pluginConfig),
|
|
86
|
+
generatePolicyFile(pluginDir, pluginConfig),
|
|
87
|
+
generateTestFile(pluginDir, pluginConfig),
|
|
88
|
+
generateReadme(pluginDir, pluginConfig),
|
|
89
|
+
generatePackageJson(pluginDir, pluginConfig),
|
|
90
|
+
generateTsConfig(pluginDir),
|
|
91
|
+
]);
|
|
92
|
+
console.log(chalk.green('✓ Created plugin structure at'), pluginDir);
|
|
93
|
+
console.log(chalk.green('✓ Generated plugin.yaml'));
|
|
94
|
+
console.log(chalk.green('✓ Generated src/index.ts'));
|
|
95
|
+
console.log(chalk.green('✓ Generated src/agent.ts'));
|
|
96
|
+
console.log(chalk.green('✓ Generated src/reward.ts'));
|
|
97
|
+
console.log(chalk.green('✓ Generated src/policy.ts'));
|
|
98
|
+
console.log(chalk.green('✓ Generated tests/plugin.test.ts'));
|
|
99
|
+
console.log(chalk.green('✓ Generated README.md'));
|
|
100
|
+
console.log(chalk.green('✓ Generated package.json'));
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
console.error(chalk.red('Error generating plugin:'), error);
|
|
104
|
+
throw error;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
async function createDirectoryStructure(pluginDir) {
|
|
108
|
+
await fs.mkdir(path.join(pluginDir, 'src'), { recursive: true });
|
|
109
|
+
await fs.mkdir(path.join(pluginDir, 'tests'), { recursive: true });
|
|
110
|
+
}
|
|
111
|
+
async function saveConfiguration(pluginDir, config) {
|
|
112
|
+
const yamlStr = YAML.stringify(config);
|
|
113
|
+
await fs.writeFile(path.join(pluginDir, 'plugin.yaml'), yamlStr, 'utf-8');
|
|
114
|
+
}
|
|
115
|
+
async function generateIndexFile(pluginDir, config) {
|
|
116
|
+
const content = `/**
|
|
117
|
+
* ${config.name}
|
|
118
|
+
* ${config.description}
|
|
119
|
+
*
|
|
120
|
+
* Generated by SQLite Vector Learning Plugin CLI
|
|
121
|
+
*/
|
|
122
|
+
|
|
123
|
+
import type { LearningPlugin, PluginConfig, Experience, Vector, Action } from 'agentdb/plugins';
|
|
124
|
+
import { ${getAgentClassName(config)} } from './agent.mjs';
|
|
125
|
+
|
|
126
|
+
export class ${getPluginClassName(config)} implements LearningPlugin {
|
|
127
|
+
name = '${config.name}';
|
|
128
|
+
version = '${config.version}';
|
|
129
|
+
config: PluginConfig;
|
|
130
|
+
|
|
131
|
+
private agent: ${getAgentClassName(config)};
|
|
132
|
+
|
|
133
|
+
async initialize(config: PluginConfig): Promise<void> {
|
|
134
|
+
this.config = config;
|
|
135
|
+
this.agent = new ${getAgentClassName(config)}(config);
|
|
136
|
+
await this.agent.initialize();
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
async destroy(): Promise<void> {
|
|
140
|
+
await this.agent.destroy();
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
async storeExperience(experience: Experience): Promise<void> {
|
|
144
|
+
await this.agent.storeExperience(experience);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
async storeBatch(experiences: Experience[]): Promise<void> {
|
|
148
|
+
await this.agent.storeBatch(experiences);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
async retrieveSimilar(state: Vector, k: number): Promise<Experience[]> {
|
|
152
|
+
return await this.agent.retrieveSimilar(state, k);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
async selectAction(state: Vector, context?: any): Promise<Action> {
|
|
156
|
+
return await this.agent.selectAction(state, context);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
async train(options?: any): Promise<any> {
|
|
160
|
+
return await this.agent.train(options);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
async getMetrics(): Promise<any> {
|
|
164
|
+
return await this.agent.getMetrics();
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
getConfig(): PluginConfig {
|
|
168
|
+
return this.config;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
async save(path: string): Promise<void> {
|
|
172
|
+
await this.agent.save(path);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
async load(path: string): Promise<void> {
|
|
176
|
+
await this.agent.load(path);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// Export plugin factory
|
|
181
|
+
export default function createPlugin(config: PluginConfig): LearningPlugin {
|
|
182
|
+
return new ${getPluginClassName(config)}();
|
|
183
|
+
}
|
|
184
|
+
`;
|
|
185
|
+
await fs.writeFile(path.join(pluginDir, 'src', 'index.ts'), content, 'utf-8');
|
|
186
|
+
}
|
|
187
|
+
async function generateAgentFile(pluginDir, config) {
|
|
188
|
+
const algorithmImpl = generateAlgorithmImplementation(config);
|
|
189
|
+
const content = `/**
|
|
190
|
+
* Learning agent implementation for ${config.name}
|
|
191
|
+
*/
|
|
192
|
+
|
|
193
|
+
import type { PluginConfig, Experience, Vector, Action } from 'agentdb/plugins';
|
|
194
|
+
import { SQLiteVectorDB } from 'agentdb';
|
|
195
|
+
import { RewardFunction } from './reward.mjs';
|
|
196
|
+
import { PolicyFunction } from './policy.mjs';
|
|
197
|
+
|
|
198
|
+
export class ${getAgentClassName(config)} {
|
|
199
|
+
private vectorDB: SQLiteVectorDB;
|
|
200
|
+
private rewardFn: RewardFunction;
|
|
201
|
+
private policy: PolicyFunction;
|
|
202
|
+
private metrics: Map<string, number[]>;
|
|
203
|
+
|
|
204
|
+
${algorithmImpl.fields}
|
|
205
|
+
|
|
206
|
+
constructor(private config: PluginConfig) {
|
|
207
|
+
this.metrics = new Map();
|
|
208
|
+
this.rewardFn = new RewardFunction(config.reward);
|
|
209
|
+
this.policy = new PolicyFunction(config.algorithm);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
async initialize(): Promise<void> {
|
|
213
|
+
// Initialize vector database
|
|
214
|
+
this.vectorDB = new SQLiteVectorDB({
|
|
215
|
+
path: this.config.storage.path,
|
|
216
|
+
hnsw: this.config.storage.hnsw,
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
${algorithmImpl.initialization}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
async destroy(): Promise<void> {
|
|
223
|
+
// Cleanup resources
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
async storeExperience(experience: Experience): Promise<void> {
|
|
227
|
+
// Store in vector database
|
|
228
|
+
await this.vectorDB.insert({
|
|
229
|
+
embedding: experience.state,
|
|
230
|
+
metadata: {
|
|
231
|
+
action: experience.action,
|
|
232
|
+
reward: experience.reward,
|
|
233
|
+
nextState: experience.nextState,
|
|
234
|
+
done: experience.done,
|
|
235
|
+
timestamp: Date.now(),
|
|
236
|
+
},
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
${algorithmImpl.onStoreExperience}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
async storeBatch(experiences: Experience[]): Promise<void> {
|
|
243
|
+
for (const exp of experiences) {
|
|
244
|
+
await this.storeExperience(exp);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
async retrieveSimilar(state: Vector, k: number): Promise<Experience[]> {
|
|
249
|
+
const results = await this.vectorDB.search(state, k);
|
|
250
|
+
return results.map((r) => ({
|
|
251
|
+
state: r.embedding,
|
|
252
|
+
action: r.metadata.action,
|
|
253
|
+
reward: r.metadata.reward,
|
|
254
|
+
nextState: r.metadata.nextState,
|
|
255
|
+
done: r.metadata.done,
|
|
256
|
+
}));
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
async selectAction(state: Vector, context?: any): Promise<Action> {
|
|
260
|
+
return await this.policy.selectAction(state, context);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
async train(options?: any): Promise<any> {
|
|
264
|
+
${algorithmImpl.training}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
async getMetrics(): Promise<any> {
|
|
268
|
+
const result: any = {};
|
|
269
|
+
for (const [key, values] of this.metrics) {
|
|
270
|
+
result[key] = {
|
|
271
|
+
current: values[values.length - 1] || 0,
|
|
272
|
+
average: values.reduce((a, b) => a + b, 0) / values.length || 0,
|
|
273
|
+
min: Math.min(...values) || 0,
|
|
274
|
+
max: Math.max(...values) || 0,
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
return result;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
async save(path: string): Promise<void> {
|
|
281
|
+
// Save model state
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
async load(path: string): Promise<void> {
|
|
285
|
+
// Load model state
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
private trackMetric(name: string, value: number): void {
|
|
289
|
+
if (!this.metrics.has(name)) {
|
|
290
|
+
this.metrics.set(name, []);
|
|
291
|
+
}
|
|
292
|
+
this.metrics.get(name)!.push(value);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
`;
|
|
296
|
+
await fs.writeFile(path.join(pluginDir, 'src', 'agent.ts'), content, 'utf-8');
|
|
297
|
+
}
|
|
298
|
+
async function generateRewardFile(pluginDir, config) {
|
|
299
|
+
// SECURITY FIX: Never use custom functions - always use predefined safe functions
|
|
300
|
+
const rewardImpl = generateDefaultReward(config.reward.type);
|
|
301
|
+
const content = `/**
|
|
302
|
+
* Reward function for ${config.name}
|
|
303
|
+
*/
|
|
304
|
+
|
|
305
|
+
export class RewardFunction {
|
|
306
|
+
constructor(private config: any) {}
|
|
307
|
+
|
|
308
|
+
compute(outcome: any, context: any): number {
|
|
309
|
+
${rewardImpl}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
`;
|
|
313
|
+
await fs.writeFile(path.join(pluginDir, 'src', 'reward.ts'), content, 'utf-8');
|
|
314
|
+
}
|
|
315
|
+
async function generatePolicyFile(pluginDir, config) {
|
|
316
|
+
const content = `/**
|
|
317
|
+
* Policy/action selection for ${config.name}
|
|
318
|
+
*/
|
|
319
|
+
|
|
320
|
+
import type { Vector, Action } from 'agentdb/plugins';
|
|
321
|
+
|
|
322
|
+
export class PolicyFunction {
|
|
323
|
+
constructor(private config: any) {}
|
|
324
|
+
|
|
325
|
+
async selectAction(state: Vector, context?: any): Promise<Action> {
|
|
326
|
+
// ${config.algorithm.action_selection || 'epsilon_greedy'} strategy
|
|
327
|
+
// TODO: Implement action selection logic
|
|
328
|
+
return { id: 0, type: 'discrete' };
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
`;
|
|
332
|
+
await fs.writeFile(path.join(pluginDir, 'src', 'policy.ts'), content, 'utf-8');
|
|
333
|
+
}
|
|
334
|
+
async function generateTestFile(pluginDir, config) {
|
|
335
|
+
const content = `/**
|
|
336
|
+
* Tests for ${config.name}
|
|
337
|
+
*/
|
|
338
|
+
|
|
339
|
+
import { describe, it, expect, beforeAll, afterAll } from 'vitest';
|
|
340
|
+
import { ${getPluginClassName(config)} } from '../src/index.mjs';
|
|
341
|
+
import type { PluginConfig } from 'agentdb/plugins';
|
|
342
|
+
|
|
343
|
+
describe('${config.name}', () => {
|
|
344
|
+
let plugin: ${getPluginClassName(config)};
|
|
345
|
+
|
|
346
|
+
beforeAll(async () => {
|
|
347
|
+
const config: PluginConfig = {
|
|
348
|
+
// Load from plugin.yaml
|
|
349
|
+
};
|
|
350
|
+
|
|
351
|
+
plugin = new ${getPluginClassName(config)}();
|
|
352
|
+
await plugin.initialize(config);
|
|
353
|
+
});
|
|
354
|
+
|
|
355
|
+
afterAll(async () => {
|
|
356
|
+
await plugin.destroy();
|
|
357
|
+
});
|
|
358
|
+
|
|
359
|
+
it('should initialize correctly', () => {
|
|
360
|
+
expect(plugin.name).toBe('${config.name}');
|
|
361
|
+
expect(plugin.version).toBe('${config.version}');
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
it('should store experiences', async () => {
|
|
365
|
+
const experience = {
|
|
366
|
+
state: new Float32Array(${config.algorithm.state_dim || 768}),
|
|
367
|
+
action: { id: 0, type: 'discrete' },
|
|
368
|
+
reward: 1.0,
|
|
369
|
+
nextState: new Float32Array(${config.algorithm.state_dim || 768}),
|
|
370
|
+
done: false,
|
|
371
|
+
};
|
|
372
|
+
|
|
373
|
+
await plugin.storeExperience(experience);
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
it('should select actions', async () => {
|
|
377
|
+
const state = new Float32Array(${config.algorithm.state_dim || 768});
|
|
378
|
+
const action = await plugin.selectAction(state);
|
|
379
|
+
expect(action).toBeDefined();
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
it('should train successfully', async () => {
|
|
383
|
+
const metrics = await plugin.train();
|
|
384
|
+
expect(metrics).toBeDefined();
|
|
385
|
+
});
|
|
386
|
+
});
|
|
387
|
+
`;
|
|
388
|
+
await fs.writeFile(path.join(pluginDir, 'tests', 'plugin.test.ts'), content, 'utf-8');
|
|
389
|
+
}
|
|
390
|
+
async function generateReadme(pluginDir, config) {
|
|
391
|
+
const content = `# ${config.name}
|
|
392
|
+
|
|
393
|
+
${config.description}
|
|
394
|
+
|
|
395
|
+
**Version:** ${config.version}
|
|
396
|
+
**Author:** ${config.author || 'Unknown'}
|
|
397
|
+
**Algorithm:** ${config.algorithm.base}
|
|
398
|
+
|
|
399
|
+
## Installation
|
|
400
|
+
|
|
401
|
+
\`\`\`bash
|
|
402
|
+
npm install
|
|
403
|
+
\`\`\`
|
|
404
|
+
|
|
405
|
+
## Usage
|
|
406
|
+
|
|
407
|
+
\`\`\`typescript
|
|
408
|
+
import { PluginRegistry } from 'agentdb/plugins';
|
|
409
|
+
|
|
410
|
+
// Load plugin
|
|
411
|
+
const plugin = await PluginRegistry.load('${config.name}');
|
|
412
|
+
|
|
413
|
+
// Initialize
|
|
414
|
+
await plugin.initialize(config);
|
|
415
|
+
|
|
416
|
+
// Use in your application
|
|
417
|
+
const action = await plugin.selectAction(state);
|
|
418
|
+
\`\`\`
|
|
419
|
+
|
|
420
|
+
## Configuration
|
|
421
|
+
|
|
422
|
+
See \`plugin.yaml\` for complete configuration options.
|
|
423
|
+
|
|
424
|
+
## Testing
|
|
425
|
+
|
|
426
|
+
\`\`\`bash
|
|
427
|
+
npm test
|
|
428
|
+
\`\`\`
|
|
429
|
+
|
|
430
|
+
## License
|
|
431
|
+
|
|
432
|
+
MIT
|
|
433
|
+
`;
|
|
434
|
+
await fs.writeFile(path.join(pluginDir, 'README.md'), content, 'utf-8');
|
|
435
|
+
}
|
|
436
|
+
async function generatePackageJson(pluginDir, config) {
|
|
437
|
+
const pkg = {
|
|
438
|
+
name: config.name,
|
|
439
|
+
version: config.version,
|
|
440
|
+
description: config.description,
|
|
441
|
+
type: 'module',
|
|
442
|
+
main: './dist/index.js',
|
|
443
|
+
types: './dist/index.d.ts',
|
|
444
|
+
scripts: {
|
|
445
|
+
build: 'tsc',
|
|
446
|
+
test: 'vitest',
|
|
447
|
+
'test:coverage': 'vitest --coverage',
|
|
448
|
+
},
|
|
449
|
+
dependencies: {
|
|
450
|
+
'agentdb': '^1.0.0',
|
|
451
|
+
},
|
|
452
|
+
devDependencies: {
|
|
453
|
+
typescript: '^5.0.0',
|
|
454
|
+
vitest: '^1.0.0',
|
|
455
|
+
'@types/node': '^20.0.0',
|
|
456
|
+
},
|
|
457
|
+
};
|
|
458
|
+
await fs.writeFile(path.join(pluginDir, 'package.json'), JSON.stringify(pkg, null, 2), 'utf-8');
|
|
459
|
+
}
|
|
460
|
+
async function generateTsConfig(pluginDir) {
|
|
461
|
+
const tsconfig = {
|
|
462
|
+
compilerOptions: {
|
|
463
|
+
target: 'ES2022',
|
|
464
|
+
module: 'ESNext',
|
|
465
|
+
moduleResolution: 'bundler',
|
|
466
|
+
declaration: true,
|
|
467
|
+
outDir: './dist',
|
|
468
|
+
strict: true,
|
|
469
|
+
esModuleInterop: true,
|
|
470
|
+
skipLibCheck: true,
|
|
471
|
+
forceConsistentCasingInFileNames: true,
|
|
472
|
+
},
|
|
473
|
+
include: ['src/**/*'],
|
|
474
|
+
exclude: ['node_modules', 'dist', 'tests'],
|
|
475
|
+
};
|
|
476
|
+
await fs.writeFile(path.join(pluginDir, 'tsconfig.json'), JSON.stringify(tsconfig, null, 2), 'utf-8');
|
|
477
|
+
}
|
|
478
|
+
// Helper functions
|
|
479
|
+
function getPluginClassName(config) {
|
|
480
|
+
return config.name
|
|
481
|
+
.split('-')
|
|
482
|
+
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
|
|
483
|
+
.join('') + 'Plugin';
|
|
484
|
+
}
|
|
485
|
+
function getAgentClassName(config) {
|
|
486
|
+
return config.name
|
|
487
|
+
.split('-')
|
|
488
|
+
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
|
|
489
|
+
.join('') + 'Agent';
|
|
490
|
+
}
|
|
491
|
+
function generateAlgorithmImplementation(config) {
|
|
492
|
+
switch (config.algorithm.base) {
|
|
493
|
+
case 'q_learning':
|
|
494
|
+
return {
|
|
495
|
+
fields: ` private qTable: Map<string, number[]>;\n private epsilon: number;`,
|
|
496
|
+
initialization: ` this.qTable = new Map();\n this.epsilon = ${config.algorithm.epsilon_start || 1.0};`,
|
|
497
|
+
onStoreExperience: ` // Update Q-values if needed`,
|
|
498
|
+
training: ` const metrics = { loss: 0, epsilon: this.epsilon };\n // TODO: Implement Q-learning training\n return metrics;`,
|
|
499
|
+
};
|
|
500
|
+
case 'decision_transformer':
|
|
501
|
+
return {
|
|
502
|
+
fields: ` private model: any; // Neural network model`,
|
|
503
|
+
initialization: ` // Initialize Decision Transformer model`,
|
|
504
|
+
onStoreExperience: ` // Store trajectory for training`,
|
|
505
|
+
training: ` const metrics = { loss: 0 };\n // TODO: Implement Decision Transformer training\n return metrics;`,
|
|
506
|
+
};
|
|
507
|
+
default:
|
|
508
|
+
return {
|
|
509
|
+
fields: '',
|
|
510
|
+
initialization: '',
|
|
511
|
+
onStoreExperience: '',
|
|
512
|
+
training: ` const metrics = {};\n // TODO: Implement training logic\n return metrics;`,
|
|
513
|
+
};
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
function generateDefaultReward(type) {
|
|
517
|
+
switch (type) {
|
|
518
|
+
case 'success_based':
|
|
519
|
+
return 'return outcome.success ? 1.0 : -1.0;';
|
|
520
|
+
case 'time_aware':
|
|
521
|
+
return `const base = outcome.success ? 1.0 : -1.0;\nconst timePenalty = -0.1 * (context.duration / 1000);\nreturn base + timePenalty;`;
|
|
522
|
+
case 'token_aware':
|
|
523
|
+
return `const base = outcome.success ? 1.0 : -1.0;\nconst tokenPenalty = -0.01 * (context.tokensUsed / 100);\nreturn base + tokenPenalty;`;
|
|
524
|
+
default:
|
|
525
|
+
return 'return outcome.success ? 1.0 : -1.0;';
|
|
526
|
+
}
|
|
527
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Comprehensive Help System for SQLite Vector CLI
|
|
4
|
+
* Organized with subsections for easy navigation
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Main help display with subsections
|
|
8
|
+
*/
|
|
9
|
+
export declare function showComprehensiveHelp(): void;
|
|
10
|
+
/**
|
|
11
|
+
* Get the complete help content
|
|
12
|
+
*/
|
|
13
|
+
export declare function getHelpContent(): string;
|
|
14
|
+
/**
|
|
15
|
+
* Show help for specific command
|
|
16
|
+
*/
|
|
17
|
+
export declare function showCommandHelp(command: string): void;
|
|
18
|
+
//# sourceMappingURL=help.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../../src/cli/help.ts"],"names":[],"mappings":";AACA;;;GAGG;AAMH;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,IAAI,CAE5C;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,MAAM,CA4BvC;AAqnBD;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAIrD"}
|