@persistadev/mcp-server 3.6.3 → 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/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * Persista MCP Server v3.0 - Complete AI Memory Infrastructure
3
+ * Persista MCP Server v4.0 - Complete AI Memory Infrastructure + Multi-Agent Coordination
4
4
  *
5
5
  * FEATURES:
6
6
  * ═══════════════════════════════════════════════════════════════
@@ -32,6 +32,14 @@
32
32
  * - User pattern learning
33
33
  * - Migration guides
34
34
  *
35
+ * 🤖 MULTI-AGENT COORDINATION (v4 - NEW!)
36
+ * - Agent registry & discovery
37
+ * - File locking (prevents conflicts)
38
+ * - Task queue & assignment
39
+ * - Agent-to-agent messaging
40
+ * - Conflict detection & resolution
41
+ * - Coordinator directives
42
+ *
35
43
  * 🚀 AUTO-HOOKS
36
44
  * - Git tracking between sessions
37
45
  * - Codebase analysis
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG"}
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
3
  /**
4
- * Persista MCP Server v3.0 - Complete AI Memory Infrastructure
4
+ * Persista MCP Server v4.0 - Complete AI Memory Infrastructure + Multi-Agent Coordination
5
5
  *
6
6
  * FEATURES:
7
7
  * ═══════════════════════════════════════════════════════════════
@@ -33,6 +33,14 @@
33
33
  * - User pattern learning
34
34
  * - Migration guides
35
35
  *
36
+ * 🤖 MULTI-AGENT COORDINATION (v4 - NEW!)
37
+ * - Agent registry & discovery
38
+ * - File locking (prevents conflicts)
39
+ * - Task queue & assignment
40
+ * - Agent-to-agent messaging
41
+ * - Conflict detection & resolution
42
+ * - Coordinator directives
43
+ *
36
44
  * 🚀 AUTO-HOOKS
37
45
  * - Git tracking between sessions
38
46
  * - Codebase analysis
@@ -51,6 +59,8 @@ const child_process_1 = require("child_process");
51
59
  const fs_1 = __importDefault(require("fs"));
52
60
  const path_1 = __importDefault(require("path"));
53
61
  const knowledge_base_js_1 = require("./knowledge-base.js");
62
+ const multi_agent_tools_js_1 = require("./multi-agent-tools.js");
63
+ const multi_agent_handlers_js_1 = require("./multi-agent-handlers.js");
54
64
  // ============================================
55
65
  // CONFIGURATION
56
66
  // ============================================
@@ -1680,10 +1690,14 @@ server.setRequestHandler(types_js_1.ReadResourceRequestSchema, async (request) =
1680
1690
  return { contents: [{ uri, mimeType: 'application/json', text: JSON.stringify(sessionState.userMemory || {}, null, 2) }] };
1681
1691
  }
1682
1692
  case 'persista://codebase/dna': {
1683
- return { contents: [{ uri, mimeType: 'application/json', text: JSON.stringify({
1693
+ return {
1694
+ contents: [{
1695
+ uri, mimeType: 'application/json', text: JSON.stringify({
1684
1696
  ...sessionState.codebaseDNA,
1685
1697
  packageVersions: sessionState.packageVersions
1686
- }, null, 2) }] };
1698
+ }, null, 2)
1699
+ }]
1700
+ };
1687
1701
  }
1688
1702
  case 'persista://codebase/dna-deep': {
1689
1703
  // Lazy load deep DNA if not already analyzed
@@ -1693,9 +1707,13 @@ server.setRequestHandler(types_js_1.ReadResourceRequestSchema, async (request) =
1693
1707
  codebaseDNADeep.decisions = await loadDecisions();
1694
1708
  }
1695
1709
  }
1696
- return { contents: [{ uri, mimeType: 'application/json', text: JSON.stringify(codebaseDNADeep || {
1710
+ return {
1711
+ contents: [{
1712
+ uri, mimeType: 'application/json', text: JSON.stringify(codebaseDNADeep || {
1697
1713
  error: 'Could not analyze codebase'
1698
- }, null, 2) }] };
1714
+ }, null, 2)
1715
+ }]
1716
+ };
1699
1717
  }
1700
1718
  case 'persista://git/changes': {
1701
1719
  return { contents: [{ uri, mimeType: 'application/json', text: JSON.stringify(sessionState.gitInfo || {}, null, 2) }] };
@@ -1715,7 +1733,9 @@ server.setRequestHandler(types_js_1.ReadResourceRequestSchema, async (request) =
1715
1733
  return { contents: [{ uri, mimeType: 'application/json', text: JSON.stringify(knowledge, null, 2) }] };
1716
1734
  }
1717
1735
  case 'persista://errors/learned': {
1718
- return { contents: [{ uri, mimeType: 'application/json', text: JSON.stringify({
1736
+ return {
1737
+ contents: [{
1738
+ uri, mimeType: 'application/json', text: JSON.stringify({
1719
1739
  _note: 'Errors and anti-patterns detected this session. Avoid these patterns!',
1720
1740
  buildHistory: sessionState.buildHistory.map(b => ({
1721
1741
  command: b.command,
@@ -1740,7 +1760,9 @@ server.setRequestHandler(types_js_1.ReadResourceRequestSchema, async (request) =
1740
1760
  lastSeen: ap.lastSeen
1741
1761
  })),
1742
1762
  recentErrors: sessionState.recentErrors.slice(-10)
1743
- }, null, 2) }] };
1763
+ }, null, 2)
1764
+ }]
1765
+ };
1744
1766
  }
1745
1767
  default:
1746
1768
  throw new Error(`Unknown resource: ${uri}`);
@@ -2162,7 +2184,11 @@ server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => {
2162
2184
  },
2163
2185
  required: ['path', 'reason']
2164
2186
  }
2165
- }
2187
+ },
2188
+ // ═══════════════════════════════════════
2189
+ // MULTI-AGENT COORDINATION TOOLS (v4)
2190
+ // ═══════════════════════════════════════
2191
+ ...multi_agent_tools_js_1.MULTI_AGENT_TOOLS
2166
2192
  ]
2167
2193
  };
2168
2194
  });
@@ -2460,10 +2486,14 @@ server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
2460
2486
  const behaviors = await apiRequest('GET', `/memory/${USER_ID}/context/behavior`);
2461
2487
  const behaviorArray = Array.isArray(behaviors) ? behaviors : [];
2462
2488
  const antiPatterns = behaviorArray.filter((b) => b.value && b.value.type === 'error_pattern');
2463
- return { content: [{ type: 'text', text: JSON.stringify({
2489
+ return {
2490
+ content: [{
2491
+ type: 'text', text: JSON.stringify({
2464
2492
  antiPatterns,
2465
2493
  recentSessionErrors: sessionState.recentErrors
2466
- }, null, 2) }] };
2494
+ }, null, 2)
2495
+ }]
2496
+ };
2467
2497
  }
2468
2498
  // ═══════════════════════════════════════
2469
2499
  // SESSION HANDLERS
@@ -2473,7 +2503,9 @@ server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
2473
2503
  return { content: [{ type: 'text', text: '✅ Session context refreshed' }] };
2474
2504
  }
2475
2505
  case 'session_summary': {
2476
- return { content: [{ type: 'text', text: JSON.stringify({
2506
+ return {
2507
+ content: [{
2508
+ type: 'text', text: JSON.stringify({
2477
2509
  user: sessionState.userId,
2478
2510
  project: sessionState.codebaseDNA,
2479
2511
  git: sessionState.gitInfo,
@@ -2486,7 +2518,9 @@ server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
2486
2518
  errors: sessionState.recentErrors.length,
2487
2519
  packageVersions: sessionState.packageVersions,
2488
2520
  sessionStart: sessionState.startTime
2489
- }, null, 2) }] };
2521
+ }, null, 2)
2522
+ }]
2523
+ };
2490
2524
  }
2491
2525
  case 'sync': {
2492
2526
  // Smart two-way sync - fetch relevant context and optionally save
@@ -2649,7 +2683,7 @@ server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
2649
2683
  // 1. SAVE SESSION SUMMARY (if provided or auto-generate minimal one)
2650
2684
  const sessionSummary = summary || 'Session completed';
2651
2685
  try {
2652
- await apiRequest('POST', `/memory/${USER_ID}/context/summary`, {
2686
+ await apiRequest('POST', `/context/${USER_ID}/summary`, {
2653
2687
  summary: sessionSummary,
2654
2688
  key_points: key_points || [],
2655
2689
  decisions: decisions?.map(d => `${d.decision} (${d.reason})`) || [],
@@ -2950,29 +2984,41 @@ server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
2950
2984
  if (!codebaseDNADeep) {
2951
2985
  codebaseDNADeep = await analyzeCodebaseDNADeep();
2952
2986
  }
2953
- return { content: [{ type: 'text', text: JSON.stringify({
2987
+ return {
2988
+ content: [{
2989
+ type: 'text', text: JSON.stringify({
2954
2990
  conventions: codebaseDNADeep?.conventions || {},
2955
2991
  _note: 'Follow these conventions when writing code for this project'
2956
- }, null, 2) }] };
2992
+ }, null, 2)
2993
+ }]
2994
+ };
2957
2995
  }
2958
2996
  case 'dna_patterns': {
2959
2997
  if (!codebaseDNADeep) {
2960
2998
  codebaseDNADeep = await analyzeCodebaseDNADeep();
2961
2999
  }
2962
- return { content: [{ type: 'text', text: JSON.stringify({
3000
+ return {
3001
+ content: [{
3002
+ type: 'text', text: JSON.stringify({
2963
3003
  patterns: codebaseDNADeep?.patterns || {},
2964
3004
  _note: 'These patterns are used throughout the codebase'
2965
- }, null, 2) }] };
3005
+ }, null, 2)
3006
+ }]
3007
+ };
2966
3008
  }
2967
3009
  case 'dna_architecture': {
2968
3010
  if (!codebaseDNADeep) {
2969
3011
  codebaseDNADeep = await analyzeCodebaseDNADeep();
2970
3012
  }
2971
- return { content: [{ type: 'text', text: JSON.stringify({
3013
+ return {
3014
+ content: [{
3015
+ type: 'text', text: JSON.stringify({
2972
3016
  architecture: codebaseDNADeep?.architecture || {},
2973
3017
  criticalPaths: codebaseDNADeep?.criticalPaths || [],
2974
3018
  _note: 'Architecture style and important paths'
2975
- }, null, 2) }] };
3019
+ }, null, 2)
3020
+ }]
3021
+ };
2976
3022
  }
2977
3023
  case 'dna_add_decision': {
2978
3024
  const decision = {
@@ -3002,11 +3048,15 @@ server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
3002
3048
  }
3003
3049
  case 'dna_decisions': {
3004
3050
  const decisions = await loadDecisions();
3005
- return { content: [{ type: 'text', text: JSON.stringify({
3051
+ return {
3052
+ content: [{
3053
+ type: 'text', text: JSON.stringify({
3006
3054
  decisions,
3007
3055
  count: decisions.length,
3008
3056
  _note: 'Past decisions for this project - consider these when making new choices'
3009
- }, null, 2) }] };
3057
+ }, null, 2)
3058
+ }]
3059
+ };
3010
3060
  }
3011
3061
  case 'dna_critical_paths': {
3012
3062
  if (!codebaseDNADeep) {
@@ -3021,10 +3071,14 @@ server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
3021
3071
  ...(codebaseDNADeep?.criticalPaths || []),
3022
3072
  ...manual
3023
3073
  ];
3024
- return { content: [{ type: 'text', text: JSON.stringify({
3074
+ return {
3075
+ content: [{
3076
+ type: 'text', text: JSON.stringify({
3025
3077
  criticalPaths: allCritical,
3026
3078
  _note: 'Be careful when modifying these paths!'
3027
- }, null, 2) }] };
3079
+ }, null, 2)
3080
+ }]
3081
+ };
3028
3082
  }
3029
3083
  case 'dna_mark_critical': {
3030
3084
  await apiRequest('POST', `/memory/${USER_ID}/context`, {
@@ -3038,10 +3092,20 @@ server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
3038
3092
  source: 'explicit',
3039
3093
  confidence: 1.0
3040
3094
  });
3041
- return { content: [{ type: 'text', text: `⚠️ Marked as critical: ${typedArgs.path}\nReason: ${typedArgs.reason}` }] };
3042
- }
3043
- default:
3095
+ return { content: [{ type: 'text', text: `⚠️ Marked as critical: ${typedArgs.path}\\nReason: ${typedArgs.reason}` }] };
3096
+ }
3097
+ //══════════════════════════════════════
3098
+ // MULTI-AGENT COORDINATION HANDLERS (v4)
3099
+ //══════════════════════════════════════
3100
+ default: {
3101
+ // Check if this is a multi-agent tool
3102
+ if (name.startsWith('agent_') || name.startsWith('file_') ||
3103
+ name.startsWith('task_') || name.startsWith('conflict_') ||
3104
+ name.startsWith('coordinator_')) {
3105
+ return await (0, multi_agent_handlers_js_1.handleMultiAgentTool)(name, typedArgs, apiRequest, USER_ID, IS_VALID_PROJECT ? PROJECT_NAME : undefined);
3106
+ }
3044
3107
  return { content: [{ type: 'text', text: `Unknown tool: ${name}` }], isError: true };
3108
+ }
3045
3109
  }
3046
3110
  }
3047
3111
  catch (error) {