wave-agent-sdk 0.12.5 → 0.12.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.
- package/builtin/skills/settings/MCP.md +17 -2
- package/dist/managers/aiManager.d.ts.map +1 -1
- package/dist/managers/aiManager.js +11 -0
- package/dist/managers/mcpManager.d.ts.map +1 -1
- package/dist/managers/mcpManager.js +38 -28
- package/dist/managers/subagentManager.d.ts +9 -0
- package/dist/managers/subagentManager.d.ts.map +1 -1
- package/dist/managers/subagentManager.js +18 -0
- package/dist/prompts/autoMemoryExtraction.d.ts +5 -0
- package/dist/prompts/autoMemoryExtraction.d.ts.map +1 -0
- package/dist/prompts/autoMemoryExtraction.js +136 -0
- package/dist/services/autoMemoryService.d.ts +24 -0
- package/dist/services/autoMemoryService.d.ts.map +1 -0
- package/dist/services/autoMemoryService.js +134 -0
- package/dist/services/configurationService.d.ts +6 -0
- package/dist/services/configurationService.d.ts.map +1 -1
- package/dist/services/configurationService.js +33 -0
- package/dist/types/configuration.d.ts +2 -0
- package/dist/types/configuration.d.ts.map +1 -1
- package/dist/types/mcp.d.ts +2 -1
- package/dist/types/mcp.d.ts.map +1 -1
- package/dist/utils/containerSetup.d.ts.map +1 -1
- package/dist/utils/containerSetup.js +3 -0
- package/package.json +1 -1
- package/src/managers/aiManager.ts +15 -0
- package/src/managers/mcpManager.ts +41 -29
- package/src/managers/subagentManager.ts +36 -0
- package/src/prompts/autoMemoryExtraction.ts +146 -0
- package/src/services/autoMemoryService.ts +178 -0
- package/src/services/configurationService.ts +43 -0
- package/src/types/configuration.ts +2 -0
- package/src/types/mcp.ts +2 -1
- package/src/utils/containerSetup.ts +4 -0
|
@@ -32,9 +32,24 @@ The `.mcp.json` file contains a list of MCP server configurations.
|
|
|
32
32
|
|
|
33
33
|
### Fields for each server:
|
|
34
34
|
|
|
35
|
-
- `command`: The executable to run (e.g., `npx`, `uvx`, `python`, `node`).
|
|
36
|
-
- `args`: An array of command-line arguments for the executable.
|
|
35
|
+
- `command`: (For stdio) The executable to run (e.g., `npx`, `uvx`, `python`, `node`).
|
|
36
|
+
- `args`: (For stdio) An array of command-line arguments for the executable.
|
|
37
37
|
- `env`: (Optional) A record of environment variables for the server process.
|
|
38
|
+
- `url`: (For SSE) The endpoint URL of a remote MCP server (e.g., `https://example.com/sse`).
|
|
39
|
+
|
|
40
|
+
## Remote MCP Servers (SSE)
|
|
41
|
+
|
|
42
|
+
Wave also supports connecting to remote MCP servers via SSE (Server-Sent Events).
|
|
43
|
+
|
|
44
|
+
```json
|
|
45
|
+
{
|
|
46
|
+
"mcpServers": {
|
|
47
|
+
"remote-server": {
|
|
48
|
+
"url": "https://mcp-server.example.com/sse"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
```
|
|
38
53
|
|
|
39
54
|
## Using MCP Tools
|
|
40
55
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aiManager.d.ts","sourceRoot":"","sources":["../../src/managers/aiManager.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,aAAa,EACb,WAAW,EACX,KAAK,EAGN,MAAM,mBAAmB,CAAC;AAY3B,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAKlD,MAAM,WAAW,kBAAkB;IACjC,wBAAwB,CAAC,EAAE,CAAC,aAAa,EAAE,OAAO,KAAK,IAAI,CAAC;IAC5D,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CACvC;AAED,MAAM,WAAW,gBAAgB;IAC/B,SAAS,CAAC,EAAE,kBAAkB,CAAC;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,uEAAuE;IACvE,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,kDAAkD;IAClD,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;A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AEtB;IAED,OAAO,KAAK,cAAc,GAEzB;IAED,OAAO,KAAK,aAAa,GAIxB;IAED,OAAO,KAAK,WAAW,GAItB;IAED,OAAO,KAAK,qBAAqB,GAEhC;IAED,OAAO,KAAK,WAAW,GAEtB;IAED,OAAO,KAAK,gBAAgB,GAM3B;IAED,OAAO,KAAK,iBAAiB,GAE5B;IAED,OAAO,KAAK,oBAAoB,GAE/B;IAGM,gBAAgB,IAAI,aAAa;IAIjC,cAAc,IAAI,WAAW;IA6B7B,iBAAiB,IAAI,MAAM;IAI3B,WAAW,IAAI,MAAM,GAAG,SAAS;IAIjC,oBAAoB,IAAI,OAAO;IAItC,OAAO,CAAC,aAAa,CAAkB;IACvC,OAAO,CAAC,SAAS,CAAqB;IAEtC;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAevB,YAAY,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI;IAItC,cAAc,IAAI,IAAI;IAuB7B,OAAO,CAAC,qBAAqB;YAsBf,8BAA8B;IAgFrC,gBAAgB,IAAI,OAAO;IAI3B,gBAAgB,CAAC,aAAa,EAAE,OAAO,GAAG,IAAI;IAOrD,OAAO,KAAK,eAAe,GAE1B;IAED,OAAO,KAAK,YAAY,GAEvB;IAEY,aAAa,CACxB,OAAO,GAAE;QACP,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,oEAAoE;QACpE,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;QACxB,SAAS,CAAC,EAAE,MAAM,CAAC;KACf,GACL,OAAO,CAAC,IAAI,CAAC;IAgmBhB;;;;OAIG;YACW,gBAAgB;IAgF9B;;;OAGG;YACW,sBAAsB;IA6DpC;;OAEG;YACW,uBAAuB;CAwDtC"}
|
|
@@ -717,6 +717,17 @@ export class AIManager {
|
|
|
717
717
|
stderr: r.stderr,
|
|
718
718
|
})));
|
|
719
719
|
}
|
|
720
|
+
// Trigger auto-memory extraction if enabled and this is the main agent
|
|
721
|
+
if (!this.subagentType) {
|
|
722
|
+
const autoMemoryService = this.container.get("AutoMemoryService");
|
|
723
|
+
if (autoMemoryService) {
|
|
724
|
+
// Trigger extraction, but don't block the return.
|
|
725
|
+
// onTurnEnd itself returns quickly after forking.
|
|
726
|
+
autoMemoryService.onTurnEnd(this.workdir).catch((err) => {
|
|
727
|
+
logger?.error("Auto-memory extraction trigger failed:", err);
|
|
728
|
+
});
|
|
729
|
+
}
|
|
730
|
+
}
|
|
720
731
|
return shouldContinue;
|
|
721
732
|
}
|
|
722
733
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcpManager.d.ts","sourceRoot":"","sources":["../../src/managers/mcpManager.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mcpManager.d.ts","sourceRoot":"","sources":["../../src/managers/mcpManager.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AAEjE,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,KAAK,EACV,MAAM,EACN,eAAe,EACf,SAAS,EACT,OAAO,EACP,eAAe,EAChB,MAAM,mBAAmB,CAAC;AAQ3B,MAAM,WAAW,mBAAmB;IAClC,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,eAAe,EAAE,KAAK,IAAI,CAAC;CACxD;AAID,MAAM,WAAW,iBAAiB;IAChC,SAAS,CAAC,EAAE,mBAAmB,CAAC;IAChC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,UAAU;IASnB,OAAO,CAAC,SAAS;IARnB,OAAO,CAAC,MAAM,CAA0B;IACxC,OAAO,CAAC,OAAO,CAA2C;IAC1D,OAAO,CAAC,WAAW,CAAyC;IAC5D,OAAO,CAAC,UAAU,CAAc;IAChC,OAAO,CAAC,OAA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,CAAA;SAAE,CAAC,CAAC;KACtD,CAAC;YAsDY,uBAAuB;IA8D/B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAS9B;;OAEG;IACH,iBAAiB,IAAI,UAAU,EAAE;IA6BjC;;OAEG;IACH,iBAAiB,IAAI,0BAA0B,EAAE;IAIjD;;OAEG;IACG,wBAAwB,CAC5B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,OAAO,EAAE,WAAW,GACnB,OAAO,CAAC,UAAU,CAAC;IActB;;OAEG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;CAcjC"}
|
|
@@ -2,6 +2,7 @@ import { promises as fs } from "fs";
|
|
|
2
2
|
import { join } from "path";
|
|
3
3
|
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
4
4
|
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
|
|
5
|
+
import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js";
|
|
5
6
|
import { createMcpToolPlugin, findToolServer } from "../utils/mcpUtils.js";
|
|
6
7
|
import { logger } from "../utils/globalLogger.js";
|
|
7
8
|
export class McpManager {
|
|
@@ -163,35 +164,44 @@ export class McpManager {
|
|
|
163
164
|
this.updateServerStatus(name, { status: "connecting" });
|
|
164
165
|
try {
|
|
165
166
|
// Create transport - it will manage the process
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
stderr.on("data", (chunk) => {
|
|
181
|
-
buffer += chunk.toString();
|
|
182
|
-
const lines = buffer.split("\n");
|
|
183
|
-
buffer = lines.pop() || "";
|
|
184
|
-
for (const line of lines) {
|
|
185
|
-
if (line.trim()) {
|
|
186
|
-
logger?.error(`[MCP Server ${name}] ${line}`);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
});
|
|
190
|
-
stderr.on("end", () => {
|
|
191
|
-
if (buffer.trim()) {
|
|
192
|
-
logger?.error(`[MCP Server ${name}] ${buffer}`);
|
|
193
|
-
}
|
|
167
|
+
let transport;
|
|
168
|
+
if (server.config.url) {
|
|
169
|
+
transport = new SSEClientTransport(new URL(server.config.url));
|
|
170
|
+
}
|
|
171
|
+
else if (server.config.command) {
|
|
172
|
+
transport = new StdioClientTransport({
|
|
173
|
+
command: server.config.command,
|
|
174
|
+
args: server.config.args || [],
|
|
175
|
+
env: {
|
|
176
|
+
...process.env,
|
|
177
|
+
...(server.config.env || {}),
|
|
178
|
+
},
|
|
179
|
+
cwd: this.workdir, // Use the agent's workdir as the process working directory
|
|
180
|
+
stderr: "pipe", // Pipe stderr to capture it
|
|
194
181
|
});
|
|
182
|
+
// Handle stderr output for StdioClientTransport
|
|
183
|
+
const stderr = transport.stderr;
|
|
184
|
+
if (stderr) {
|
|
185
|
+
let buffer = "";
|
|
186
|
+
stderr.on("data", (chunk) => {
|
|
187
|
+
buffer += chunk.toString();
|
|
188
|
+
const lines = buffer.split("\n");
|
|
189
|
+
buffer = lines.pop() || "";
|
|
190
|
+
for (const line of lines) {
|
|
191
|
+
if (line.trim()) {
|
|
192
|
+
logger?.error(`[MCP Server ${name}] ${line}`);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
stderr.on("end", () => {
|
|
197
|
+
if (buffer.trim()) {
|
|
198
|
+
logger?.error(`[MCP Server ${name}] ${buffer}`);
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
throw new Error(`MCP server ${name} configuration must include either 'command' or 'url'`);
|
|
195
205
|
}
|
|
196
206
|
// Create client
|
|
197
207
|
const client = new Client({
|
|
@@ -82,6 +82,15 @@ export declare class SubagentManager {
|
|
|
82
82
|
model?: string;
|
|
83
83
|
stream?: boolean;
|
|
84
84
|
}, runInBackground?: boolean, onUpdate?: () => void): Promise<SubagentInstance>;
|
|
85
|
+
/**
|
|
86
|
+
* Create a new subagent instance initialized with a copy of the current message history.
|
|
87
|
+
* This is used for background tasks like auto-memory extraction.
|
|
88
|
+
*/
|
|
89
|
+
forkAgent(subagentType: string, messages: Message[], parameters: {
|
|
90
|
+
description: string;
|
|
91
|
+
allowedTools?: string[];
|
|
92
|
+
model?: string;
|
|
93
|
+
}, onUpdate?: () => void): Promise<SubagentInstance>;
|
|
85
94
|
/**
|
|
86
95
|
* Execute agent using subagent instance
|
|
87
96
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subagentManager.d.ts","sourceRoot":"","sources":["../../src/managers/subagentManager.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AAEzB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAQ/C,OAAO,EACL,iBAAiB,EACjB,KAAK,0BAA0B,EAChC,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAIlD,MAAM,WAAW,wBAAwB;IAEvC,gDAAgD;IAChD,0BAA0B,CAAC,EAAE,CAC3B,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,iBAAiB,KACtB,IAAI,CAAC;IACV,wDAAwD;IACxD,+BAA+B,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/D,0DAA0D;IAC1D,iCAAiC,CAAC,EAAE,CACl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AAM,EACpB,QAAQ,EAAE,OAAO,EAAE,EACnB,UAAU,EAAE;QACV,WAAW,EAAE,MAAM,CAAC;QACpB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;QACxB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,EACD,QAAQ,CAAC,EAAE,MAAM,IAAI,GACpB,OAAO,CAAC,gBAAgB,CAAC;IAuB5B;;;;;OAKG;IACG,YAAY,CAChB,QAAQ,EAAE,gBAAgB,EAC1B,MAAM,EAAE,MAAM,EACd,WAAW,CAAC,EAAE,WAAW,EACzB,eAAe,CAAC,EAAE,OAAO,GACxB,OAAO,CAAC,MAAM,CAAC;IA+EZ,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;YA4C/C,eAAe;IA0G7B;;OAEG;IACH,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,gBAAgB,GAAG,IAAI;IAIxD;;OAEG;IACH,oBAAoB,CAClB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,gBAAgB,CAAC,QAAQ,CAAC,GACjC,IAAI;IAOP;;OAEG;IACH,oBAAoB,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI;IAOhE;;OAEG;IACH,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAYzC;;OAEG;IACH,kBAAkB,IAAI,gBAAgB,EAAE;IAOxC;;OAEG;IACH,OAAO,IAAI,IAAI;IAIf;;;OAGG;IACH,OAAO,CAAC,uBAAuB;CAgGhC"}
|
|
@@ -132,6 +132,24 @@ export class SubagentManager {
|
|
|
132
132
|
this.instances.set(subagentId, instance);
|
|
133
133
|
return instance;
|
|
134
134
|
}
|
|
135
|
+
/**
|
|
136
|
+
* Create a new subagent instance initialized with a copy of the current message history.
|
|
137
|
+
* This is used for background tasks like auto-memory extraction.
|
|
138
|
+
*/
|
|
139
|
+
async forkAgent(subagentType, messages, parameters, onUpdate) {
|
|
140
|
+
const configuration = await this.findSubagent(subagentType);
|
|
141
|
+
if (!configuration) {
|
|
142
|
+
throw new Error(`Subagent type ${subagentType} not found`);
|
|
143
|
+
}
|
|
144
|
+
const instance = await this.createInstance(configuration, {
|
|
145
|
+
...parameters,
|
|
146
|
+
subagent_type: subagentType,
|
|
147
|
+
prompt: "", // Forked agents start with history
|
|
148
|
+
}, false, onUpdate);
|
|
149
|
+
// Initialize the message manager with provided messages
|
|
150
|
+
instance.messageManager.setMessages(messages);
|
|
151
|
+
return instance;
|
|
152
|
+
}
|
|
135
153
|
/**
|
|
136
154
|
* Execute agent using subagent instance
|
|
137
155
|
*
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"autoMemoryExtraction.d.ts","sourceRoot":"","sources":["../../src/prompts/autoMemoryExtraction.ts"],"names":[],"mappings":"AA+FA;;GAEG;AACH,wBAAgB,+BAA+B,CAC7C,eAAe,EAAE,MAAM,EACvB,wBAAwB,EAAE,MAAM,GAC/B,MAAM,CA4CR"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Memory types taxonomy and examples.
|
|
3
|
+
*/
|
|
4
|
+
const MEMORY_TYPES = ["user", "feedback", "project", "reference"];
|
|
5
|
+
const TYPES_SECTION = [
|
|
6
|
+
"## Types of memory",
|
|
7
|
+
"",
|
|
8
|
+
"There are several discrete types of memory that you can store in your memory system:",
|
|
9
|
+
"",
|
|
10
|
+
"<types>",
|
|
11
|
+
"<type>",
|
|
12
|
+
" <name>user</name>",
|
|
13
|
+
" <description>Contain information about the user's role, goals, responsibilities, and knowledge. Great user memories help you tailor your future behavior to the user's preferences and perspective. Your goal in reading and writing these memories is to build up an understanding of who the user is and how you can be most helpful to them specifically. For example, you should collaborate with a senior software engineer differently than a student who is coding for the very first time. Keep in mind, that the aim here is to be helpful to the user. Avoid writing memories about the user that could be viewed as a negative judgement or that are not relevant to the work you're trying to accomplish together.</description>",
|
|
14
|
+
" <when_to_save>When you learn any details about the user's role, preferences, responsibilities, or knowledge</when_to_save>",
|
|
15
|
+
" <how_to_use>When your work should be informed by the user's profile or perspective. For example, if the user is asking you to explain a part of the code, you should answer that question in a way that is tailored to the specific details that they will find most valuable or that helps them build their mental model in relation to domain knowledge they already have.</how_to_use>",
|
|
16
|
+
" <examples>",
|
|
17
|
+
" user: I'm a data scientist investigating what logging we have in place",
|
|
18
|
+
" assistant: [saves user memory: user is a data scientist, currently focused on observability/logging]",
|
|
19
|
+
"",
|
|
20
|
+
" user: I've been writing Go for ten years but this is my first time touching the React side of this repo",
|
|
21
|
+
" assistant: [saves user memory: deep Go expertise, new to React and this project's frontend — frame frontend explanations in terms of backend analogues]",
|
|
22
|
+
" </examples>",
|
|
23
|
+
"</type>",
|
|
24
|
+
"<type>",
|
|
25
|
+
" <name>feedback</name>",
|
|
26
|
+
" <description>Guidance the user has given you about how to approach work — both what to avoid and what to keep doing. These are a very important type of memory to read and write as they allow you to remain coherent and responsive to the way you should approach work in the project. Record from failure AND success: if you only save corrections, you will avoid past mistakes but drift away from approaches the user has already validated, and may grow overly cautious.</description>",
|
|
27
|
+
' <when_to_save>Any time the user corrects your approach ("no not that", "don\'t", "stop doing X") OR confirms a non-obvious approach worked ("yes exactly", "perfect, keep doing that", accepting an unusual choice without pushback). Corrections are easy to notice; confirmations are quieter — watch for them. In both cases, save what is applicable to future conversations, especially if surprising or not obvious from the code. Include *why* so you can judge edge cases later.</when_to_save>',
|
|
28
|
+
" <how_to_use>Let these memories guide your behavior so that the user does not need to offer the same guidance twice.</how_to_use>",
|
|
29
|
+
" <body_structure>Lead with the rule itself, then a **Why:** line (the reason the user gave — often a past incident or strong preference) and a **How to apply:** line (when/where this guidance kicks in). Knowing *why* lets you judge edge cases instead of blindly following the rule.</body_structure>",
|
|
30
|
+
" <examples>",
|
|
31
|
+
" user: don't mock the database in these tests — we got burned last quarter when mocked tests passed but the prod migration failed",
|
|
32
|
+
" assistant: [saves feedback memory: integration tests must hit a real database, not mocks. Reason: prior incident where mock/prod divergence masked a broken migration]",
|
|
33
|
+
"",
|
|
34
|
+
" user: stop summarizing what you just did at the end of every response, I can read the diff",
|
|
35
|
+
" assistant: [saves feedback memory: this user wants terse responses with no trailing summaries]",
|
|
36
|
+
"",
|
|
37
|
+
" user: yeah the single bundled PR was the right call here, splitting this one would've just been churn",
|
|
38
|
+
" assistant: [saves feedback memory: for refactors in this area, user prefers one bundled PR over many small ones. Confirmed after I chose this approach — a validated judgment call, not a correction]",
|
|
39
|
+
" </examples>",
|
|
40
|
+
"</type>",
|
|
41
|
+
"<type>",
|
|
42
|
+
" <name>project</name>",
|
|
43
|
+
" <description>Information that you learn about ongoing work, goals, initiatives, bugs, or incidents within the project that is not otherwise derivable from the code or git history. Project memories help you understand the broader context and motivation behind the work the user is doing within this working directory.</description>",
|
|
44
|
+
' <when_to_save>When you learn who is doing what, why, or by when. These states change relatively quickly so try to keep your understanding of this up to date. Always convert relative dates in user messages to absolute dates when saving (e.g., "Thursday" → "2026-03-05"), so the memory remains interpretable after time passes.</when_to_save>',
|
|
45
|
+
" <how_to_use>Use these memories to more fully understand the details and nuance behind the user's request and make better informed suggestions.</how_to_use>",
|
|
46
|
+
" <body_structure>Lead with the fact or decision, then a **Why:** line (the motivation — often a constraint, deadline, or stakeholder ask) and a **How to apply:** line (how this should shape your suggestions). Project memories decay fast, so the why helps future-you judge whether the memory is still load-bearing.</body_structure>",
|
|
47
|
+
" <examples>",
|
|
48
|
+
" user: we're freezing all non-critical merges after Thursday — mobile team is cutting a release branch",
|
|
49
|
+
" assistant: [saves project memory: merge freeze begins 2026-03-05 for mobile release cut. Flag any non-critical PR work scheduled after that date]",
|
|
50
|
+
"",
|
|
51
|
+
" user: the reason we're ripping out the old auth middleware is that legal flagged it for storing session tokens in a way that doesn't meet the new compliance requirements",
|
|
52
|
+
" assistant: [saves project memory: auth middleware rewrite is driven by legal/compliance requirements around session token storage, not tech-debt cleanup — scope decisions should favor compliance over ergonomics]",
|
|
53
|
+
" </examples>",
|
|
54
|
+
"</type>",
|
|
55
|
+
"<type>",
|
|
56
|
+
" <name>reference</name>",
|
|
57
|
+
" <description>Stores pointers to where information can be found in external systems. These memories allow you to remember where to look to find up-to-date information outside of the project directory.</description>",
|
|
58
|
+
" <when_to_save>When you learn about resources in external systems and their purpose. For example, that bugs are tracked in a specific project in Linear or that feedback can be found in a specific Slack channel.</when_to_save>",
|
|
59
|
+
" <how_to_use>When the user references an external system or information that may be in an external system.</how_to_use>",
|
|
60
|
+
" <examples>",
|
|
61
|
+
' user: check the Linear project "INGEST" if you want context on these tickets, that\'s where we track all pipeline bugs',
|
|
62
|
+
' assistant: [saves reference memory: pipeline bugs are tracked in Linear project "INGEST"]',
|
|
63
|
+
"",
|
|
64
|
+
" user: the Grafana board at grafana.internal/d/api-latency is what oncall watches — if you're touching request handling, that's the thing that'll page someone",
|
|
65
|
+
" assistant: [saves reference memory: grafana.internal/d/api-latency is the oncall latency dashboard — check it when editing request-path code]",
|
|
66
|
+
" </examples>",
|
|
67
|
+
"</type>",
|
|
68
|
+
"</types>",
|
|
69
|
+
].join("\n");
|
|
70
|
+
const WHAT_NOT_TO_SAVE_SECTION = [
|
|
71
|
+
"## What NOT to save in memory",
|
|
72
|
+
"",
|
|
73
|
+
"- Code patterns, conventions, architecture, file paths, or project structure — these can be derived by reading the current project state.",
|
|
74
|
+
"- Git history, recent changes, or who-changed-what — `git log` / `git blame` are authoritative.",
|
|
75
|
+
"- Debugging solutions or fix recipes — the fix is in the code; the commit message has the context.",
|
|
76
|
+
"- Anything already documented in CLAUDE.md files.",
|
|
77
|
+
"- Ephemeral task details: in-progress work, temporary state, current conversation context.",
|
|
78
|
+
"",
|
|
79
|
+
"These exclusions apply even when the user explicitly asks you to save. If they ask you to save a PR list or activity summary, ask what was *surprising* or *non-obvious* about it — that is the part worth keeping.",
|
|
80
|
+
].join("\n");
|
|
81
|
+
const MEMORY_FRONTMATTER_EXAMPLE = [
|
|
82
|
+
"```markdown",
|
|
83
|
+
"---",
|
|
84
|
+
"name: {{memory name}}",
|
|
85
|
+
"description: {{one-line description — used to decide relevance in future conversations, so be specific}}",
|
|
86
|
+
`type: {{${MEMORY_TYPES.join(", ")}}}`,
|
|
87
|
+
"---",
|
|
88
|
+
"",
|
|
89
|
+
"{{memory content — for feedback/project types, structure as: rule/fact, then **Why:** and **How to apply:** lines}}",
|
|
90
|
+
"```",
|
|
91
|
+
].join("\n");
|
|
92
|
+
/**
|
|
93
|
+
* Build the auto-memory extraction prompt for the background agent.
|
|
94
|
+
*/
|
|
95
|
+
export function buildAutoMemoryExtractionPrompt(newMessageCount, existingMemoriesManifest) {
|
|
96
|
+
const manifestSection = existingMemoriesManifest.length > 0
|
|
97
|
+
? `\n\n## Existing memory files\n\n${existingMemoriesManifest}\n\nCheck this list before writing — update an existing file rather than creating a duplicate.`
|
|
98
|
+
: "";
|
|
99
|
+
const howToSave = [
|
|
100
|
+
"## How to save memories",
|
|
101
|
+
"",
|
|
102
|
+
"Saving a memory is a two-step process:",
|
|
103
|
+
"",
|
|
104
|
+
"**Step 1** — write the memory to its own file (e.g., `user_role.md`, `feedback_testing.md`) using this frontmatter format:",
|
|
105
|
+
"",
|
|
106
|
+
MEMORY_FRONTMATTER_EXAMPLE,
|
|
107
|
+
"",
|
|
108
|
+
"**Step 2** — add a pointer to that file in `MEMORY.md`. `MEMORY.md` is an index, not a memory — each entry should be one line, under ~150 characters: `- [Title](file.md) — one-line hook`. It has no frontmatter. Never write memory content directly into `MEMORY.md`.",
|
|
109
|
+
"",
|
|
110
|
+
"- `MEMORY.md` is always loaded into your system prompt — lines after 200 will be truncated, so keep the index concise",
|
|
111
|
+
"- Organize memory semantically by topic, not chronologically",
|
|
112
|
+
"- Update or remove memories that turn out to be wrong or outdated",
|
|
113
|
+
"- Do not write duplicate memories. First check if there is an existing memory you can update before writing a new one.",
|
|
114
|
+
].join("\n");
|
|
115
|
+
return [
|
|
116
|
+
`You are now acting as the memory extraction subagent. Analyze the most recent ~${newMessageCount} messages above and use them to update your persistent memory systems.`,
|
|
117
|
+
"",
|
|
118
|
+
`Available tools: Read, Grep, Glob, read-only Bash (ls/find/cat/stat/wc/head/tail and similar), and Write/Edit for paths inside the memory directory only. Bash rm is not permitted. All other tools — MCP, Agent, write-capable Bash, etc — will be denied.`,
|
|
119
|
+
"",
|
|
120
|
+
`You have a limited turn budget. Edit requires a prior Read of the same file, so the efficient strategy is: turn 1 — issue all Read calls in parallel for every file you might update; turn 2 — issue all Write/Edit calls in parallel. Do not interleave reads and writes across multiple turns.`,
|
|
121
|
+
"",
|
|
122
|
+
`You MUST only use content from the last ~${newMessageCount} messages to update your persistent memories. Do not waste any turns attempting to investigate or verify that content further — no grepping source files, no reading code to confirm a pattern exists, no git commands.` +
|
|
123
|
+
manifestSection,
|
|
124
|
+
"",
|
|
125
|
+
"If the user explicitly asks you to remember something, save it immediately as whichever type fits best. If they ask you to forget something, find and remove the relevant entry.",
|
|
126
|
+
"",
|
|
127
|
+
TYPES_SECTION,
|
|
128
|
+
"",
|
|
129
|
+
WHAT_NOT_TO_SAVE_SECTION,
|
|
130
|
+
"",
|
|
131
|
+
howToSave,
|
|
132
|
+
"",
|
|
133
|
+
"### Task:",
|
|
134
|
+
"Extract new memories from the latest turns and save them to the memory directory.",
|
|
135
|
+
].join("\n");
|
|
136
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Container } from "../utils/container.js";
|
|
2
|
+
/**
|
|
3
|
+
* Service responsible for managing the auto-memory background agent lifecycle.
|
|
4
|
+
* Extracts and updates persistent project-level memory from conversation history.
|
|
5
|
+
*/
|
|
6
|
+
export declare class AutoMemoryService {
|
|
7
|
+
private container;
|
|
8
|
+
private lastMemoryMessageId;
|
|
9
|
+
private turnsSinceLastExtraction;
|
|
10
|
+
constructor(container: Container);
|
|
11
|
+
private get messageManager();
|
|
12
|
+
private get subagentManager();
|
|
13
|
+
private get memoryService();
|
|
14
|
+
private get configurationService();
|
|
15
|
+
/**
|
|
16
|
+
* Called at the end of each conversation turn to trigger auto-memory extraction if needed.
|
|
17
|
+
*/
|
|
18
|
+
onTurnEnd(workdir: string): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Initialize and execute the background extraction subagent.
|
|
21
|
+
*/
|
|
22
|
+
private runExtraction;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=autoMemoryService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"autoMemoryService.d.ts","sourceRoot":"","sources":["../../src/services/autoMemoryService.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAUlD;;;GAGG;AACH,qBAAa,iBAAiB;IAIhB,OAAO,CAAC,SAAS;IAH7B,OAAO,CAAC,mBAAmB,CAAuB;IAClD,OAAO,CAAC,wBAAwB,CAAa;gBAEzB,SAAS,EAAE,SAAS;IAExC,OAAO,KAAK,cAAc,GAEzB;IAED,OAAO,KAAK,eAAe,GAE1B;IAED,OAAO,KAAK,aAAa,GAExB;IAED,OAAO,KAAK,oBAAoB,GAE/B;IAED;;OAEG;IACG,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAqE/C;;OAEG;YACW,aAAa;CAgE5B"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import * as path from "node:path";
|
|
2
|
+
import * as fs from "node:fs/promises";
|
|
3
|
+
import { logger } from "../utils/globalLogger.js";
|
|
4
|
+
import { isPathInside } from "../utils/pathSafety.js";
|
|
5
|
+
import { buildAutoMemoryExtractionPrompt } from "../prompts/autoMemoryExtraction.js";
|
|
6
|
+
/**
|
|
7
|
+
* Service responsible for managing the auto-memory background agent lifecycle.
|
|
8
|
+
* Extracts and updates persistent project-level memory from conversation history.
|
|
9
|
+
*/
|
|
10
|
+
export class AutoMemoryService {
|
|
11
|
+
constructor(container) {
|
|
12
|
+
this.container = container;
|
|
13
|
+
this.lastMemoryMessageId = null;
|
|
14
|
+
this.turnsSinceLastExtraction = 0;
|
|
15
|
+
}
|
|
16
|
+
get messageManager() {
|
|
17
|
+
return this.container.get("MessageManager");
|
|
18
|
+
}
|
|
19
|
+
get subagentManager() {
|
|
20
|
+
return this.container.get("SubagentManager");
|
|
21
|
+
}
|
|
22
|
+
get memoryService() {
|
|
23
|
+
return this.container.get("MemoryService");
|
|
24
|
+
}
|
|
25
|
+
get configurationService() {
|
|
26
|
+
return this.container.get("ConfigurationService");
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Called at the end of each conversation turn to trigger auto-memory extraction if needed.
|
|
30
|
+
*/
|
|
31
|
+
async onTurnEnd(workdir) {
|
|
32
|
+
if (!this.configurationService.resolveAutoMemoryEnabled()) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
this.turnsSinceLastExtraction++;
|
|
36
|
+
const messages = this.messageManager.getMessages();
|
|
37
|
+
if (messages.length === 0)
|
|
38
|
+
return;
|
|
39
|
+
// 1. Check if we should run based on throttling
|
|
40
|
+
const frequency = this.configurationService.resolveAutoMemoryFrequency();
|
|
41
|
+
if (this.turnsSinceLastExtraction < frequency) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
// 2. Check for mutual exclusion: skip if main agent manually updated memory in this turn
|
|
45
|
+
const memoryDir = this.memoryService.getAutoMemoryDirectory(workdir);
|
|
46
|
+
// Find messages since last extraction
|
|
47
|
+
let startIndex = 0;
|
|
48
|
+
if (this.lastMemoryMessageId) {
|
|
49
|
+
startIndex =
|
|
50
|
+
messages.findIndex((m) => m.id === this.lastMemoryMessageId) + 1;
|
|
51
|
+
if (startIndex <= 0)
|
|
52
|
+
startIndex = 0;
|
|
53
|
+
}
|
|
54
|
+
const recentMessages = messages.slice(startIndex);
|
|
55
|
+
const hasManualMemoryWrite = recentMessages.some((m) => m.role === "assistant" &&
|
|
56
|
+
m.blocks.some((b) => {
|
|
57
|
+
if (b.type === "tool" && (b.name === "Write" || b.name === "Edit")) {
|
|
58
|
+
try {
|
|
59
|
+
const params = b.parameters ? JSON.parse(b.parameters) : null;
|
|
60
|
+
const filePath = params?.file_path || params?.path;
|
|
61
|
+
if (filePath) {
|
|
62
|
+
const absolutePath = path.isAbsolute(filePath)
|
|
63
|
+
? filePath
|
|
64
|
+
: path.resolve(workdir, filePath);
|
|
65
|
+
return isPathInside(absolutePath, memoryDir);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return false;
|
|
73
|
+
}));
|
|
74
|
+
if (hasManualMemoryWrite) {
|
|
75
|
+
logger.debug("Skipping auto-memory extraction: manual memory write detected in this turn.");
|
|
76
|
+
this.lastMemoryMessageId = messages[messages.length - 1].id || null;
|
|
77
|
+
this.turnsSinceLastExtraction = 0;
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
// 3. Trigger background extraction using a forked subagent
|
|
81
|
+
try {
|
|
82
|
+
await this.runExtraction(workdir, messages);
|
|
83
|
+
this.lastMemoryMessageId = messages[messages.length - 1].id || null;
|
|
84
|
+
this.turnsSinceLastExtraction = 0;
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
logger.error("Auto-memory extraction failed to trigger:", error);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Initialize and execute the background extraction subagent.
|
|
92
|
+
*/
|
|
93
|
+
async runExtraction(workdir, messages) {
|
|
94
|
+
const memoryDir = this.memoryService.getAutoMemoryDirectory(workdir);
|
|
95
|
+
// Ensure memory directory exists before starting
|
|
96
|
+
await this.memoryService.ensureAutoMemoryDirectory(workdir);
|
|
97
|
+
// Prepare manifest of existing memory files
|
|
98
|
+
let existingMemoriesManifest = "";
|
|
99
|
+
try {
|
|
100
|
+
const files = await fs.readdir(memoryDir);
|
|
101
|
+
existingMemoriesManifest = files
|
|
102
|
+
.filter((f) => f.endsWith(".md"))
|
|
103
|
+
.map((f) => `- ${f}`)
|
|
104
|
+
.join("\n");
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
// Ignore if directory doesn't exist yet
|
|
108
|
+
}
|
|
109
|
+
// Calculate how many new messages to analyze
|
|
110
|
+
let newMessageCount = messages.length;
|
|
111
|
+
if (this.lastMemoryMessageId) {
|
|
112
|
+
const lastIndex = messages.findIndex((m) => m.id === this.lastMemoryMessageId);
|
|
113
|
+
if (lastIndex !== -1) {
|
|
114
|
+
newMessageCount = messages.length - 1 - lastIndex;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
// Fork the general-purpose agent with restricted tool access
|
|
118
|
+
const instance = await this.subagentManager.forkAgent("general-purpose", messages, {
|
|
119
|
+
description: "Auto-memory extraction background agent",
|
|
120
|
+
allowedTools: [
|
|
121
|
+
"Read",
|
|
122
|
+
"Glob",
|
|
123
|
+
"Grep",
|
|
124
|
+
`Write(${memoryDir}/**/*)`,
|
|
125
|
+
`Edit(${memoryDir}/**/*)`,
|
|
126
|
+
],
|
|
127
|
+
model: "fastModel", // Use fast model for background tasks to reduce latency and cost
|
|
128
|
+
});
|
|
129
|
+
const prompt = buildAutoMemoryExtractionPrompt(newMessageCount, existingMemoriesManifest);
|
|
130
|
+
// Execute in background so it doesn't block the main conversation flow
|
|
131
|
+
await this.subagentManager.executeAgent(instance, `${prompt}\n\nThe memory directory for this project is: ${memoryDir}`, undefined, true);
|
|
132
|
+
logger.debug("Auto-memory extraction started in background.");
|
|
133
|
+
}
|
|
134
|
+
}
|
|
@@ -85,6 +85,12 @@ export declare class ConfigurationService {
|
|
|
85
85
|
* @returns Resolved auto-memory enabled state
|
|
86
86
|
*/
|
|
87
87
|
resolveAutoMemoryEnabled(): boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Resolves auto-memory extraction frequency with fallbacks
|
|
90
|
+
* Resolution priority: settings.json > WAVE_AUTO_MEMORY_FREQUENCY > default (1)
|
|
91
|
+
* @returns Resolved auto-memory extraction frequency (turns)
|
|
92
|
+
*/
|
|
93
|
+
resolveAutoMemoryFrequency(): number;
|
|
88
94
|
/**
|
|
89
95
|
* Resolves max output tokens with fallbacks
|
|
90
96
|
* Resolution priority: override > options > env (from settings.json) > process.env > default
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configurationService.d.ts","sourceRoot":"","sources":["../../src/services/configurationService.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EACV,uBAAuB,EACvB,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,KAAK,EACN,MAAM,2BAA2B,CAAC;AAOnC,OAAO,EACL,KAAK,2BAA2B,EAChC,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,EAE7B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,aAAa,EACb,WAAW,EAGX,cAAc,EACd,YAAY,EACb,MAAM,mBAAmB,CAAC;AAK3B,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAGvC;;;;;GAKG;AACH,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,oBAAoB,CAAkC;IAC9D,OAAO,CAAC,GAAG,CAA8B;IACzC,OAAO,CAAC,OAAO,CAAoB;IAEnC;;OAEG;IACH,UAAU,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI;IAMvC;;OAEG;IACG,uBAAuB,CAC3B,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,uBAAuB,CAAC;IA4DnC;;OAEG;IACH,qBAAqB,CAAC,MAAM,EAAE,iBAAiB,GAAG,gBAAgB;
|
|
1
|
+
{"version":3,"file":"configurationService.d.ts","sourceRoot":"","sources":["../../src/services/configurationService.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EACV,uBAAuB,EACvB,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,KAAK,EACN,MAAM,2BAA2B,CAAC;AAOnC,OAAO,EACL,KAAK,2BAA2B,EAChC,KAAK,wBAAwB,EAC7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,CAAC,GAAG,SAAS,EAC3C,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,EAC9C,OAAO,GAAE,uBAA4B,GACpC,wBAAwB,CAoC1B;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,MAAM,GACf,iBAAiB,GAAG,IAAI,CA6B1B;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,MAAM,GACd,iBAAiB,GAAG,IAAI,CAyJ1B"}
|
|
@@ -208,6 +208,13 @@ export class ConfigurationService {
|
|
|
208
208
|
result.isValid = false;
|
|
209
209
|
result.errors.push("autoMemoryEnabled configuration must be a boolean");
|
|
210
210
|
}
|
|
211
|
+
// Validate autoMemoryFrequency if present
|
|
212
|
+
if (config.autoMemoryFrequency !== undefined &&
|
|
213
|
+
(typeof config.autoMemoryFrequency !== "number" ||
|
|
214
|
+
config.autoMemoryFrequency <= 0)) {
|
|
215
|
+
result.isValid = false;
|
|
216
|
+
result.errors.push("autoMemoryFrequency configuration must be a positive number");
|
|
217
|
+
}
|
|
211
218
|
// Validate models if present
|
|
212
219
|
if (config.models !== undefined) {
|
|
213
220
|
if (typeof config.models !== "object" || config.models === null) {
|
|
@@ -464,6 +471,28 @@ export class ConfigurationService {
|
|
|
464
471
|
// 3. Default (true)
|
|
465
472
|
return true;
|
|
466
473
|
}
|
|
474
|
+
/**
|
|
475
|
+
* Resolves auto-memory extraction frequency with fallbacks
|
|
476
|
+
* Resolution priority: settings.json > WAVE_AUTO_MEMORY_FREQUENCY > default (1)
|
|
477
|
+
* @returns Resolved auto-memory extraction frequency (turns)
|
|
478
|
+
*/
|
|
479
|
+
resolveAutoMemoryFrequency() {
|
|
480
|
+
// 1. settings.json (merged)
|
|
481
|
+
if (this.currentConfiguration?.autoMemoryFrequency !== undefined) {
|
|
482
|
+
return this.currentConfiguration.autoMemoryFrequency;
|
|
483
|
+
}
|
|
484
|
+
// 2. WAVE_AUTO_MEMORY_FREQUENCY environment variable
|
|
485
|
+
const envFrequency = this.env.WAVE_AUTO_MEMORY_FREQUENCY ||
|
|
486
|
+
process.env.WAVE_AUTO_MEMORY_FREQUENCY;
|
|
487
|
+
if (envFrequency) {
|
|
488
|
+
const parsed = parseInt(envFrequency, 10);
|
|
489
|
+
if (!isNaN(parsed) && parsed > 0) {
|
|
490
|
+
return parsed;
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
// 3. Default (1)
|
|
494
|
+
return 1;
|
|
495
|
+
}
|
|
467
496
|
/**
|
|
468
497
|
* Resolves max output tokens with fallbacks
|
|
469
498
|
* Resolution priority: override > options > env (from settings.json) > process.env > default
|
|
@@ -859,6 +888,10 @@ export function loadMergedWaveConfig(workdir) {
|
|
|
859
888
|
if (config.autoMemoryEnabled !== undefined) {
|
|
860
889
|
mergedConfig.autoMemoryEnabled = config.autoMemoryEnabled;
|
|
861
890
|
}
|
|
891
|
+
// Merge autoMemoryFrequency (last one wins)
|
|
892
|
+
if (config.autoMemoryFrequency !== undefined) {
|
|
893
|
+
mergedConfig.autoMemoryFrequency = config.autoMemoryFrequency;
|
|
894
|
+
}
|
|
862
895
|
// Merge models
|
|
863
896
|
if (config.models) {
|
|
864
897
|
if (!mergedConfig.models)
|
|
@@ -32,6 +32,8 @@ export interface WaveConfiguration {
|
|
|
32
32
|
language?: string;
|
|
33
33
|
/** Whether auto-memory is enabled */
|
|
34
34
|
autoMemoryEnabled?: boolean;
|
|
35
|
+
/** Frequency of auto-memory extraction turns */
|
|
36
|
+
autoMemoryFrequency?: number;
|
|
35
37
|
/** Model-specific configuration overrides */
|
|
36
38
|
models?: Record<string, Partial<ModelConfig>>;
|
|
37
39
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configuration.d.ts","sourceRoot":"","sources":["../../src/types/configuration.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,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