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