@lanonasis/mem-intel-sdk 2.0.3 → 2.0.5
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/server/index.cjs +182 -0
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.js +182 -0
- package/dist/server/index.js.map +1 -1
- package/package.json +2 -2
package/dist/server/index.js
CHANGED
|
@@ -1502,6 +1502,188 @@ ${data.overall_summary}
|
|
|
1502
1502
|
}
|
|
1503
1503
|
}
|
|
1504
1504
|
);
|
|
1505
|
+
server.registerTool(
|
|
1506
|
+
"behavior_record",
|
|
1507
|
+
{
|
|
1508
|
+
title: "Record Behavior Pattern",
|
|
1509
|
+
description: `Record a successful workflow pattern for future recall.`,
|
|
1510
|
+
inputSchema: z.object({
|
|
1511
|
+
user_id: z.string().uuid(),
|
|
1512
|
+
trigger: z.string().min(1, "Trigger description is required"),
|
|
1513
|
+
context: z.object({
|
|
1514
|
+
directory: z.string(),
|
|
1515
|
+
project_type: z.string().optional(),
|
|
1516
|
+
branch: z.string().optional(),
|
|
1517
|
+
files_touched: z.array(z.string()).optional()
|
|
1518
|
+
}).optional(),
|
|
1519
|
+
actions: z.array(z.object({
|
|
1520
|
+
tool: z.string(),
|
|
1521
|
+
parameters: z.record(z.unknown()).optional(),
|
|
1522
|
+
outcome: z.enum(["success", "partial", "failed"]),
|
|
1523
|
+
timestamp: z.string().optional(),
|
|
1524
|
+
duration_ms: z.number().optional()
|
|
1525
|
+
})).min(1, "At least one action is required"),
|
|
1526
|
+
final_outcome: z.enum(["success", "partial", "failed"]),
|
|
1527
|
+
confidence: z.number().min(0).max(1).default(0.7)
|
|
1528
|
+
}).strict(),
|
|
1529
|
+
annotations: {
|
|
1530
|
+
readOnlyHint: false,
|
|
1531
|
+
destructiveHint: false,
|
|
1532
|
+
idempotentHint: true,
|
|
1533
|
+
openWorldHint: false
|
|
1534
|
+
}
|
|
1535
|
+
},
|
|
1536
|
+
async (rawParams) => {
|
|
1537
|
+
try {
|
|
1538
|
+
const response = await client.recordBehavior({
|
|
1539
|
+
user_id: rawParams.user_id,
|
|
1540
|
+
trigger: rawParams.trigger,
|
|
1541
|
+
context: rawParams.context || {},
|
|
1542
|
+
actions: rawParams.actions,
|
|
1543
|
+
final_outcome: rawParams.final_outcome,
|
|
1544
|
+
confidence: rawParams.confidence
|
|
1545
|
+
});
|
|
1546
|
+
return {
|
|
1547
|
+
content: [{
|
|
1548
|
+
type: "text",
|
|
1549
|
+
text: `Behavior pattern recorded: ${response.data.message}
|
|
1550
|
+
Pattern ID: ${response.data.pattern.id}
|
|
1551
|
+
Was duplicate: ${response.data.was_duplicate}`
|
|
1552
|
+
}]
|
|
1553
|
+
};
|
|
1554
|
+
} catch (error) {
|
|
1555
|
+
return {
|
|
1556
|
+
isError: true,
|
|
1557
|
+
content: [
|
|
1558
|
+
{
|
|
1559
|
+
type: "text",
|
|
1560
|
+
text: `Error: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
1561
|
+
}
|
|
1562
|
+
]
|
|
1563
|
+
};
|
|
1564
|
+
}
|
|
1565
|
+
}
|
|
1566
|
+
);
|
|
1567
|
+
server.registerTool(
|
|
1568
|
+
"behavior_recall",
|
|
1569
|
+
{
|
|
1570
|
+
title: "Recall Behavior Patterns",
|
|
1571
|
+
description: `Recall similar behavior patterns based on current context.`,
|
|
1572
|
+
inputSchema: z.object({
|
|
1573
|
+
user_id: z.string().uuid(),
|
|
1574
|
+
context: z.object({
|
|
1575
|
+
current_task: z.string().min(1, "Current task description is required"),
|
|
1576
|
+
directory: z.string().optional(),
|
|
1577
|
+
project_type: z.string().optional()
|
|
1578
|
+
}),
|
|
1579
|
+
limit: z.number().int().min(1).max(20).default(5),
|
|
1580
|
+
similarity_threshold: z.number().min(0).max(1).default(0.7)
|
|
1581
|
+
}).strict(),
|
|
1582
|
+
annotations: {
|
|
1583
|
+
readOnlyHint: true,
|
|
1584
|
+
destructiveHint: false,
|
|
1585
|
+
idempotentHint: true,
|
|
1586
|
+
openWorldHint: true
|
|
1587
|
+
}
|
|
1588
|
+
},
|
|
1589
|
+
async (rawParams) => {
|
|
1590
|
+
try {
|
|
1591
|
+
const response = await client.recallBehavior({
|
|
1592
|
+
user_id: rawParams.user_id,
|
|
1593
|
+
context: rawParams.context,
|
|
1594
|
+
limit: rawParams.limit,
|
|
1595
|
+
similarity_threshold: rawParams.similarity_threshold
|
|
1596
|
+
});
|
|
1597
|
+
const patterns = response.data?.patterns || [];
|
|
1598
|
+
let text = `Found ${patterns.length} behavior patterns:
|
|
1599
|
+
|
|
1600
|
+
`;
|
|
1601
|
+
patterns.forEach((pattern, i) => {
|
|
1602
|
+
text += `${i + 1}. "${pattern.pattern.trigger}" (${Math.round(pattern.similarity_score * 100)}% similar)
|
|
1603
|
+
`;
|
|
1604
|
+
text += ` Actions: ${pattern.pattern.actions.map((a) => a.tool).join(" \u2192 ")}
|
|
1605
|
+
`;
|
|
1606
|
+
text += ` Outcome: ${pattern.pattern.final_outcome}
|
|
1607
|
+
|
|
1608
|
+
`;
|
|
1609
|
+
});
|
|
1610
|
+
return {
|
|
1611
|
+
content: [{ type: "text", text }]
|
|
1612
|
+
};
|
|
1613
|
+
} catch (error) {
|
|
1614
|
+
return {
|
|
1615
|
+
isError: true,
|
|
1616
|
+
content: [
|
|
1617
|
+
{
|
|
1618
|
+
type: "text",
|
|
1619
|
+
text: `Error: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
1620
|
+
}
|
|
1621
|
+
]
|
|
1622
|
+
};
|
|
1623
|
+
}
|
|
1624
|
+
}
|
|
1625
|
+
);
|
|
1626
|
+
server.registerTool(
|
|
1627
|
+
"behavior_suggest",
|
|
1628
|
+
{
|
|
1629
|
+
title: "Suggest Next Actions",
|
|
1630
|
+
description: `Get AI-powered action suggestions based on learned patterns.`,
|
|
1631
|
+
inputSchema: z.object({
|
|
1632
|
+
user_id: z.string().uuid(),
|
|
1633
|
+
current_state: z.object({
|
|
1634
|
+
task_description: z.string().min(1, "Task description is required"),
|
|
1635
|
+
completed_steps: z.array(z.object({
|
|
1636
|
+
tool: z.string(),
|
|
1637
|
+
params: z.record(z.unknown()).optional()
|
|
1638
|
+
})).optional()
|
|
1639
|
+
}),
|
|
1640
|
+
max_suggestions: z.number().int().min(1).max(10).default(3)
|
|
1641
|
+
}).strict(),
|
|
1642
|
+
annotations: {
|
|
1643
|
+
readOnlyHint: true,
|
|
1644
|
+
destructiveHint: false,
|
|
1645
|
+
idempotentHint: true,
|
|
1646
|
+
openWorldHint: true
|
|
1647
|
+
}
|
|
1648
|
+
},
|
|
1649
|
+
async (rawParams) => {
|
|
1650
|
+
try {
|
|
1651
|
+
const response = await client.suggestAction({
|
|
1652
|
+
user_id: rawParams.user_id,
|
|
1653
|
+
current_state: rawParams.current_state,
|
|
1654
|
+
max_suggestions: rawParams.max_suggestions
|
|
1655
|
+
});
|
|
1656
|
+
const suggestions = response.data?.suggestions || [];
|
|
1657
|
+
let text = `Suggested actions:
|
|
1658
|
+
|
|
1659
|
+
`;
|
|
1660
|
+
suggestions.forEach((suggestion, i) => {
|
|
1661
|
+
text += `${i + 1}. ${suggestion.action}
|
|
1662
|
+
`;
|
|
1663
|
+
text += ` Tool: ${suggestion.tool}
|
|
1664
|
+
`;
|
|
1665
|
+
text += ` Confidence: ${Math.round(suggestion.confidence * 100)}%
|
|
1666
|
+
`;
|
|
1667
|
+
text += ` Reasoning: ${suggestion.reasoning}
|
|
1668
|
+
|
|
1669
|
+
`;
|
|
1670
|
+
});
|
|
1671
|
+
return {
|
|
1672
|
+
content: [{ type: "text", text }]
|
|
1673
|
+
};
|
|
1674
|
+
} catch (error) {
|
|
1675
|
+
return {
|
|
1676
|
+
isError: true,
|
|
1677
|
+
content: [
|
|
1678
|
+
{
|
|
1679
|
+
type: "text",
|
|
1680
|
+
text: `Error: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
1681
|
+
}
|
|
1682
|
+
]
|
|
1683
|
+
};
|
|
1684
|
+
}
|
|
1685
|
+
}
|
|
1686
|
+
);
|
|
1505
1687
|
return server;
|
|
1506
1688
|
}
|
|
1507
1689
|
|