wave-agent-sdk 1.2.0 → 1.3.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/agent.d.ts +58 -4
- package/dist/agent.js +91 -19
- package/dist/builtin/index.js +2 -0
- package/dist/builtin/skills/settings.js +1 -12
- package/dist/builtin/skills/wave-daemon.d.ts +1 -0
- package/dist/builtin/skills/wave-daemon.js +194 -0
- package/dist/constants/images.d.ts +26 -0
- package/dist/constants/images.js +26 -0
- package/dist/constants/index.d.ts +16 -0
- package/dist/constants/index.js +16 -0
- package/dist/constants/memory.d.ts +26 -0
- package/dist/constants/memory.js +34 -0
- package/dist/constants/messages.d.ts +11 -0
- package/dist/constants/messages.js +11 -0
- package/dist/constants/plugins.d.ts +8 -0
- package/dist/constants/plugins.js +8 -0
- package/dist/constants/tools.d.ts +1 -0
- package/dist/constants/tools.js +1 -0
- package/dist/core/plugin.d.ts +53 -13
- package/dist/core/plugin.js +134 -26
- package/dist/core/session.d.ts +1 -1
- package/dist/core/session.js +1 -1
- package/dist/exec/catalog.d.ts +140 -0
- package/dist/exec/catalog.js +470 -0
- package/dist/exec/catalogAnnouncement.d.ts +89 -0
- package/dist/exec/catalogAnnouncement.js +293 -0
- package/dist/exec/constants.d.ts +51 -0
- package/dist/exec/constants.js +51 -0
- package/dist/exec/execRuntime.d.ts +55 -0
- package/dist/exec/execRuntime.js +217 -0
- package/dist/exec/workerSource.d.ts +28 -0
- package/dist/exec/workerSource.js +299 -0
- package/dist/host/index.d.ts +23 -0
- package/dist/host/index.js +23 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +6 -0
- package/dist/managers/MemoryRuleManager.d.ts +6 -0
- package/dist/managers/MemoryRuleManager.js +12 -0
- package/dist/managers/aiManager.d.ts +35 -1
- package/dist/managers/aiManager.js +190 -21
- package/dist/managers/backgroundTaskManager.js +14 -0
- package/dist/managers/hookManager.d.ts +13 -0
- package/dist/managers/hookManager.js +31 -4
- package/dist/managers/liveConfigManager.d.ts +33 -0
- package/dist/managers/liveConfigManager.js +103 -8
- package/dist/managers/lspManager.d.ts +9 -0
- package/dist/managers/lspManager.js +47 -18
- package/dist/managers/mcpManager.d.ts +45 -10
- package/dist/managers/mcpManager.js +103 -1
- package/dist/managers/messageManager.d.ts +48 -5
- package/dist/managers/messageManager.js +107 -21
- package/dist/managers/permissionManager.d.ts +40 -0
- package/dist/managers/permissionManager.js +63 -8
- package/dist/managers/pluginManager.d.ts +46 -2
- package/dist/managers/pluginManager.js +117 -11
- package/dist/managers/pluginScopeManager.d.ts +15 -2
- package/dist/managers/pluginScopeManager.js +20 -1
- package/dist/managers/skillManager.d.ts +19 -0
- package/dist/managers/skillManager.js +44 -0
- package/dist/managers/slashCommandManager.d.ts +10 -0
- package/dist/managers/slashCommandManager.js +35 -3
- package/dist/managers/subagentManager.d.ts +8 -0
- package/dist/managers/subagentManager.js +20 -0
- package/dist/managers/toolManager.d.ts +29 -3
- package/dist/managers/toolManager.js +87 -13
- package/dist/prompts/autoMemory.d.ts +9 -0
- package/dist/prompts/autoMemory.js +30 -31
- package/dist/prompts/autoMemoryExtraction.d.ts +4 -0
- package/dist/prompts/autoMemoryExtraction.js +8 -111
- package/dist/prompts/memoryTypes.d.ts +63 -0
- package/dist/prompts/memoryTypes.js +191 -0
- package/dist/services/GitService.d.ts +7 -0
- package/dist/services/GitService.js +23 -0
- package/dist/services/MarketplaceService.d.ts +101 -17
- package/dist/services/MarketplaceService.js +318 -119
- package/dist/services/artifactContent.d.ts +84 -0
- package/dist/services/artifactContent.js +204 -0
- package/dist/services/artifactSession.d.ts +6 -0
- package/dist/services/artifactSession.js +17 -0
- package/dist/services/autoMemoryService.js +5 -13
- package/dist/services/configurationService.d.ts +60 -9
- package/dist/services/configurationService.js +129 -54
- package/dist/services/contentSummarizer.d.ts +15 -0
- package/dist/services/contentSummarizer.js +45 -0
- package/dist/services/execAvailability.d.ts +9 -0
- package/dist/services/execAvailability.js +32 -0
- package/dist/services/fileWatcher.js +61 -6
- package/dist/services/initializationService.js +19 -15
- package/dist/services/interactionService.d.ts +9 -1
- package/dist/services/interactionService.js +28 -8
- package/dist/services/jsonlHandler.d.ts +84 -0
- package/dist/services/jsonlHandler.js +209 -14
- package/dist/services/memory.d.ts +3 -1
- package/dist/services/memory.js +13 -9
- package/dist/services/officialMarketplaceMirror.js +3 -2
- package/dist/services/pluginLoader.d.ts +12 -4
- package/dist/services/pluginLoader.js +38 -7
- package/dist/services/remoteSettingsService.js +16 -2
- package/dist/services/session.d.ts +74 -0
- package/dist/services/session.js +144 -3
- package/dist/services/sessionEntries.d.ts +2 -0
- package/dist/services/sessionEntries.js +20 -0
- package/dist/stdio/index.d.ts +3 -1
- package/dist/stdio/index.js +3 -1
- package/dist/stdio/notificationRouter.js +1 -0
- package/dist/stdio/stdioAgent.d.ts +14 -7
- package/dist/stdio/stdioAgent.js +19 -0
- package/dist/tools/artifactTool.js +406 -273
- package/dist/tools/bashTool.js +8 -6
- package/dist/tools/editTool.js +6 -3
- package/dist/tools/execTool.d.ts +2 -0
- package/dist/tools/execTool.js +165 -0
- package/dist/tools/grepTool.js +7 -1
- package/dist/tools/readTool.js +30 -2
- package/dist/tools/types.d.ts +34 -8
- package/dist/tools/webFetchTool.js +15 -166
- package/dist/tools/workflowTool.js +40 -8
- package/dist/tools/writeTool.js +6 -3
- package/dist/types/agent.d.ts +20 -5
- package/dist/types/configuration.d.ts +39 -1
- package/dist/types/marketplace.d.ts +40 -2
- package/dist/types/mcp.d.ts +39 -0
- package/dist/types/permissions.d.ts +22 -0
- package/dist/types/permissions.js +17 -0
- package/dist/types/plugins.d.ts +26 -2
- package/dist/types/skills.d.ts +15 -0
- package/dist/utils/constants.d.ts +10 -0
- package/dist/utils/constants.js +10 -0
- package/dist/utils/containerSetup.js +43 -0
- package/dist/utils/convertMessagesForAPI.d.ts +7 -1
- package/dist/utils/convertMessagesForAPI.js +64 -14
- package/dist/utils/fileChangeReminder.d.ts +20 -0
- package/dist/utils/fileChangeReminder.js +153 -0
- package/dist/utils/fileSearch.js +4 -3
- package/dist/utils/fileUtils.d.ts +33 -0
- package/dist/utils/fileUtils.js +81 -0
- package/dist/utils/frontmatterYaml.d.ts +33 -0
- package/dist/utils/frontmatterYaml.js +192 -0
- package/dist/utils/imageBudget.d.ts +85 -0
- package/dist/utils/imageBudget.js +109 -0
- package/dist/utils/imageDimensions.d.ts +83 -0
- package/dist/utils/imageDimensions.js +232 -0
- package/dist/utils/imageProcessor.d.ts +66 -0
- package/dist/utils/imageProcessor.js +84 -0
- package/dist/utils/imageRewrite.d.ts +29 -0
- package/dist/utils/imageRewrite.js +251 -0
- package/dist/utils/markdownParser.d.ts +5 -1
- package/dist/utils/markdownParser.js +9 -51
- package/dist/utils/mcpInstructions.d.ts +61 -0
- package/dist/utils/mcpInstructions.js +126 -0
- package/dist/utils/mcpUtils.d.ts +7 -0
- package/dist/utils/mcpUtils.js +11 -2
- package/dist/utils/memoryAge.d.ts +32 -0
- package/dist/utils/memoryAge.js +47 -0
- package/dist/utils/memoryEntrypoint.d.ts +20 -0
- package/dist/utils/memoryEntrypoint.js +49 -0
- package/dist/utils/memoryIndex.d.ts +30 -0
- package/dist/utils/memoryIndex.js +76 -0
- package/dist/utils/messageOperations.d.ts +6 -2
- package/dist/utils/messageOperations.js +40 -29
- package/dist/utils/nestedMemory.d.ts +22 -0
- package/dist/utils/nestedMemory.js +61 -0
- package/dist/utils/npmTarball.d.ts +19 -0
- package/dist/utils/npmTarball.js +92 -0
- package/dist/utils/pluginSource.d.ts +37 -0
- package/dist/utils/pluginSource.js +73 -0
- package/dist/utils/ripgrep.d.ts +18 -4
- package/dist/utils/ripgrep.js +56 -4
- package/dist/utils/runtimeDeps.d.ts +35 -0
- package/dist/utils/runtimeDeps.js +426 -0
- package/dist/utils/skillParser.js +22 -52
- package/dist/utils/subagentParser.js +39 -43
- package/dist/utils/userSettings.d.ts +90 -0
- package/dist/utils/userSettings.js +291 -0
- package/package.json +10 -7
|
@@ -10,7 +10,12 @@ import { cronDeleteTool } from "../tools/cronDeleteTool.js";
|
|
|
10
10
|
import { cronListTool } from "../tools/cronListTool.js";
|
|
11
11
|
import { webFetchTool } from "../tools/webFetchTool.js";
|
|
12
12
|
import { artifactTool } from "../tools/artifactTool.js";
|
|
13
|
+
import { execTool } from "../tools/execTool.js";
|
|
13
14
|
import { isArtifactEnabled } from "../services/artifactAvailability.js";
|
|
15
|
+
import { isExecEnabled } from "../services/execAvailability.js";
|
|
16
|
+
import { buildExecPool, renderCatalog } from "../exec/catalog.js";
|
|
17
|
+
import { EXEC_DEFAULT_CATALOG_TOKENS } from "../exec/constants.js";
|
|
18
|
+
import { EXEC_TOOL_NAME } from "../constants/tools.js";
|
|
14
19
|
// New tools
|
|
15
20
|
import { globTool } from "../tools/globTool.js";
|
|
16
21
|
import { grepTool } from "../tools/grepTool.js";
|
|
@@ -102,6 +107,13 @@ class ToolManager {
|
|
|
102
107
|
if (isArtifactEnabled(this.container.get("Workdir"))) {
|
|
103
108
|
builtInTools.push(artifactTool);
|
|
104
109
|
}
|
|
110
|
+
// Exec is on by default; enableExec: false restores flat MCP declarations.
|
|
111
|
+
// Registration is decoupled from declaration: getToolsConfig() only declares
|
|
112
|
+
// it (and only then collapses the MCP pool) once MCP servers have connected
|
|
113
|
+
// and yielded a non-empty pool, which cannot be known until then.
|
|
114
|
+
if (isExecEnabled(this.container.get("Workdir"))) {
|
|
115
|
+
builtInTools.push(execTool);
|
|
116
|
+
}
|
|
105
117
|
for (const tool of builtInTools) {
|
|
106
118
|
if (this.shouldEnableTool(tool.name)) {
|
|
107
119
|
this.toolsRegistry.set(tool.name, tool);
|
|
@@ -117,12 +129,14 @@ class ToolManager {
|
|
|
117
129
|
/**
|
|
118
130
|
* Re-evaluate feature-gated built-in tools after a live configuration
|
|
119
131
|
* reload. Currently gates the Artifact tool on settings.json
|
|
120
|
-
* `enableArtifact`. Safe to call multiple
|
|
121
|
-
* from the registry first, then
|
|
122
|
-
* only if still enabled (so
|
|
132
|
+
* `enableArtifact` and the Exec tool on `enableExec`. Safe to call multiple
|
|
133
|
+
* times: gated tools are removed from the registry first, then
|
|
134
|
+
* initializeBuiltInTools() re-registers them only if still enabled (so
|
|
135
|
+
* toggling a flag off actually unregisters).
|
|
123
136
|
*/
|
|
124
137
|
reloadFeatureGatedTools() {
|
|
125
138
|
this.toolsRegistry.delete(artifactTool.name);
|
|
139
|
+
this.toolsRegistry.delete(execTool.name);
|
|
126
140
|
this.initializeBuiltInTools();
|
|
127
141
|
}
|
|
128
142
|
/**
|
|
@@ -139,6 +153,22 @@ class ToolManager {
|
|
|
139
153
|
}
|
|
140
154
|
return this.tools.some((toolName) => toolName.toLowerCase() === name.toLowerCase());
|
|
141
155
|
}
|
|
156
|
+
/**
|
|
157
|
+
* The auto-memory directory for this session, or undefined when the feature
|
|
158
|
+
* is off. Consumers (Read) treat "unset" as "not a memory file".
|
|
159
|
+
*/
|
|
160
|
+
resolveAutoMemoryDir(workdir) {
|
|
161
|
+
if (!this.container.has("MemoryService"))
|
|
162
|
+
return undefined;
|
|
163
|
+
const configuration = this.container.has("ConfigurationService")
|
|
164
|
+
? this.container.get("ConfigurationService")
|
|
165
|
+
: undefined;
|
|
166
|
+
if (!configuration?.resolveAutoMemoryEnabled?.())
|
|
167
|
+
return undefined;
|
|
168
|
+
return this.container
|
|
169
|
+
.get("MemoryService")
|
|
170
|
+
?.getAutoMemoryDirectory?.(workdir);
|
|
171
|
+
}
|
|
142
172
|
/**
|
|
143
173
|
* Execute a tool by name with the provided arguments and context
|
|
144
174
|
*
|
|
@@ -202,6 +232,7 @@ class ToolManager {
|
|
|
202
232
|
.get("ConfigurationService")
|
|
203
233
|
?.getMergedEnv?.()
|
|
204
234
|
: undefined,
|
|
235
|
+
autoMemoryDir: this.resolveAutoMemoryDir(context.workdir),
|
|
205
236
|
sessionId: context.sessionId,
|
|
206
237
|
toolCallId: context.toolCallId,
|
|
207
238
|
};
|
|
@@ -287,10 +318,53 @@ class ToolManager {
|
|
|
287
318
|
.filter((tool) => !permissionManager?.isToolDenied(tool.name));
|
|
288
319
|
return [...builtInTools, ...mcpTools];
|
|
289
320
|
}
|
|
321
|
+
/**
|
|
322
|
+
* Whether `Exec` is declared at all: registered and not denied. Exactly when the
|
|
323
|
+
* catalog channel is open — an undeclared `Exec` cannot be called, so a catalog
|
|
324
|
+
* for it would advertise a way in that does not exist.
|
|
325
|
+
*/
|
|
326
|
+
isExecDeclared() {
|
|
327
|
+
return (this.toolsRegistry.has(EXEC_TOOL_NAME) &&
|
|
328
|
+
!this.getPermissionManager()?.isToolDenied(EXEC_TOOL_NAME));
|
|
329
|
+
}
|
|
330
|
+
/** The tools the sandbox may reach — the pool the flat declarations give up. */
|
|
331
|
+
execPool() {
|
|
332
|
+
return buildExecPool(this.mcpManager, this.getPermissionManager());
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* The MCP catalog as the model is meant to see it, or `undefined` when the
|
|
336
|
+
* catalog channel is closed.
|
|
337
|
+
*
|
|
338
|
+
* A function of the pool alone, and computed per call: with the catalog out of
|
|
339
|
+
* `tools[]` the declaration no longer moves when a server comes or goes, and the
|
|
340
|
+
* announcement channel diffs this against the history. Caching the rendering would
|
|
341
|
+
* mean caching pool state, which is exactly the process-side bookkeeping the
|
|
342
|
+
* channel is built to avoid.
|
|
343
|
+
*/
|
|
344
|
+
getExecCatalog() {
|
|
345
|
+
if (!this.isExecDeclared())
|
|
346
|
+
return undefined;
|
|
347
|
+
return renderCatalog(this.execPool(), EXEC_DEFAULT_CATALOG_TOKENS);
|
|
348
|
+
}
|
|
290
349
|
getToolsConfig(options) {
|
|
291
|
-
const permissionManager = this.
|
|
350
|
+
const permissionManager = this.getPermissionManager();
|
|
351
|
+
// Exec either replaces the flat MCP declarations or is absent: the two must
|
|
352
|
+
// never coexist, or the model would see the same tool twice while the
|
|
353
|
+
// catalog claimed to be the only way in. Both halves are derived from the
|
|
354
|
+
// same pool, and the pool is exactly what the agent could already call
|
|
355
|
+
// directly, so collapsing it cannot widen access.
|
|
356
|
+
const execPool = this.execPool();
|
|
357
|
+
// No minimum pool size: any catalogable tool collapses the pool, matching
|
|
358
|
+
// opencode. The switch (`enableExec`), not a count, decides whether Exec is
|
|
359
|
+
// used at all.
|
|
360
|
+
const collapseMcp = this.isExecDeclared() && execPool.length > 0;
|
|
292
361
|
const builtInToolsConfig = Array.from(this.toolsRegistry.values())
|
|
293
362
|
.filter((tool) => {
|
|
363
|
+
// With an empty pool there is nothing to collapse, so Exec stays
|
|
364
|
+
// registered but undeclared rather than declaring an empty catalog.
|
|
365
|
+
if (tool.name === EXEC_TOOL_NAME && !collapseMcp) {
|
|
366
|
+
return false;
|
|
367
|
+
}
|
|
294
368
|
// If tool is explicitly denied by name in permission rules, filter it out
|
|
295
369
|
if (permissionManager?.isToolDenied(tool.name)) {
|
|
296
370
|
return false;
|
|
@@ -307,18 +381,18 @@ class ToolManager {
|
|
|
307
381
|
};
|
|
308
382
|
// Override description with prompt if available
|
|
309
383
|
if (tool.prompt) {
|
|
310
|
-
config.function.description = tool.prompt(options);
|
|
384
|
+
config.function.description = tool.prompt({ ...options });
|
|
311
385
|
}
|
|
312
386
|
return config;
|
|
313
387
|
});
|
|
314
|
-
const mcpToolsConfig =
|
|
315
|
-
|
|
316
|
-
.filter((tool) => {
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
388
|
+
const mcpToolsConfig = collapseMcp
|
|
389
|
+
? []
|
|
390
|
+
: this.mcpManager.getMcpToolsConfig().filter((tool) => {
|
|
391
|
+
if (permissionManager?.isToolDenied(tool.function.name)) {
|
|
392
|
+
return false;
|
|
393
|
+
}
|
|
394
|
+
return true;
|
|
395
|
+
});
|
|
322
396
|
return [...builtInToolsConfig, ...mcpToolsConfig];
|
|
323
397
|
}
|
|
324
398
|
/**
|
|
@@ -1 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build the main agent's auto-memory prompt. The section order mirrors Claude
|
|
3
|
+
* Code's `buildMemoryLines()` (individual-only variant). The index content of
|
|
4
|
+
* `MEMORY.md` is appended separately by the system prompt builder, so this
|
|
5
|
+
* function only produces the behavioral instructions.
|
|
6
|
+
*
|
|
7
|
+
* Every section except the directory line is shared with the extraction fork
|
|
8
|
+
* prompt (`autoMemoryExtraction.ts`) — see `memoryTypes.ts` for why.
|
|
9
|
+
*/
|
|
1
10
|
export declare function buildAutoMemoryPrompt(memoryDir: string): string;
|
|
@@ -1,33 +1,32 @@
|
|
|
1
|
+
import { DIR_EXISTS_GUIDANCE, MEMORY_AND_OTHER_PERSISTENCE_SECTION, TYPES_SECTION, TRUSTING_RECALL_SECTION, WHAT_NOT_TO_SAVE_SECTION, WHEN_TO_ACCESS_SECTION, buildHowToSaveSection, } from "./memoryTypes.js";
|
|
2
|
+
/**
|
|
3
|
+
* Build the main agent's auto-memory prompt. The section order mirrors Claude
|
|
4
|
+
* Code's `buildMemoryLines()` (individual-only variant). The index content of
|
|
5
|
+
* `MEMORY.md` is appended separately by the system prompt builder, so this
|
|
6
|
+
* function only produces the behavioral instructions.
|
|
7
|
+
*
|
|
8
|
+
* Every section except the directory line is shared with the extraction fork
|
|
9
|
+
* prompt (`autoMemoryExtraction.ts`) — see `memoryTypes.ts` for why.
|
|
10
|
+
*/
|
|
1
11
|
export function buildAutoMemoryPrompt(memoryDir) {
|
|
2
|
-
return
|
|
3
|
-
# auto memory
|
|
4
|
-
|
|
5
|
-
You have a persistent
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
## What NOT to save:
|
|
24
|
-
- Session-specific context (current task details, in-progress work, temporary state)
|
|
25
|
-
- Information that might be incomplete — verify against project docs before writing
|
|
26
|
-
- Anything that duplicates or contradicts existing AGENTS.md instructions
|
|
27
|
-
- Speculative or unverified conclusions from reading a single file
|
|
28
|
-
|
|
29
|
-
## Explicit user requests:
|
|
30
|
-
- When the user asks you to remember something across sessions (e.g., "always use bun", "never auto-commit"), save it — no need to wait for multiple interactions
|
|
31
|
-
- When the user asks to forget or stop remembering something, find and remove the relevant entries from your memory files
|
|
32
|
-
`;
|
|
12
|
+
return [
|
|
13
|
+
"# auto memory",
|
|
14
|
+
"",
|
|
15
|
+
`You have a persistent, file-based memory system at \`${memoryDir}\`. ${DIR_EXISTS_GUIDANCE}`,
|
|
16
|
+
"",
|
|
17
|
+
"You should build up this memory system over time so that future conversations can have a complete picture of who the user is, how they'd like to collaborate with you, what behaviors to avoid or repeat, and the context behind the work the user gives you.",
|
|
18
|
+
"",
|
|
19
|
+
"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.",
|
|
20
|
+
"",
|
|
21
|
+
...TYPES_SECTION,
|
|
22
|
+
...WHAT_NOT_TO_SAVE_SECTION,
|
|
23
|
+
"",
|
|
24
|
+
...buildHowToSaveSection(),
|
|
25
|
+
"",
|
|
26
|
+
...WHEN_TO_ACCESS_SECTION,
|
|
27
|
+
"",
|
|
28
|
+
...TRUSTING_RECALL_SECTION,
|
|
29
|
+
"",
|
|
30
|
+
...MEMORY_AND_OTHER_PERSISTENCE_SECTION,
|
|
31
|
+
].join("\n");
|
|
33
32
|
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Build the auto-memory extraction prompt for the background agent.
|
|
3
|
+
*
|
|
4
|
+
* The taxonomy, the "what not to save" list, and the save procedure are shared
|
|
5
|
+
* with the main agent's memory prompt (`memoryTypes.ts`): the fork reuses the
|
|
6
|
+
* main system prompt, so both texts are in the same request.
|
|
3
7
|
*/
|
|
4
8
|
export declare function buildAutoMemoryExtractionPrompt(newMessageCount: number, existingMemoriesManifest: string): string;
|
|
@@ -1,117 +1,15 @@
|
|
|
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");
|
|
1
|
+
import { TYPES_SECTION, WHAT_NOT_TO_SAVE_SECTION, buildHowToSaveSection, } from "./memoryTypes.js";
|
|
92
2
|
/**
|
|
93
3
|
* Build the auto-memory extraction prompt for the background agent.
|
|
4
|
+
*
|
|
5
|
+
* The taxonomy, the "what not to save" list, and the save procedure are shared
|
|
6
|
+
* with the main agent's memory prompt (`memoryTypes.ts`): the fork reuses the
|
|
7
|
+
* main system prompt, so both texts are in the same request.
|
|
94
8
|
*/
|
|
95
9
|
export function buildAutoMemoryExtractionPrompt(newMessageCount, existingMemoriesManifest) {
|
|
96
10
|
const manifestSection = existingMemoriesManifest.length > 0
|
|
97
11
|
? `\n\n## Existing memory files\n\n${existingMemoriesManifest}\n\nCheck this list before writing — update an existing file rather than creating a duplicate.`
|
|
98
12
|
: "";
|
|
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
13
|
return [
|
|
116
14
|
`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
15
|
"",
|
|
@@ -124,11 +22,10 @@ export function buildAutoMemoryExtractionPrompt(newMessageCount, existingMemorie
|
|
|
124
22
|
"",
|
|
125
23
|
"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
24
|
"",
|
|
127
|
-
TYPES_SECTION,
|
|
128
|
-
|
|
129
|
-
WHAT_NOT_TO_SAVE_SECTION,
|
|
25
|
+
...TYPES_SECTION,
|
|
26
|
+
...WHAT_NOT_TO_SAVE_SECTION,
|
|
130
27
|
"",
|
|
131
|
-
|
|
28
|
+
...buildHowToSaveSection(),
|
|
132
29
|
"",
|
|
133
30
|
"### Task:",
|
|
134
31
|
"Extract new memories from the latest turns and save them to the memory directory.",
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto-memory taxonomy and shared prompt sections.
|
|
3
|
+
*
|
|
4
|
+
* These sections are shared by the main agent's memory prompt
|
|
5
|
+
* (`prompts/autoMemory.ts`) and the background extraction fork prompt
|
|
6
|
+
* (`prompts/autoMemoryExtraction.ts`). Sharing them is load-bearing, not
|
|
7
|
+
* tidiness: the fork reuses the main system prompt, so both texts land in the
|
|
8
|
+
* same request — a duplicated copy that drifts turns into a request that
|
|
9
|
+
* simultaneously tells the model to save and not to save the same category.
|
|
10
|
+
*
|
|
11
|
+
* Aligned with Claude Code's `memdir/memoryTypes.ts`, individual-only variant
|
|
12
|
+
* (no `<scope>` tags, no private/team split: Wave has a single memory
|
|
13
|
+
* directory).
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Appended to the memory directory line. Shipped because the model was burning
|
|
17
|
+
* turns on `ls` / `mkdir -p` before writing; the harness guarantees the
|
|
18
|
+
* directory exists (`MemoryService.ensureAutoMemoryDirectory`).
|
|
19
|
+
*/
|
|
20
|
+
export declare const DIR_EXISTS_GUIDANCE = "This directory already exists \u2014 write to it directly with the Write tool (do not run mkdir or check for its existence).";
|
|
21
|
+
/**
|
|
22
|
+
* `## Types of memory` section.
|
|
23
|
+
*/
|
|
24
|
+
export declare const TYPES_SECTION: readonly string[];
|
|
25
|
+
/**
|
|
26
|
+
* `## What NOT to save in memory` section. The closing paragraph is the
|
|
27
|
+
* explicit-save gate: it applies even when the user asks for something the
|
|
28
|
+
* model would otherwise happily record, which is exactly the case where
|
|
29
|
+
* activity-log noise gets in.
|
|
30
|
+
*/
|
|
31
|
+
export declare const WHAT_NOT_TO_SAVE_SECTION: readonly string[];
|
|
32
|
+
/**
|
|
33
|
+
* Recall-side drift caveat, a single bullet under `## When to access memories`.
|
|
34
|
+
*/
|
|
35
|
+
export declare const MEMORY_DRIFT_CAVEAT = "- Memory records can become stale over time. Use memory as context for what was true at a given point in time. Before answering the user or building assumptions based solely on information in memory records, verify that the memory is still correct and up-to-date by reading the current state of the files or resources. If a recalled memory conflicts with current information, trust what you observe now \u2014 and update or remove the stale memory rather than acting on it.";
|
|
36
|
+
/**
|
|
37
|
+
* `## When to access memories` section, including the drift caveat.
|
|
38
|
+
*
|
|
39
|
+
* The "ignore" bullet is deliberate: without it the model tends to treat
|
|
40
|
+
* "ignore memory about X" as "acknowledge memory about X, then override it",
|
|
41
|
+
* and mentions the memory anyway.
|
|
42
|
+
*/
|
|
43
|
+
export declare const WHEN_TO_ACCESS_SECTION: readonly string[];
|
|
44
|
+
/**
|
|
45
|
+
* `## Before recommending from memory` section. Header wording is deliberate:
|
|
46
|
+
* the action cue at the decision point works where an abstract header
|
|
47
|
+
* ("Trusting what you recall") does not.
|
|
48
|
+
*/
|
|
49
|
+
export declare const TRUSTING_RECALL_SECTION: readonly string[];
|
|
50
|
+
/**
|
|
51
|
+
* `## Memory and other forms of persistence` section: how memory divides
|
|
52
|
+
* labor with plans and tasks.
|
|
53
|
+
*/
|
|
54
|
+
export declare const MEMORY_AND_OTHER_PERSISTENCE_SECTION: readonly string[];
|
|
55
|
+
/**
|
|
56
|
+
* Frontmatter format example with the `type` field.
|
|
57
|
+
*/
|
|
58
|
+
export declare const MEMORY_FRONTMATTER_EXAMPLE: readonly string[];
|
|
59
|
+
/**
|
|
60
|
+
* `## How to save memories` section: the two-step write (topic file, then
|
|
61
|
+
* index pointer) plus the entrypoint rules.
|
|
62
|
+
*/
|
|
63
|
+
export declare function buildHowToSaveSection(): readonly string[];
|