@gethmy/mcp 2.3.2 → 2.3.3

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.
@@ -1,147 +0,0 @@
1
- import { createRequire } from "node:module";
2
- var __create = Object.create;
3
- var __getProtoOf = Object.getPrototypeOf;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __toESM = (mod, isNodeMode, target) => {
8
- target = mod != null ? __create(__getProtoOf(mod)) : {};
9
- const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
10
- for (let key of __getOwnPropNames(mod))
11
- if (!__hasOwnProp.call(to, key))
12
- __defProp(to, key, {
13
- get: () => mod[key],
14
- enumerable: true
15
- });
16
- return to;
17
- };
18
- var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
19
- var __export = (target, all) => {
20
- for (var name in all)
21
- __defProp(target, name, {
22
- get: all[name],
23
- enumerable: true,
24
- configurable: true,
25
- set: (newValue) => all[name] = () => newValue
26
- });
27
- };
28
- var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
29
- var __require = /* @__PURE__ */ createRequire(import.meta.url);
30
-
31
- // src/graph-expansion.ts
32
- async function autoExpandGraph(client, entityId, title, content, _tags, workspaceId, projectId, maxRelations = 5) {
33
- try {
34
- const contentSnippet = content.slice(0, 200).trim();
35
- const query = [title, contentSnippet].filter(Boolean).join(" ");
36
- let candidates = [];
37
- const { entities } = await client.searchMemoryEntities(workspaceId, query, {
38
- project_id: projectId,
39
- limit: 20
40
- });
41
- candidates = entities.filter((e) => e.id !== entityId).slice(0, maxRelations);
42
- if (candidates.length === 0) {
43
- await new Promise((resolve) => setTimeout(resolve, 2000));
44
- const retry = await client.searchMemoryEntities(workspaceId, query, {
45
- project_id: projectId,
46
- limit: 20
47
- });
48
- candidates = retry.entities.filter((e) => e.id !== entityId).slice(0, maxRelations);
49
- }
50
- let relationsCreated = 0;
51
- for (const candidate of candidates) {
52
- try {
53
- await client.createMemoryRelation({
54
- source_id: entityId,
55
- target_id: candidate.id,
56
- relation_type: "relates_to",
57
- confidence: 0.6
58
- });
59
- relationsCreated++;
60
- } catch (err) {
61
- const status = err?.status;
62
- if (status !== 409) {}
63
- }
64
- }
65
- return { relationsCreated };
66
- } catch {
67
- return { relationsCreated: 0 };
68
- }
69
- }
70
- async function findSimilarEntities(client, title, content, workspaceId, options) {
71
- const contentSnippet = content.slice(0, 200).trim();
72
- const query = [title, contentSnippet].filter(Boolean).join(" ");
73
- try {
74
- const { entities } = await client.searchMemoryEntities(workspaceId, query, {
75
- project_id: options?.projectId,
76
- limit: options?.limit ?? 20,
77
- type: options?.type
78
- });
79
- const minScore = options?.minRrfScore ?? 0;
80
- const excludeSet = new Set(options?.excludeIds || []);
81
- return entities.filter((e) => {
82
- if (excludeSet.has(e.id))
83
- return false;
84
- if (minScore > 0 && (e.rrf_score ?? 0) < minScore)
85
- return false;
86
- return true;
87
- });
88
- } catch {
89
- return [];
90
- }
91
- }
92
- var CAUSAL_LOOKUP = [
93
- {
94
- sourceType: "error",
95
- targetType: "solution",
96
- relation: "resolved_by",
97
- direction: "forward"
98
- },
99
- {
100
- sourceType: "solution",
101
- targetType: "error",
102
- relation: "resolved_by",
103
- direction: "reverse"
104
- },
105
- {
106
- sourceType: "lesson",
107
- targetType: "error",
108
- relation: "learned_from",
109
- direction: "forward"
110
- }
111
- ];
112
- async function linkCrossTypeNeighbors(client, entityId, entityType, title, content, workspaceId, projectId) {
113
- const rules = CAUSAL_LOOKUP.filter((r) => r.sourceType === entityType);
114
- if (rules.length === 0)
115
- return { relationsCreated: 0 };
116
- let relationsCreated = 0;
117
- for (const rule of rules) {
118
- try {
119
- const matches = await findSimilarEntities(client, title, content, workspaceId, {
120
- projectId,
121
- limit: 10,
122
- minRrfScore: 0.04,
123
- excludeIds: [entityId],
124
- type: rule.targetType
125
- });
126
- for (const match of matches.slice(0, 3)) {
127
- const sourceId = rule.direction === "forward" ? entityId : match.id;
128
- const targetId = rule.direction === "forward" ? match.id : entityId;
129
- try {
130
- await client.createMemoryRelation({
131
- source_id: sourceId,
132
- target_id: targetId,
133
- relation_type: rule.relation,
134
- confidence: 0.65
135
- });
136
- relationsCreated++;
137
- } catch {}
138
- }
139
- } catch {}
140
- }
141
- return { relationsCreated };
142
- }
143
- export {
144
- linkCrossTypeNeighbors,
145
- findSimilarEntities,
146
- autoExpandGraph
147
- };