@mclawnet/mcp-server 0.1.5 → 0.1.7

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.
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=log-setup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log-setup.d.ts","sourceRoot":"","sources":["../src/log-setup.ts"],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ // Side-effect module: must be the FIRST import in mcp-server's entry.
2
+ // ESM hoists all `import` statements before any non-import code, so we can't
3
+ // set this env var inline in server.ts and expect the logger module to see
4
+ // it at load time. Importing this module as the very first import ensures
5
+ // the env var is set before @mclawnet/logger runs its pino() initializer.
6
+ process.env.CLAWNET_LOG_STDERR = "1";
7
+ export {};
8
+ //# sourceMappingURL=log-setup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log-setup.js","sourceRoot":"","sources":["../src/log-setup.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,6EAA6E;AAC7E,2EAA2E;AAC3E,0EAA0E;AAC1E,0EAA0E;AAC1E,OAAO,CAAC,GAAG,CAAC,kBAAkB,GAAG,GAAG,CAAC"}
package/dist/server.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
- export {};
2
+ import "./log-setup.js";
3
3
  //# sourceMappingURL=server.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";AAOA,OAAO,gBAAgB,CAAC"}
package/dist/server.js CHANGED
@@ -1,4 +1,11 @@
1
1
  #!/usr/bin/env node
2
+ // MCP protocol uses stdout exclusively for JSON-RPC frames. Logging to
3
+ // stdout corrupts the protocol stream and causes the client (codex's rmcp,
4
+ // claude-code's MCP client) to fail with parse errors / "Transport closed".
5
+ // The log-setup module sets CLAWNET_LOG_STDERR=1 — it MUST be the first
6
+ // import so the env var is in place before @mclawnet/logger initializes
7
+ // pino (ESM hoists all imports above non-import statements).
8
+ import "./log-setup.js";
2
9
  import { Server } from "@modelcontextprotocol/sdk/server/index.js";
3
10
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
4
11
  import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
@@ -26,7 +33,7 @@ const embeddingService = new EmbeddingService(db, providers);
26
33
  const skillStore = new SkillStore(clawnetDir);
27
34
  const evolutionPipeline = new EvolutionPipeline(clawnetDir);
28
35
  const context = {
29
- memory: { store, embeddingService },
36
+ memory: { store, embeddingService, workDir: process.cwd() },
30
37
  skill: { store: skillStore },
31
38
  evolution: { pipeline: evolutionPipeline },
32
39
  task: { rootDir: homeDir },
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EACL,wBAAwB,EACxB,gBAAgB,EAChB,YAAY,EACZ,WAAW,GACZ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACxE,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAoB,MAAM,kBAAkB,CAAC;AAE1F,MAAM,GAAG,GAAG,YAAY,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,CAAC;AAEnD,sBA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IAAI,EAAE,CAAC,IAAI,IAAI,EAAE,CAA4B,EAAE,OAAO,CAAC,CAAC;AAC/E,CAAC,CAAC,CAAC;AAEH,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;AAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AAEhC,GAAG,CAAC,IAAI,CAAC,wCAAwC,CAAC,CAAC;AAEnD,SAAS,OAAO;IACd,GAAG,CAAC,IAAI,CAAC,kCAAkC,CAAC,CAAC;IAC7C,IAAI,CAAC;QACH,EAAE,CAAC,KAAK,EAAE,CAAC;IACb,CAAC;IAAC,MAAM,CAAC;QACP,SAAS;IACX,CAAC;AACH,CAAC;AAED,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAC5B,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;IACxB,OAAO,EAAE,CAAC;IACV,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC;AACH,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE;IACzB,OAAO,EAAE,CAAC;IACV,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -55,6 +55,10 @@ export declare function getAllToolDefinitions(): ({
55
55
  };
56
56
  description: string;
57
57
  };
58
+ planTaskId: {
59
+ type: string;
60
+ description: string;
61
+ };
58
62
  sourceMessageId?: undefined;
59
63
  sourceInstanceId?: undefined;
60
64
  taskId?: undefined;
@@ -112,6 +116,10 @@ export declare function getAllToolDefinitions(): ({
112
116
  };
113
117
  description: string;
114
118
  };
119
+ planTaskId: {
120
+ type: string;
121
+ description: string;
122
+ };
115
123
  sourceMessageId: {
116
124
  type: string;
117
125
  description: string;
@@ -155,6 +163,7 @@ export declare function getAllToolDefinitions(): ({
155
163
  owner?: undefined;
156
164
  from?: undefined;
157
165
  blockedBy?: undefined;
166
+ planTaskId?: undefined;
158
167
  sourceMessageId?: undefined;
159
168
  sourceInstanceId?: undefined;
160
169
  status?: undefined;
@@ -198,6 +207,7 @@ export declare function getAllToolDefinitions(): ({
198
207
  description?: undefined;
199
208
  from?: undefined;
200
209
  blockedBy?: undefined;
210
+ planTaskId?: undefined;
201
211
  sourceMessageId?: undefined;
202
212
  sourceInstanceId?: undefined;
203
213
  taskId?: undefined;
@@ -239,6 +249,7 @@ export declare function getAllToolDefinitions(): ({
239
249
  owner?: undefined;
240
250
  from?: undefined;
241
251
  blockedBy?: undefined;
252
+ planTaskId?: undefined;
242
253
  sourceMessageId?: undefined;
243
254
  sourceInstanceId?: undefined;
244
255
  author?: undefined;
@@ -280,6 +291,7 @@ export declare function getAllToolDefinitions(): ({
280
291
  description?: undefined;
281
292
  swarmId?: undefined;
282
293
  blockedBy?: undefined;
294
+ planTaskId?: undefined;
283
295
  sourceMessageId?: undefined;
284
296
  sourceInstanceId?: undefined;
285
297
  status?: undefined;
@@ -332,6 +344,7 @@ export declare function getAllToolDefinitions(): ({
332
344
  owner?: undefined;
333
345
  from?: undefined;
334
346
  blockedBy?: undefined;
347
+ planTaskId?: undefined;
335
348
  sourceMessageId?: undefined;
336
349
  sourceInstanceId?: undefined;
337
350
  status?: undefined;
@@ -368,6 +381,7 @@ export declare function getAllToolDefinitions(): ({
368
381
  owner?: undefined;
369
382
  from?: undefined;
370
383
  blockedBy?: undefined;
384
+ planTaskId?: undefined;
371
385
  sourceMessageId?: undefined;
372
386
  sourceInstanceId?: undefined;
373
387
  taskId?: undefined;
@@ -412,6 +426,7 @@ export declare function getAllToolDefinitions(): ({
412
426
  owner?: undefined;
413
427
  from?: undefined;
414
428
  blockedBy?: undefined;
429
+ planTaskId?: undefined;
415
430
  sourceMessageId?: undefined;
416
431
  sourceInstanceId?: undefined;
417
432
  taskId?: undefined;
@@ -452,6 +467,7 @@ export declare function getAllToolDefinitions(): ({
452
467
  owner?: undefined;
453
468
  from?: undefined;
454
469
  blockedBy?: undefined;
470
+ planTaskId?: undefined;
455
471
  sourceMessageId?: undefined;
456
472
  sourceInstanceId?: undefined;
457
473
  taskId?: undefined;
@@ -501,6 +517,7 @@ export declare function getAllToolDefinitions(): ({
501
517
  owner?: undefined;
502
518
  from?: undefined;
503
519
  blockedBy?: undefined;
520
+ planTaskId?: undefined;
504
521
  sourceMessageId?: undefined;
505
522
  sourceInstanceId?: undefined;
506
523
  taskId?: undefined;
@@ -595,10 +612,6 @@ export declare function getAllToolDefinitions(): ({
595
612
  inputSchema: {
596
613
  type: "object";
597
614
  properties: {
598
- roleId: {
599
- type: string;
600
- description: string;
601
- };
602
615
  query: {
603
616
  type: string;
604
617
  description: string;
@@ -611,7 +624,11 @@ export declare function getAllToolDefinitions(): ({
611
624
  type: string;
612
625
  description: string;
613
626
  };
614
- crossRole: {
627
+ crossWorkdir: {
628
+ type: string;
629
+ description: string;
630
+ };
631
+ workDir: {
615
632
  type: string;
616
633
  description: string;
617
634
  };
@@ -629,10 +646,6 @@ export declare function getAllToolDefinitions(): ({
629
646
  inputSchema: {
630
647
  type: "object";
631
648
  properties: {
632
- roleId: {
633
- type: string;
634
- description: string;
635
- };
636
649
  content: {
637
650
  type: string;
638
651
  description: string;
@@ -657,9 +670,13 @@ export declare function getAllToolDefinitions(): ({
657
670
  type: string;
658
671
  description: string;
659
672
  };
673
+ workDir: {
674
+ type: string;
675
+ description: string;
676
+ };
660
677
  query?: undefined;
661
678
  limit?: undefined;
662
- crossRole?: undefined;
679
+ crossWorkdir?: undefined;
663
680
  scope?: undefined;
664
681
  };
665
682
  required: string[];
@@ -670,21 +687,21 @@ export declare function getAllToolDefinitions(): ({
670
687
  inputSchema: {
671
688
  type: "object";
672
689
  properties: {
673
- roleId: {
690
+ workDir: {
674
691
  type: string;
675
692
  description: string;
676
693
  };
677
694
  query?: undefined;
678
695
  domain?: undefined;
679
696
  limit?: undefined;
680
- crossRole?: undefined;
697
+ crossWorkdir?: undefined;
681
698
  content?: undefined;
682
699
  type?: undefined;
683
700
  tags?: undefined;
684
701
  importance?: undefined;
685
702
  scope?: undefined;
686
703
  };
687
- required: string[];
704
+ required?: undefined;
688
705
  };
689
706
  } | {
690
707
  name: string;
@@ -692,25 +709,25 @@ export declare function getAllToolDefinitions(): ({
692
709
  inputSchema: {
693
710
  type: "object";
694
711
  properties: {
695
- roleId: {
712
+ scope: {
696
713
  type: string;
714
+ enum: string[];
697
715
  description: string;
698
716
  };
699
- scope: {
717
+ workDir: {
700
718
  type: string;
701
- enum: string[];
702
719
  description: string;
703
720
  };
704
721
  query?: undefined;
705
722
  domain?: undefined;
706
723
  limit?: undefined;
707
- crossRole?: undefined;
724
+ crossWorkdir?: undefined;
708
725
  content?: undefined;
709
726
  type?: undefined;
710
727
  tags?: undefined;
711
728
  importance?: undefined;
712
729
  };
713
- required: string[];
730
+ required?: undefined;
714
731
  };
715
732
  } | {
716
733
  name: string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkD,KAAK,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACrG,OAAO,EAAgD,KAAK,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACjG,OAAO,EAGL,KAAK,oBAAoB,EAC1B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAIL,KAAK,eAAe,EACrB,MAAM,WAAW,CAAC;AACnB,OAAO,EAIL,KAAK,gBAAgB,EAEtB,MAAM,YAAY,CAAC;AACpB,OAAO,EAIL,KAAK,qBAAqB,EAC3B,MAAM,kBAAkB,CAAC;AAE1B,YAAY,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACnE,YAAY,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAE9D,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,iBAAiB,CAAC;IAC1B,KAAK,EAAE,gBAAgB,CAAC;IACxB,SAAS,EAAE,oBAAoB,CAAC;IA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EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACnD,YAAY,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAC3D,YAAY,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC"}
@@ -2,6 +2,16 @@ import { type EmbeddingService, type MemoryStore } from "@mclawnet/memory";
2
2
  export interface MemoryToolContext {
3
3
  store: MemoryStore;
4
4
  embeddingService: EmbeddingService;
5
+ /**
6
+ * Default working directory for this server instance — used when the caller
7
+ * doesn't pass `workDir` in the request args. Acts as a fallback only; the
8
+ * authoritative value is the request-supplied `workDir` so a single stdio
9
+ * server can be shared across multiple sessions / swarm instances without
10
+ * leaking memory between projects.
11
+ */
12
+ workDir: string;
13
+ /** Optional role hint stored alongside the memory for legacy compatibility. */
14
+ roleId?: string;
5
15
  }
6
16
  export declare function getMemoryToolDefinitions(): ({
7
17
  name: string;
@@ -9,10 +19,6 @@ export declare function getMemoryToolDefinitions(): ({
9
19
  inputSchema: {
10
20
  type: "object";
11
21
  properties: {
12
- roleId: {
13
- type: string;
14
- description: string;
15
- };
16
22
  query: {
17
23
  type: string;
18
24
  description: string;
@@ -25,7 +31,11 @@ export declare function getMemoryToolDefinitions(): ({
25
31
  type: string;
26
32
  description: string;
27
33
  };
28
- crossRole: {
34
+ crossWorkdir: {
35
+ type: string;
36
+ description: string;
37
+ };
38
+ workDir: {
29
39
  type: string;
30
40
  description: string;
31
41
  };
@@ -43,10 +53,6 @@ export declare function getMemoryToolDefinitions(): ({
43
53
  inputSchema: {
44
54
  type: "object";
45
55
  properties: {
46
- roleId: {
47
- type: string;
48
- description: string;
49
- };
50
56
  content: {
51
57
  type: string;
52
58
  description: string;
@@ -71,9 +77,13 @@ export declare function getMemoryToolDefinitions(): ({
71
77
  type: string;
72
78
  description: string;
73
79
  };
80
+ workDir: {
81
+ type: string;
82
+ description: string;
83
+ };
74
84
  query?: undefined;
75
85
  limit?: undefined;
76
- crossRole?: undefined;
86
+ crossWorkdir?: undefined;
77
87
  scope?: undefined;
78
88
  };
79
89
  required: string[];
@@ -84,21 +94,21 @@ export declare function getMemoryToolDefinitions(): ({
84
94
  inputSchema: {
85
95
  type: "object";
86
96
  properties: {
87
- roleId: {
97
+ workDir: {
88
98
  type: string;
89
99
  description: string;
90
100
  };
91
101
  query?: undefined;
92
102
  domain?: undefined;
93
103
  limit?: undefined;
94
- crossRole?: undefined;
104
+ crossWorkdir?: undefined;
95
105
  content?: undefined;
96
106
  type?: undefined;
97
107
  tags?: undefined;
98
108
  importance?: undefined;
99
109
  scope?: undefined;
100
110
  };
101
- required: string[];
111
+ required?: undefined;
102
112
  };
103
113
  } | {
104
114
  name: string;
@@ -106,25 +116,25 @@ export declare function getMemoryToolDefinitions(): ({
106
116
  inputSchema: {
107
117
  type: "object";
108
118
  properties: {
109
- roleId: {
119
+ scope: {
110
120
  type: string;
121
+ enum: string[];
111
122
  description: string;
112
123
  };
113
- scope: {
124
+ workDir: {
114
125
  type: string;
115
- enum: string[];
116
126
  description: string;
117
127
  };
118
128
  query?: undefined;
119
129
  domain?: undefined;
120
130
  limit?: undefined;
121
- crossRole?: undefined;
131
+ crossWorkdir?: undefined;
122
132
  content?: undefined;
123
133
  type?: undefined;
124
134
  tags?: undefined;
125
135
  importance?: undefined;
126
136
  };
127
- required: string[];
137
+ required?: undefined;
128
138
  };
129
139
  })[];
130
140
  export declare function handleMemoryToolCall(name: string, args: Record<string, unknown>, context: MemoryToolContext): Promise<{
@@ -1 +1 @@
1
- {"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../src/tools/memory.ts"],"names":[],"mappings":"AACA,OAAO,EAKL,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAEjB,MAAM,kBAAkB,CAAC;AAI1B,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,WAAW,CAAC;IACnB,gBAAgB,EAAE,gBAAgB,CAAC;CACpC;AAED,wBAAgB,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAE,CAAC,CA0BhF"}
@@ -1,30 +1,47 @@
1
1
  import { createLogger } from "@mclawnet/logger";
2
- import { EWCGuard, pruneMemories, recalculateAllImportance, storeWithFusion, } from "@mclawnet/memory";
2
+ import { DEFAULT_ASSISTANT_ROLE_ID, EWCGuard, pruneMemories, recalculateAllImportance, storeWithFusion, } from "@mclawnet/memory";
3
3
  const log = createLogger({ module: "mcp-server/tools/memory" });
4
+ /**
5
+ * Resolve the effective workDir for a request: prefer the caller-supplied
6
+ * `workDir` arg, else fall back to the server default (ToolContext.workDir
7
+ * which itself is initialised from process.cwd() at startup). This is the
8
+ * single chokepoint that lets a shared stdio server serve multiple workDirs.
9
+ */
10
+ function resolveWorkDir(args, context) {
11
+ const requested = typeof args.workDir === "string" && args.workDir.length > 0
12
+ ? args.workDir
13
+ : undefined;
14
+ return requested ?? context.workDir;
15
+ }
4
16
  export function getMemoryToolDefinitions() {
5
17
  return [
6
18
  {
7
19
  name: "memory_search",
8
- description: "Search role memories by semantic similarity. Returns the most relevant past experiences, patterns, and lessons.",
20
+ description: "Search memories by semantic similarity, scoped to the current working directory. Returns the most relevant past experiences, patterns, and lessons.",
9
21
  inputSchema: {
10
22
  type: "object",
11
23
  properties: {
12
- roleId: { type: "string", description: "Role ID for memory scope" },
13
24
  query: { type: "string", description: "Natural language search query" },
14
25
  domain: { type: "string", description: "Filter by domain label" },
15
26
  limit: { type: "number", description: "Max results to return (default 5)" },
16
- crossRole: { type: "boolean", description: "Search across all roles (ignore roleId filter)" },
27
+ crossWorkdir: {
28
+ type: "boolean",
29
+ description: "Search across all working directories (ignore workdir filter)",
30
+ },
31
+ workDir: {
32
+ type: "string",
33
+ description: "Override working-directory scope for this call (defaults to the server's process.cwd()).",
34
+ },
17
35
  },
18
- required: ["roleId", "query"],
36
+ required: ["query"],
19
37
  },
20
38
  },
21
39
  {
22
40
  name: "memory_store",
23
- description: "Store a new memory entry for the specified role. Use this to persist valuable experiences, patterns, error lessons, or preferences.",
41
+ description: "Store a new memory entry scoped to the current working directory. Use this to persist valuable experiences, patterns, error lessons, or preferences.",
24
42
  inputSchema: {
25
43
  type: "object",
26
44
  properties: {
27
- roleId: { type: "string", description: "Role ID for memory scope" },
28
45
  content: { type: "string", description: "Memory content in natural language" },
29
46
  type: {
30
47
  type: "string",
@@ -37,23 +54,26 @@ export function getMemoryToolDefinitions() {
37
54
  description: "Tags for categorisation",
38
55
  },
39
56
  domain: { type: "string", description: "Domain label (e.g. 'frontend', 'backend')" },
40
- importance: {
41
- type: "number",
42
- description: "Importance score 0-1 (default 0.5)",
57
+ importance: { type: "number", description: "Importance score 0-1 (default 0.5)" },
58
+ workDir: {
59
+ type: "string",
60
+ description: "Override working-directory scope for this call (defaults to the server's process.cwd()).",
43
61
  },
44
62
  },
45
- required: ["roleId", "content", "type"],
63
+ required: ["content", "type"],
46
64
  },
47
65
  },
48
66
  {
49
67
  name: "memory_stats",
50
- description: "Get memory statistics for the specified role: total count, breakdown by type/level, top domains.",
68
+ description: "Get memory statistics for the current working directory: total count, breakdown by type/status, top domains.",
51
69
  inputSchema: {
52
70
  type: "object",
53
71
  properties: {
54
- roleId: { type: "string", description: "Role ID for memory scope" },
72
+ workDir: {
73
+ type: "string",
74
+ description: "Override working-directory scope for this call (defaults to the server's process.cwd()).",
75
+ },
55
76
  },
56
- required: ["roleId"],
57
77
  },
58
78
  },
59
79
  {
@@ -62,22 +82,23 @@ export function getMemoryToolDefinitions() {
62
82
  inputSchema: {
63
83
  type: "object",
64
84
  properties: {
65
- roleId: { type: "string", description: "Role ID for memory scope" },
66
85
  scope: {
67
86
  type: "string",
68
87
  enum: ["light", "full"],
69
88
  description: "Reflection depth: light (quick) or full (thorough)",
70
89
  },
90
+ workDir: {
91
+ type: "string",
92
+ description: "Override working-directory scope for this call (defaults to the server's process.cwd()).",
93
+ },
71
94
  },
72
- required: ["roleId"],
73
95
  },
74
96
  },
75
97
  ];
76
98
  }
77
99
  export async function handleMemoryToolCall(name, args, context) {
78
100
  try {
79
- const roleId = args.roleId;
80
- log.info({ tool: name, roleId }, "MCP tool called");
101
+ log.info({ tool: name, workDir: context.workDir }, "MCP tool called");
81
102
  switch (name) {
82
103
  case "memory_search":
83
104
  return await handleMemorySearch(args, context);
@@ -105,51 +126,60 @@ export async function handleMemoryToolCall(name, args, context) {
105
126
  }
106
127
  async function handleMemorySearch(args, context) {
107
128
  const query = args.query;
108
- const crossRole = args.crossRole;
109
- const roleId = crossRole ? undefined : args.roleId;
129
+ const crossWorkdir = args.crossWorkdir;
110
130
  const domain = args.domain;
111
131
  const limit = args.limit ?? 5;
132
+ const workDir = resolveWorkDir(args, context);
112
133
  const queryEmbedding = await context.embeddingService.embed(query);
113
134
  const results = context.store.searchMemories(queryEmbedding, {
114
- roleId,
115
135
  domain,
116
136
  limit,
117
- crossRole,
137
+ workdir: workDir,
138
+ crossWorkdir,
118
139
  });
119
140
  const serialisable = results.map((m) => ({
120
141
  id: m.id,
121
142
  roleId: m.roleId,
122
143
  content: m.content,
123
144
  type: m.type,
124
- level: m.level,
145
+ status: m.status,
146
+ workdir: m.workdir,
125
147
  tags: m.tags,
126
148
  domain: m.domain,
127
149
  importance: m.importance,
128
150
  accessCount: m.accessCount,
129
151
  createdAt: m.createdAt,
130
152
  }));
131
- log.info({ query, roleId: args.roleId, crossRole, resultCount: serialisable.length }, "memory_search completed");
153
+ log.info({ query, workDir, crossWorkdir, resultCount: serialisable.length }, "memory_search completed");
132
154
  return {
133
155
  content: [{ type: "text", text: JSON.stringify(serialisable, null, 2) }],
134
156
  };
135
157
  }
136
158
  async function handleMemoryStore(args, context) {
137
- const roleId = args.roleId;
138
159
  const content = args.content;
139
160
  const type = args.type;
140
161
  const tags = args.tags ?? [];
141
162
  const domain = args.domain;
142
163
  const importance = args.importance;
164
+ const workDir = resolveWorkDir(args, context);
143
165
  const result = await storeWithFusion(context.store, context.embeddingService, {
144
- roleId,
166
+ roleId: context.roleId ?? DEFAULT_ASSISTANT_ROLE_ID,
145
167
  content,
146
168
  type,
147
- level: "long-term",
169
+ status: "active",
170
+ workdir: workDir,
148
171
  tags,
149
172
  domain,
150
173
  importance,
151
174
  });
152
- log.info({ id: result.memory.id, roleId, type, domain, importance, fusionAction: result.fusionAction }, "memory_store completed");
175
+ log.info({
176
+ id: result.memory.id,
177
+ workDir,
178
+ type,
179
+ domain,
180
+ importance,
181
+ fusionAction: result.fusionAction,
182
+ }, "memory_store completed");
153
183
  return {
154
184
  content: [
155
185
  {
@@ -164,35 +194,46 @@ async function handleMemoryStore(args, context) {
164
194
  };
165
195
  }
166
196
  async function handleMemoryStats(args, context) {
167
- const roleId = args.roleId;
168
- const stats = context.store.getStats(roleId);
197
+ const workDir = resolveWorkDir(args, context);
198
+ const stats = context.store.getStatsByWorkdir(workDir);
169
199
  return {
170
200
  content: [{ type: "text", text: JSON.stringify(stats, null, 2) }],
171
201
  };
172
202
  }
173
203
  async function handleMemoryReflect(args, context) {
174
- const roleId = args.roleId;
175
204
  const scope = args.scope ?? "light";
205
+ const workDir = resolveWorkDir(args, context);
176
206
  const db = context.store.getDb();
177
207
  const vectorIndex = context.store.getVectorIndex();
178
208
  if (scope === "light") {
179
- const pruneResult = pruneMemories(roleId, db, vectorIndex);
180
- log.info({ roleId, scope, ...pruneResult }, "memory_reflect completed");
209
+ const roleIds = db
210
+ .prepare("SELECT DISTINCT role_id FROM memories WHERE workdir = ?")
211
+ .all(workDir).map((r) => r.role_id);
212
+ let archived = 0;
213
+ let deleted = 0;
214
+ let recalculated = 0;
215
+ for (const rid of roleIds) {
216
+ const r = pruneMemories(rid, db, vectorIndex);
217
+ archived += r.archived;
218
+ deleted += r.deleted;
219
+ recalculated += r.recalculated;
220
+ }
221
+ log.info({ workDir, scope, archived, deleted }, "memory_reflect completed");
181
222
  return {
182
- content: [{ type: "text", text: JSON.stringify({ scope, ...pruneResult }) }],
223
+ content: [
224
+ { type: "text", text: JSON.stringify({ scope, archived, deleted, recalculated }) },
225
+ ],
183
226
  };
184
227
  }
185
228
  // scope === "full": re-embed if needed + recalculate all + prune all roles
186
229
  const reembedResult = await context.store.reembedAll(context.embeddingService);
187
230
  const recalculated = recalculateAllImportance(db);
188
231
  const roleIds = db.prepare("SELECT DISTINCT role_id FROM memories").all().map((r) => r.role_id);
189
- let totalDemotedToLongTerm = 0;
190
- let totalDemotedToArchived = 0;
232
+ let totalArchived = 0;
191
233
  let totalDeleted = 0;
192
234
  for (const rid of roleIds) {
193
235
  const r = pruneMemories(rid, db, vectorIndex);
194
- totalDemotedToLongTerm += r.demotedToLongTerm;
195
- totalDemotedToArchived += r.demotedToArchived;
236
+ totalArchived += r.archived;
196
237
  totalDeleted += r.deleted;
197
238
  }
198
239
  const ewcGuard = new EWCGuard(db);
@@ -208,8 +249,7 @@ async function handleMemoryReflect(args, context) {
208
249
  reembedFailed: reembedResult.failed,
209
250
  recalculated,
210
251
  rolesProcessed: roleIds.length,
211
- demotedToLongTerm: totalDemotedToLongTerm,
212
- demotedToArchived: totalDemotedToArchived,
252
+ archived: totalArchived,
213
253
  deleted: totalDeleted,
214
254
  profilesRefreshed,
215
255
  };