agentic-flow 2.0.2 → 2.0.4
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/.claude/agents/test-neural.md +14 -0
- package/.claude/settings.json +9 -133
- package/README.md +622 -1862
- package/dist/.tsbuildinfo +1 -1
- package/dist/billing/mcp/tools.js +0 -1
- package/dist/billing/mcp/tools.js.map +1 -1
- package/dist/cli/commands/hooks.d.ts.map +1 -1
- package/dist/cli/commands/hooks.js +4 -79
- package/dist/cli/commands/hooks.js.map +1 -1
- package/dist/cli-proxy.js +1 -89
- package/dist/cli-proxy.js.map +1 -1
- package/dist/core/agentdb-fast.js +3 -3
- package/dist/core/agentdb-fast.js.map +1 -1
- package/dist/core/agentdb-wrapper-enhanced.d.ts.map +1 -1
- package/dist/core/agentdb-wrapper-enhanced.js +4 -20
- package/dist/core/agentdb-wrapper-enhanced.js.map +1 -1
- package/dist/core/agentdb-wrapper.d.ts +2 -3
- package/dist/core/agentdb-wrapper.d.ts.map +1 -1
- package/dist/core/agentdb-wrapper.js +1 -15
- package/dist/core/agentdb-wrapper.js.map +1 -1
- package/dist/core/attention-native.d.ts +0 -4
- package/dist/core/attention-native.d.ts.map +1 -1
- package/dist/core/attention-native.js +2 -14
- package/dist/core/attention-native.js.map +1 -1
- package/dist/federation/SecurityManager.d.ts +2 -11
- package/dist/federation/SecurityManager.d.ts.map +1 -1
- package/dist/federation/SecurityManager.js +17 -50
- package/dist/federation/SecurityManager.js.map +1 -1
- package/dist/federation/integrations/supabase-adapter-debug.js +3 -3
- package/dist/federation/integrations/supabase-adapter-debug.js.map +1 -1
- package/dist/hooks/swarm-learning-optimizer.js +5 -5
- package/dist/hooks/swarm-learning-optimizer.js.map +1 -1
- package/dist/intelligence/IntelligenceStore.d.ts +26 -35
- package/dist/intelligence/IntelligenceStore.d.ts.map +1 -1
- package/dist/intelligence/IntelligenceStore.js +123 -308
- package/dist/intelligence/IntelligenceStore.js.map +1 -1
- package/dist/intelligence/RuVectorIntelligence.d.ts +1 -26
- package/dist/intelligence/RuVectorIntelligence.d.ts.map +1 -1
- package/dist/intelligence/RuVectorIntelligence.js +10 -49
- package/dist/intelligence/RuVectorIntelligence.js.map +1 -1
- package/dist/intelligence/agent-booster-enhanced.d.ts +0 -1
- package/dist/intelligence/agent-booster-enhanced.d.ts.map +1 -1
- package/dist/intelligence/agent-booster-enhanced.js +3 -24
- package/dist/intelligence/agent-booster-enhanced.js.map +1 -1
- package/dist/intelligence/index.d.ts +3 -29
- package/dist/intelligence/index.d.ts.map +1 -1
- package/dist/intelligence/index.js +3 -13
- package/dist/intelligence/index.js.map +1 -1
- package/dist/mcp/claudeFlowSdkServer.d.ts.map +1 -1
- package/dist/mcp/claudeFlowSdkServer.js +3 -9
- package/dist/mcp/claudeFlowSdkServer.js.map +1 -1
- package/dist/mcp/fastmcp/tools/hooks/intelligence-bridge.js +5 -5
- package/dist/mcp/fastmcp/tools/hooks/intelligence-bridge.js.map +1 -1
- package/dist/mcp/fastmcp/tools/swarm/init.d.ts.map +1 -1
- package/dist/mcp/fastmcp/tools/swarm/init.js +7 -36
- package/dist/mcp/fastmcp/tools/swarm/init.js.map +1 -1
- package/dist/mcp/fastmcp/tools/swarm/spawn.d.ts.map +1 -1
- package/dist/mcp/fastmcp/tools/swarm/spawn.js +8 -47
- package/dist/mcp/fastmcp/tools/swarm/spawn.js.map +1 -1
- package/dist/mcp/tools/agent-booster-tools.d.ts +1 -1
- package/dist/mcp/tools/agent-booster-tools.d.ts.map +1 -1
- package/dist/mcp/tools/agent-booster-tools.js +4 -10
- package/dist/mcp/tools/agent-booster-tools.js.map +1 -1
- package/dist/mcp/tools/sona-tools.d.ts.map +1 -1
- package/dist/mcp/tools/sona-tools.js +0 -6
- package/dist/mcp/tools/sona-tools.js.map +1 -1
- package/dist/optimizations/agent-booster-migration.d.ts.map +1 -1
- package/dist/optimizations/agent-booster-migration.js +2 -5
- package/dist/optimizations/agent-booster-migration.js.map +1 -1
- package/dist/proxy/anthropic-to-openrouter.js.map +1 -1
- package/dist/proxy/anthropic-to-requesty.js.map +1 -1
- package/dist/proxy/quic-proxy.d.ts +1 -0
- package/dist/proxy/quic-proxy.d.ts.map +1 -1
- package/dist/proxy/quic-proxy.js +2 -2
- package/dist/proxy/quic-proxy.js.map +1 -1
- package/dist/reasoningbank/AdvancedMemory.js +1 -1
- package/dist/reasoningbank/AdvancedMemory.js.map +1 -1
- package/dist/reasoningbank/HybridBackend.d.ts.map +1 -1
- package/dist/reasoningbank/HybridBackend.js +5 -2
- package/dist/reasoningbank/HybridBackend.js.map +1 -1
- package/dist/reasoningbank/backend-selector.d.ts +1 -11
- package/dist/reasoningbank/backend-selector.d.ts.map +1 -1
- package/dist/reasoningbank/backend-selector.js +5 -45
- package/dist/reasoningbank/backend-selector.js.map +1 -1
- package/dist/reasoningbank/core/consolidate.d.ts.map +1 -1
- package/dist/reasoningbank/core/consolidate.js +45 -113
- package/dist/reasoningbank/core/consolidate.js.map +1 -1
- package/dist/reasoningbank/index-new.d.ts +6 -1
- package/dist/reasoningbank/index-new.d.ts.map +1 -1
- package/dist/reasoningbank/index-new.js +6 -1
- package/dist/reasoningbank/index-new.js.map +1 -1
- package/dist/reasoningbank/index.d.ts +6 -2
- package/dist/reasoningbank/index.d.ts.map +1 -1
- package/dist/reasoningbank/index.js +6 -2
- package/dist/reasoningbank/index.js.map +1 -1
- package/dist/reasoningbank/utils/embeddings.d.ts +0 -1
- package/dist/reasoningbank/utils/embeddings.d.ts.map +1 -1
- package/dist/reasoningbank/utils/embeddings.js +26 -53
- package/dist/reasoningbank/utils/embeddings.js.map +1 -1
- package/dist/router/index.d.ts +17 -0
- package/dist/router/index.d.ts.map +1 -0
- package/dist/router/index.js +19 -0
- package/dist/router/index.js.map +1 -0
- package/dist/router/providers/onnx-local-optimized.d.ts +0 -2
- package/dist/router/providers/onnx-local-optimized.d.ts.map +1 -1
- package/dist/router/providers/onnx-local-optimized.js +0 -10
- package/dist/router/providers/onnx-local-optimized.js.map +1 -1
- package/dist/router/providers/onnx-local.d.ts +0 -1
- package/dist/router/providers/onnx-local.d.ts.map +1 -1
- package/dist/router/providers/onnx-local.js +5 -22
- package/dist/router/providers/onnx-local.js.map +1 -1
- package/dist/services/embedding-service.js.map +1 -1
- package/dist/services/sona-agent-training.d.ts +0 -1
- package/dist/services/sona-agent-training.d.ts.map +1 -1
- package/dist/services/sona-agent-training.js.map +1 -1
- package/dist/services/sona-agentdb-integration.d.ts.map +1 -1
- package/dist/services/sona-agentdb-integration.js +6 -9
- package/dist/services/sona-agentdb-integration.js.map +1 -1
- package/dist/services/sona-service.d.ts.map +1 -1
- package/dist/services/sona-service.js +5 -6
- package/dist/services/sona-service.js.map +1 -1
- package/dist/utils/cli.d.ts +1 -1
- package/dist/utils/cli.d.ts.map +1 -1
- package/dist/utils/cli.js +0 -21
- package/dist/utils/cli.js.map +1 -1
- package/package.json +7 -19
- package/scripts/postinstall.js +4 -45
- package/wasm/reasoningbank/reasoningbank_wasm_bg.js +2 -2
- package/wasm/reasoningbank/reasoningbank_wasm_bg.wasm +0 -0
- package/.claude/agents/.claude-flow/metrics/agent-metrics.json +0 -1
- package/.claude/agents/.claude-flow/metrics/performance.json +0 -87
- package/.claude/agents/.claude-flow/metrics/task-metrics.json +0 -10
- package/.claude/skills/.claude-flow/metrics/agent-metrics.json +0 -1
- package/.claude/skills/.claude-flow/metrics/performance.json +0 -87
- package/.claude/skills/.claude-flow/metrics/task-metrics.json +0 -10
- package/.claude/skills/agentic-flow-quickstart/skill.md +0 -69
- package/.claude/skills/hooks-automation/skill.md +0 -155
- package/.claude/skills/memory-patterns/skill.md +0 -110
- package/.claude/skills/skill-builder/.claude-flow/metrics/agent-metrics.json +0 -1
- package/.claude/skills/skill-builder/.claude-flow/metrics/performance.json +0 -87
- package/.claude/skills/skill-builder/.claude-flow/metrics/task-metrics.json +0 -10
- package/.claude/skills/sparc-methodology/skill.md +0 -137
- package/.claude/skills/swarm-coordination/skill.md +0 -94
- package/.claude/skills/worker-benchmarks/skill.md +0 -135
- package/.claude/skills/worker-integration/skill.md +0 -154
- package/.claude/statusline.mjs +0 -109
- package/.claude/statusline.sh +0 -71
- package/dist/agentdb/benchmarks/comprehensive-benchmark.js +0 -664
- package/dist/agentdb/benchmarks/frontier-benchmark.js +0 -419
- package/dist/agentdb/benchmarks/reflexion-benchmark.js +0 -370
- package/dist/agentdb/cli/agentdb-cli.js +0 -717
- package/dist/agentdb/controllers/CausalMemoryGraph.js +0 -322
- package/dist/agentdb/controllers/CausalRecall.js +0 -281
- package/dist/agentdb/controllers/EmbeddingService.d.ts +0 -37
- package/dist/agentdb/controllers/EmbeddingService.d.ts.map +0 -1
- package/dist/agentdb/controllers/EmbeddingService.js +0 -119
- package/dist/agentdb/controllers/EmbeddingService.js.map +0 -1
- package/dist/agentdb/controllers/ExplainableRecall.js +0 -387
- package/dist/agentdb/controllers/NightlyLearner.js +0 -382
- package/dist/agentdb/controllers/ReflexionMemory.js +0 -239
- package/dist/agentdb/controllers/SkillLibrary.js +0 -276
- package/dist/agentdb/controllers/frontier-index.js +0 -9
- package/dist/agentdb/controllers/index.js +0 -8
- package/dist/agentdb/optimizations/BatchOperations.js +0 -198
- package/dist/agentdb/optimizations/QueryOptimizer.js +0 -225
- package/dist/agentdb/optimizations/index.js +0 -7
- package/dist/agentdb/tests/frontier-features.test.js +0 -665
- package/dist/benchmarks/embeddings-benchmark.d.ts +0 -38
- package/dist/benchmarks/embeddings-benchmark.d.ts.map +0 -1
- package/dist/benchmarks/embeddings-benchmark.js +0 -282
- package/dist/benchmarks/embeddings-benchmark.js.map +0 -1
- package/dist/cli/commands/embeddings.d.ts +0 -12
- package/dist/cli/commands/embeddings.d.ts.map +0 -1
- package/dist/cli/commands/embeddings.js +0 -386
- package/dist/cli/commands/embeddings.js.map +0 -1
- package/dist/cli/commands/init.d.ts +0 -8
- package/dist/cli/commands/init.d.ts.map +0 -1
- package/dist/cli/commands/init.js +0 -514
- package/dist/cli/commands/init.js.map +0 -1
- package/dist/cli/commands/workers.d.ts +0 -9
- package/dist/cli/commands/workers.d.ts.map +0 -1
- package/dist/cli/commands/workers.js +0 -991
- package/dist/cli/commands/workers.js.map +0 -1
- package/dist/cli/skills-manager.js +0 -1297
- package/dist/cli/update-message.js +0 -175
- package/dist/embeddings/index.d.ts +0 -17
- package/dist/embeddings/index.d.ts.map +0 -1
- package/dist/embeddings/index.js +0 -17
- package/dist/embeddings/index.js.map +0 -1
- package/dist/embeddings/neural-substrate.d.ts +0 -206
- package/dist/embeddings/neural-substrate.d.ts.map +0 -1
- package/dist/embeddings/neural-substrate.js +0 -629
- package/dist/embeddings/neural-substrate.js.map +0 -1
- package/dist/embeddings/optimized-embedder.d.ts +0 -103
- package/dist/embeddings/optimized-embedder.d.ts.map +0 -1
- package/dist/embeddings/optimized-embedder.js +0 -730
- package/dist/embeddings/optimized-embedder.js.map +0 -1
- package/dist/examples/embedding-geometry.d.ts +0 -105
- package/dist/examples/embedding-geometry.d.ts.map +0 -1
- package/dist/examples/embedding-geometry.js +0 -528
- package/dist/examples/embedding-geometry.js.map +0 -1
- package/dist/memory/SharedMemoryPool.d.ts +0 -129
- package/dist/memory/SharedMemoryPool.d.ts.map +0 -1
- package/dist/memory/SharedMemoryPool.js +0 -243
- package/dist/memory/SharedMemoryPool.js.map +0 -1
- package/dist/memory/index.d.ts +0 -8
- package/dist/memory/index.d.ts.map +0 -1
- package/dist/memory/index.js +0 -7
- package/dist/memory/index.js.map +0 -1
- package/dist/proxy/http3-proxy-old.js +0 -331
- package/dist/proxy/proxy/anthropic-to-gemini.js +0 -439
- package/dist/proxy/utils/logger.js +0 -59
- package/dist/reasoningbank/agentdb-adapter.js +0 -125
- package/dist/reasoningbank/core/database.js +0 -250
- package/dist/reasoningbank/core/memory-engine.js +0 -335
- package/dist/swarm/ipfs-swarm.d.ts +0 -265
- package/dist/swarm/ipfs-swarm.d.ts.map +0 -1
- package/dist/swarm/ipfs-swarm.js +0 -508
- package/dist/swarm/ipfs-swarm.js.map +0 -1
- package/dist/swarm/p2p-free-swarm.d.ts +0 -344
- package/dist/swarm/p2p-free-swarm.d.ts.map +0 -1
- package/dist/swarm/p2p-free-swarm.js +0 -603
- package/dist/swarm/p2p-free-swarm.js.map +0 -1
- package/dist/swarm/real-p2p-swarm.d.ts +0 -183
- package/dist/swarm/real-p2p-swarm.d.ts.map +0 -1
- package/dist/swarm/real-p2p-swarm.js +0 -469
- package/dist/swarm/real-p2p-swarm.js.map +0 -1
- package/dist/utils/adaptive-pool-sizing.js +0 -414
- package/dist/utils/agentdbCommands.js +0 -175
- package/dist/utils/circular-rate-limiter.js +0 -391
- package/dist/utils/dynamic-compression.js +0 -298
- package/dist/utils/http2-multiplexing.js +0 -319
- package/dist/utils/index.d.ts +0 -6
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js +0 -6
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/lazy-auth.js +0 -311
- package/dist/utils/model-cache.d.ts +0 -61
- package/dist/utils/model-cache.d.ts.map +0 -1
- package/dist/utils/model-cache.js +0 -176
- package/dist/utils/model-cache.js.map +0 -1
- package/dist/utils/server-push.js +0 -251
- package/dist/utils/suppress-warnings.d.ts +0 -19
- package/dist/utils/suppress-warnings.d.ts.map +0 -1
- package/dist/utils/suppress-warnings.js +0 -59
- package/dist/utils/suppress-warnings.js.map +0 -1
- package/dist/utils/zero-copy-buffer.js +0 -286
- package/dist/workers/consolidated-phases.d.ts +0 -40
- package/dist/workers/consolidated-phases.d.ts.map +0 -1
- package/dist/workers/consolidated-phases.js +0 -497
- package/dist/workers/consolidated-phases.js.map +0 -1
- package/dist/workers/custom-worker-config.d.ts +0 -133
- package/dist/workers/custom-worker-config.d.ts.map +0 -1
- package/dist/workers/custom-worker-config.js +0 -215
- package/dist/workers/custom-worker-config.js.map +0 -1
- package/dist/workers/custom-worker-factory.d.ts +0 -89
- package/dist/workers/custom-worker-factory.d.ts.map +0 -1
- package/dist/workers/custom-worker-factory.js +0 -404
- package/dist/workers/custom-worker-factory.js.map +0 -1
- package/dist/workers/dispatch-service.d.ts +0 -123
- package/dist/workers/dispatch-service.d.ts.map +0 -1
- package/dist/workers/dispatch-service.js +0 -1024
- package/dist/workers/dispatch-service.js.map +0 -1
- package/dist/workers/hooks-integration.d.ts +0 -79
- package/dist/workers/hooks-integration.d.ts.map +0 -1
- package/dist/workers/hooks-integration.js +0 -286
- package/dist/workers/hooks-integration.js.map +0 -1
- package/dist/workers/index.d.ts +0 -42
- package/dist/workers/index.d.ts.map +0 -1
- package/dist/workers/index.js +0 -52
- package/dist/workers/index.js.map +0 -1
- package/dist/workers/mcp-tools.d.ts +0 -56
- package/dist/workers/mcp-tools.d.ts.map +0 -1
- package/dist/workers/mcp-tools.js +0 -359
- package/dist/workers/mcp-tools.js.map +0 -1
- package/dist/workers/phase-executors.d.ts +0 -22
- package/dist/workers/phase-executors.d.ts.map +0 -1
- package/dist/workers/phase-executors.js +0 -445
- package/dist/workers/phase-executors.js.map +0 -1
- package/dist/workers/resource-governor.d.ts +0 -75
- package/dist/workers/resource-governor.d.ts.map +0 -1
- package/dist/workers/resource-governor.js +0 -187
- package/dist/workers/resource-governor.js.map +0 -1
- package/dist/workers/ruvector-integration.d.ts +0 -163
- package/dist/workers/ruvector-integration.d.ts.map +0 -1
- package/dist/workers/ruvector-integration.js +0 -543
- package/dist/workers/ruvector-integration.js.map +0 -1
- package/dist/workers/ruvector-native-integration.d.ts +0 -91
- package/dist/workers/ruvector-native-integration.d.ts.map +0 -1
- package/dist/workers/ruvector-native-integration.js +0 -254
- package/dist/workers/ruvector-native-integration.js.map +0 -1
- package/dist/workers/trigger-detector.d.ts +0 -68
- package/dist/workers/trigger-detector.d.ts.map +0 -1
- package/dist/workers/trigger-detector.js +0 -281
- package/dist/workers/trigger-detector.js.map +0 -1
- package/dist/workers/types.d.ts +0 -145
- package/dist/workers/types.d.ts.map +0 -1
- package/dist/workers/types.js +0 -6
- package/dist/workers/types.js.map +0 -1
- package/dist/workers/worker-agent-integration.d.ts +0 -140
- package/dist/workers/worker-agent-integration.d.ts.map +0 -1
- package/dist/workers/worker-agent-integration.js +0 -471
- package/dist/workers/worker-agent-integration.js.map +0 -1
- package/dist/workers/worker-benchmarks.d.ts +0 -88
- package/dist/workers/worker-benchmarks.d.ts.map +0 -1
- package/dist/workers/worker-benchmarks.js +0 -452
- package/dist/workers/worker-benchmarks.js.map +0 -1
- package/dist/workers/worker-registry.d.ts +0 -85
- package/dist/workers/worker-registry.d.ts.map +0 -1
- package/dist/workers/worker-registry.js +0 -547
- package/dist/workers/worker-registry.js.map +0 -1
- package/docs/.claude-flow/metrics/agent-metrics.json +0 -1
- package/docs/.claude-flow/metrics/performance.json +0 -87
- package/docs/.claude-flow/metrics/task-metrics.json +0 -10
- package/docs/embeddings/EMBEDDING_GEOMETRY.md +0 -935
- /package/.claude/agents/analysis/{analyze-code-quality.md → code-review/analyze-code-quality.md} +0 -0
- /package/.claude/agents/architecture/{arch-system-design.md → system-design/arch-system-design.md} +0 -0
- /package/.claude/agents/data/{data-ml-model.md → ml/data-ml-model.md} +0 -0
- /package/.claude/agents/development/{dev-backend-api.md → backend/dev-backend-api.md} +0 -0
- /package/.claude/agents/devops/{ops-cicd-github.md → ci-cd/ops-cicd-github.md} +0 -0
- /package/.claude/agents/documentation/{docs-api-openapi.md → api-docs/docs-api-openapi.md} +0 -0
- /package/.claude/agents/specialized/{spec-mobile-react-native.md → mobile/spec-mobile-react-native.md} +0 -0
- /package/.claude/agents/testing/{tdd-london-swarm.md → unit/tdd-london-swarm.md} +0 -0
- /package/.claude/agents/testing/{production-validator.md → validation/production-validator.md} +0 -0
|
@@ -1,286 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Zero-Copy Buffer Implementation
|
|
3
|
-
* Direct memory access without intermediate copies for 10-15% memory/CPU reduction
|
|
4
|
-
* Phase 2 Optimization
|
|
5
|
-
*/
|
|
6
|
-
import { Buffer } from 'buffer';
|
|
7
|
-
/**
|
|
8
|
-
* Zero-Copy Buffer Pool
|
|
9
|
-
* Manages reusable buffers to avoid allocations and copies
|
|
10
|
-
*/
|
|
11
|
-
export class ZeroCopyBufferPool {
|
|
12
|
-
config;
|
|
13
|
-
availableBuffers = [];
|
|
14
|
-
inUseBuffers = new Set();
|
|
15
|
-
stats = {
|
|
16
|
-
allocated: 0,
|
|
17
|
-
reused: 0,
|
|
18
|
-
copiesAvoided: 0,
|
|
19
|
-
memorySaved: 0
|
|
20
|
-
};
|
|
21
|
-
constructor(config) {
|
|
22
|
-
this.config = {
|
|
23
|
-
enabled: config.enabled,
|
|
24
|
-
poolSize: config.poolSize || 100,
|
|
25
|
-
bufferSize: config.bufferSize || 64 * 1024, // 64KB default
|
|
26
|
-
reuseBuffers: config.reuseBuffers !== false
|
|
27
|
-
};
|
|
28
|
-
// Pre-allocate buffer pool
|
|
29
|
-
if (this.config.enabled) {
|
|
30
|
-
this.initializePool();
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Initialize the buffer pool
|
|
35
|
-
*/
|
|
36
|
-
initializePool() {
|
|
37
|
-
for (let i = 0; i < this.config.poolSize; i++) {
|
|
38
|
-
const buffer = Buffer.allocUnsafe(this.config.bufferSize);
|
|
39
|
-
this.availableBuffers.push(buffer);
|
|
40
|
-
this.stats.allocated++;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Acquire a buffer from the pool
|
|
45
|
-
*/
|
|
46
|
-
acquire(size) {
|
|
47
|
-
if (!this.config.enabled || !this.config.reuseBuffers) {
|
|
48
|
-
const buffer = Buffer.allocUnsafe(size || this.config.bufferSize);
|
|
49
|
-
this.stats.allocated++;
|
|
50
|
-
return buffer;
|
|
51
|
-
}
|
|
52
|
-
// Try to reuse an existing buffer
|
|
53
|
-
let buffer = this.availableBuffers.pop();
|
|
54
|
-
if (buffer) {
|
|
55
|
-
this.stats.reused++;
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
// Pool exhausted, allocate new buffer
|
|
59
|
-
buffer = Buffer.allocUnsafe(size || this.config.bufferSize);
|
|
60
|
-
this.stats.allocated++;
|
|
61
|
-
}
|
|
62
|
-
this.inUseBuffers.add(buffer);
|
|
63
|
-
return buffer;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Release a buffer back to the pool
|
|
67
|
-
*/
|
|
68
|
-
release(buffer) {
|
|
69
|
-
if (!this.config.enabled || !this.config.reuseBuffers) {
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
if (this.inUseBuffers.has(buffer)) {
|
|
73
|
-
this.inUseBuffers.delete(buffer);
|
|
74
|
-
// Only keep buffers up to pool size
|
|
75
|
-
if (this.availableBuffers.length < this.config.poolSize) {
|
|
76
|
-
this.availableBuffers.push(buffer);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Get buffer statistics
|
|
82
|
-
*/
|
|
83
|
-
getStats() {
|
|
84
|
-
return { ...this.stats };
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Reset statistics
|
|
88
|
-
*/
|
|
89
|
-
resetStats() {
|
|
90
|
-
this.stats = {
|
|
91
|
-
allocated: this.availableBuffers.length + this.inUseBuffers.size,
|
|
92
|
-
reused: 0,
|
|
93
|
-
copiesAvoided: 0,
|
|
94
|
-
memorySaved: 0
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Clear the pool
|
|
99
|
-
*/
|
|
100
|
-
clear() {
|
|
101
|
-
this.availableBuffers = [];
|
|
102
|
-
this.inUseBuffers.clear();
|
|
103
|
-
this.resetStats();
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Zero-Copy Stream Handler
|
|
108
|
-
* Handles streaming data without unnecessary copies
|
|
109
|
-
*/
|
|
110
|
-
export class ZeroCopyStreamHandler {
|
|
111
|
-
bufferPool;
|
|
112
|
-
stats;
|
|
113
|
-
constructor(bufferPool) {
|
|
114
|
-
this.bufferPool = bufferPool;
|
|
115
|
-
this.stats = {
|
|
116
|
-
allocated: 0,
|
|
117
|
-
reused: 0,
|
|
118
|
-
copiesAvoided: 0,
|
|
119
|
-
memorySaved: 0
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Process stream chunk without copying
|
|
124
|
-
* Uses Buffer.slice() which creates a view, not a copy
|
|
125
|
-
*/
|
|
126
|
-
processChunk(chunk, offset = 0, length) {
|
|
127
|
-
const actualLength = length || (chunk.length - offset);
|
|
128
|
-
// Create a view of the chunk (zero-copy)
|
|
129
|
-
const view = chunk.subarray(offset, offset + actualLength);
|
|
130
|
-
// Track statistics
|
|
131
|
-
this.stats.copiesAvoided++;
|
|
132
|
-
this.stats.memorySaved += actualLength;
|
|
133
|
-
return view;
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Concatenate buffers efficiently
|
|
137
|
-
* Uses Buffer.concat which is optimized internally
|
|
138
|
-
*/
|
|
139
|
-
concat(buffers) {
|
|
140
|
-
if (buffers.length === 0) {
|
|
141
|
-
return Buffer.allocUnsafe(0);
|
|
142
|
-
}
|
|
143
|
-
if (buffers.length === 1) {
|
|
144
|
-
// No need to concat
|
|
145
|
-
this.stats.copiesAvoided++;
|
|
146
|
-
return buffers[0];
|
|
147
|
-
}
|
|
148
|
-
// Calculate total length
|
|
149
|
-
const totalLength = buffers.reduce((sum, buf) => sum + buf.length, 0);
|
|
150
|
-
// Use Buffer.concat which is optimized
|
|
151
|
-
return Buffer.concat(buffers, totalLength);
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* Transfer data between buffers without intermediate copies
|
|
155
|
-
*/
|
|
156
|
-
transfer(source, target, sourceStart = 0, targetStart = 0, length) {
|
|
157
|
-
const actualLength = length || (source.length - sourceStart);
|
|
158
|
-
// Use copy which is optimized in native code
|
|
159
|
-
const copied = source.copy(target, targetStart, sourceStart, sourceStart + actualLength);
|
|
160
|
-
if (copied > 0) {
|
|
161
|
-
this.stats.copiesAvoided++;
|
|
162
|
-
this.stats.memorySaved += copied;
|
|
163
|
-
}
|
|
164
|
-
return copied;
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* Get statistics
|
|
168
|
-
*/
|
|
169
|
-
getStats() {
|
|
170
|
-
return { ...this.stats };
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* Reset statistics
|
|
174
|
-
*/
|
|
175
|
-
resetStats() {
|
|
176
|
-
this.stats = {
|
|
177
|
-
allocated: 0,
|
|
178
|
-
reused: 0,
|
|
179
|
-
copiesAvoided: 0,
|
|
180
|
-
memorySaved: 0
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* Zero-Copy Response Builder
|
|
186
|
-
* Build HTTP responses without unnecessary buffer copies
|
|
187
|
-
*/
|
|
188
|
-
export class ZeroCopyResponseBuilder {
|
|
189
|
-
chunks = [];
|
|
190
|
-
totalLength = 0;
|
|
191
|
-
/**
|
|
192
|
-
* Add a chunk to the response (stores reference, not copy)
|
|
193
|
-
*/
|
|
194
|
-
addChunk(chunk) {
|
|
195
|
-
const buffer = typeof chunk === 'string' ? Buffer.from(chunk) : chunk;
|
|
196
|
-
this.chunks.push(buffer);
|
|
197
|
-
this.totalLength += buffer.length;
|
|
198
|
-
}
|
|
199
|
-
/**
|
|
200
|
-
* Build the final response buffer
|
|
201
|
-
* Only concatenates when needed
|
|
202
|
-
*/
|
|
203
|
-
build() {
|
|
204
|
-
if (this.chunks.length === 0) {
|
|
205
|
-
return Buffer.allocUnsafe(0);
|
|
206
|
-
}
|
|
207
|
-
if (this.chunks.length === 1) {
|
|
208
|
-
return this.chunks[0];
|
|
209
|
-
}
|
|
210
|
-
// Efficient concatenation
|
|
211
|
-
return Buffer.concat(this.chunks, this.totalLength);
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* Get response length without building
|
|
215
|
-
*/
|
|
216
|
-
getLength() {
|
|
217
|
-
return this.totalLength;
|
|
218
|
-
}
|
|
219
|
-
/**
|
|
220
|
-
* Clear chunks
|
|
221
|
-
*/
|
|
222
|
-
clear() {
|
|
223
|
-
this.chunks = [];
|
|
224
|
-
this.totalLength = 0;
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
/**
|
|
228
|
-
* Shared buffer for zero-copy operations
|
|
229
|
-
*/
|
|
230
|
-
export class SharedBuffer {
|
|
231
|
-
buffer;
|
|
232
|
-
refCount = 0;
|
|
233
|
-
isDetached = false;
|
|
234
|
-
constructor(size) {
|
|
235
|
-
this.buffer = Buffer.allocUnsafe(size);
|
|
236
|
-
}
|
|
237
|
-
/**
|
|
238
|
-
* Acquire a reference to this buffer
|
|
239
|
-
*/
|
|
240
|
-
acquire() {
|
|
241
|
-
if (this.isDetached) {
|
|
242
|
-
throw new Error('Cannot acquire detached buffer');
|
|
243
|
-
}
|
|
244
|
-
this.refCount++;
|
|
245
|
-
return this.buffer;
|
|
246
|
-
}
|
|
247
|
-
/**
|
|
248
|
-
* Release a reference
|
|
249
|
-
*/
|
|
250
|
-
release() {
|
|
251
|
-
if (this.refCount > 0) {
|
|
252
|
-
this.refCount--;
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
/**
|
|
256
|
-
* Check if buffer can be reused
|
|
257
|
-
*/
|
|
258
|
-
canReuse() {
|
|
259
|
-
return this.refCount === 0 && !this.isDetached;
|
|
260
|
-
}
|
|
261
|
-
/**
|
|
262
|
-
* Detach buffer (mark as unusable)
|
|
263
|
-
*/
|
|
264
|
-
detach() {
|
|
265
|
-
this.isDetached = true;
|
|
266
|
-
}
|
|
267
|
-
/**
|
|
268
|
-
* Get current reference count
|
|
269
|
-
*/
|
|
270
|
-
getReferenceCount() {
|
|
271
|
-
return this.refCount;
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
/**
|
|
275
|
-
* Calculate memory savings from zero-copy optimizations
|
|
276
|
-
*/
|
|
277
|
-
export function calculateMemorySavings(stats) {
|
|
278
|
-
const totalAllocated = stats.allocated * 64 * 1024; // Assuming 64KB average
|
|
279
|
-
const savings = stats.memorySaved;
|
|
280
|
-
const savingsPercentage = totalAllocated > 0 ? (savings / totalAllocated) * 100 : 0;
|
|
281
|
-
return {
|
|
282
|
-
savingsPercentage,
|
|
283
|
-
savingsBytes: savings,
|
|
284
|
-
savingsMB: savings / (1024 * 1024)
|
|
285
|
-
};
|
|
286
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Consolidated Phase System
|
|
3
|
-
*
|
|
4
|
-
* Eliminates redundancy between phase-executors.ts and ruvector-native-integration.ts
|
|
5
|
-
* by providing a unified phase registry that:
|
|
6
|
-
* 1. Uses native implementations as primary (faster, SIMD-optimized)
|
|
7
|
-
* 2. Falls back to legacy implementations if needed
|
|
8
|
-
* 3. Shares the cached ONNX embedder across all phases
|
|
9
|
-
*/
|
|
10
|
-
import { WorkerContext } from './types.js';
|
|
11
|
-
import { PhaseResult } from './custom-worker-config.js';
|
|
12
|
-
export interface UnifiedPhaseContext {
|
|
13
|
-
files: string[];
|
|
14
|
-
patterns: string[];
|
|
15
|
-
bytes: number;
|
|
16
|
-
dependencies: Map<string, string[]>;
|
|
17
|
-
metrics: Record<string, number>;
|
|
18
|
-
embeddings: Map<string, Float32Array>;
|
|
19
|
-
vectors: Map<string, number[]>;
|
|
20
|
-
phaseData: Map<string, Record<string, unknown>>;
|
|
21
|
-
vulnerabilities: Array<{
|
|
22
|
-
type: string;
|
|
23
|
-
file: string;
|
|
24
|
-
line: number;
|
|
25
|
-
severity: string;
|
|
26
|
-
}>;
|
|
27
|
-
}
|
|
28
|
-
export declare function createUnifiedContext(): UnifiedPhaseContext;
|
|
29
|
-
export type UnifiedPhaseExecutor = (workerContext: WorkerContext, phaseContext: UnifiedPhaseContext, options: Record<string, unknown>) => Promise<PhaseResult>;
|
|
30
|
-
export declare function registerUnifiedPhase(type: string, executor: UnifiedPhaseExecutor): void;
|
|
31
|
-
export declare function getUnifiedPhase(type: string): UnifiedPhaseExecutor | undefined;
|
|
32
|
-
export declare function listUnifiedPhases(): string[];
|
|
33
|
-
export declare function runUnifiedPipeline(workerContext: WorkerContext, phases: string[], options?: Record<string, unknown>): Promise<{
|
|
34
|
-
success: boolean;
|
|
35
|
-
phases: string[];
|
|
36
|
-
context: UnifiedPhaseContext;
|
|
37
|
-
results: Record<string, PhaseResult>;
|
|
38
|
-
duration: number;
|
|
39
|
-
}>;
|
|
40
|
-
//# sourceMappingURL=consolidated-phases.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"consolidated-phases.d.ts","sourceRoot":"","sources":["../../src/workers/consolidated-phases.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAyC,MAAM,2BAA2B,CAAC;AAO/F,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACpC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACtC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAC/B,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAChD,eAAe,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACxF;AAED,wBAAgB,oBAAoB,IAAI,mBAAmB,CAY1D;AAMD,MAAM,MAAM,oBAAoB,GAAG,CACjC,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,mBAAmB,EACjC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC7B,OAAO,CAAC,WAAW,CAAC,CAAC;AAI1B,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,oBAAoB,GAAG,IAAI,CAEvF;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,oBAAoB,GAAG,SAAS,CAE9E;AAED,wBAAgB,iBAAiB,IAAI,MAAM,EAAE,CAE5C;AAqeD,wBAAsB,kBAAkB,CACtC,aAAa,EAAE,aAAa,EAC5B,MAAM,EAAE,MAAM,EAAE,EAChB,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GACpC,OAAO,CAAC;IACT,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,OAAO,EAAE,mBAAmB,CAAC;IAC7B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACrC,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC,CAqCD"}
|