wyrm-mcp 7.2.0 → 7.2.2
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 +26 -667
- package/NOTICE +14 -33
- package/dist/activation.d.ts.map +1 -1
- package/dist/activation.js +1 -44
- package/dist/activation.js.map +1 -1
- package/dist/agent-daemon.js +4 -281
- package/dist/agent-loop.js +7 -332
- package/dist/analytics.js +13 -236
- package/dist/attribution.js +1 -49
- package/dist/audit.js +2 -457
- package/dist/auto-capture.js +3 -138
- package/dist/auto-orchestrator.js +1 -325
- package/dist/autoconfig.js +39 -840
- package/dist/buddy-runner.js +1 -109
- package/dist/buddy.js +14 -564
- package/dist/build-flags.js +1 -17
- package/dist/capabilities.js +3 -183
- package/dist/capture.js +1 -56
- package/dist/causality.js +6 -107
- package/dist/cli.js +20 -281
- package/dist/cloud/cli.js +5 -541
- package/dist/cloud/client.js +1 -221
- package/dist/cloud/crypto.js +1 -85
- package/dist/cloud/machine-id.js +2 -113
- package/dist/cloud/recovery.js +1 -60
- package/dist/cloud/sync-engine.js +7 -543
- package/dist/cloud-backup.js +5 -579
- package/dist/cloud-profile.js +1 -138
- package/dist/cloud-sync-entrypoint.js +1 -47
- package/dist/cloud-sync.js +2 -309
- package/dist/constellation.js +12 -168
- package/dist/context-build-budgeted.js +4 -144
- package/dist/context-ranking.js +1 -69
- package/dist/crypto.js +1 -179
- package/dist/daemon-write-endpoint.js +1 -290
- package/dist/daemon-writer.js +2 -406
- package/dist/database.js +43 -1110
- package/dist/deprecations.js +2 -162
- package/dist/design.js +13 -141
- package/dist/event-replication.js +1 -112
- package/dist/events-sse.js +7 -43
- package/dist/events.js +6 -238
- package/dist/failure-patterns.js +42 -659
- package/dist/federation.js +12 -236
- package/dist/goals.js +13 -101
- package/dist/golden.js +3 -355
- package/dist/handlers/agent.js +4 -165
- package/dist/handlers/alias-adapters.js +1 -129
- package/dist/handlers/aliases.js +1 -171
- package/dist/handlers/audit.js +1 -87
- package/dist/handlers/boundary.js +1 -221
- package/dist/handlers/capture.js +73 -1109
- package/dist/handlers/causality.js +7 -114
- package/dist/handlers/cloud.js +85 -382
- package/dist/handlers/companion.js +28 -459
- package/dist/handlers/datalake.js +7 -187
- package/dist/handlers/dispatch-context.js +0 -22
- package/dist/handlers/entity.js +25 -256
- package/dist/handlers/events.js +16 -335
- package/dist/handlers/failure.js +13 -340
- package/dist/handlers/goals.js +4 -296
- package/dist/handlers/intelligence.js +126 -674
- package/dist/handlers/invoicing.js +1 -70
- package/dist/handlers/mcpclient.js +6 -137
- package/dist/handlers/orchestration.js +40 -125
- package/dist/handlers/output-schemas.js +1 -24
- package/dist/handlers/presence.js +3 -99
- package/dist/handlers/project.js +28 -182
- package/dist/handlers/prompts.js +6 -157
- package/dist/handlers/quest.js +4 -224
- package/dist/handlers/recall.js +11 -218
- package/dist/handlers/registry.js +1 -167
- package/dist/handlers/resources.js +1 -288
- package/dist/handlers/review.js +11 -74
- package/dist/handlers/run.js +17 -487
- package/dist/handlers/search.js +15 -326
- package/dist/handlers/session.js +28 -615
- package/dist/handlers/share.js +8 -184
- package/dist/handlers/shims.js +1 -464
- package/dist/handlers/skill.js +67 -449
- package/dist/handlers/survivors.js +1 -120
- package/dist/handlers/symbols.js +8 -109
- package/dist/handlers/syncops.js +4 -302
- package/dist/handlers/types.js +1 -27
- package/dist/harvest.js +5 -191
- package/dist/hours.js +7 -156
- package/dist/http-auth.js +3 -321
- package/dist/http-fast.js +21 -1137
- package/dist/icons.js +1 -47
- package/dist/index.js +2 -924
- package/dist/indexer.js +4 -145
- package/dist/intelligence.js +31 -261
- package/dist/internal-dispatch.js +3 -212
- package/dist/keyset.js +1 -110
- package/dist/knowledge-graph.js +12 -176
- package/dist/license.d.ts +11 -0
- package/dist/license.d.ts.map +1 -1
- package/dist/license.js +2 -414
- package/dist/license.js.map +1 -1
- package/dist/logger.js +2 -199
- package/dist/maintenance.js +2 -148
- package/dist/mcp-client.js +6 -262
- package/dist/memory-artifacts.js +30 -449
- package/dist/migrate-prompt.js +2 -124
- package/dist/migrations.js +40 -655
- package/dist/performance.js +1 -228
- package/dist/presence.js +11 -140
- package/dist/priority-embed.js +5 -164
- package/dist/providers/embedding-provider.js +1 -196
- package/dist/readonly-gate.js +1 -29
- package/dist/rehydration.js +9 -157
- package/dist/reindex.js +1 -88
- package/dist/render-target.js +21 -514
- package/dist/render.js +4 -280
- package/dist/repl-guard.js +1 -173
- package/dist/replication-daemon-entrypoint.js +1 -31
- package/dist/replication-daemon.js +2 -262
- package/dist/resilience.js +1 -591
- package/dist/reverse-bridge.js +5 -360
- package/dist/security.js +1 -244
- package/dist/session-seen.js +3 -51
- package/dist/setup.js +1 -260
- package/dist/skill-author.js +5 -168
- package/dist/spec-kit.js +1 -191
- package/dist/sqlite-busy.js +1 -154
- package/dist/statusline.js +11 -315
- package/dist/sub-agent.js +13 -262
- package/dist/summarizer.js +13 -139
- package/dist/symbols.js +7 -283
- package/dist/sync.js +5 -359
- package/dist/tasks-dispatch.js +1 -84
- package/dist/tasks.js +1 -282
- package/dist/token-budget.js +1 -143
- package/dist/tool-analytics.js +7 -129
- package/dist/tool-annotations.js +1 -365
- package/dist/tool-manifest-v2.json +1 -1
- package/dist/tool-manifest.json +1 -1
- package/dist/tool-profiles.js +1 -75
- package/dist/trace-harvest.js +6 -244
- package/dist/types.js +1 -30
- package/dist/ui-dashboard.js +41 -50
- package/dist/ulid.js +1 -81
- package/dist/validate.js +1 -129
- package/dist/vault.js +1 -534
- package/dist/vectors.js +3 -184
- package/dist/version-check.js +4 -136
- package/dist/visibility.js +19 -155
- package/dist/wyrm-cli.js +98 -2451
- package/dist/wyrm-cli.js.map +1 -1
- package/dist/wyrm-guard.js +14 -424
- package/dist/wyrm-loop.js +3 -150
- package/dist/wyrm-manifest.json +1 -1
- package/dist/wyrm-statusline-daemon.js +1 -11
- package/dist/wyrm-statusline.js +4 -56
- package/dist/wyrm-ui.js +9 -77
- package/package.json +4 -2
|
@@ -1,187 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import { cache } from "../performance.js";
|
|
9
|
-
import { sanitizeFtsQuery, sanitizeString, validateBatchSize } from "../security.js";
|
|
10
|
-
export const datalakeToolSpecs = [
|
|
11
|
-
{
|
|
12
|
-
name: "wyrm_data_insert",
|
|
13
|
-
description: "Insert data into the data lake for a project",
|
|
14
|
-
inputSchema: {
|
|
15
|
-
type: "object",
|
|
16
|
-
properties: {
|
|
17
|
-
projectPath: { type: "string", description: "Project path" },
|
|
18
|
-
category: { type: "string", description: "Data category (e.g., 'logs', 'metrics', 'artifacts')" },
|
|
19
|
-
key: { type: "string", description: "Data key/identifier" },
|
|
20
|
-
value: { type: "string", description: "Data value (can be JSON string)" },
|
|
21
|
-
metadata: { type: "object", description: "Optional metadata object" },
|
|
22
|
-
},
|
|
23
|
-
required: ["projectPath", "category", "key", "value"],
|
|
24
|
-
},
|
|
25
|
-
annotations: TOOL_ANNOTATIONS["wyrm_data_insert"],
|
|
26
|
-
aliases: [],
|
|
27
|
-
handler: async (args, ctx) => {
|
|
28
|
-
const { db, vectorStore, wyrmCrypto } = ctx;
|
|
29
|
-
const a = args || {};
|
|
30
|
-
const requireArgs = (fields) => {
|
|
31
|
-
const missing = fields.filter(f => !a[f] && a[f] !== 0 && a[f] !== false);
|
|
32
|
-
if (missing.length > 0) {
|
|
33
|
-
return { content: [{ type: "text", text: `Missing required arguments: ${missing.join(', ')}` }], isError: true };
|
|
34
|
-
}
|
|
35
|
-
return null;
|
|
36
|
-
};
|
|
37
|
-
const argErr = requireArgs(['projectPath', 'category', 'key', 'value']);
|
|
38
|
-
if (argErr)
|
|
39
|
-
return argErr;
|
|
40
|
-
const { projectPath, category, key, value, metadata } = args;
|
|
41
|
-
const project = db.getProject(projectPath);
|
|
42
|
-
if (!project) {
|
|
43
|
-
return { content: [{ type: "text", text: "Project not found" }] };
|
|
44
|
-
}
|
|
45
|
-
const sanitizedCategory = sanitizeString(category, 200);
|
|
46
|
-
const sanitizedKey = sanitizeString(key, 500);
|
|
47
|
-
const sanitizedValue = sanitizeString(value);
|
|
48
|
-
const encryptedValue = wyrmCrypto.maybeEncrypt(sanitizedValue);
|
|
49
|
-
// v7 F2 (T012): canonical write seam — sanitize + encrypt stay
|
|
50
|
-
// CLIENT-side (the daemon never needs WYRM_ENCRYPTION_KEY); only the
|
|
51
|
-
// final prepared row crosses the loopback hop. Direct path unchanged.
|
|
52
|
-
// The idempotency identity is the PLAINTEXT tuple: encrypt() salts +
|
|
53
|
-
// IVs per call, so the ciphertext differs on every invocation and can
|
|
54
|
-
// never key the caller-level retry contract (the breadcrumb's stored
|
|
55
|
-
// bytes make the retry re-send the ORIGINAL ciphertext).
|
|
56
|
-
const dataPoint = await daemonOr('data_insert', project.id, { category: sanitizedCategory, key: sanitizedKey, value: encryptedValue, metadata }, () => db.insertData(project.id, sanitizedCategory, sanitizedKey, encryptedValue, metadata), { category: sanitizedCategory, key: sanitizedKey, value: sanitizedValue, metadata });
|
|
57
|
-
// Index in vector store if available
|
|
58
|
-
if (vectorStore) {
|
|
59
|
-
vectorStore.addVector(`${category} ${key} ${value}`, 'note', dataPoint.id, project.id).catch(() => { });
|
|
60
|
-
}
|
|
61
|
-
return {
|
|
62
|
-
content: [{
|
|
63
|
-
type: "text",
|
|
64
|
-
text: ` Data inserted: ${category}/${key} (ID: ${dataPoint.id})${wyrmCrypto.isEnabled() ? ' 🔒' : ''}`
|
|
65
|
-
}]
|
|
66
|
-
};
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
name: "wyrm_data_batch_insert",
|
|
71
|
-
description: "Batch insert multiple data points efficiently",
|
|
72
|
-
inputSchema: {
|
|
73
|
-
type: "object",
|
|
74
|
-
properties: {
|
|
75
|
-
projectPath: { type: "string", description: "Project path" },
|
|
76
|
-
data: {
|
|
77
|
-
type: "array",
|
|
78
|
-
items: {
|
|
79
|
-
type: "object",
|
|
80
|
-
properties: {
|
|
81
|
-
category: { type: "string" },
|
|
82
|
-
key: { type: "string" },
|
|
83
|
-
value: { type: "string" },
|
|
84
|
-
metadata: { type: "object" },
|
|
85
|
-
},
|
|
86
|
-
required: ["category", "key", "value"],
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
required: ["projectPath", "data"],
|
|
91
|
-
},
|
|
92
|
-
annotations: TOOL_ANNOTATIONS["wyrm_data_batch_insert"],
|
|
93
|
-
aliases: [],
|
|
94
|
-
handler: async (args, ctx) => {
|
|
95
|
-
const { db, wyrmCrypto } = ctx;
|
|
96
|
-
const { projectPath, data } = args;
|
|
97
|
-
validateBatchSize(data);
|
|
98
|
-
const project = db.getProject(projectPath);
|
|
99
|
-
if (!project) {
|
|
100
|
-
return { content: [{ type: "text", text: "Project not found" }] };
|
|
101
|
-
}
|
|
102
|
-
const items = data.map(d => ({
|
|
103
|
-
...d,
|
|
104
|
-
projectId: project.id,
|
|
105
|
-
value: wyrmCrypto.maybeEncrypt(sanitizeString(d.value)),
|
|
106
|
-
}));
|
|
107
|
-
const count = db.insertDataBatch(items);
|
|
108
|
-
return {
|
|
109
|
-
content: [{
|
|
110
|
-
type: "text",
|
|
111
|
-
text: ` Batch inserted ${count} data points${wyrmCrypto.isEnabled() ? ' 🔒' : ''}`
|
|
112
|
-
}]
|
|
113
|
-
};
|
|
114
|
-
},
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
name: "wyrm_data_query",
|
|
118
|
-
description: "Query data from the data lake",
|
|
119
|
-
inputSchema: {
|
|
120
|
-
type: "object",
|
|
121
|
-
properties: {
|
|
122
|
-
projectPath: { type: "string", description: "Project path" },
|
|
123
|
-
category: { type: "string", description: "Filter by category" },
|
|
124
|
-
search: { type: "string", description: "Full-text search query" },
|
|
125
|
-
limit: { type: "number", description: "Max results" },
|
|
126
|
-
offset: { type: "number", description: "Offset for pagination" },
|
|
127
|
-
},
|
|
128
|
-
required: ["projectPath"],
|
|
129
|
-
},
|
|
130
|
-
annotations: TOOL_ANNOTATIONS["wyrm_data_query"],
|
|
131
|
-
aliases: [],
|
|
132
|
-
handler: async (args, ctx) => {
|
|
133
|
-
const { cachedResponse, db, wyrmCrypto } = ctx;
|
|
134
|
-
const cacheKey = currentReadCacheKey();
|
|
135
|
-
const { projectPath, category, search, limit, offset } = args;
|
|
136
|
-
const project = db.getProject(projectPath);
|
|
137
|
-
if (!project) {
|
|
138
|
-
return { content: [{ type: "text", text: "Project not found" }] };
|
|
139
|
-
}
|
|
140
|
-
let results;
|
|
141
|
-
if (search) {
|
|
142
|
-
const sanitizedSearch = sanitizeFtsQuery(search);
|
|
143
|
-
results = db.searchData(sanitizedSearch, project.id);
|
|
144
|
-
}
|
|
145
|
-
else {
|
|
146
|
-
results = db.queryData(project.id, category, limit || 100, offset || 0);
|
|
147
|
-
}
|
|
148
|
-
const text = results.slice(0, 50).map(d => {
|
|
149
|
-
const val = wyrmCrypto.maybeDecrypt(d.value);
|
|
150
|
-
return `- **${d.category}/${d.key}:** ${val.slice(0, 100)}${val.length > 100 ? '...' : ''}`;
|
|
151
|
-
}).join('\n');
|
|
152
|
-
const response = cachedResponse(` **${results.length} Results**\n\n${text}`);
|
|
153
|
-
if (cacheKey)
|
|
154
|
-
cache.set(cacheKey, response, 30000);
|
|
155
|
-
return response;
|
|
156
|
-
},
|
|
157
|
-
},
|
|
158
|
-
{
|
|
159
|
-
name: "wyrm_data_categories",
|
|
160
|
-
description: "List all data categories for a project",
|
|
161
|
-
inputSchema: {
|
|
162
|
-
type: "object",
|
|
163
|
-
properties: {
|
|
164
|
-
projectPath: { type: "string", description: "Project path" },
|
|
165
|
-
},
|
|
166
|
-
required: ["projectPath"],
|
|
167
|
-
},
|
|
168
|
-
annotations: TOOL_ANNOTATIONS["wyrm_data_categories"],
|
|
169
|
-
aliases: [],
|
|
170
|
-
handler: async (args, ctx) => {
|
|
171
|
-
const { cachedResponse, db } = ctx;
|
|
172
|
-
const cacheKey = currentReadCacheKey();
|
|
173
|
-
const { projectPath } = args;
|
|
174
|
-
const project = db.getProject(projectPath);
|
|
175
|
-
if (!project) {
|
|
176
|
-
return { content: [{ type: "text", text: "Project not found" }] };
|
|
177
|
-
}
|
|
178
|
-
const categories = db.getDataCategories(project.id);
|
|
179
|
-
const text = categories.map(c => `- ${c.category}: ${c.count} items`).join('\n');
|
|
180
|
-
const response = cachedResponse(` **Data Categories for ${project.name}**\n\n${text}`);
|
|
181
|
-
if (cacheKey)
|
|
182
|
-
cache.set(cacheKey, response, 30000);
|
|
183
|
-
return response;
|
|
184
|
-
},
|
|
185
|
-
},
|
|
186
|
-
];
|
|
187
|
-
//# sourceMappingURL=datalake.js.map
|
|
1
|
+
import{TOOL_ANNOTATIONS as j}from"../tool-annotations.js";import{currentReadCacheKey as x}from"./boundary.js";import{daemonOr as q}from"../daemon-writer.js";import{cache as v}from"../performance.js";import{sanitizeFtsQuery as w,sanitizeString as f,validateBatchSize as D}from"../security.js";const A=[{name:"wyrm_data_insert",description:"Insert data into the data lake for a project",inputSchema:{type:"object",properties:{projectPath:{type:"string",description:"Project path"},category:{type:"string",description:"Data category (e.g., 'logs', 'metrics', 'artifacts')"},key:{type:"string",description:"Data key/identifier"},value:{type:"string",description:"Data value (can be JSON string)"},metadata:{type:"object",description:"Optional metadata object"}},required:["projectPath","category","key","value"]},annotations:j.wyrm_data_insert,aliases:[],handler:async(c,y)=>{const{db:a,vectorStore:t,wyrmCrypto:n}=y,e=c||{},d=(k=>{const $=k.filter(P=>!e[P]&&e[P]!==0&&e[P]!==!1);return $.length>0?{content:[{type:"text",text:`Missing required arguments: ${$.join(", ")}`}],isError:!0}:null})(["projectPath","category","key","value"]);if(d)return d;const{projectPath:u,category:r,key:s,value:l,metadata:p}=c,m=a.getProject(u);if(!m)return{content:[{type:"text",text:"Project not found"}]};const g=f(r,200),i=f(s,500),h=f(l),b=n.maybeEncrypt(h),_=await q("data_insert",m.id,{category:g,key:i,value:b,metadata:p},()=>a.insertData(m.id,g,i,b,p),{category:g,key:i,value:h,metadata:p});return t&&t.addVector(`${r} ${s} ${l}`,"note",_.id,m.id).catch(()=>{}),{content:[{type:"text",text:`\u{F115D} Data inserted: ${r}/${s} (ID: ${_.id})${n.isEnabled()?" \u{1F512}":""}`}]}}},{name:"wyrm_data_batch_insert",description:"Batch insert multiple data points efficiently",inputSchema:{type:"object",properties:{projectPath:{type:"string",description:"Project path"},data:{type:"array",items:{type:"object",properties:{category:{type:"string"},key:{type:"string"},value:{type:"string"},metadata:{type:"object"}},required:["category","key","value"]}}},required:["projectPath","data"]},annotations:j.wyrm_data_batch_insert,aliases:[],handler:async(c,y)=>{const{db:a,wyrmCrypto:t}=y,{projectPath:n,data:e}=c;D(e);const o=a.getProject(n);if(!o)return{content:[{type:"text",text:"Project not found"}]};const d=e.map(r=>({...r,projectId:o.id,value:t.maybeEncrypt(f(r.value))}));return{content:[{type:"text",text:`\u{F115D} Batch inserted ${a.insertDataBatch(d)} data points${t.isEnabled()?" \u{1F512}":""}`}]}}},{name:"wyrm_data_query",description:"Query data from the data lake",inputSchema:{type:"object",properties:{projectPath:{type:"string",description:"Project path"},category:{type:"string",description:"Filter by category"},search:{type:"string",description:"Full-text search query"},limit:{type:"number",description:"Max results"},offset:{type:"number",description:"Offset for pagination"}},required:["projectPath"]},annotations:j.wyrm_data_query,aliases:[],handler:async(c,y)=>{const{cachedResponse:a,db:t,wyrmCrypto:n}=y,e=x(),{projectPath:o,category:d,search:u,limit:r,offset:s}=c,l=t.getProject(o);if(!l)return{content:[{type:"text",text:"Project not found"}]};let p;if(u){const i=w(u);p=t.searchData(i,l.id)}else p=t.queryData(l.id,d,r||100,s||0);const m=p.slice(0,50).map(i=>{const h=n.maybeDecrypt(i.value);return`- **${i.category}/${i.key}:** ${h.slice(0,100)}${h.length>100?"...":""}`}).join(`
|
|
2
|
+
`),g=a(`\u{F115D} **${p.length} Results**
|
|
3
|
+
|
|
4
|
+
${m}`);return e&&v.set(e,g,3e4),g}},{name:"wyrm_data_categories",description:"List all data categories for a project",inputSchema:{type:"object",properties:{projectPath:{type:"string",description:"Project path"}},required:["projectPath"]},annotations:j.wyrm_data_categories,aliases:[],handler:async(c,y)=>{const{cachedResponse:a,db:t}=y,n=x(),{projectPath:e}=c,o=t.getProject(e);if(!o)return{content:[{type:"text",text:"Project not found"}]};const u=t.getDataCategories(o.id).map(s=>`- ${s.category}: ${s.count} items`).join(`
|
|
5
|
+
`),r=a(`\u{F115D} **Data Categories for ${o.name}**
|
|
6
|
+
|
|
7
|
+
${u}`);return n&&v.set(n,r,3e4),r}}];export{A as datalakeToolSpecs};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Dispatcher context (v7 F4 T036 — the monolith drain).
|
|
3
|
-
*
|
|
4
|
-
* The remaining non-hot domains were lifted VERBATIM out of the index.ts
|
|
5
|
-
* `switch (name)` into per-domain ToolSpec modules (handlers/<domain>.ts).
|
|
6
|
-
* Those case bodies referenced module-scoped subsystem singletons by bare
|
|
7
|
-
* name (`db`, `graph`, `mcpClient`, …) and a handful of index.ts helper
|
|
8
|
-
* closures (`cachedResponse`, `runCompanionBuddy`, …). To move the bodies
|
|
9
|
-
* with ZERO behavior drift, this context carries every one of those names —
|
|
10
|
-
* index.ts wires the live singletons + closures into `dispatcherCtx`, and each
|
|
11
|
-
* handler destructures the ones it uses from `ctx`.
|
|
12
|
-
*
|
|
13
|
-
* It EXTENDS `HandlerContext` (the hot-path slice) so an extracted handler can
|
|
14
|
-
* also reach the narrow capabilities the hot domains use (`store`, `raw()`,
|
|
15
|
-
* `cache`, `getActor`, …). The hot-path domains keep their narrow slices; this
|
|
16
|
-
* broad context is only the drain seam for the formerly-switch-resident tools.
|
|
17
|
-
*
|
|
18
|
-
* @copyright 2026 Ghost Protocol (Pvt) Ltd.
|
|
19
|
-
* @license AGPL-3.0-or-later
|
|
20
|
-
*/
|
|
21
|
-
export {};
|
|
22
|
-
//# sourceMappingURL=dispatch-context.js.map
|
package/dist/handlers/entity.js
CHANGED
|
@@ -1,256 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const { db, graph } = ctx;
|
|
27
|
-
const { projectPath: ePath, name: eName, type: eType, metadata: eMeta, aliases: eAliases } = args;
|
|
28
|
-
const eProject = db.getProject(ePath);
|
|
29
|
-
if (!eProject)
|
|
30
|
-
return { content: [{ type: "text", text: `Project not found: ${ePath}` }], isError: true };
|
|
31
|
-
const existingEntity = graph.findEntity(eProject.id, eName, eType);
|
|
32
|
-
if (existingEntity) {
|
|
33
|
-
return { content: [{ type: "text", text: ` Entity already exists: **${eName}** (${eType}) — id ${existingEntity.id}` }] };
|
|
34
|
-
}
|
|
35
|
-
const entity = graph.addEntity(eProject.id, eName, eType, eMeta);
|
|
36
|
-
if (eAliases?.length) {
|
|
37
|
-
for (const alias of eAliases)
|
|
38
|
-
graph.addAlias(entity.id, alias);
|
|
39
|
-
}
|
|
40
|
-
cache.invalidate('wyrm_entity_search');
|
|
41
|
-
cache.invalidate('wyrm_entity_graph');
|
|
42
|
-
cache.invalidate('wyrm_stats');
|
|
43
|
-
let text = ` **Entity Added**\n\n- **${entity.name}** _(${entity.type})_\n- ID: ${entity.id}\n`;
|
|
44
|
-
if (eAliases?.length)
|
|
45
|
-
text += `- Aliases: ${eAliases.join(', ')}\n`;
|
|
46
|
-
return { content: [{ type: "text", text }] };
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
name: "wyrm_entity_link",
|
|
51
|
-
description: "Create a relationship between two entities in the knowledge graph",
|
|
52
|
-
inputSchema: {
|
|
53
|
-
type: "object",
|
|
54
|
-
properties: {
|
|
55
|
-
projectPath: { type: "string", description: "Project containing the entities" },
|
|
56
|
-
source: { type: "string", description: "Source entity name" },
|
|
57
|
-
target: { type: "string", description: "Target entity name" },
|
|
58
|
-
relationship: { type: "string", description: "Relationship type (e.g., uses, depends_on, created_by, extends)" },
|
|
59
|
-
weight: { type: "number", description: "Relationship weight 0-1 (default: 1.0)" },
|
|
60
|
-
confidence: { type: "number", description: "Confidence score 0-1 (default: 1.0)" },
|
|
61
|
-
sourceMemory: { type: "string", description: "Source of this knowledge (e.g., session:42, quest:7)" },
|
|
62
|
-
},
|
|
63
|
-
required: ["projectPath", "source", "target", "relationship"],
|
|
64
|
-
},
|
|
65
|
-
annotations: TOOL_ANNOTATIONS["wyrm_entity_link"],
|
|
66
|
-
aliases: [],
|
|
67
|
-
handler: async (args, ctx) => {
|
|
68
|
-
const { db, graph } = ctx;
|
|
69
|
-
const { projectPath: lPath, source, target, relationship, weight, confidence, sourceMemory } = args;
|
|
70
|
-
const lProject = db.getProject(lPath);
|
|
71
|
-
if (!lProject)
|
|
72
|
-
return { content: [{ type: "text", text: `Project not found: ${lPath}` }], isError: true };
|
|
73
|
-
const srcEntity = graph.findEntity(lProject.id, source) ?? graph.findByAlias(lProject.id, source);
|
|
74
|
-
const tgtEntity = graph.findEntity(lProject.id, target) ?? graph.findByAlias(lProject.id, target);
|
|
75
|
-
if (!srcEntity)
|
|
76
|
-
return { content: [{ type: "text", text: `Entity not found: "${source}". Use wyrm_entity_add first.` }], isError: true };
|
|
77
|
-
if (!tgtEntity)
|
|
78
|
-
return { content: [{ type: "text", text: `Entity not found: "${target}". Use wyrm_entity_add first.` }], isError: true };
|
|
79
|
-
const rel = graph.addRelationship(lProject.id, srcEntity.id, tgtEntity.id, relationship, {
|
|
80
|
-
weight: weight ?? 1.0,
|
|
81
|
-
confidence: confidence ?? 1.0,
|
|
82
|
-
sourceMemory,
|
|
83
|
-
});
|
|
84
|
-
cache.invalidate('wyrm_entity_search');
|
|
85
|
-
cache.invalidate('wyrm_entity_graph');
|
|
86
|
-
cache.invalidate('wyrm_stats');
|
|
87
|
-
return { content: [{ type: "text", text: ` **Relationship Created**\n\n**${source}** —[${relationship}]→ **${target}**\n- ID: ${rel.id}${sourceMemory ? `\n- Source: ${sourceMemory}` : ''}` }] };
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
name: "wyrm_entity_search",
|
|
92
|
-
description: "Search for entities in the knowledge graph",
|
|
93
|
-
inputSchema: {
|
|
94
|
-
type: "object",
|
|
95
|
-
properties: {
|
|
96
|
-
projectPath: { type: "string", description: "Project to search in" },
|
|
97
|
-
query: { type: "string", description: "Search query for entity names" },
|
|
98
|
-
type: { type: "string", description: "Filter by entity type" },
|
|
99
|
-
limit: { type: "number", description: "Max results (default: 20)" },
|
|
100
|
-
},
|
|
101
|
-
required: ["projectPath", "query"],
|
|
102
|
-
},
|
|
103
|
-
annotations: TOOL_ANNOTATIONS["wyrm_entity_search"],
|
|
104
|
-
aliases: [],
|
|
105
|
-
handler: async (args, ctx) => {
|
|
106
|
-
const { cachedResponse, db, graph } = ctx;
|
|
107
|
-
const cacheKey = currentReadCacheKey();
|
|
108
|
-
const { projectPath: sePath, query: seQuery, type: seType, limit: seLimit } = args;
|
|
109
|
-
const seProject = db.getProject(sePath);
|
|
110
|
-
if (!seProject)
|
|
111
|
-
return { content: [{ type: "text", text: `Project not found: ${sePath}` }], isError: true };
|
|
112
|
-
const entities = graph.searchEntities(seProject.id, seQuery, seLimit ?? 20);
|
|
113
|
-
const filtered = seType ? entities.filter(e => e.type === seType) : entities;
|
|
114
|
-
if (filtered.length === 0) {
|
|
115
|
-
return { content: [{ type: "text", text: ` No entities found matching "${seQuery}"` }] };
|
|
116
|
-
}
|
|
117
|
-
let text = ` **Entities matching "${seQuery}"** (${filtered.length})\n\n`;
|
|
118
|
-
for (const e of filtered) {
|
|
119
|
-
const rels = graph.getRelationships(e.id, 'both');
|
|
120
|
-
const aliases = graph.getAliases(e.id);
|
|
121
|
-
text += `- **${e.name}** _(${e.type})_ — ${rels.length} connection${rels.length !== 1 ? 's' : ''}`;
|
|
122
|
-
if (aliases.length)
|
|
123
|
-
text += ` | also: ${aliases.join(', ')}`;
|
|
124
|
-
text += '\n';
|
|
125
|
-
}
|
|
126
|
-
const response = cachedResponse(text);
|
|
127
|
-
if (cacheKey)
|
|
128
|
-
cache.set(cacheKey, response, 15000);
|
|
129
|
-
return response;
|
|
130
|
-
},
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
name: "wyrm_entity_graph",
|
|
134
|
-
description: "Get the neighborhood graph around an entity — all connected nodes within N hops",
|
|
135
|
-
inputSchema: {
|
|
136
|
-
type: "object",
|
|
137
|
-
properties: {
|
|
138
|
-
projectPath: { type: "string", description: "Project containing the entity" },
|
|
139
|
-
entity: { type: "string", description: "Entity name to center on" },
|
|
140
|
-
depth: { type: "number", description: "Max hops from center (1-5, default: 2)" },
|
|
141
|
-
},
|
|
142
|
-
required: ["projectPath", "entity"],
|
|
143
|
-
},
|
|
144
|
-
annotations: TOOL_ANNOTATIONS["wyrm_entity_graph"],
|
|
145
|
-
aliases: [],
|
|
146
|
-
handler: async (args, ctx) => {
|
|
147
|
-
const { cachedResponse, db, graph } = ctx;
|
|
148
|
-
const a = args || {};
|
|
149
|
-
const cacheKey = currentReadCacheKey();
|
|
150
|
-
const { projectPath: gPath, entity: gEntity, depth: gDepth } = args;
|
|
151
|
-
const gProject = db.getProject(gPath);
|
|
152
|
-
if (!gProject)
|
|
153
|
-
return { content: [{ type: "text", text: `Project not found: ${gPath}` }], isError: true };
|
|
154
|
-
const centerEntity = graph.findEntity(gProject.id, gEntity) ?? graph.findByAlias(gProject.id, gEntity);
|
|
155
|
-
if (!centerEntity)
|
|
156
|
-
return { content: [{ type: "text", text: `Entity not found: "${gEntity}". Use wyrm_entity_search to find entities.` }], isError: true };
|
|
157
|
-
const hood = graph.getNeighborhood(centerEntity.id, Math.min(gDepth ?? 2, 5));
|
|
158
|
-
let text = ` **Graph: ${centerEntity.name}** _(depth: ${gDepth ?? 2})_\n\n`;
|
|
159
|
-
text += `**${hood.nodes.length} nodes, ${hood.edges.length} edges**\n\n`;
|
|
160
|
-
// Group nodes by depth
|
|
161
|
-
const byDepth = {};
|
|
162
|
-
for (const n of hood.nodes) {
|
|
163
|
-
if (!byDepth[n.depth])
|
|
164
|
-
byDepth[n.depth] = [];
|
|
165
|
-
byDepth[n.depth].push(n);
|
|
166
|
-
}
|
|
167
|
-
for (const [depth, nodes] of Object.entries(byDepth).sort((a, b) => Number(a[0]) - Number(b[0]))) {
|
|
168
|
-
const label = depth === '0' ? '🎯 Center' : `Hop ${depth}`;
|
|
169
|
-
text += `**${label}:** ${nodes.map(n => `${n.name} (${n.type})`).join(', ')}\n`;
|
|
170
|
-
}
|
|
171
|
-
if (hood.edges.length > 0) {
|
|
172
|
-
text += '\n**Connections:**\n';
|
|
173
|
-
for (const e of hood.edges.slice(0, 20)) {
|
|
174
|
-
text += `- ${e.source_name} —[${e.relationship_type}]→ ${e.target_name}\n`;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
const response = cachedResponse(text);
|
|
178
|
-
if (cacheKey)
|
|
179
|
-
cache.set(cacheKey, response, 15000);
|
|
180
|
-
return response;
|
|
181
|
-
},
|
|
182
|
-
},
|
|
183
|
-
{
|
|
184
|
-
name: "wyrm_entity_path",
|
|
185
|
-
description: "Find the shortest path between two entities in the knowledge graph",
|
|
186
|
-
inputSchema: {
|
|
187
|
-
type: "object",
|
|
188
|
-
properties: {
|
|
189
|
-
projectPath: { type: "string", description: "Project containing the entities" },
|
|
190
|
-
source: { type: "string", description: "Source entity name" },
|
|
191
|
-
target: { type: "string", description: "Target entity name" },
|
|
192
|
-
maxDepth: { type: "number", description: "Max path length (1-5, default: 5)" },
|
|
193
|
-
},
|
|
194
|
-
required: ["projectPath", "source", "target"],
|
|
195
|
-
},
|
|
196
|
-
annotations: TOOL_ANNOTATIONS["wyrm_entity_path"],
|
|
197
|
-
aliases: [],
|
|
198
|
-
handler: async (args, ctx) => {
|
|
199
|
-
const { db, graph } = ctx;
|
|
200
|
-
const { projectPath: pPath, source: pSource, target: pTarget, maxDepth: pDepth } = args;
|
|
201
|
-
const pProject = db.getProject(pPath);
|
|
202
|
-
if (!pProject)
|
|
203
|
-
return { content: [{ type: "text", text: `Project not found: ${pPath}` }], isError: true };
|
|
204
|
-
const pSrc = graph.findEntity(pProject.id, pSource) ?? graph.findByAlias(pProject.id, pSource);
|
|
205
|
-
const pTgt = graph.findEntity(pProject.id, pTarget) ?? graph.findByAlias(pProject.id, pTarget);
|
|
206
|
-
if (!pSrc)
|
|
207
|
-
return { content: [{ type: "text", text: `Entity not found: "${pSource}"` }], isError: true };
|
|
208
|
-
if (!pTgt)
|
|
209
|
-
return { content: [{ type: "text", text: `Entity not found: "${pTarget}"` }], isError: true };
|
|
210
|
-
const path = graph.findPath(pSrc.id, pTgt.id, Math.min(pDepth ?? 5, 5));
|
|
211
|
-
if (!path) {
|
|
212
|
-
return { content: [{ type: "text", text: ` No path found between **${pSource}** and **${pTarget}** within ${pDepth ?? 5} hops.` }] };
|
|
213
|
-
}
|
|
214
|
-
// Resolve entity names for path display
|
|
215
|
-
const pathEntities = path.map(id => graph.getEntity(id)).filter(Boolean);
|
|
216
|
-
const pathStr = pathEntities.map(e => e.name).join(' → ');
|
|
217
|
-
return { content: [{ type: "text", text: ` **Path Found** (${path.length - 1} hops)\n\n${pathStr}` }] };
|
|
218
|
-
},
|
|
219
|
-
},
|
|
220
|
-
{
|
|
221
|
-
name: "wyrm_entity_merge",
|
|
222
|
-
description: "Merge two entities — combines aliases, redirects relationships, deletes the source",
|
|
223
|
-
inputSchema: {
|
|
224
|
-
type: "object",
|
|
225
|
-
properties: {
|
|
226
|
-
projectPath: { type: "string", description: "Project containing the entities" },
|
|
227
|
-
source: { type: "string", description: "Entity name to merge FROM (will be deleted)" },
|
|
228
|
-
target: { type: "string", description: "Entity name to merge INTO (will be kept)" },
|
|
229
|
-
},
|
|
230
|
-
required: ["projectPath", "source", "target"],
|
|
231
|
-
},
|
|
232
|
-
annotations: TOOL_ANNOTATIONS["wyrm_entity_merge"],
|
|
233
|
-
aliases: [],
|
|
234
|
-
handler: async (args, ctx) => {
|
|
235
|
-
const { db, graph } = ctx;
|
|
236
|
-
const { projectPath: mPath, source: mSource, target: mTarget } = args;
|
|
237
|
-
const mProject = db.getProject(mPath);
|
|
238
|
-
if (!mProject)
|
|
239
|
-
return { content: [{ type: "text", text: `Project not found: ${mPath}` }], isError: true };
|
|
240
|
-
const mSrc = graph.findEntity(mProject.id, mSource) ?? graph.findByAlias(mProject.id, mSource);
|
|
241
|
-
const mTgt = graph.findEntity(mProject.id, mTarget) ?? graph.findByAlias(mProject.id, mTarget);
|
|
242
|
-
if (!mSrc)
|
|
243
|
-
return { content: [{ type: "text", text: `Entity not found: "${mSource}"` }], isError: true };
|
|
244
|
-
if (!mTgt)
|
|
245
|
-
return { content: [{ type: "text", text: `Entity not found: "${mTarget}"` }], isError: true };
|
|
246
|
-
if (mSrc.id === mTgt.id)
|
|
247
|
-
return { content: [{ type: "text", text: `Cannot merge entity with itself.` }], isError: true };
|
|
248
|
-
graph.mergeEntities(mSrc.id, mTgt.id);
|
|
249
|
-
cache.invalidate('wyrm_entity_search');
|
|
250
|
-
cache.invalidate('wyrm_entity_graph');
|
|
251
|
-
cache.invalidate('wyrm_stats');
|
|
252
|
-
return { content: [{ type: "text", text: ` **Merged** "${mSource}" → "${mTarget}"\n\n"${mSource}" is now an alias of "${mTarget}". All relationships redirected.` }] };
|
|
253
|
-
},
|
|
254
|
-
},
|
|
255
|
-
];
|
|
256
|
-
//# sourceMappingURL=entity.js.map
|
|
1
|
+
import{TOOL_ANNOTATIONS as _}from"../tool-annotations.js";import{currentReadCacheKey as P}from"./boundary.js";import{cache as m}from"../performance.js";const S=[{name:"wyrm_entity_add",description:"Add an entity to the knowledge graph (person, concept, tool, etc.)",inputSchema:{type:"object",properties:{projectPath:{type:"string",description:"Project to add entity to"},name:{type:"string",description:"Entity name"},type:{type:"string",description:"Entity type (e.g., person, concept, tool, framework, service)"},metadata:{type:"string",description:"JSON metadata about the entity"},aliases:{type:"array",items:{type:"string"},description:"Alternative names for the entity"}},required:["projectPath","name","type"]},annotations:_.wyrm_entity_add,aliases:[],handler:async(g,l)=>{const{db:u,graph:t}=l,{projectPath:s,name:n,type:e,metadata:o,aliases:i}=g,a=u.getProject(s);if(!a)return{content:[{type:"text",text:`Project not found: ${s}`}],isError:!0};const p=t.findEntity(a.id,n,e);if(p)return{content:[{type:"text",text:`\u{F115D} Entity already exists: **${n}** (${e}) \u2014 id ${p.id}`}]};const r=t.addEntity(a.id,n,e,o);if(i?.length)for(const c of i)t.addAlias(r.id,c);m.invalidate("wyrm_entity_search"),m.invalidate("wyrm_entity_graph"),m.invalidate("wyrm_stats");let d=`\u{F115D} **Entity Added**
|
|
2
|
+
|
|
3
|
+
- **${r.name}** _(${r.type})_
|
|
4
|
+
- ID: ${r.id}
|
|
5
|
+
`;return i?.length&&(d+=`- Aliases: ${i.join(", ")}
|
|
6
|
+
`),{content:[{type:"text",text:d}]}}},{name:"wyrm_entity_link",description:"Create a relationship between two entities in the knowledge graph",inputSchema:{type:"object",properties:{projectPath:{type:"string",description:"Project containing the entities"},source:{type:"string",description:"Source entity name"},target:{type:"string",description:"Target entity name"},relationship:{type:"string",description:"Relationship type (e.g., uses, depends_on, created_by, extends)"},weight:{type:"number",description:"Relationship weight 0-1 (default: 1.0)"},confidence:{type:"number",description:"Confidence score 0-1 (default: 1.0)"},sourceMemory:{type:"string",description:"Source of this knowledge (e.g., session:42, quest:7)"}},required:["projectPath","source","target","relationship"]},annotations:_.wyrm_entity_link,aliases:[],handler:async(g,l)=>{const{db:u,graph:t}=l,{projectPath:s,source:n,target:e,relationship:o,weight:i,confidence:a,sourceMemory:p}=g,r=u.getProject(s);if(!r)return{content:[{type:"text",text:`Project not found: ${s}`}],isError:!0};const d=t.findEntity(r.id,n)??t.findByAlias(r.id,n),c=t.findEntity(r.id,e)??t.findByAlias(r.id,e);if(!d)return{content:[{type:"text",text:`Entity not found: "${n}". Use wyrm_entity_add first.`}],isError:!0};if(!c)return{content:[{type:"text",text:`Entity not found: "${e}". Use wyrm_entity_add first.`}],isError:!0};const h=t.addRelationship(r.id,d.id,c.id,o,{weight:i??1,confidence:a??1,sourceMemory:p});return m.invalidate("wyrm_entity_search"),m.invalidate("wyrm_entity_graph"),m.invalidate("wyrm_stats"),{content:[{type:"text",text:`\u{F115D} **Relationship Created**
|
|
7
|
+
|
|
8
|
+
**${n}** \u2014[${o}]\u2192 **${e}**
|
|
9
|
+
- ID: ${h.id}${p?`
|
|
10
|
+
- Source: ${p}`:""}`}]}}},{name:"wyrm_entity_search",description:"Search for entities in the knowledge graph",inputSchema:{type:"object",properties:{projectPath:{type:"string",description:"Project to search in"},query:{type:"string",description:"Search query for entity names"},type:{type:"string",description:"Filter by entity type"},limit:{type:"number",description:"Max results (default: 20)"}},required:["projectPath","query"]},annotations:_.wyrm_entity_search,aliases:[],handler:async(g,l)=>{const{cachedResponse:u,db:t,graph:s}=l,n=P(),{projectPath:e,query:o,type:i,limit:a}=g,p=t.getProject(e);if(!p)return{content:[{type:"text",text:`Project not found: ${e}`}],isError:!0};const r=s.searchEntities(p.id,o,a??20),d=i?r.filter(f=>f.type===i):r;if(d.length===0)return{content:[{type:"text",text:`\u{F115D} No entities found matching "${o}"`}]};let c=`\u{F115D} **Entities matching "${o}"** (${d.length})
|
|
11
|
+
|
|
12
|
+
`;for(const f of d){const y=s.getRelationships(f.id,"both"),$=s.getAliases(f.id);c+=`- **${f.name}** _(${f.type})_ \u2014 ${y.length} connection${y.length!==1?"s":""}`,$.length&&(c+=` | also: ${$.join(", ")}`),c+=`
|
|
13
|
+
`}const h=u(c);return n&&m.set(n,h,15e3),h}},{name:"wyrm_entity_graph",description:"Get the neighborhood graph around an entity \u2014 all connected nodes within N hops",inputSchema:{type:"object",properties:{projectPath:{type:"string",description:"Project containing the entity"},entity:{type:"string",description:"Entity name to center on"},depth:{type:"number",description:"Max hops from center (1-5, default: 2)"}},required:["projectPath","entity"]},annotations:_.wyrm_entity_graph,aliases:[],handler:async(g,l)=>{const{cachedResponse:u,db:t,graph:s}=l,n=g||{},e=P(),{projectPath:o,entity:i,depth:a}=g,p=t.getProject(o);if(!p)return{content:[{type:"text",text:`Project not found: ${o}`}],isError:!0};const r=s.findEntity(p.id,i)??s.findByAlias(p.id,i);if(!r)return{content:[{type:"text",text:`Entity not found: "${i}". Use wyrm_entity_search to find entities.`}],isError:!0};const d=s.getNeighborhood(r.id,Math.min(a??2,5));let c=`\u{F115D} **Graph: ${r.name}** _(depth: ${a??2})_
|
|
14
|
+
|
|
15
|
+
`;c+=`**${d.nodes.length} nodes, ${d.edges.length} edges**
|
|
16
|
+
|
|
17
|
+
`;const h={};for(const y of d.nodes)h[y.depth]||(h[y.depth]=[]),h[y.depth].push(y);for(const[y,$]of Object.entries(h).sort((x,j)=>Number(x[0])-Number(j[0]))){const x=y==="0"?"\u{1F3AF} Center":`Hop ${y}`;c+=`**${x}:** ${$.map(j=>`${j.name} (${j.type})`).join(", ")}
|
|
18
|
+
`}if(d.edges.length>0){c+=`
|
|
19
|
+
**Connections:**
|
|
20
|
+
`;for(const y of d.edges.slice(0,20))c+=`- ${y.source_name} \u2014[${y.relationship_type}]\u2192 ${y.target_name}
|
|
21
|
+
`}const f=u(c);return e&&m.set(e,f,15e3),f}},{name:"wyrm_entity_path",description:"Find the shortest path between two entities in the knowledge graph",inputSchema:{type:"object",properties:{projectPath:{type:"string",description:"Project containing the entities"},source:{type:"string",description:"Source entity name"},target:{type:"string",description:"Target entity name"},maxDepth:{type:"number",description:"Max path length (1-5, default: 5)"}},required:["projectPath","source","target"]},annotations:_.wyrm_entity_path,aliases:[],handler:async(g,l)=>{const{db:u,graph:t}=l,{projectPath:s,source:n,target:e,maxDepth:o}=g,i=u.getProject(s);if(!i)return{content:[{type:"text",text:`Project not found: ${s}`}],isError:!0};const a=t.findEntity(i.id,n)??t.findByAlias(i.id,n),p=t.findEntity(i.id,e)??t.findByAlias(i.id,e);if(!a)return{content:[{type:"text",text:`Entity not found: "${n}"`}],isError:!0};if(!p)return{content:[{type:"text",text:`Entity not found: "${e}"`}],isError:!0};const r=t.findPath(a.id,p.id,Math.min(o??5,5));if(!r)return{content:[{type:"text",text:`\u{F115D} No path found between **${n}** and **${e}** within ${o??5} hops.`}]};const c=r.map(h=>t.getEntity(h)).filter(Boolean).map(h=>h.name).join(" \u2192 ");return{content:[{type:"text",text:`\u{F115D} **Path Found** (${r.length-1} hops)
|
|
22
|
+
|
|
23
|
+
${c}`}]}}},{name:"wyrm_entity_merge",description:"Merge two entities \u2014 combines aliases, redirects relationships, deletes the source",inputSchema:{type:"object",properties:{projectPath:{type:"string",description:"Project containing the entities"},source:{type:"string",description:"Entity name to merge FROM (will be deleted)"},target:{type:"string",description:"Entity name to merge INTO (will be kept)"}},required:["projectPath","source","target"]},annotations:_.wyrm_entity_merge,aliases:[],handler:async(g,l)=>{const{db:u,graph:t}=l,{projectPath:s,source:n,target:e}=g,o=u.getProject(s);if(!o)return{content:[{type:"text",text:`Project not found: ${s}`}],isError:!0};const i=t.findEntity(o.id,n)??t.findByAlias(o.id,n),a=t.findEntity(o.id,e)??t.findByAlias(o.id,e);return i?a?i.id===a.id?{content:[{type:"text",text:"Cannot merge entity with itself."}],isError:!0}:(t.mergeEntities(i.id,a.id),m.invalidate("wyrm_entity_search"),m.invalidate("wyrm_entity_graph"),m.invalidate("wyrm_stats"),{content:[{type:"text",text:`\u{F115D} **Merged** "${n}" \u2192 "${e}"
|
|
24
|
+
|
|
25
|
+
"${n}" is now an alias of "${e}". All relationships redirected.`}]}):{content:[{type:"text",text:`Entity not found: "${e}"`}],isError:!0}:{content:[{type:"text",text:`Entity not found: "${n}"`}],isError:!0}}}];export{S as entityToolSpecs};
|