@4da/mcp-server 3.2.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +160 -63
- package/dist/db.d.ts +27 -2
- package/dist/db.d.ts.map +1 -1
- package/dist/db.js +104 -1
- package/dist/db.js.map +1 -1
- package/dist/doctor.d.ts +15 -0
- package/dist/doctor.d.ts.map +1 -0
- package/dist/doctor.js +98 -0
- package/dist/doctor.js.map +1 -0
- package/dist/http-transport.d.ts +25 -0
- package/dist/http-transport.d.ts.map +1 -0
- package/dist/http-transport.js +126 -0
- package/dist/http-transport.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +130 -10
- package/dist/index.js.map +1 -1
- package/dist/llm.d.ts +20 -2
- package/dist/llm.d.ts.map +1 -1
- package/dist/llm.js +77 -20
- package/dist/llm.js.map +1 -1
- package/dist/schema-registry.d.ts.map +1 -1
- package/dist/schema-registry.js +44 -0
- package/dist/schema-registry.js.map +1 -1
- package/dist/schemas/agent-memory.json +49 -0
- package/dist/schemas/agent-session-brief.json +25 -0
- package/dist/schemas/attention-report.json +13 -0
- package/dist/schemas/autophagy-status.json +13 -0
- package/dist/schemas/compound-advantage.json +14 -0
- package/dist/schemas/decision-enforcement.json +22 -0
- package/dist/schemas/decision-memory.json +54 -0
- package/dist/schemas/decision-windows.json +22 -0
- package/dist/schemas/delegation-score.json +18 -0
- package/dist/schemas/developer-dna.json +219 -0
- package/dist/schemas/export-context.json +17 -0
- package/dist/schemas/knowledge-gaps.json +14 -0
- package/dist/schemas/project-health.json +13 -0
- package/dist/schemas/reverse-mentions.json +13 -0
- package/dist/schemas/semantic-shifts.json +17 -0
- package/dist/schemas/signal-chains.json +19 -0
- package/dist/schemas/tech-radar.json +23 -0
- package/dist/setup.d.ts +17 -0
- package/dist/setup.d.ts.map +1 -0
- package/dist/setup.js +137 -0
- package/dist/setup.js.map +1 -0
- package/dist/tools/agent-memory.d.ts +94 -0
- package/dist/tools/agent-memory.d.ts.map +1 -0
- package/dist/tools/agent-memory.js +229 -0
- package/dist/tools/agent-memory.js.map +1 -0
- package/dist/tools/agent-session-brief.d.ts +44 -0
- package/dist/tools/agent-session-brief.d.ts.map +1 -0
- package/dist/tools/agent-session-brief.js +178 -0
- package/dist/tools/agent-session-brief.js.map +1 -0
- package/dist/tools/attention-report.d.ts +6 -5
- package/dist/tools/attention-report.d.ts.map +1 -1
- package/dist/tools/attention-report.js.map +1 -1
- package/dist/tools/autophagy-status.d.ts +25 -0
- package/dist/tools/autophagy-status.d.ts.map +1 -0
- package/dist/tools/autophagy-status.js +56 -0
- package/dist/tools/autophagy-status.js.map +1 -0
- package/dist/tools/compound-advantage.d.ts +27 -0
- package/dist/tools/compound-advantage.d.ts.map +1 -0
- package/dist/tools/compound-advantage.js +76 -0
- package/dist/tools/compound-advantage.js.map +1 -0
- package/dist/tools/decision-enforcement.d.ts +59 -0
- package/dist/tools/decision-enforcement.d.ts.map +1 -0
- package/dist/tools/decision-enforcement.js +184 -0
- package/dist/tools/decision-enforcement.js.map +1 -0
- package/dist/tools/decision-memory.d.ts +130 -0
- package/dist/tools/decision-memory.d.ts.map +1 -0
- package/dist/tools/decision-memory.js +265 -0
- package/dist/tools/decision-memory.js.map +1 -0
- package/dist/tools/decision-windows.d.ts +37 -0
- package/dist/tools/decision-windows.d.ts.map +1 -0
- package/dist/tools/decision-windows.js +67 -0
- package/dist/tools/decision-windows.js.map +1 -0
- package/dist/tools/delegation-score.d.ts +34 -0
- package/dist/tools/delegation-score.d.ts.map +1 -0
- package/dist/tools/delegation-score.js +250 -0
- package/dist/tools/delegation-score.js.map +1 -0
- package/dist/tools/developer-dna.d.ts +79 -0
- package/dist/tools/developer-dna.d.ts.map +1 -0
- package/dist/tools/developer-dna.js +377 -0
- package/dist/tools/developer-dna.js.map +1 -0
- package/dist/tools/export-context.d.ts +14 -6
- package/dist/tools/export-context.d.ts.map +1 -1
- package/dist/tools/export-context.js +13 -13
- package/dist/tools/export-context.js.map +1 -1
- package/dist/tools/index.d.ts +10 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +14 -0
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/knowledge-gaps.d.ts +11 -1
- package/dist/tools/knowledge-gaps.d.ts.map +1 -1
- package/dist/tools/knowledge-gaps.js.map +1 -1
- package/dist/tools/project-health.d.ts +6 -6
- package/dist/tools/project-health.d.ts.map +1 -1
- package/dist/tools/project-health.js +1 -1
- package/dist/tools/project-health.js.map +1 -1
- package/dist/tools/reverse-mentions.d.ts +8 -8
- package/dist/tools/reverse-mentions.d.ts.map +1 -1
- package/dist/tools/reverse-mentions.js.map +1 -1
- package/dist/tools/semantic-shifts.d.ts +17 -1
- package/dist/tools/semantic-shifts.d.ts.map +1 -1
- package/dist/tools/semantic-shifts.js.map +1 -1
- package/dist/tools/signal-chains.d.ts +14 -7
- package/dist/tools/signal-chains.d.ts.map +1 -1
- package/dist/tools/signal-chains.js.map +1 -1
- package/dist/tools/tech-radar.d.ts +38 -0
- package/dist/tools/tech-radar.d.ts.map +1 -0
- package/dist/tools/tech-radar.js +248 -0
- package/dist/tools/tech-radar.js.map +1 -0
- package/dist/types.d.ts +109 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +26 -14
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* agent_memory tool
|
|
3
|
+
*
|
|
4
|
+
* Cross-agent persistent memory. What Claude Code learns, Cursor can access.
|
|
5
|
+
* Enables AI agents to store and recall memories across sessions and tools.
|
|
6
|
+
*/
|
|
7
|
+
// ============================================================================
|
|
8
|
+
// Tool Definition
|
|
9
|
+
// ============================================================================
|
|
10
|
+
export const agentMemoryTool = {
|
|
11
|
+
name: "agent_memory",
|
|
12
|
+
description: "Cross-agent persistent memory. Actions: store (save a memory), recall (search by subject), recall_by_tags (search by tags), get_recent (memories since timestamp). What one agent learns, all agents can access.",
|
|
13
|
+
inputSchema: {
|
|
14
|
+
type: "object",
|
|
15
|
+
properties: {
|
|
16
|
+
action: {
|
|
17
|
+
type: "string",
|
|
18
|
+
enum: ["store", "recall", "recall_by_tags", "get_recent"],
|
|
19
|
+
description: "Action to perform",
|
|
20
|
+
},
|
|
21
|
+
session_id: {
|
|
22
|
+
type: "string",
|
|
23
|
+
description: "Session identifier (for store)",
|
|
24
|
+
},
|
|
25
|
+
agent_type: {
|
|
26
|
+
type: "string",
|
|
27
|
+
description: "Agent identifier, e.g. claude_code, cursor, windsurf (for store)",
|
|
28
|
+
},
|
|
29
|
+
memory_type: {
|
|
30
|
+
type: "string",
|
|
31
|
+
enum: ["discovery", "decision", "context", "warning", "preference"],
|
|
32
|
+
description: "Type of memory (for store). Default: context",
|
|
33
|
+
},
|
|
34
|
+
subject: {
|
|
35
|
+
type: "string",
|
|
36
|
+
description: "Short subject line for the memory (for store)",
|
|
37
|
+
},
|
|
38
|
+
content: {
|
|
39
|
+
type: "string",
|
|
40
|
+
description: "Full memory content (for store)",
|
|
41
|
+
},
|
|
42
|
+
context_tags: {
|
|
43
|
+
type: "array",
|
|
44
|
+
items: { type: "string" },
|
|
45
|
+
description: "Tags for categorization (for store)",
|
|
46
|
+
},
|
|
47
|
+
expires_at: {
|
|
48
|
+
type: "string",
|
|
49
|
+
description: "ISO datetime when this memory expires (for store, optional)",
|
|
50
|
+
},
|
|
51
|
+
query: {
|
|
52
|
+
type: "string",
|
|
53
|
+
description: "Search term to match against subject and tags (for recall)",
|
|
54
|
+
},
|
|
55
|
+
filter_agent: {
|
|
56
|
+
type: "string",
|
|
57
|
+
description: "Filter results to a specific agent type (for recall, get_recent)",
|
|
58
|
+
},
|
|
59
|
+
limit: {
|
|
60
|
+
type: "number",
|
|
61
|
+
description: "Max results to return (default 20)",
|
|
62
|
+
},
|
|
63
|
+
tags: {
|
|
64
|
+
type: "array",
|
|
65
|
+
items: { type: "string" },
|
|
66
|
+
description: "Tags to search for (for recall_by_tags)",
|
|
67
|
+
},
|
|
68
|
+
since: {
|
|
69
|
+
type: "string",
|
|
70
|
+
description: "ISO datetime to get memories after (for get_recent)",
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
required: ["action"],
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
// ============================================================================
|
|
77
|
+
// Helpers
|
|
78
|
+
// ============================================================================
|
|
79
|
+
function parseMemoryRow(row) {
|
|
80
|
+
return {
|
|
81
|
+
id: row.id,
|
|
82
|
+
session_id: row.session_id,
|
|
83
|
+
agent_type: row.agent_type,
|
|
84
|
+
memory_type: row.memory_type,
|
|
85
|
+
subject: row.subject,
|
|
86
|
+
content: row.content,
|
|
87
|
+
context_tags: JSON.parse(row.context_tags || "[]"),
|
|
88
|
+
created_at: row.created_at,
|
|
89
|
+
expires_at: row.expires_at,
|
|
90
|
+
promoted_to_decision_id: row.promoted_to_decision_id,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
// ============================================================================
|
|
94
|
+
// Execute
|
|
95
|
+
// ============================================================================
|
|
96
|
+
export function executeAgentMemory(db, params) {
|
|
97
|
+
const rawDb = db.getRawDb();
|
|
98
|
+
switch (params.action) {
|
|
99
|
+
// ========================================================================
|
|
100
|
+
// STORE
|
|
101
|
+
// ========================================================================
|
|
102
|
+
case "store": {
|
|
103
|
+
if (!params.subject || !params.content) {
|
|
104
|
+
return { error: "subject and content are required for store action" };
|
|
105
|
+
}
|
|
106
|
+
try {
|
|
107
|
+
const stmt = rawDb.prepare(`INSERT INTO agent_memory
|
|
108
|
+
(session_id, agent_type, memory_type, subject, content, context_tags, expires_at)
|
|
109
|
+
VALUES (?, ?, ?, ?, ?, ?, ?)`);
|
|
110
|
+
const result = stmt.run(params.session_id || "unknown", params.agent_type || "unknown", params.memory_type || "context", params.subject, params.content, JSON.stringify(params.context_tags || []), params.expires_at || null);
|
|
111
|
+
return {
|
|
112
|
+
success: true,
|
|
113
|
+
id: result.lastInsertRowid,
|
|
114
|
+
message: `Memory stored: ${params.subject}`,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
return {
|
|
119
|
+
error: `Failed to store memory: ${error instanceof Error ? error.message : String(error)}`,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
// ========================================================================
|
|
124
|
+
// RECALL
|
|
125
|
+
// ========================================================================
|
|
126
|
+
case "recall": {
|
|
127
|
+
if (!params.query) {
|
|
128
|
+
return { error: "query is required for recall action" };
|
|
129
|
+
}
|
|
130
|
+
try {
|
|
131
|
+
const pattern = `%${params.query.toLowerCase()}%`;
|
|
132
|
+
let sql = `SELECT id, session_id, agent_type, memory_type, subject, content,
|
|
133
|
+
context_tags, created_at, expires_at, promoted_to_decision_id
|
|
134
|
+
FROM agent_memory
|
|
135
|
+
WHERE (LOWER(subject) LIKE ? OR LOWER(context_tags) LIKE ?)
|
|
136
|
+
AND (expires_at IS NULL OR expires_at > datetime('now'))`;
|
|
137
|
+
const sqlParams = [pattern, pattern];
|
|
138
|
+
if (params.filter_agent) {
|
|
139
|
+
sql += ` AND agent_type = ?`;
|
|
140
|
+
sqlParams.push(params.filter_agent);
|
|
141
|
+
}
|
|
142
|
+
sql += ` ORDER BY created_at DESC LIMIT ?`;
|
|
143
|
+
sqlParams.push(params.limit || 20);
|
|
144
|
+
const rows = rawDb.prepare(sql).all(...sqlParams);
|
|
145
|
+
return {
|
|
146
|
+
memories: rows.map(parseMemoryRow),
|
|
147
|
+
count: rows.length,
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
catch (error) {
|
|
151
|
+
return {
|
|
152
|
+
memories: [],
|
|
153
|
+
count: 0,
|
|
154
|
+
error: `Failed to recall memories: ${error instanceof Error ? error.message : String(error)}`,
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
// ========================================================================
|
|
159
|
+
// RECALL BY TAGS
|
|
160
|
+
// ========================================================================
|
|
161
|
+
case "recall_by_tags": {
|
|
162
|
+
if (!params.tags || params.tags.length === 0) {
|
|
163
|
+
return { error: "tags array is required for recall_by_tags action" };
|
|
164
|
+
}
|
|
165
|
+
try {
|
|
166
|
+
// Build OR conditions for each tag
|
|
167
|
+
const conditions = params.tags.map(() => `LOWER(context_tags) LIKE ?`);
|
|
168
|
+
const tagParams = params.tags.map((t) => `%${t.toLowerCase()}%`);
|
|
169
|
+
const sql = `SELECT id, session_id, agent_type, memory_type, subject, content,
|
|
170
|
+
context_tags, created_at, expires_at, promoted_to_decision_id
|
|
171
|
+
FROM agent_memory
|
|
172
|
+
WHERE (${conditions.join(" OR ")})
|
|
173
|
+
AND (expires_at IS NULL OR expires_at > datetime('now'))
|
|
174
|
+
ORDER BY created_at DESC LIMIT ?`;
|
|
175
|
+
const rows = rawDb
|
|
176
|
+
.prepare(sql)
|
|
177
|
+
.all(...tagParams, params.limit || 20);
|
|
178
|
+
return {
|
|
179
|
+
memories: rows.map(parseMemoryRow),
|
|
180
|
+
count: rows.length,
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
catch (error) {
|
|
184
|
+
return {
|
|
185
|
+
memories: [],
|
|
186
|
+
count: 0,
|
|
187
|
+
error: `Failed to recall by tags: ${error instanceof Error ? error.message : String(error)}`,
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
// ========================================================================
|
|
192
|
+
// GET RECENT
|
|
193
|
+
// ========================================================================
|
|
194
|
+
case "get_recent": {
|
|
195
|
+
const since = params.since ||
|
|
196
|
+
new Date(Date.now() - 24 * 60 * 60 * 1000).toISOString();
|
|
197
|
+
try {
|
|
198
|
+
let sql = `SELECT id, session_id, agent_type, memory_type, subject, content,
|
|
199
|
+
context_tags, created_at, expires_at, promoted_to_decision_id
|
|
200
|
+
FROM agent_memory
|
|
201
|
+
WHERE created_at > ?`;
|
|
202
|
+
const sqlParams = [since];
|
|
203
|
+
if (params.filter_agent) {
|
|
204
|
+
sql += ` AND agent_type = ?`;
|
|
205
|
+
sqlParams.push(params.filter_agent);
|
|
206
|
+
}
|
|
207
|
+
sql += ` ORDER BY created_at DESC LIMIT ?`;
|
|
208
|
+
sqlParams.push(params.limit || 50);
|
|
209
|
+
const rows = rawDb.prepare(sql).all(...sqlParams);
|
|
210
|
+
return {
|
|
211
|
+
memories: rows.map(parseMemoryRow),
|
|
212
|
+
count: rows.length,
|
|
213
|
+
since,
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
catch (error) {
|
|
217
|
+
return {
|
|
218
|
+
memories: [],
|
|
219
|
+
count: 0,
|
|
220
|
+
since,
|
|
221
|
+
error: `Failed to get recent memories: ${error instanceof Error ? error.message : String(error)}`,
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
default:
|
|
226
|
+
return { error: `Unknown action: ${params.action}` };
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
//# sourceMappingURL=agent-memory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-memory.js","sourceRoot":"","sources":["../../src/tools/agent-memory.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAyCH,+EAA+E;AAC/E,kBAAkB;AAClB,+EAA+E;AAE/E,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,IAAI,EAAE,cAAc;IACpB,WAAW,EACT,kNAAkN;IACpN,WAAW,EAAE;QACX,IAAI,EAAE,QAAiB;QACvB,UAAU,EAAE;YACV,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,YAAY,CAAC;gBACzD,WAAW,EAAE,mBAAmB;aACjC;YACD,UAAU,EAAE;gBACV,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,gCAAgC;aAC9C;YACD,UAAU,EAAE;gBACV,IAAI,EAAE,QAAQ;gBACd,WAAW,EACT,kEAAkE;aACrE;YACD,WAAW,EAAE;gBACX,IAAI,EAAE,QAAQ;gB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,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* agent_session_brief tool
|
|
3
|
+
*
|
|
4
|
+
* Tailored session startup context for AI agents.
|
|
5
|
+
* Call at the START of every agent session to get caught up on:
|
|
6
|
+
* - Active developer decisions
|
|
7
|
+
* - Ecosystem changes (security, breaking, releases)
|
|
8
|
+
* - Recent agent memories from all agents
|
|
9
|
+
* - Latest briefing text
|
|
10
|
+
*/
|
|
11
|
+
import type { FourDADatabase } from "../db.js";
|
|
12
|
+
export interface AgentSessionBriefParams {
|
|
13
|
+
agent_type?: string;
|
|
14
|
+
since?: string;
|
|
15
|
+
include_decisions?: boolean;
|
|
16
|
+
include_memories?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare const agentSessionBriefTool: {
|
|
19
|
+
name: string;
|
|
20
|
+
description: string;
|
|
21
|
+
inputSchema: {
|
|
22
|
+
type: "object";
|
|
23
|
+
properties: {
|
|
24
|
+
agent_type: {
|
|
25
|
+
type: string;
|
|
26
|
+
description: string;
|
|
27
|
+
};
|
|
28
|
+
since: {
|
|
29
|
+
type: string;
|
|
30
|
+
description: string;
|
|
31
|
+
};
|
|
32
|
+
include_decisions: {
|
|
33
|
+
type: string;
|
|
34
|
+
description: string;
|
|
35
|
+
};
|
|
36
|
+
include_memories: {
|
|
37
|
+
type: string;
|
|
38
|
+
description: string;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
export declare function executeAgentSessionBrief(db: FourDADatabase, params: AgentSessionBriefParams): object;
|
|
44
|
+
//# sourceMappingURL=agent-session-brief.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-session-brief.d.ts","sourceRoot":"","sources":["../../src/tools/agent-session-brief.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAM/C,MAAM,WAAW,uBAAuB;IACtC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAmCD,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;CA2BjC,CAAC;AAMF,wBAAgB,wBAAwB,CACtC,EAAE,EAAE,cAAc,EAClB,MAAM,EAAE,uBAAuB,GAC9B,MAAM,CAwJR"}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* agent_session_brief tool
|
|
3
|
+
*
|
|
4
|
+
* Tailored session startup context for AI agents.
|
|
5
|
+
* Call at the START of every agent session to get caught up on:
|
|
6
|
+
* - Active developer decisions
|
|
7
|
+
* - Ecosystem changes (security, breaking, releases)
|
|
8
|
+
* - Recent agent memories from all agents
|
|
9
|
+
* - Latest briefing text
|
|
10
|
+
*/
|
|
11
|
+
// ============================================================================
|
|
12
|
+
// Tool Definition
|
|
13
|
+
// ============================================================================
|
|
14
|
+
export const agentSessionBriefTool = {
|
|
15
|
+
name: "agent_session_brief",
|
|
16
|
+
description: "Tailored session startup context for AI agents. Returns active decisions, ecosystem changes, recent agent memories, and latest briefing. Call at START of every agent session.",
|
|
17
|
+
inputSchema: {
|
|
18
|
+
type: "object",
|
|
19
|
+
properties: {
|
|
20
|
+
agent_type: {
|
|
21
|
+
type: "string",
|
|
22
|
+
description: "Agent identifier (e.g. claude_code, cursor). Filters memories to this agent if provided.",
|
|
23
|
+
},
|
|
24
|
+
since: {
|
|
25
|
+
type: "string",
|
|
26
|
+
description: "ISO datetime to look back from. Default: 24 hours ago.",
|
|
27
|
+
},
|
|
28
|
+
include_decisions: {
|
|
29
|
+
type: "boolean",
|
|
30
|
+
description: "Include active developer decisions. Default: true.",
|
|
31
|
+
},
|
|
32
|
+
include_memories: {
|
|
33
|
+
type: "boolean",
|
|
34
|
+
description: "Include recent agent memories. Default: true.",
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
// ============================================================================
|
|
40
|
+
// Execute
|
|
41
|
+
// ============================================================================
|
|
42
|
+
export function executeAgentSessionBrief(db, params) {
|
|
43
|
+
const rawDb = db.getRawDb();
|
|
44
|
+
const agentType = params.agent_type || "unknown";
|
|
45
|
+
const since = params.since ||
|
|
46
|
+
new Date(Date.now() - 24 * 60 * 60 * 1000).toISOString();
|
|
47
|
+
const includeDecisions = params.include_decisions !== false;
|
|
48
|
+
const includeMemories = params.include_memories !== false;
|
|
49
|
+
// 1. Active decisions
|
|
50
|
+
let activeDecisions = [];
|
|
51
|
+
if (includeDecisions) {
|
|
52
|
+
try {
|
|
53
|
+
const rows = rawDb
|
|
54
|
+
.prepare(`SELECT id, subject, decision, decision_type, confidence
|
|
55
|
+
FROM developer_decisions
|
|
56
|
+
WHERE status = 'active'
|
|
57
|
+
ORDER BY confidence DESC
|
|
58
|
+
LIMIT 20`)
|
|
59
|
+
.all();
|
|
60
|
+
activeDecisions = rows.map((r) => ({
|
|
61
|
+
id: r.id,
|
|
62
|
+
subject: r.subject,
|
|
63
|
+
decision: r.decision,
|
|
64
|
+
type: r.decision_type,
|
|
65
|
+
confidence: r.confidence,
|
|
66
|
+
}));
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
// developer_decisions table may not exist yet
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
// 2. Ecosystem changes (security, breaking, releases, updates)
|
|
73
|
+
let ecosystemChanges = [];
|
|
74
|
+
try {
|
|
75
|
+
const rows = rawDb
|
|
76
|
+
.prepare(`SELECT id, title, source_type, created_at
|
|
77
|
+
FROM source_items
|
|
78
|
+
WHERE created_at > ?
|
|
79
|
+
AND (
|
|
80
|
+
LOWER(title) LIKE '%security%'
|
|
81
|
+
OR LOWER(title) LIKE '%breaking%'
|
|
82
|
+
OR LOWER(title) LIKE '%release%'
|
|
83
|
+
OR LOWER(title) LIKE '%update%'
|
|
84
|
+
)
|
|
85
|
+
ORDER BY created_at DESC
|
|
86
|
+
LIMIT 20`)
|
|
87
|
+
.all(since);
|
|
88
|
+
ecosystemChanges = rows.map((r) => {
|
|
89
|
+
const titleLower = r.title.toLowerCase();
|
|
90
|
+
let changeType = "update";
|
|
91
|
+
if (titleLower.includes("security"))
|
|
92
|
+
changeType = "security";
|
|
93
|
+
else if (titleLower.includes("breaking"))
|
|
94
|
+
changeType = "breaking_change";
|
|
95
|
+
else if (titleLower.includes("release"))
|
|
96
|
+
changeType = "release";
|
|
97
|
+
return {
|
|
98
|
+
change_type: changeType,
|
|
99
|
+
subject: r.title,
|
|
100
|
+
summary: `[${r.source_type}] ${r.title}`,
|
|
101
|
+
};
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
catch {
|
|
105
|
+
// source_items table may not exist yet
|
|
106
|
+
}
|
|
107
|
+
// 3. Recent agent memories
|
|
108
|
+
let agentMemories = [];
|
|
109
|
+
if (includeMemories) {
|
|
110
|
+
try {
|
|
111
|
+
let memorySql = `SELECT id, agent_type, memory_type, subject, content, created_at
|
|
112
|
+
FROM agent_memory
|
|
113
|
+
WHERE created_at > ?`;
|
|
114
|
+
const memoryParams = [since];
|
|
115
|
+
if (params.agent_type) {
|
|
116
|
+
memorySql += ` AND agent_type = ?`;
|
|
117
|
+
memoryParams.push(params.agent_type);
|
|
118
|
+
}
|
|
119
|
+
memorySql += ` ORDER BY created_at DESC LIMIT 30`;
|
|
120
|
+
const rows = rawDb
|
|
121
|
+
.prepare(memorySql)
|
|
122
|
+
.all(...memoryParams);
|
|
123
|
+
agentMemories = rows.map((r) => ({
|
|
124
|
+
id: r.id,
|
|
125
|
+
agent_type: r.agent_type,
|
|
126
|
+
memory_type: r.memory_type,
|
|
127
|
+
subject: r.subject,
|
|
128
|
+
content: r.content.length > 200
|
|
129
|
+
? r.content.substring(0, 200) + "..."
|
|
130
|
+
: r.content,
|
|
131
|
+
created_at: r.created_at,
|
|
132
|
+
}));
|
|
133
|
+
}
|
|
134
|
+
catch {
|
|
135
|
+
// agent_memory table may not exist yet
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
// 4. Latest briefing
|
|
139
|
+
let recentBriefing = null;
|
|
140
|
+
try {
|
|
141
|
+
const row = rawDb
|
|
142
|
+
.prepare(`SELECT content, created_at FROM briefings ORDER BY created_at DESC LIMIT 1`)
|
|
143
|
+
.get();
|
|
144
|
+
if (row) {
|
|
145
|
+
recentBriefing = row.content;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
catch {
|
|
149
|
+
// briefings table may not exist yet
|
|
150
|
+
}
|
|
151
|
+
// 5. Build summary
|
|
152
|
+
const summaryParts = [];
|
|
153
|
+
if (activeDecisions.length > 0) {
|
|
154
|
+
summaryParts.push(`${activeDecisions.length} active decisions`);
|
|
155
|
+
}
|
|
156
|
+
if (ecosystemChanges.length > 0) {
|
|
157
|
+
summaryParts.push(`${ecosystemChanges.length} ecosystem changes`);
|
|
158
|
+
}
|
|
159
|
+
if (agentMemories.length > 0) {
|
|
160
|
+
summaryParts.push(`${agentMemories.length} recent memories`);
|
|
161
|
+
}
|
|
162
|
+
if (recentBriefing) {
|
|
163
|
+
summaryParts.push("briefing available");
|
|
164
|
+
}
|
|
165
|
+
const summary = summaryParts.length > 0
|
|
166
|
+
? `Session brief for ${agentType}: ${summaryParts.join(", ")}`
|
|
167
|
+
: `No recent activity found since ${since}`;
|
|
168
|
+
return {
|
|
169
|
+
generated_at: new Date().toISOString(),
|
|
170
|
+
agent_type: agentType,
|
|
171
|
+
active_decisions: activeDecisions,
|
|
172
|
+
ecosystem_changes: ecosystemChanges,
|
|
173
|
+
agent_memories: agentMemories,
|
|
174
|
+
recent_briefing: recentBriefing,
|
|
175
|
+
summary,
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
//# sourceMappingURL=agent-session-brief.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-session-brief.js","sourceRoot":"","sources":["../../src/tools/agent-session-brief.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AA4CH,+EAA+E;AAC/E,kBAAkB;AAClB,+EAA+E;AAE/E,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,IAAI,EAAE,qBAAqB;IAC3B,WAAW,EACT,gLAAgL;IAClL,WAAW,EAAE;QACX,IAAI,EAAE,QAAiB;QACvB,UAAU,EAAE;YACV,UAAU,EAAE;gBACV,IAAI,EAAE,QAAQ;gBACd,WAAW,EACT,0FAA0F;aAC7F;YACD,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,WAAW,EACT,wDAAwD;aAC3D;YACD,iBAAiB,EAAE;gBACjB,IAAI,EAAE,SAAS;gBACf,WAAW,EAAE,oDAAoD;aAClE;YACD,gBAAgB,EAAE;gBAChB,IAAI,EAAE,SAAS;gBACf,WAAW,EAAE,+CAA+C;aAC7D;SACF;KACF;CACF,CAAC;AAEF,+EAA+E;AAC/E,UAAU;AACV,+EAA+E;AAE/E,MAAM,UAAU,wBAAwB,CACtC,EAAkB,EAClB,MAA+B;IAE/B,MAAM,KAAK,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC;IAC5B,MAAM,SAAS,GAAG,MAAM,CAAC,UAAU,IAAI,SAAS,CAAC;IACjD,MAAM,KAAK,GACT,MAAM,CAAC,KAAK;QACZ,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;IAC3D,MAAM,gBAAgB,GAAG,MAAM,CAAC,iBAAiB,KAAK,KAAK,CAAC;IAC5D,MAAM,eAAe,GAAG,MAAM,CAAC,gBAAgB,KAAK,KAAK,CAAC;IAE1D,sBAAsB;IACtB,IAAI,eAAe,GAAa,EAAE,CAAC;IACnC,IAAI,gBAAgB,EAAE,CAAC;QACrB,IAAI,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
+
import type { EngagementRow, TopicAffinityRow, CodebaseTopicRow } from "../types.js";
|
|
7
8
|
export interface AttentionReportParams {
|
|
8
9
|
period_days?: number;
|
|
9
10
|
}
|
|
@@ -23,12 +24,12 @@ export declare const attentionReportTool: {
|
|
|
23
24
|
};
|
|
24
25
|
export declare function executeAttentionReport(db: FourDADatabase, params: AttentionReportParams): {
|
|
25
26
|
period_days: number;
|
|
26
|
-
total_interactions:
|
|
27
|
-
engagement_by_source:
|
|
28
|
-
topic_affinities:
|
|
29
|
-
codebase_topics:
|
|
27
|
+
total_interactions: number;
|
|
28
|
+
engagement_by_source: EngagementRow[];
|
|
29
|
+
topic_affinities: TopicAffinityRow[];
|
|
30
|
+
codebase_topics: CodebaseTopicRow[];
|
|
30
31
|
blind_spots: {
|
|
31
|
-
topic:
|
|
32
|
+
topic: string;
|
|
32
33
|
in_codebase: boolean;
|
|
33
34
|
engagement_level: number;
|
|
34
35
|
risk_level: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attention-report.d.ts","sourceRoot":"","sources":["../../src/tools/attention-report.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"attention-report.d.ts","sourceRoot":"","sources":["../../src/tools/attention-report.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAErF,MAAM,WAAW,qBAAqB;IACpC,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;CAa/B,CAAC;AAEF,wBAAgB,sBAAsB,CACpC,EAAE,EAAE,cAAc,EAClB,MAAM,EAAE,qBAAqB;;;;;;;;;;;;;;EAsE9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attention-report.js","sourceRoot":"","sources":["../../src/tools/attention-report.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"attention-report.js","sourceRoot":"","sources":["../../src/tools/attention-report.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,IAAI,EAAE,kBAAkB;IACxB,WAAW,EAAE,8IAA8I;IAC3J,WAAW,EAAE;QACX,IAAI,EAAE,QAAiB;QACvB,UAAU,EAAE;YACV,WAAW,EAAE;gBACX,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,qCAAqC;gBAClD,OAAO,EAAE,CAAC;aACX;SACF;KACF;CACF,CAAC;AAEF,MAAM,UAAU,sBAAsB,CACpC,EAAkB,EAClB,MAA6B;IAE7B,MAAM,KAAK,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC;IAC5B,MAAM,IAAI,GAAG,MAAM,CAAC,WAAW,IAAI,CAAC,CAAC;IAErC,2DAA2D;IAC3D,MAAM,cAAc,GAAG,KAAK;SACzB,OAAO,CACN;;;;;kCAK4B,CAC7B;SACA,GAAG,CAAC,IAAI,CAAoB,CAAC;IAEhC,2CAA2C;IAC3C,MAAM,eAAe,GAAG,KAAK;SAC1B,OAAO,CACN;;;;;gBAKU,CACX;SACA,GAAG,EAAwB,CAAC;IAE/B,yCAAyC;IACzC,MAAM,cAAc,GAAG,KAAK;SACzB,OAAO,CACN;;;gBAGU,CACX;SACA,GAAG,EAAwB,CAAC;IAE/B,uDAAuD;IACvD,MAAM,aAAa,GAAG,IAAI,GAAG,CAC3B,eAAe;SACZ,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,eAAe,GAAG,CAAC,CAAC;SACpC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CACrC,CAAC;IAEF,MAAM,UAAU,GAAG,cAAc;SAC9B,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,aAAa,CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC;SAC1D,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;QACZ,KAAK,EAAE,EAAE,CAAC,KAAK;QACf,WAAW,EAAE,IAAI;QACjB,gBAAgB,EAAE,CAAC;QACnB,UAAU,EAAE,EAAE,CAAC,UAAU,GAAG,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ;QACnD,eAAe,EAAE,GAAG,EAAE,CAAC,KAAK,yBAAyB,EAAE,CAAC,QAAQ,0BAA0B;KAC3F,CAAC,CAAC,CAAC;IAEN,MAAM,iBAAiB,GAAG,cAAc,CAAC,MAAM,CAC7C,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,YAAY,EAChC,CAAC,CACF,CAAC;IAEF,OAAO;QACL,WAAW,EAAE,IAAI;QACjB,kBAAkB,EAAE,iBAAiB;QACrC,oBAAoB,EAAE,cAAc;QACpC,gBAAgB,EAAE,eAAe,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC;QAC9C,eAAe,EAAE,cAAc;QAC/B,WAAW,EAAE,UAAU;QACvB,OAAO,EAAE,GAAG,iBAAiB,sBAAsB,IAAI,UAAU,UAAU,CAAC,MAAM,cAAc,UAAU,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,WAAW;KAC9I,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* autophagy_status tool
|
|
3
|
+
*
|
|
4
|
+
* Intelligence metabolism status — autophagy cycles, calibrations, anti-patterns.
|
|
5
|
+
*/
|
|
6
|
+
import type { FourDADatabase } from "../db.js";
|
|
7
|
+
export interface AutophagyStatusParams {
|
|
8
|
+
limit?: number;
|
|
9
|
+
}
|
|
10
|
+
export declare const autophagyStatusTool: {
|
|
11
|
+
name: string;
|
|
12
|
+
description: string;
|
|
13
|
+
inputSchema: {
|
|
14
|
+
type: "object";
|
|
15
|
+
properties: {
|
|
16
|
+
limit: {
|
|
17
|
+
type: string;
|
|
18
|
+
description: string;
|
|
19
|
+
default: number;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export declare function executeAutophagyStatus(db: FourDADatabase, params: AutophagyStatusParams): object;
|
|
25
|
+
//# sourceMappingURL=autophagy-status.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"autophagy-status.d.ts","sourceRoot":"","sources":["../../src/tools/autophagy-status.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/C,MAAM,WAAW,qBAAqB;IACpC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAmBD,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;CAc/B,CAAC;AAOF,wBAAgB,sBAAsB,CAAC,EAAE,EAAE,cAAc,EAAE,MAAM,EAAE,qBAAqB,GAAG,MAAM,CAwChG"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
export const autophagyStatusTool = {
|
|
2
|
+
name: "autophagy_status",
|
|
3
|
+
description: "Get intelligence metabolism status — autophagy cycle history, calibration accuracy, anti-patterns detected, and scoring corrections applied",
|
|
4
|
+
inputSchema: {
|
|
5
|
+
type: "object",
|
|
6
|
+
properties: {
|
|
7
|
+
limit: {
|
|
8
|
+
type: "number",
|
|
9
|
+
description: "Maximum autophagy cycles to return. Default: 5",
|
|
10
|
+
default: 5,
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
function safeAll(rawDb, sql, ...args) {
|
|
16
|
+
try {
|
|
17
|
+
return rawDb.prepare(sql).all(...args);
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return [];
|
|
21
|
+
} // Table may not exist yet
|
|
22
|
+
}
|
|
23
|
+
export function executeAutophagyStatus(db, params) {
|
|
24
|
+
const rawDb = db.getRawDb();
|
|
25
|
+
const limit = params.limit ?? 5;
|
|
26
|
+
const cycles = safeAll(rawDb, `SELECT id, items_analyzed, calibrations_produced,
|
|
27
|
+
anti_patterns_detected, duration_ms, created_at
|
|
28
|
+
FROM autophagy_cycles ORDER BY created_at DESC LIMIT ?`, limit);
|
|
29
|
+
const calibrations = safeAll(rawDb, `SELECT id, digest_type, content, confidence, created_at
|
|
30
|
+
FROM digested_intelligence
|
|
31
|
+
WHERE digest_type = 'calibration' AND superseded_by IS NULL
|
|
32
|
+
ORDER BY created_at DESC`);
|
|
33
|
+
const antiPatterns = safeAll(rawDb, `SELECT id, digest_type, content, confidence, created_at
|
|
34
|
+
FROM digested_intelligence
|
|
35
|
+
WHERE digest_type = 'anti_pattern' AND superseded_by IS NULL
|
|
36
|
+
ORDER BY created_at DESC`);
|
|
37
|
+
let totalCycles = 0;
|
|
38
|
+
if (cycles.length > 0) {
|
|
39
|
+
const row = rawDb.prepare("SELECT COUNT(*) as cnt FROM autophagy_cycles").get();
|
|
40
|
+
totalCycles = row?.cnt ?? 0;
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
cycles,
|
|
44
|
+
active_calibrations: calibrations,
|
|
45
|
+
active_anti_patterns: antiPatterns,
|
|
46
|
+
totals: {
|
|
47
|
+
cycles_run: totalCycles,
|
|
48
|
+
active_calibrations: calibrations.length,
|
|
49
|
+
active_anti_patterns: antiPatterns.length,
|
|
50
|
+
},
|
|
51
|
+
summary: totalCycles === 0
|
|
52
|
+
? "No autophagy cycles have run yet. The metabolism system will activate as content accumulates."
|
|
53
|
+
: `${totalCycles} cycles completed — ${calibrations.length} active calibrations, ${antiPatterns.length} active anti-patterns`,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=autophagy-status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"autophagy-status.js","sourceRoot":"","sources":["../../src/tools/autophagy-status.ts"],"names":[],"mappings":"AA4BA,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,IAAI,EAAE,kBAAkB;IACxB,WAAW,EACT,6IAA6I;IAC/I,WAAW,EAAE;QACX,IAAI,EAAE,QAAiB;QACvB,UAAU,EAAE;YACV,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,gDAAgD;gBAC7D,OAAO,EAAE,CAAC;aACX;SACF;KACF;CACF,CAAC;AAEF,SAAS,OAAO,CAAI,KAA6C,EAAE,GAAW,EAAE,GAAG,IAAe;IAChG,IAAI,CAAC;QAAC,OAAO,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,CAAQ,CAAC;IAAC,CAAC;IACtD,MAAM,CAAC;QAAC,OAAO,EAAE,CAAC;IAAC,CAAC,CAAC,0BAA0B;AACjD,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,EAAkB,EAAE,MAA6B;IACtF,MAAM,KAAK,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC;IAC5B,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,IAAI,CAAC,CAAC;IAEhC,MAAM,MAAM,GAAG,OAAO,CAAW,KAAK,EACpC;;4DAEwD,EAAE,KAAK,CAAC,CAAC;IAEnE,MAAM,YAAY,GAAG,OAAO,CAAY,KAAK,EAC3C;;;8BAG0B,CAAC,CAAC;IAE9B,MAAM,YAAY,GAAG,OAAO,CAAY,KAAK,EAC3C;;;8BAG0B,CAAC,CAAC;IAE9B,IAAI,WAAW,GAAG,CAAC,CAAC;IACpB,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,MAAM,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC,8CAA8C,CAAC,CAAC,GAAG,EAAiC,CAAC;QAC/G,WAAW,GAAG,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;IAC9B,CAAC;IAED,OAAO;QACL,MAAM;QACN,mBAAmB,EAAE,YAAY;QACjC,oBAAoB,EAAE,YAAY;QAClC,MAAM,EAAE;YACN,UAAU,EAAE,WAAW;YACvB,mBAAmB,EAAE,YAAY,CAAC,MAAM;YACxC,oBAAoB,EAAE,YAAY,CAAC,MAAM;SAC1C;QACD,OAAO,EAAE,WAAW,KAAK,CAAC;YACxB,CAAC,CAAC,+FAA+F;YACjG,CAAC,CAAC,GAAG,WAAW,uBAAuB,YAAY,CAAC,MAAM,yBAAyB,YAAY,CAAC,MAAM,uBAAuB;KAChI,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* compound_advantage tool
|
|
3
|
+
*
|
|
4
|
+
* Compound advantage score — measures how effectively you leverage
|
|
5
|
+
* 4DA intelligence for time-sensitive decisions.
|
|
6
|
+
*/
|
|
7
|
+
import type { FourDADatabase } from "../db.js";
|
|
8
|
+
export interface CompoundAdvantageParams {
|
|
9
|
+
period?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare const compoundAdvantageTool: {
|
|
12
|
+
name: string;
|
|
13
|
+
description: string;
|
|
14
|
+
inputSchema: {
|
|
15
|
+
type: "object";
|
|
16
|
+
properties: {
|
|
17
|
+
period: {
|
|
18
|
+
type: string;
|
|
19
|
+
enum: string[];
|
|
20
|
+
description: string;
|
|
21
|
+
default: string;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
export declare function executeCompoundAdvantage(db: FourDADatabase, params: CompoundAdvantageParams): object;
|
|
27
|
+
//# sourceMappingURL=compound-advantage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compound-advantage.d.ts","sourceRoot":"","sources":["../../src/tools/compound-advantage.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/C,MAAM,WAAW,uBAAuB;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAYD,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;CAejC,CAAC;AAEF,wBAAgB,wBAAwB,CAAC,EAAE,EAAE,cAAc,EAAE,MAAM,EAAE,uBAAuB,GAAG,MAAM,CA4DpG"}
|