ultracode 5.4.0 → 5.6.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/dist/chunks/analysis-tool-handlers-GH5FDEWW.js +817 -0
- package/dist/chunks/analysis-tool-handlers-IXP4MWZX.js +817 -0
- package/dist/chunks/analysis-tool-handlers-LC2BTQYK.js +13 -0
- package/dist/chunks/analysis-tool-handlers-QYFKQPFL.js +817 -0
- package/dist/chunks/autodoc-tool-handlers-2HF6ERYN.js +1112 -0
- package/dist/chunks/autodoc-tool-handlers-4OGQJ7C3.js +1112 -0
- package/dist/chunks/autodoc-tool-handlers-N736CB56.js +138 -0
- package/dist/chunks/autodoc-tool-handlers-NQYBY6U4.js +1112 -0
- package/dist/chunks/branch-tool-handlers-KW3H4FJK.js +276 -0
- package/dist/chunks/branch-tool-handlers-QOUDZKJ2.js +276 -0
- package/dist/chunks/branch-tool-handlers-RB2U36KI.js +2 -0
- package/dist/chunks/branch-tool-handlers-ZHJM6PDK.js +276 -0
- package/dist/chunks/chunk-2Z6OQPYC.js +656 -0
- package/dist/chunks/chunk-3MQ7LRPN.js +322 -0
- package/dist/chunks/chunk-4W6QYGXZ.js +10 -0
- package/dist/chunks/chunk-533NFGUG.js +1 -0
- package/dist/chunks/chunk-5NUPOPWM.js +1 -0
- package/dist/chunks/chunk-AK4HIPA2.js +322 -0
- package/dist/chunks/chunk-B3H5NS3I.js +656 -0
- package/dist/chunks/chunk-DPTZHDST.js +4 -0
- package/dist/chunks/chunk-E5HQWLU5.js +322 -0
- package/dist/chunks/chunk-EOH25B5P.js +572 -0
- package/dist/chunks/chunk-ESV6F6E3.js +3179 -0
- package/dist/chunks/chunk-FPELPFER.js +924 -0
- package/dist/chunks/chunk-G6J42I55.js +161 -0
- package/dist/chunks/chunk-GCQE7ZYW.js +1 -0
- package/dist/chunks/chunk-GTIF6MOX.js +1 -0
- package/dist/chunks/chunk-I6STSSAK.js +2 -0
- package/dist/chunks/chunk-J2WBGTK2.js +4697 -0
- package/dist/chunks/chunk-KAYOX5EB.js +4697 -0
- package/dist/chunks/chunk-KPMTACOT.js +656 -0
- package/dist/chunks/chunk-L376GZ44.js +3179 -0
- package/dist/chunks/chunk-LCTOTHDA.js +15 -0
- package/dist/chunks/chunk-LEDJ7GVQ.js +316 -0
- package/dist/chunks/chunk-LH4OUKNZ.js +277 -0
- package/dist/chunks/chunk-O6IE2MEZ.js +161 -0
- package/dist/chunks/chunk-OEXPCY3F.js +316 -0
- package/dist/chunks/chunk-OMXOLFDN.js +924 -0
- package/dist/chunks/chunk-PLPBXWOU.js +3179 -0
- package/dist/chunks/chunk-PWLE5DN2.js +572 -0
- package/dist/chunks/chunk-PY43JPWL.js +447 -0
- package/dist/chunks/chunk-Q3B4EB7A.js +15 -0
- package/dist/chunks/chunk-Q5LPVLXA.js +337 -0
- package/dist/chunks/chunk-QIRZHZK2.js +5 -0
- package/dist/chunks/chunk-ROQ27LSL.js +924 -0
- package/dist/chunks/chunk-S5Q7BD6J.js +572 -0
- package/dist/chunks/chunk-SAMX3HJQ.js +337 -0
- package/dist/chunks/chunk-SV3WKUNV.js +1 -0
- package/dist/chunks/chunk-TCHCDCDO.js +167 -0
- package/dist/chunks/chunk-TR3HS7U6.js +316 -0
- package/dist/chunks/chunk-TUWE6FCW.js +167 -0
- package/dist/chunks/chunk-TVOTA7EE.js +277 -0
- package/dist/chunks/chunk-VS44D772.js +337 -0
- package/dist/chunks/chunk-WIE3G5ES.js +167 -0
- package/dist/chunks/chunk-XG3ACLWR.js +5 -0
- package/dist/chunks/chunk-XJ2Z5QQO.js +1 -0
- package/dist/chunks/chunk-XK2NY7RB.js +277 -0
- package/dist/chunks/chunk-Y4F7NZFZ.js +4700 -0
- package/dist/chunks/chunk-YS75L3ZS.js +161 -0
- package/dist/chunks/chunk-ZVG5HHI3.js +15 -0
- package/dist/chunks/dev-agent-DDDIVWOF.js +1 -0
- package/dist/chunks/dev-agent-E2VCFKXN.js +1624 -0
- package/dist/chunks/dev-agent-KJNSU5KQ.js +1624 -0
- package/dist/chunks/dev-agent-NDERYIPV.js +1624 -0
- package/dist/chunks/faiss-provider-7R4BQDIV.js +12 -0
- package/dist/chunks/faiss-provider-7ZFRSDN5.js +12 -0
- package/dist/chunks/faiss-provider-SXB7FTLB.js +1 -0
- package/dist/chunks/faiss-provider-TKLBEUSH.js +12 -0
- package/dist/chunks/file-tool-handlers-5DODQXGF.js +1027 -0
- package/dist/chunks/file-tool-handlers-KGHLE4KR.js +1027 -0
- package/dist/chunks/file-tool-handlers-KTOQ4NFS.js +12 -0
- package/dist/chunks/file-tool-handlers-V4SFUDQB.js +1027 -0
- package/dist/chunks/graph-metrics-tool-handlers-3AV4X4ZY.js +65 -0
- package/dist/chunks/graph-metrics-tool-handlers-3VMDQHJ6.js +65 -0
- package/dist/chunks/graph-metrics-tool-handlers-BZ6E6YHF.js +1 -0
- package/dist/chunks/graph-metrics-tool-handlers-IYBGSXL7.js +65 -0
- package/dist/chunks/graph-storage-factory-2CQ2RPDV.js +13 -0
- package/dist/chunks/graph-storage-factory-C5SMMYL6.js +13 -0
- package/dist/chunks/graph-storage-factory-EEO2V3GJ.js +1 -0
- package/dist/chunks/graph-storage-factory-WBCTXP34.js +13 -0
- package/dist/chunks/history-tool-handlers-AS7OQFZI.js +1 -0
- package/dist/chunks/history-tool-handlers-FSNJYXV2.js +208 -0
- package/dist/chunks/history-tool-handlers-JZAH4EIQ.js +208 -0
- package/dist/chunks/history-tool-handlers-KCSCXZ7T.js +208 -0
- package/dist/chunks/incremental-updater-A2EL4QXU.js +14 -0
- package/dist/chunks/incremental-updater-EQIKBVY2.js +14 -0
- package/dist/chunks/incremental-updater-JFGRPH3B.js +14 -0
- package/dist/chunks/incremental-updater-S5BAAGHP.js +1 -0
- package/dist/chunks/indexer-agent-ASKY7JPG.js +1 -0
- package/dist/chunks/indexer-agent-NKAOF323.js +21 -0
- package/dist/chunks/indexer-agent-PJN5IOKQ.js +21 -0
- package/dist/chunks/indexer-agent-WRJFWKZX.js +21 -0
- package/dist/chunks/indexing-pipeline-D4P2O72Z.js +249 -0
- package/dist/chunks/indexing-pipeline-L7C543N4.js +1 -0
- package/dist/chunks/indexing-pipeline-NHPRN3AB.js +249 -0
- package/dist/chunks/indexing-pipeline-ZAXCZU22.js +249 -0
- package/dist/chunks/layered-faiss-provider-62CNW54X.js +1 -0
- package/dist/chunks/layered-faiss-provider-O7L77GFX.js +12 -0
- package/dist/chunks/layered-faiss-provider-RVHLHLPK.js +12 -0
- package/dist/chunks/layered-faiss-provider-YT7EDIJI.js +12 -0
- package/dist/chunks/merge-agent-3RF7VFF5.js +2481 -0
- package/dist/chunks/merge-agent-JCKTCBCE.js +2481 -0
- package/dist/chunks/merge-agent-VCL7OXPN.js +2481 -0
- package/dist/chunks/merge-agent-ZGK24WVF.js +11 -0
- package/dist/chunks/merge-tool-handlers-GV2LOIKU.js +277 -0
- package/dist/chunks/merge-tool-handlers-TYDWU5X2.js +277 -0
- package/dist/chunks/merge-tool-handlers-U7X2ZO2M.js +1 -0
- package/dist/chunks/merge-tool-handlers-YH62ZLPJ.js +277 -0
- package/dist/chunks/pattern-tool-handlers-76NF5JDS.js +13 -0
- package/dist/chunks/pattern-tool-handlers-IJAGEIVD.js +1549 -0
- package/dist/chunks/pattern-tool-handlers-VA5WYA62.js +1549 -0
- package/dist/chunks/pattern-tool-handlers-WQ6UBMJS.js +1549 -0
- package/dist/chunks/query-agent-36ADGCFZ.js +1 -0
- package/dist/chunks/query-agent-H22CR5N5.js +191 -0
- package/dist/chunks/query-agent-K2UGZS4M.js +191 -0
- package/dist/chunks/query-agent-YJCEHOXD.js +191 -0
- package/dist/chunks/semantic-agent-AC7CBEDE.js +6381 -0
- package/dist/chunks/semantic-agent-HK5X6CKU.js +6381 -0
- package/dist/chunks/semantic-agent-KONIKEGW.js +6381 -0
- package/dist/chunks/semantic-agent-LH6IZ2L7.js +137 -0
- package/dist/chunks/semantic-tool-handlers-5LMSH2U7.js +3 -0
- package/dist/chunks/semantic-tool-handlers-735UMO7Y.js +817 -0
- package/dist/chunks/semantic-tool-handlers-BNUYPP7X.js +817 -0
- package/dist/chunks/semantic-tool-handlers-MYZPEUD2.js +817 -0
- package/dist/chunks/snapshot-tool-handlers-6SIHZT2F.js +201 -0
- package/dist/chunks/snapshot-tool-handlers-DS4P3KOT.js +201 -0
- package/dist/chunks/snapshot-tool-handlers-JYHRFPC7.js +201 -0
- package/dist/chunks/snapshot-tool-handlers-YEHMAT3L.js +1 -0
- package/dist/chunks/storage-paths-A3C7WHHG.js +8 -0
- package/dist/chunks/storage-paths-HDYH7WPM.js +1 -0
- package/dist/chunks/storage-paths-IMFRHBWF.js +8 -0
- package/dist/chunks/storage-paths-P3PUSMUD.js +8 -0
- package/dist/chunks/taint-tool-handlers-CWESOOMQ.js +68 -0
- package/dist/chunks/taint-tool-handlers-OG3NVVP3.js +1 -0
- package/dist/chunks/taint-tool-handlers-ON3G3FA7.js +68 -0
- package/dist/chunks/taint-tool-handlers-P4P5J6DB.js +68 -0
- package/dist/chunks/tracing-tool-handlers-4BDCXTZZ.js +3935 -0
- package/dist/chunks/tracing-tool-handlers-6FPNM7HX.js +3935 -0
- package/dist/chunks/tracing-tool-handlers-LQTQ5SKK.js +89 -0
- package/dist/chunks/tracing-tool-handlers-XRQX2DTS.js +3935 -0
- package/dist/chunks/validation-tool-handlers-DZUG7KYY.js +2 -0
- package/dist/chunks/validation-tool-handlers-O6TGFSH5.js +555 -0
- package/dist/chunks/validation-tool-handlers-RREUYKIR.js +555 -0
- package/dist/chunks/validation-tool-handlers-XPWSMS37.js +555 -0
- package/dist/index.js +13 -13
- package/dist/roslyn-addon/.build-hash +1 -1
- package/dist/roslyn-addon/ILGPU.Algorithms.dll +0 -0
- package/dist/roslyn-addon/ILGPU.dll +0 -0
- package/dist/roslyn-addon/UltraCode.CSharp.deps.json +35 -0
- package/dist/roslyn-addon/UltraCode.CSharp.dll +0 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {a}from'./chunk-7YC4KTAW.js';import {b}from'./chunk-V5VLOVE7.js';import {d}from'./chunk-PY43JPWL.js';import'./chunk-RK5TLU72.js';import'./chunk-LESND2CW.js';import'./chunk-QUO46LUP.js';import'./chunk-3IFLFBQ4.js';import'./chunk-I6STSSAK.js';import'./chunk-SV3WKUNV.js';import'./chunk-PZF7YC35.js';import'./chunk-NWQZW3Y6.js';import {g,b as b$1}from'./chunk-KXUWGHHN.js';import'./chunk-2KIPXYOB.js';import'./chunk-OG62YNVF.js';import {R,I}from'./chunk-4BI7EBPQ.js';import'./chunk-F45ISXCP.js';import'./chunk-DXB73IDG.js';import f from'p-limit';g();R();var y=class extends b{storage=null;ttlCache=new Map;cacheTtlMs=3e4;concurrencyLimiter;stats={queries:0,totalMs:0,hits:0,misses:0};taskDispatch=new Map([["query:entities",t=>this.findEntities(t)],["query:relationships",t=>{let{entityId:e,type:i}=t;return this.findRelationships(e,i)}],["query:graph",t=>this.getGraph(t)],["query:dependencies",t=>this.analyzeDependencies(t.entityId)],["query:impact",t=>this.analyzeImpact(t.entityId)]]);constructor(){let e=b$1().queryAgent,i=e?.maxConcurrency??10;super("query",{maxConcurrency:i,memoryLimit:e?.memoryLimit??112,priority:e?.priority??9}),this.concurrencyLimiter=f(i);}async handleMessage(t){}async onInitialize(){I.i("QUERYAGENT","init_start",{id:this.id}),this.storage=await d(),a.subscribe(this.id,"graph:updated",()=>{I.d("QUERYAGENT","graph_updated",{id:this.id}),this.ttlCache.clear();}),a.subscribe(this.id,"index:complete",()=>{I.d("QUERYAGENT","index_complete",{id:this.id}),this.ttlCache.clear();}),I.i("QUERYAGENT","init_done",{id:this.id});}async onShutdown(){I.i("QUERYAGENT","shutdown_start",{id:this.id}),this.ttlCache.clear(),I.i("QUERYAGENT","shutdown_done",{id:this.id});}canProcessTask(t){return t.type.startsWith("query:")}async processTask(t){let e=Date.now();try{let i=this.taskDispatch.get(t.type);if(!i)throw new Error(`Unknown query type: ${t.type}`);let s=await this.concurrencyLimiter(()=>i(t.payload));return this.stats.queries++,this.stats.totalMs+=Date.now()-e,s}catch(i){throw I.e("QUERYAGENT","query_fail",{id:this.id,err:String(i)}),i}}cacheGet(t){let e=this.ttlCache.get(t);return e?Date.now()>e.expiry?(this.ttlCache.delete(t),null):e.value:null}cacheSet(t,e){this.ttlCache.set(t,{value:e,expiry:Date.now()+this.cacheTtlMs});}async findEntities(t){if(!this.storage)return [];let e=`entities:${JSON.stringify(t)}`,i=this.cacheGet(e);if(i)return this.stats.hits++,i;this.stats.misses++;let s=await this.storage.searchEntities({namePattern:typeof t.name=="string"?t.name:t.name?.source,types:Array.isArray(t.type)?t.type:t.type?[t.type]:void 0,filePath:Array.isArray(t.filePath)?t.filePath[0]:t.filePath,limit:100});return this.cacheSet(e,s),s}async findRelationships(t,e){if(!this.storage)return [];let i=`rels:${t}:${e??"all"}`,s=this.cacheGet(i);if(s)return this.stats.hits++,s;this.stats.misses++;let r=await this.storage.getRelationshipsForEntity(t,e);return this.cacheSet(i,r),r}async getGraph(t){if(!this.storage)return {entities:[],relationships:[]};let e=await this.storage.executeQuery(t);return {entities:e.entities,relationships:e.relationships}}async analyzeDependencies(t){if(!this.storage)return {root:t,children:[]};let e=await this.storage.getRelationshipsForEntity(t);return {root:t,children:e.filter(i=>i.fromId===t).map(i=>({root:i.toId,children:[]}))}}async analyzeImpact(t){if(!this.storage)return {source:t,directImpact:[],transitiveImpact:[],riskLevel:"low"};let i=(await this.storage.getRelationshipsForEntity(t)).filter(a=>a.toId===t).map(a=>a.fromId),s=[];for(let a of i){let u=await this.storage.getRelationshipsForEntity(a);for(let o of u)o.toId===a&&!i.includes(o.fromId)&&o.fromId!==t&&s.push(o.fromId);}let r=i.length+s.length,m=r>50?"critical":r>20?"high":r>5?"medium":"low";return {source:t,directImpact:i,transitiveImpact:s,riskLevel:m}}async findPaths(t,e,i){return []}async findCycles(t,e){return []}async analyzeHotspots(t){return []}async analyzeRippleEffects(t){return []}getQueryMetrics(){let{queries:t,totalMs:e,hits:i,misses:s}=this.stats,r=i+s;return {totalQueries:t,totalTime:e,cacheHits:i,cacheMisses:s,avgQueryTime:t>0?Math.round(e/t):0,cacheHitRate:r>0?Math.round(i/r*100):0}}};export{y as QueryAgent};
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { knowledgeBus } from './chunk-JPI46FLQ.js';
|
|
2
|
+
import { BaseAgent } from './chunk-IGUCJL3R.js';
|
|
3
|
+
import { getGraphStorage } from './chunk-J2WBGTK2.js';
|
|
4
|
+
import './chunk-HNDYLCWI.js';
|
|
5
|
+
import './chunk-CTXFPNDA.js';
|
|
6
|
+
import './chunk-TJSOOFXA.js';
|
|
7
|
+
import './chunk-AIZUHUK6.js';
|
|
8
|
+
import './chunk-YS75L3ZS.js';
|
|
9
|
+
import './chunk-XK2NY7RB.js';
|
|
10
|
+
import './chunk-HEMJHRHZ.js';
|
|
11
|
+
import './chunk-GMVGCSNU.js';
|
|
12
|
+
import { init_yaml_config, getConfig } from './chunk-XV6GNSLC.js';
|
|
13
|
+
import './chunk-F7CKCMXI.js';
|
|
14
|
+
import './chunk-BMHPPH2B.js';
|
|
15
|
+
import { init_logging, log } from './chunk-VCCBEJQ5.js';
|
|
16
|
+
import './chunk-UN27MREV.js';
|
|
17
|
+
import './chunk-NAQKA54E.js';
|
|
18
|
+
import pLimit from 'p-limit';
|
|
19
|
+
|
|
20
|
+
// src/agents/query-agent.ts
|
|
21
|
+
init_yaml_config();
|
|
22
|
+
init_logging();
|
|
23
|
+
var QueryAgent = class extends BaseAgent {
|
|
24
|
+
storage = null;
|
|
25
|
+
ttlCache = /* @__PURE__ */ new Map();
|
|
26
|
+
cacheTtlMs = 3e4;
|
|
27
|
+
concurrencyLimiter;
|
|
28
|
+
stats = { queries: 0, totalMs: 0, hits: 0, misses: 0 };
|
|
29
|
+
taskDispatch = /* @__PURE__ */ new Map([
|
|
30
|
+
["query:entities", (p) => this.findEntities(p)],
|
|
31
|
+
[
|
|
32
|
+
"query:relationships",
|
|
33
|
+
(p) => {
|
|
34
|
+
const { entityId, type } = p;
|
|
35
|
+
return this.findRelationships(entityId, type);
|
|
36
|
+
}
|
|
37
|
+
],
|
|
38
|
+
["query:graph", (p) => this.getGraph(p)],
|
|
39
|
+
["query:dependencies", (p) => this.analyzeDependencies(p.entityId)],
|
|
40
|
+
["query:impact", (p) => this.analyzeImpact(p.entityId)]
|
|
41
|
+
]);
|
|
42
|
+
constructor() {
|
|
43
|
+
const cfg = getConfig();
|
|
44
|
+
const qa = cfg.queryAgent;
|
|
45
|
+
const maxConcurrency = qa?.maxConcurrency ?? 10;
|
|
46
|
+
super("query" /* QUERY */, {
|
|
47
|
+
maxConcurrency,
|
|
48
|
+
memoryLimit: qa?.memoryLimit ?? 112,
|
|
49
|
+
priority: qa?.priority ?? 9
|
|
50
|
+
});
|
|
51
|
+
this.concurrencyLimiter = pLimit(maxConcurrency);
|
|
52
|
+
}
|
|
53
|
+
async handleMessage(_message) {
|
|
54
|
+
}
|
|
55
|
+
async onInitialize() {
|
|
56
|
+
log.i("QUERYAGENT", "init_start", { id: this.id });
|
|
57
|
+
this.storage = await getGraphStorage();
|
|
58
|
+
knowledgeBus.subscribe(this.id, "graph:updated", () => {
|
|
59
|
+
log.d("QUERYAGENT", "graph_updated", { id: this.id });
|
|
60
|
+
this.ttlCache.clear();
|
|
61
|
+
});
|
|
62
|
+
knowledgeBus.subscribe(this.id, "index:complete", () => {
|
|
63
|
+
log.d("QUERYAGENT", "index_complete", { id: this.id });
|
|
64
|
+
this.ttlCache.clear();
|
|
65
|
+
});
|
|
66
|
+
log.i("QUERYAGENT", "init_done", { id: this.id });
|
|
67
|
+
}
|
|
68
|
+
async onShutdown() {
|
|
69
|
+
log.i("QUERYAGENT", "shutdown_start", { id: this.id });
|
|
70
|
+
this.ttlCache.clear();
|
|
71
|
+
log.i("QUERYAGENT", "shutdown_done", { id: this.id });
|
|
72
|
+
}
|
|
73
|
+
canProcessTask(task) {
|
|
74
|
+
return task.type.startsWith("query:");
|
|
75
|
+
}
|
|
76
|
+
async processTask(task) {
|
|
77
|
+
const startTime = Date.now();
|
|
78
|
+
try {
|
|
79
|
+
const handler = this.taskDispatch.get(task.type);
|
|
80
|
+
if (!handler) throw new Error(`Unknown query type: ${task.type}`);
|
|
81
|
+
const result = await this.concurrencyLimiter(() => handler(task.payload));
|
|
82
|
+
this.stats.queries++;
|
|
83
|
+
this.stats.totalMs += Date.now() - startTime;
|
|
84
|
+
return result;
|
|
85
|
+
} catch (error) {
|
|
86
|
+
log.e("QUERYAGENT", "query_fail", { id: this.id, err: String(error) });
|
|
87
|
+
throw error;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
cacheGet(key) {
|
|
91
|
+
const entry = this.ttlCache.get(key);
|
|
92
|
+
if (!entry) return null;
|
|
93
|
+
if (Date.now() > entry.expiry) {
|
|
94
|
+
this.ttlCache.delete(key);
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
return entry.value;
|
|
98
|
+
}
|
|
99
|
+
cacheSet(key, value) {
|
|
100
|
+
this.ttlCache.set(key, { value, expiry: Date.now() + this.cacheTtlMs });
|
|
101
|
+
}
|
|
102
|
+
async findEntities(filter) {
|
|
103
|
+
if (!this.storage) return [];
|
|
104
|
+
const cacheKey = `entities:${JSON.stringify(filter)}`;
|
|
105
|
+
const cached = this.cacheGet(cacheKey);
|
|
106
|
+
if (cached) {
|
|
107
|
+
this.stats.hits++;
|
|
108
|
+
return cached;
|
|
109
|
+
}
|
|
110
|
+
this.stats.misses++;
|
|
111
|
+
const results = await this.storage.searchEntities({
|
|
112
|
+
namePattern: typeof filter.name === "string" ? filter.name : filter.name?.source,
|
|
113
|
+
types: Array.isArray(filter.type) ? filter.type : filter.type ? [filter.type] : void 0,
|
|
114
|
+
filePath: Array.isArray(filter.filePath) ? filter.filePath[0] : filter.filePath,
|
|
115
|
+
limit: 100
|
|
116
|
+
});
|
|
117
|
+
this.cacheSet(cacheKey, results);
|
|
118
|
+
return results;
|
|
119
|
+
}
|
|
120
|
+
async findRelationships(entityId, type) {
|
|
121
|
+
if (!this.storage) return [];
|
|
122
|
+
const cacheKey = `rels:${entityId}:${type ?? "all"}`;
|
|
123
|
+
const cached = this.cacheGet(cacheKey);
|
|
124
|
+
if (cached) {
|
|
125
|
+
this.stats.hits++;
|
|
126
|
+
return cached;
|
|
127
|
+
}
|
|
128
|
+
this.stats.misses++;
|
|
129
|
+
const results = await this.storage.getRelationshipsForEntity(entityId, type);
|
|
130
|
+
this.cacheSet(cacheKey, results);
|
|
131
|
+
return results;
|
|
132
|
+
}
|
|
133
|
+
async getGraph(query) {
|
|
134
|
+
if (!this.storage) return { entities: [], relationships: [] };
|
|
135
|
+
const result = await this.storage.executeQuery(query);
|
|
136
|
+
return { entities: result.entities, relationships: result.relationships };
|
|
137
|
+
}
|
|
138
|
+
async analyzeDependencies(entityId) {
|
|
139
|
+
if (!this.storage) return { root: entityId, children: [] };
|
|
140
|
+
const rels = await this.storage.getRelationshipsForEntity(entityId);
|
|
141
|
+
return {
|
|
142
|
+
root: entityId,
|
|
143
|
+
children: rels.filter((r) => r.fromId === entityId).map((r) => ({ root: r.toId, children: [] }))
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
async analyzeImpact(entityId) {
|
|
147
|
+
if (!this.storage) return { source: entityId, directImpact: [], transitiveImpact: [], riskLevel: "low" };
|
|
148
|
+
const rels = await this.storage.getRelationshipsForEntity(entityId);
|
|
149
|
+
const directImpact = rels.filter((r) => r.toId === entityId).map((r) => r.fromId);
|
|
150
|
+
const transitiveImpact = [];
|
|
151
|
+
for (const id of directImpact) {
|
|
152
|
+
const tRels = await this.storage.getRelationshipsForEntity(id);
|
|
153
|
+
for (const r of tRels) {
|
|
154
|
+
if (r.toId === id && !directImpact.includes(r.fromId) && r.fromId !== entityId) {
|
|
155
|
+
transitiveImpact.push(r.fromId);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
const total = directImpact.length + transitiveImpact.length;
|
|
160
|
+
const riskLevel = total > 50 ? "critical" : total > 20 ? "high" : total > 5 ? "medium" : "low";
|
|
161
|
+
return { source: entityId, directImpact, transitiveImpact, riskLevel };
|
|
162
|
+
}
|
|
163
|
+
async findPaths(_source, _target, _maxDepth) {
|
|
164
|
+
return [];
|
|
165
|
+
}
|
|
166
|
+
async findCycles(_entityId, _maxDepth) {
|
|
167
|
+
return [];
|
|
168
|
+
}
|
|
169
|
+
async analyzeHotspots(_filter) {
|
|
170
|
+
return [];
|
|
171
|
+
}
|
|
172
|
+
async analyzeRippleEffects(_changeSet) {
|
|
173
|
+
return [];
|
|
174
|
+
}
|
|
175
|
+
getQueryMetrics() {
|
|
176
|
+
const { queries, totalMs, hits, misses } = this.stats;
|
|
177
|
+
const total = hits + misses;
|
|
178
|
+
return {
|
|
179
|
+
totalQueries: queries,
|
|
180
|
+
totalTime: totalMs,
|
|
181
|
+
cacheHits: hits,
|
|
182
|
+
cacheMisses: misses,
|
|
183
|
+
avgQueryTime: queries > 0 ? Math.round(totalMs / queries) : 0,
|
|
184
|
+
cacheHitRate: total > 0 ? Math.round(hits / total * 100) : 0
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
export { QueryAgent };
|
|
190
|
+
//# sourceMappingURL=query-agent-H22CR5N5.js.map
|
|
191
|
+
//# sourceMappingURL=query-agent-H22CR5N5.js.map
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { knowledgeBus } from './chunk-JPI46FLQ.js';
|
|
2
|
+
import { BaseAgent } from './chunk-IGUCJL3R.js';
|
|
3
|
+
import { getGraphStorage } from './chunk-Y4F7NZFZ.js';
|
|
4
|
+
import './chunk-HNDYLCWI.js';
|
|
5
|
+
import './chunk-CTXFPNDA.js';
|
|
6
|
+
import './chunk-TJSOOFXA.js';
|
|
7
|
+
import './chunk-AIZUHUK6.js';
|
|
8
|
+
import './chunk-O6IE2MEZ.js';
|
|
9
|
+
import './chunk-LH4OUKNZ.js';
|
|
10
|
+
import './chunk-HEMJHRHZ.js';
|
|
11
|
+
import './chunk-GMVGCSNU.js';
|
|
12
|
+
import { init_yaml_config, getConfig } from './chunk-XV6GNSLC.js';
|
|
13
|
+
import './chunk-F7CKCMXI.js';
|
|
14
|
+
import './chunk-BMHPPH2B.js';
|
|
15
|
+
import { init_logging, log } from './chunk-VCCBEJQ5.js';
|
|
16
|
+
import './chunk-UN27MREV.js';
|
|
17
|
+
import './chunk-NAQKA54E.js';
|
|
18
|
+
import pLimit from 'p-limit';
|
|
19
|
+
|
|
20
|
+
// src/agents/query-agent.ts
|
|
21
|
+
init_yaml_config();
|
|
22
|
+
init_logging();
|
|
23
|
+
var QueryAgent = class extends BaseAgent {
|
|
24
|
+
storage = null;
|
|
25
|
+
ttlCache = /* @__PURE__ */ new Map();
|
|
26
|
+
cacheTtlMs = 3e4;
|
|
27
|
+
concurrencyLimiter;
|
|
28
|
+
stats = { queries: 0, totalMs: 0, hits: 0, misses: 0 };
|
|
29
|
+
taskDispatch = /* @__PURE__ */ new Map([
|
|
30
|
+
["query:entities", (p) => this.findEntities(p)],
|
|
31
|
+
[
|
|
32
|
+
"query:relationships",
|
|
33
|
+
(p) => {
|
|
34
|
+
const { entityId, type } = p;
|
|
35
|
+
return this.findRelationships(entityId, type);
|
|
36
|
+
}
|
|
37
|
+
],
|
|
38
|
+
["query:graph", (p) => this.getGraph(p)],
|
|
39
|
+
["query:dependencies", (p) => this.analyzeDependencies(p.entityId)],
|
|
40
|
+
["query:impact", (p) => this.analyzeImpact(p.entityId)]
|
|
41
|
+
]);
|
|
42
|
+
constructor() {
|
|
43
|
+
const cfg = getConfig();
|
|
44
|
+
const qa = cfg.queryAgent;
|
|
45
|
+
const maxConcurrency = qa?.maxConcurrency ?? 10;
|
|
46
|
+
super("query" /* QUERY */, {
|
|
47
|
+
maxConcurrency,
|
|
48
|
+
memoryLimit: qa?.memoryLimit ?? 112,
|
|
49
|
+
priority: qa?.priority ?? 9
|
|
50
|
+
});
|
|
51
|
+
this.concurrencyLimiter = pLimit(maxConcurrency);
|
|
52
|
+
}
|
|
53
|
+
async handleMessage(_message) {
|
|
54
|
+
}
|
|
55
|
+
async onInitialize() {
|
|
56
|
+
log.i("QUERYAGENT", "init_start", { id: this.id });
|
|
57
|
+
this.storage = await getGraphStorage();
|
|
58
|
+
knowledgeBus.subscribe(this.id, "graph:updated", () => {
|
|
59
|
+
log.d("QUERYAGENT", "graph_updated", { id: this.id });
|
|
60
|
+
this.ttlCache.clear();
|
|
61
|
+
});
|
|
62
|
+
knowledgeBus.subscribe(this.id, "index:complete", () => {
|
|
63
|
+
log.d("QUERYAGENT", "index_complete", { id: this.id });
|
|
64
|
+
this.ttlCache.clear();
|
|
65
|
+
});
|
|
66
|
+
log.i("QUERYAGENT", "init_done", { id: this.id });
|
|
67
|
+
}
|
|
68
|
+
async onShutdown() {
|
|
69
|
+
log.i("QUERYAGENT", "shutdown_start", { id: this.id });
|
|
70
|
+
this.ttlCache.clear();
|
|
71
|
+
log.i("QUERYAGENT", "shutdown_done", { id: this.id });
|
|
72
|
+
}
|
|
73
|
+
canProcessTask(task) {
|
|
74
|
+
return task.type.startsWith("query:");
|
|
75
|
+
}
|
|
76
|
+
async processTask(task) {
|
|
77
|
+
const startTime = Date.now();
|
|
78
|
+
try {
|
|
79
|
+
const handler = this.taskDispatch.get(task.type);
|
|
80
|
+
if (!handler) throw new Error(`Unknown query type: ${task.type}`);
|
|
81
|
+
const result = await this.concurrencyLimiter(() => handler(task.payload));
|
|
82
|
+
this.stats.queries++;
|
|
83
|
+
this.stats.totalMs += Date.now() - startTime;
|
|
84
|
+
return result;
|
|
85
|
+
} catch (error) {
|
|
86
|
+
log.e("QUERYAGENT", "query_fail", { id: this.id, err: String(error) });
|
|
87
|
+
throw error;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
cacheGet(key) {
|
|
91
|
+
const entry = this.ttlCache.get(key);
|
|
92
|
+
if (!entry) return null;
|
|
93
|
+
if (Date.now() > entry.expiry) {
|
|
94
|
+
this.ttlCache.delete(key);
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
return entry.value;
|
|
98
|
+
}
|
|
99
|
+
cacheSet(key, value) {
|
|
100
|
+
this.ttlCache.set(key, { value, expiry: Date.now() + this.cacheTtlMs });
|
|
101
|
+
}
|
|
102
|
+
async findEntities(filter) {
|
|
103
|
+
if (!this.storage) return [];
|
|
104
|
+
const cacheKey = `entities:${JSON.stringify(filter)}`;
|
|
105
|
+
const cached = this.cacheGet(cacheKey);
|
|
106
|
+
if (cached) {
|
|
107
|
+
this.stats.hits++;
|
|
108
|
+
return cached;
|
|
109
|
+
}
|
|
110
|
+
this.stats.misses++;
|
|
111
|
+
const results = await this.storage.searchEntities({
|
|
112
|
+
namePattern: typeof filter.name === "string" ? filter.name : filter.name?.source,
|
|
113
|
+
types: Array.isArray(filter.type) ? filter.type : filter.type ? [filter.type] : void 0,
|
|
114
|
+
filePath: Array.isArray(filter.filePath) ? filter.filePath[0] : filter.filePath,
|
|
115
|
+
limit: 100
|
|
116
|
+
});
|
|
117
|
+
this.cacheSet(cacheKey, results);
|
|
118
|
+
return results;
|
|
119
|
+
}
|
|
120
|
+
async findRelationships(entityId, type) {
|
|
121
|
+
if (!this.storage) return [];
|
|
122
|
+
const cacheKey = `rels:${entityId}:${type ?? "all"}`;
|
|
123
|
+
const cached = this.cacheGet(cacheKey);
|
|
124
|
+
if (cached) {
|
|
125
|
+
this.stats.hits++;
|
|
126
|
+
return cached;
|
|
127
|
+
}
|
|
128
|
+
this.stats.misses++;
|
|
129
|
+
const results = await this.storage.getRelationshipsForEntity(entityId, type);
|
|
130
|
+
this.cacheSet(cacheKey, results);
|
|
131
|
+
return results;
|
|
132
|
+
}
|
|
133
|
+
async getGraph(query) {
|
|
134
|
+
if (!this.storage) return { entities: [], relationships: [] };
|
|
135
|
+
const result = await this.storage.executeQuery(query);
|
|
136
|
+
return { entities: result.entities, relationships: result.relationships };
|
|
137
|
+
}
|
|
138
|
+
async analyzeDependencies(entityId) {
|
|
139
|
+
if (!this.storage) return { root: entityId, children: [] };
|
|
140
|
+
const rels = await this.storage.getRelationshipsForEntity(entityId);
|
|
141
|
+
return {
|
|
142
|
+
root: entityId,
|
|
143
|
+
children: rels.filter((r) => r.fromId === entityId).map((r) => ({ root: r.toId, children: [] }))
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
async analyzeImpact(entityId) {
|
|
147
|
+
if (!this.storage) return { source: entityId, directImpact: [], transitiveImpact: [], riskLevel: "low" };
|
|
148
|
+
const rels = await this.storage.getRelationshipsForEntity(entityId);
|
|
149
|
+
const directImpact = rels.filter((r) => r.toId === entityId).map((r) => r.fromId);
|
|
150
|
+
const transitiveImpact = [];
|
|
151
|
+
for (const id of directImpact) {
|
|
152
|
+
const tRels = await this.storage.getRelationshipsForEntity(id);
|
|
153
|
+
for (const r of tRels) {
|
|
154
|
+
if (r.toId === id && !directImpact.includes(r.fromId) && r.fromId !== entityId) {
|
|
155
|
+
transitiveImpact.push(r.fromId);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
const total = directImpact.length + transitiveImpact.length;
|
|
160
|
+
const riskLevel = total > 50 ? "critical" : total > 20 ? "high" : total > 5 ? "medium" : "low";
|
|
161
|
+
return { source: entityId, directImpact, transitiveImpact, riskLevel };
|
|
162
|
+
}
|
|
163
|
+
async findPaths(_source, _target, _maxDepth) {
|
|
164
|
+
return [];
|
|
165
|
+
}
|
|
166
|
+
async findCycles(_entityId, _maxDepth) {
|
|
167
|
+
return [];
|
|
168
|
+
}
|
|
169
|
+
async analyzeHotspots(_filter) {
|
|
170
|
+
return [];
|
|
171
|
+
}
|
|
172
|
+
async analyzeRippleEffects(_changeSet) {
|
|
173
|
+
return [];
|
|
174
|
+
}
|
|
175
|
+
getQueryMetrics() {
|
|
176
|
+
const { queries, totalMs, hits, misses } = this.stats;
|
|
177
|
+
const total = hits + misses;
|
|
178
|
+
return {
|
|
179
|
+
totalQueries: queries,
|
|
180
|
+
totalTime: totalMs,
|
|
181
|
+
cacheHits: hits,
|
|
182
|
+
cacheMisses: misses,
|
|
183
|
+
avgQueryTime: queries > 0 ? Math.round(totalMs / queries) : 0,
|
|
184
|
+
cacheHitRate: total > 0 ? Math.round(hits / total * 100) : 0
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
export { QueryAgent };
|
|
190
|
+
//# sourceMappingURL=query-agent-K2UGZS4M.js.map
|
|
191
|
+
//# sourceMappingURL=query-agent-K2UGZS4M.js.map
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { knowledgeBus } from './chunk-JPI46FLQ.js';
|
|
2
|
+
import { BaseAgent } from './chunk-IGUCJL3R.js';
|
|
3
|
+
import { getGraphStorage } from './chunk-KAYOX5EB.js';
|
|
4
|
+
import './chunk-HNDYLCWI.js';
|
|
5
|
+
import './chunk-CTXFPNDA.js';
|
|
6
|
+
import './chunk-TJSOOFXA.js';
|
|
7
|
+
import './chunk-AIZUHUK6.js';
|
|
8
|
+
import './chunk-G6J42I55.js';
|
|
9
|
+
import './chunk-TVOTA7EE.js';
|
|
10
|
+
import './chunk-HEMJHRHZ.js';
|
|
11
|
+
import './chunk-GMVGCSNU.js';
|
|
12
|
+
import { init_yaml_config, getConfig } from './chunk-XV6GNSLC.js';
|
|
13
|
+
import './chunk-F7CKCMXI.js';
|
|
14
|
+
import './chunk-BMHPPH2B.js';
|
|
15
|
+
import { init_logging, log } from './chunk-VCCBEJQ5.js';
|
|
16
|
+
import './chunk-UN27MREV.js';
|
|
17
|
+
import './chunk-NAQKA54E.js';
|
|
18
|
+
import pLimit from 'p-limit';
|
|
19
|
+
|
|
20
|
+
// src/agents/query-agent.ts
|
|
21
|
+
init_yaml_config();
|
|
22
|
+
init_logging();
|
|
23
|
+
var QueryAgent = class extends BaseAgent {
|
|
24
|
+
storage = null;
|
|
25
|
+
ttlCache = /* @__PURE__ */ new Map();
|
|
26
|
+
cacheTtlMs = 3e4;
|
|
27
|
+
concurrencyLimiter;
|
|
28
|
+
stats = { queries: 0, totalMs: 0, hits: 0, misses: 0 };
|
|
29
|
+
taskDispatch = /* @__PURE__ */ new Map([
|
|
30
|
+
["query:entities", (p) => this.findEntities(p)],
|
|
31
|
+
[
|
|
32
|
+
"query:relationships",
|
|
33
|
+
(p) => {
|
|
34
|
+
const { entityId, type } = p;
|
|
35
|
+
return this.findRelationships(entityId, type);
|
|
36
|
+
}
|
|
37
|
+
],
|
|
38
|
+
["query:graph", (p) => this.getGraph(p)],
|
|
39
|
+
["query:dependencies", (p) => this.analyzeDependencies(p.entityId)],
|
|
40
|
+
["query:impact", (p) => this.analyzeImpact(p.entityId)]
|
|
41
|
+
]);
|
|
42
|
+
constructor() {
|
|
43
|
+
const cfg = getConfig();
|
|
44
|
+
const qa = cfg.queryAgent;
|
|
45
|
+
const maxConcurrency = qa?.maxConcurrency ?? 10;
|
|
46
|
+
super("query" /* QUERY */, {
|
|
47
|
+
maxConcurrency,
|
|
48
|
+
memoryLimit: qa?.memoryLimit ?? 112,
|
|
49
|
+
priority: qa?.priority ?? 9
|
|
50
|
+
});
|
|
51
|
+
this.concurrencyLimiter = pLimit(maxConcurrency);
|
|
52
|
+
}
|
|
53
|
+
async handleMessage(_message) {
|
|
54
|
+
}
|
|
55
|
+
async onInitialize() {
|
|
56
|
+
log.i("QUERYAGENT", "init_start", { id: this.id });
|
|
57
|
+
this.storage = await getGraphStorage();
|
|
58
|
+
knowledgeBus.subscribe(this.id, "graph:updated", () => {
|
|
59
|
+
log.d("QUERYAGENT", "graph_updated", { id: this.id });
|
|
60
|
+
this.ttlCache.clear();
|
|
61
|
+
});
|
|
62
|
+
knowledgeBus.subscribe(this.id, "index:complete", () => {
|
|
63
|
+
log.d("QUERYAGENT", "index_complete", { id: this.id });
|
|
64
|
+
this.ttlCache.clear();
|
|
65
|
+
});
|
|
66
|
+
log.i("QUERYAGENT", "init_done", { id: this.id });
|
|
67
|
+
}
|
|
68
|
+
async onShutdown() {
|
|
69
|
+
log.i("QUERYAGENT", "shutdown_start", { id: this.id });
|
|
70
|
+
this.ttlCache.clear();
|
|
71
|
+
log.i("QUERYAGENT", "shutdown_done", { id: this.id });
|
|
72
|
+
}
|
|
73
|
+
canProcessTask(task) {
|
|
74
|
+
return task.type.startsWith("query:");
|
|
75
|
+
}
|
|
76
|
+
async processTask(task) {
|
|
77
|
+
const startTime = Date.now();
|
|
78
|
+
try {
|
|
79
|
+
const handler = this.taskDispatch.get(task.type);
|
|
80
|
+
if (!handler) throw new Error(`Unknown query type: ${task.type}`);
|
|
81
|
+
const result = await this.concurrencyLimiter(() => handler(task.payload));
|
|
82
|
+
this.stats.queries++;
|
|
83
|
+
this.stats.totalMs += Date.now() - startTime;
|
|
84
|
+
return result;
|
|
85
|
+
} catch (error) {
|
|
86
|
+
log.e("QUERYAGENT", "query_fail", { id: this.id, err: String(error) });
|
|
87
|
+
throw error;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
cacheGet(key) {
|
|
91
|
+
const entry = this.ttlCache.get(key);
|
|
92
|
+
if (!entry) return null;
|
|
93
|
+
if (Date.now() > entry.expiry) {
|
|
94
|
+
this.ttlCache.delete(key);
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
return entry.value;
|
|
98
|
+
}
|
|
99
|
+
cacheSet(key, value) {
|
|
100
|
+
this.ttlCache.set(key, { value, expiry: Date.now() + this.cacheTtlMs });
|
|
101
|
+
}
|
|
102
|
+
async findEntities(filter) {
|
|
103
|
+
if (!this.storage) return [];
|
|
104
|
+
const cacheKey = `entities:${JSON.stringify(filter)}`;
|
|
105
|
+
const cached = this.cacheGet(cacheKey);
|
|
106
|
+
if (cached) {
|
|
107
|
+
this.stats.hits++;
|
|
108
|
+
return cached;
|
|
109
|
+
}
|
|
110
|
+
this.stats.misses++;
|
|
111
|
+
const results = await this.storage.searchEntities({
|
|
112
|
+
namePattern: typeof filter.name === "string" ? filter.name : filter.name?.source,
|
|
113
|
+
types: Array.isArray(filter.type) ? filter.type : filter.type ? [filter.type] : void 0,
|
|
114
|
+
filePath: Array.isArray(filter.filePath) ? filter.filePath[0] : filter.filePath,
|
|
115
|
+
limit: 100
|
|
116
|
+
});
|
|
117
|
+
this.cacheSet(cacheKey, results);
|
|
118
|
+
return results;
|
|
119
|
+
}
|
|
120
|
+
async findRelationships(entityId, type) {
|
|
121
|
+
if (!this.storage) return [];
|
|
122
|
+
const cacheKey = `rels:${entityId}:${type ?? "all"}`;
|
|
123
|
+
const cached = this.cacheGet(cacheKey);
|
|
124
|
+
if (cached) {
|
|
125
|
+
this.stats.hits++;
|
|
126
|
+
return cached;
|
|
127
|
+
}
|
|
128
|
+
this.stats.misses++;
|
|
129
|
+
const results = await this.storage.getRelationshipsForEntity(entityId, type);
|
|
130
|
+
this.cacheSet(cacheKey, results);
|
|
131
|
+
return results;
|
|
132
|
+
}
|
|
133
|
+
async getGraph(query) {
|
|
134
|
+
if (!this.storage) return { entities: [], relationships: [] };
|
|
135
|
+
const result = await this.storage.executeQuery(query);
|
|
136
|
+
return { entities: result.entities, relationships: result.relationships };
|
|
137
|
+
}
|
|
138
|
+
async analyzeDependencies(entityId) {
|
|
139
|
+
if (!this.storage) return { root: entityId, children: [] };
|
|
140
|
+
const rels = await this.storage.getRelationshipsForEntity(entityId);
|
|
141
|
+
return {
|
|
142
|
+
root: entityId,
|
|
143
|
+
children: rels.filter((r) => r.fromId === entityId).map((r) => ({ root: r.toId, children: [] }))
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
async analyzeImpact(entityId) {
|
|
147
|
+
if (!this.storage) return { source: entityId, directImpact: [], transitiveImpact: [], riskLevel: "low" };
|
|
148
|
+
const rels = await this.storage.getRelationshipsForEntity(entityId);
|
|
149
|
+
const directImpact = rels.filter((r) => r.toId === entityId).map((r) => r.fromId);
|
|
150
|
+
const transitiveImpact = [];
|
|
151
|
+
for (const id of directImpact) {
|
|
152
|
+
const tRels = await this.storage.getRelationshipsForEntity(id);
|
|
153
|
+
for (const r of tRels) {
|
|
154
|
+
if (r.toId === id && !directImpact.includes(r.fromId) && r.fromId !== entityId) {
|
|
155
|
+
transitiveImpact.push(r.fromId);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
const total = directImpact.length + transitiveImpact.length;
|
|
160
|
+
const riskLevel = total > 50 ? "critical" : total > 20 ? "high" : total > 5 ? "medium" : "low";
|
|
161
|
+
return { source: entityId, directImpact, transitiveImpact, riskLevel };
|
|
162
|
+
}
|
|
163
|
+
async findPaths(_source, _target, _maxDepth) {
|
|
164
|
+
return [];
|
|
165
|
+
}
|
|
166
|
+
async findCycles(_entityId, _maxDepth) {
|
|
167
|
+
return [];
|
|
168
|
+
}
|
|
169
|
+
async analyzeHotspots(_filter) {
|
|
170
|
+
return [];
|
|
171
|
+
}
|
|
172
|
+
async analyzeRippleEffects(_changeSet) {
|
|
173
|
+
return [];
|
|
174
|
+
}
|
|
175
|
+
getQueryMetrics() {
|
|
176
|
+
const { queries, totalMs, hits, misses } = this.stats;
|
|
177
|
+
const total = hits + misses;
|
|
178
|
+
return {
|
|
179
|
+
totalQueries: queries,
|
|
180
|
+
totalTime: totalMs,
|
|
181
|
+
cacheHits: hits,
|
|
182
|
+
cacheMisses: misses,
|
|
183
|
+
avgQueryTime: queries > 0 ? Math.round(totalMs / queries) : 0,
|
|
184
|
+
cacheHitRate: total > 0 ? Math.round(hits / total * 100) : 0
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
export { QueryAgent };
|
|
190
|
+
//# sourceMappingURL=query-agent-YJCEHOXD.js.map
|
|
191
|
+
//# sourceMappingURL=query-agent-YJCEHOXD.js.map
|