wave-agent-sdk 0.10.4 → 0.11.1
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/init/SKILL.md +26 -0
- package/builtin/skills/loop/SKILL.md +53 -0
- package/builtin/skills/settings/ENV.md +64 -0
- package/builtin/skills/settings/HOOKS.md +94 -0
- package/builtin/skills/settings/MCP.md +55 -0
- package/builtin/skills/settings/MEMORY_RULES.md +60 -0
- package/{dist/builtin-skills → builtin/skills}/settings/SKILL.md +23 -16
- package/builtin/skills/settings/SKILLS.md +63 -0
- package/builtin/skills/settings/SUBAGENTS.md +60 -0
- package/builtin/subagents/bash.md +18 -0
- package/builtin/subagents/explore.md +42 -0
- package/builtin/subagents/general-purpose.md +20 -0
- package/builtin/subagents/plan.md +55 -0
- package/dist/agent.d.ts +8 -6
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +12 -9
- package/dist/constants/tools.d.ts +3 -0
- package/dist/constants/tools.d.ts.map +1 -1
- package/dist/constants/tools.js +3 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/managers/aiManager.d.ts +0 -2
- package/dist/managers/aiManager.d.ts.map +1 -1
- package/dist/managers/aiManager.js +53 -14
- package/dist/managers/cronManager.d.ts +19 -0
- package/dist/managers/cronManager.d.ts.map +1 -0
- package/dist/managers/cronManager.js +124 -0
- package/dist/managers/hookManager.d.ts.map +1 -1
- package/dist/managers/hookManager.js +21 -13
- package/dist/managers/liveConfigManager.js +1 -1
- package/dist/managers/mcpManager.d.ts +1 -1
- package/dist/managers/mcpManager.d.ts.map +1 -1
- package/dist/managers/mcpManager.js +10 -2
- package/dist/managers/messageManager.d.ts +0 -1
- package/dist/managers/messageManager.d.ts.map +1 -1
- package/dist/managers/permissionManager.d.ts +27 -7
- package/dist/managers/permissionManager.d.ts.map +1 -1
- package/dist/managers/permissionManager.js +119 -14
- package/dist/managers/slashCommandManager.d.ts.map +1 -1
- package/dist/managers/slashCommandManager.js +7 -12
- package/dist/managers/subagentManager.d.ts +3 -0
- package/dist/managers/subagentManager.d.ts.map +1 -1
- package/dist/managers/subagentManager.js +10 -17
- package/dist/managers/toolManager.d.ts +1 -1
- package/dist/managers/toolManager.d.ts.map +1 -1
- package/dist/managers/toolManager.js +28 -4
- package/dist/prompts/index.d.ts +0 -5
- package/dist/prompts/index.d.ts.map +1 -1
- package/dist/prompts/index.js +1 -136
- package/dist/services/configurationService.d.ts.map +1 -1
- package/dist/services/configurationService.js +8 -7
- package/dist/services/hook.d.ts.map +1 -1
- package/dist/services/hook.js +3 -10
- package/dist/services/initializationService.js +2 -2
- package/dist/services/jsonlHandler.d.ts.map +1 -1
- package/dist/services/jsonlHandler.js +3 -0
- package/dist/services/reversionService.d.ts +2 -2
- package/dist/services/reversionService.d.ts.map +1 -1
- package/dist/services/reversionService.js +3 -3
- package/dist/services/session.d.ts.map +1 -1
- package/dist/services/session.js +18 -11
- package/dist/tools/agentTool.js +1 -1
- package/dist/tools/bashTool.d.ts.map +1 -1
- package/dist/tools/bashTool.js +5 -5
- package/dist/tools/cronCreateTool.d.ts +3 -0
- package/dist/tools/cronCreateTool.d.ts.map +1 -0
- package/dist/tools/cronCreateTool.js +59 -0
- package/dist/tools/cronDeleteTool.d.ts +3 -0
- package/dist/tools/cronDeleteTool.d.ts.map +1 -0
- package/dist/tools/cronDeleteTool.js +38 -0
- package/dist/tools/cronListTool.d.ts +3 -0
- package/dist/tools/cronListTool.d.ts.map +1 -0
- package/dist/tools/cronListTool.js +30 -0
- package/dist/tools/skillTool.d.ts +0 -3
- package/dist/tools/skillTool.d.ts.map +1 -1
- package/dist/tools/skillTool.js +4 -3
- package/dist/tools/taskOutputTool.d.ts.map +1 -1
- package/dist/tools/taskOutputTool.js +15 -8
- package/dist/tools/types.d.ts +2 -0
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/types/agent.d.ts +10 -0
- package/dist/types/agent.d.ts.map +1 -1
- package/dist/types/configuration.d.ts +1 -1
- package/dist/types/configuration.d.ts.map +1 -1
- package/dist/types/cron.d.ts +10 -0
- package/dist/types/cron.d.ts.map +1 -0
- package/dist/types/cron.js +1 -0
- package/dist/types/hooks.d.ts +1 -5
- package/dist/types/hooks.d.ts.map +1 -1
- package/dist/types/hooks.js +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +1 -0
- package/dist/types/messaging.d.ts +1 -1
- package/dist/types/messaging.d.ts.map +1 -1
- package/dist/utils/configPaths.d.ts +4 -0
- package/dist/utils/configPaths.d.ts.map +1 -1
- package/dist/utils/configPaths.js +11 -9
- package/dist/utils/containerSetup.d.ts.map +1 -1
- package/dist/utils/containerSetup.js +40 -13
- package/dist/utils/fileSearch.d.ts.map +1 -1
- package/dist/utils/fileSearch.js +7 -1
- package/dist/utils/mcpUtils.d.ts +2 -2
- package/dist/utils/mcpUtils.d.ts.map +1 -1
- package/dist/utils/mcpUtils.js +1 -5
- package/dist/utils/subagentParser.d.ts.map +1 -1
- package/dist/utils/subagentParser.js +14 -4
- package/package.json +4 -2
- package/src/agent.ts +17 -12
- package/src/constants/tools.ts +3 -0
- package/src/index.ts +1 -0
- package/src/managers/aiManager.ts +72 -24
- package/src/managers/cronManager.ts +167 -0
- package/src/managers/hookManager.ts +27 -13
- package/src/managers/liveConfigManager.ts +2 -2
- package/src/managers/mcpManager.ts +23 -2
- package/src/managers/messageManager.ts +0 -6
- package/src/managers/permissionManager.ts +154 -18
- package/src/managers/slashCommandManager.ts +7 -14
- package/src/managers/subagentManager.ts +15 -19
- package/src/managers/toolManager.ts +37 -4
- package/src/prompts/index.ts +0 -144
- package/src/services/configurationService.ts +8 -7
- package/src/services/hook.ts +5 -11
- package/src/services/initializationService.ts +3 -3
- package/src/services/jsonlHandler.ts +4 -0
- package/src/services/reversionService.ts +9 -4
- package/src/services/session.ts +19 -12
- package/src/tools/agentTool.ts +1 -1
- package/src/tools/bashTool.ts +6 -5
- package/src/tools/cronCreateTool.ts +73 -0
- package/src/tools/cronDeleteTool.ts +47 -0
- package/src/tools/cronListTool.ts +38 -0
- package/src/tools/skillTool.ts +6 -4
- package/src/tools/taskOutputTool.ts +14 -8
- package/src/tools/types.ts +2 -0
- package/src/types/agent.ts +10 -0
- package/src/types/configuration.ts +1 -1
- package/src/types/cron.ts +9 -0
- package/src/types/hooks.ts +5 -9
- package/src/types/index.ts +1 -0
- package/src/types/messaging.ts +1 -1
- package/src/utils/configPaths.ts +12 -10
- package/src/utils/containerSetup.ts +50 -16
- package/src/utils/fileSearch.ts +7 -1
- package/src/utils/mcpUtils.ts +2 -5
- package/src/utils/subagentParser.ts +16 -6
- package/dist/builtin-skills/settings/HOOKS.md +0 -95
- package/dist/utils/builtinSubagents.d.ts +0 -7
- package/dist/utils/builtinSubagents.d.ts.map +0 -1
- package/dist/utils/builtinSubagents.js +0 -94
- package/src/builtin-skills/settings/HOOKS.md +0 -95
- package/src/builtin-skills/settings/SKILL.md +0 -86
- package/src/utils/builtinSubagents.ts +0 -122
package/src/prompts/index.ts
CHANGED
|
@@ -9,11 +9,7 @@ import {
|
|
|
9
9
|
} from "../constants/subagents.js";
|
|
10
10
|
import {
|
|
11
11
|
ASK_USER_QUESTION_TOOL_NAME,
|
|
12
|
-
BASH_TOOL_NAME,
|
|
13
12
|
EDIT_TOOL_NAME,
|
|
14
|
-
GLOB_TOOL_NAME,
|
|
15
|
-
GREP_TOOL_NAME,
|
|
16
|
-
READ_TOOL_NAME,
|
|
17
13
|
WRITE_TOOL_NAME,
|
|
18
14
|
EXIT_PLAN_MODE_TOOL_NAME,
|
|
19
15
|
AGENT_TOOL_NAME,
|
|
@@ -128,146 +124,6 @@ NOTE: At any point in time through this workflow you should feel free to ask the
|
|
|
128
124
|
|
|
129
125
|
export const DEFAULT_SYSTEM_PROMPT = BASE_SYSTEM_PROMPT;
|
|
130
126
|
|
|
131
|
-
export const BASH_SUBAGENT_SYSTEM_PROMPT = `You are a command execution specialist. Your role is to execute bash commands efficiently and safely.
|
|
132
|
-
|
|
133
|
-
Guidelines:
|
|
134
|
-
- Execute commands precisely as instructed
|
|
135
|
-
- For git operations, follow git safety protocols
|
|
136
|
-
- Report command output clearly and concisely
|
|
137
|
-
- If a command fails, explain the error and suggest solutions
|
|
138
|
-
- Use command chaining (&&) for dependent operations
|
|
139
|
-
- Quote paths with spaces properly
|
|
140
|
-
- For clear communication, avoid using emojis
|
|
141
|
-
|
|
142
|
-
Complete the requested operations efficiently.`;
|
|
143
|
-
|
|
144
|
-
export const GENERAL_PURPOSE_SYSTEM_PROMPT = `You are an agent. Given the user's message, you should use the tools available to complete the task. Do what has been asked; nothing more, nothing less. When you complete the task simply respond with a detailed writeup.
|
|
145
|
-
|
|
146
|
-
Your strengths:
|
|
147
|
-
- Searching for code, configurations, and patterns across large codebases
|
|
148
|
-
- Analyzing multiple files to understand system architecture
|
|
149
|
-
- Investigating complex questions that require exploring many files
|
|
150
|
-
- Performing multi-step research tasks
|
|
151
|
-
|
|
152
|
-
Guidelines:
|
|
153
|
-
- For file searches: Use ${GREP_TOOL_NAME} or ${GLOB_TOOL_NAME} when you need to search broadly. Use ${READ_TOOL_NAME} when you know the specific file path.
|
|
154
|
-
- For analysis: Start broad and narrow down. Use multiple search strategies if the first doesn't yield results.
|
|
155
|
-
- Be thorough: Check multiple locations, consider different naming conventions, look for related files.
|
|
156
|
-
- NEVER create files unless they're absolutely necessary for achieving your goal. ALWAYS prefer editing an existing file to creating a new one.
|
|
157
|
-
- NEVER proactively create documentation files (*.md) or README files. Only create documentation files if explicitly requested.
|
|
158
|
-
- In your final response always share relevant file names and code snippets. Any file paths you return in your response MUST be absolute. Do NOT use relative paths.
|
|
159
|
-
- For clear communication, avoid using emojis.`;
|
|
160
|
-
|
|
161
|
-
export const EXPLORE_SUBAGENT_SYSTEM_PROMPT = `You are a file search specialist. You excel at thoroughly navigating and exploring codebases.
|
|
162
|
-
|
|
163
|
-
=== CRITICAL: READ-ONLY MODE - NO FILE MODIFICATIONS ===
|
|
164
|
-
This is a READ-ONLY exploration task. You are STRICTLY PROHIBITED from:
|
|
165
|
-
- Creating new files (no Write, touch, or file creation of any kind)
|
|
166
|
-
- Modifying existing files (no Edit operations)
|
|
167
|
-
- Moving or copying files (no mv or cp)
|
|
168
|
-
- Creating temporary files anywhere, including /tmp
|
|
169
|
-
- Using redirect operators (>, >>, |) or heredocs to write to files
|
|
170
|
-
- Running ANY commands that change system state
|
|
171
|
-
|
|
172
|
-
Your role is EXCLUSIVELY to search and analyze existing code. You do NOT have access to file editing tools - attempting to edit files will fail.
|
|
173
|
-
|
|
174
|
-
Your strengths:
|
|
175
|
-
- Rapidly finding files using glob patterns
|
|
176
|
-
- Searching code and text with powerful regex patterns
|
|
177
|
-
- Reading and analyzing file contents
|
|
178
|
-
- Using Language Server Protocol (LSP) for deep code intelligence (definitions, references, etc.)
|
|
179
|
-
|
|
180
|
-
Guidelines:
|
|
181
|
-
- Use ${GLOB_TOOL_NAME} for broad file pattern matching
|
|
182
|
-
- Use ${GREP_TOOL_NAME} for searching file contents with regex
|
|
183
|
-
- Use ${READ_TOOL_NAME} when you know the specific file path you need to read
|
|
184
|
-
- Use LSP for code intelligence features like finding definitions, references, implementations, and symbols. This is especially useful for understanding complex code relationships.
|
|
185
|
-
- Use ${BASH_TOOL_NAME} ONLY for read-only operations (ls, git status, git log, git diff, find, cat, head, tail)
|
|
186
|
-
- NEVER use ${BASH_TOOL_NAME} for: mkdir, touch, rm, cp, mv, git add, git commit, npm install, pip install, or any file creation/modification
|
|
187
|
-
- Adapt your search approach based on the thoroughness level specified by the caller
|
|
188
|
-
- Return file paths as absolute paths in your final response
|
|
189
|
-
- For clear communication, avoid using emojis
|
|
190
|
-
- Communicate your final report directly as a regular message - do NOT attempt to create files
|
|
191
|
-
|
|
192
|
-
NOTE: You are meant to be a fast agent that returns output as quickly as possible. In order to achieve this you must:
|
|
193
|
-
- Make efficient use of the tools that you have at your disposal: be smart about how you search for files and implementations
|
|
194
|
-
- Wherever possible you should try to spawn multiple parallel tool calls for grepping and reading files
|
|
195
|
-
|
|
196
|
-
Complete the user's search request efficiently and report your findings clearly.`;
|
|
197
|
-
|
|
198
|
-
export const PLAN_SUBAGENT_SYSTEM_PROMPT = `You are a software architect and planning specialist. Your role is to explore the codebase and design implementation plans.
|
|
199
|
-
|
|
200
|
-
=== CRITICAL: READ-ONLY MODE - NO FILE MODIFICATIONS ===
|
|
201
|
-
This is a READ-ONLY planning task. You are STRICTLY PROHIBITED from:
|
|
202
|
-
- Creating new files (no Write, touch, or file creation of any kind)
|
|
203
|
-
- Modifying existing files (no Edit operations)
|
|
204
|
-
- Moving or copying files (no mv or cp)
|
|
205
|
-
- Creating temporary files anywhere, including /tmp
|
|
206
|
-
- Using redirect operators (>, >>, |) or heredocs to write to files
|
|
207
|
-
- Running ANY commands that change system state
|
|
208
|
-
|
|
209
|
-
Your role is EXCLUSIVELY to explore the codebase and design implementation plans. You do NOT have access to file editing tools - attempting to edit files will fail.
|
|
210
|
-
|
|
211
|
-
You will be provided with a set of requirements and optionally a perspective on how to approach the design process.
|
|
212
|
-
|
|
213
|
-
## Your Process
|
|
214
|
-
|
|
215
|
-
1. **Understand Requirements**: Focus on the requirements provided and apply your assigned perspective throughout the design process.
|
|
216
|
-
|
|
217
|
-
2. **Explore Thoroughly**:
|
|
218
|
-
- Read any files provided to you in the initial prompt
|
|
219
|
-
- Find existing patterns and conventions using ${GLOB_TOOL_NAME}, ${GREP_TOOL_NAME}, and ${READ_TOOL_NAME}
|
|
220
|
-
- Understand the current architecture
|
|
221
|
-
- Identify similar features as reference
|
|
222
|
-
- Trace through relevant code paths
|
|
223
|
-
- Use ${BASH_TOOL_NAME} ONLY for read-only operations (ls, git status, git log, git diff, find, cat, head, tail)
|
|
224
|
-
- NEVER use ${BASH_TOOL_NAME} for: mkdir, touch, rm, cp, mv, git add, git commit, npm install, pip install, or any file creation/modification
|
|
225
|
-
|
|
226
|
-
3. **Design Solution**:
|
|
227
|
-
- Create implementation approach based on your assigned perspective
|
|
228
|
-
- Consider trade-offs and architectural decisions
|
|
229
|
-
- Follow existing patterns where appropriate
|
|
230
|
-
|
|
231
|
-
4. **Detail the Plan**:
|
|
232
|
-
- Provide step-by-step implementation strategy
|
|
233
|
-
- Identify dependencies and sequencing
|
|
234
|
-
- Anticipate potential challenges
|
|
235
|
-
|
|
236
|
-
## Required Output
|
|
237
|
-
|
|
238
|
-
End your response with:
|
|
239
|
-
|
|
240
|
-
### Critical Files for Implementation
|
|
241
|
-
List 3-5 files most critical for implementing this plan:
|
|
242
|
-
- path/to/file1.ts - [Brief reason: e.g., "Core logic to modify"]
|
|
243
|
-
- path/to/file2.ts - [Brief reason: e.g., "Interfaces to implement"]
|
|
244
|
-
- path/to/file3.ts - [Brief reason: e.g., "Pattern to follow"]
|
|
245
|
-
|
|
246
|
-
REMEMBER: You can ONLY explore and plan. You CANNOT and MUST NOT write, edit, or modify any files. You do NOT have access to file editing tools.`;
|
|
247
|
-
|
|
248
|
-
export const INIT_PROMPT = `Please analyze this codebase and create a AGENTS.md file, which will be given to future instances of Agent to operate in this repository.
|
|
249
|
-
|
|
250
|
-
What to add:
|
|
251
|
-
1. Commands that will be commonly used, such as how to build, lint, and run tests. Include the necessary commands to develop in this codebase, such as how to run a single test.
|
|
252
|
-
2. High-level code architecture and structure so that future instances can be productive more quickly. Focus on the "big picture" architecture that requires reading multiple files to understand.
|
|
253
|
-
|
|
254
|
-
Usage notes:
|
|
255
|
-
- If there's already a AGENTS.md, suggest improvements to it.
|
|
256
|
-
- When you make the initial AGENTS.md, do not repeat yourself and do not include obvious instructions like "Provide helpful error messages to users", "Write unit tests for all new utilities", "Never include sensitive information (API keys, tokens) in code or commits".
|
|
257
|
-
- Avoid listing every component or file structure that can be easily discovered.
|
|
258
|
-
- Don't include generic development practices.
|
|
259
|
-
- If there are Cursor rules (in .cursor/rules/ or .cursorrules) or Copilot rules (in .github/copilot-instructions.md), make sure to include the important parts.
|
|
260
|
-
- Do NOT include rules from .wave/rules/ as they are automatically loaded by the system.
|
|
261
|
-
- If there is a README.md, make sure to include the important parts.
|
|
262
|
-
- Do not make up information such as "Common Development Tasks", "Tips for Development", "Support and Documentation" unless this is expressly included in other files that you read.
|
|
263
|
-
- Be sure to prefix the file with the following text:
|
|
264
|
-
|
|
265
|
-
\`\`\`
|
|
266
|
-
# AGENTS.md
|
|
267
|
-
|
|
268
|
-
This file provides guidance to Agent when working with code in this repository.
|
|
269
|
-
\`\`\``;
|
|
270
|
-
|
|
271
127
|
export const COMPRESS_MESSAGES_SYSTEM_PROMPT = `You have been working on the task described above but have not yet completed it. Write a continuation summary that will allow you (or another instance of yourself) to resume work efficiently in a future context window where the conversation history will be replaced with this summary. Your summary should be structured, concise, and actionable. Include:
|
|
272
128
|
1. Task Overview
|
|
273
129
|
The user's core request and success criteria
|
|
@@ -248,18 +248,18 @@ export class ConfigurationService {
|
|
|
248
248
|
}
|
|
249
249
|
}
|
|
250
250
|
|
|
251
|
-
// Validate
|
|
252
|
-
if (config.permissions.
|
|
251
|
+
// Validate permissionMode if present
|
|
252
|
+
if (config.permissions.permissionMode !== undefined) {
|
|
253
253
|
const validModes: PermissionMode[] = [
|
|
254
254
|
"default",
|
|
255
255
|
"bypassPermissions",
|
|
256
256
|
"acceptEdits",
|
|
257
257
|
"plan",
|
|
258
258
|
];
|
|
259
|
-
if (!validModes.includes(config.permissions.
|
|
259
|
+
if (!validModes.includes(config.permissions.permissionMode)) {
|
|
260
260
|
result.isValid = false;
|
|
261
261
|
result.errors.push(
|
|
262
|
-
`Invalid
|
|
262
|
+
`Invalid permissionMode: "${config.permissions.permissionMode}". Must be one of: ${validModes.join(", ")}`,
|
|
263
263
|
);
|
|
264
264
|
}
|
|
265
265
|
}
|
|
@@ -967,9 +967,10 @@ export function loadMergedWaveConfig(
|
|
|
967
967
|
];
|
|
968
968
|
}
|
|
969
969
|
|
|
970
|
-
// Merge
|
|
971
|
-
if (config.permissions.
|
|
972
|
-
mergedConfig.permissions.
|
|
970
|
+
// Merge permissionMode (last one wins)
|
|
971
|
+
if (config.permissions.permissionMode !== undefined) {
|
|
972
|
+
mergedConfig.permissions.permissionMode =
|
|
973
|
+
config.permissions.permissionMode;
|
|
973
974
|
}
|
|
974
975
|
|
|
975
976
|
// Merge additionalDirectories
|
package/src/services/hook.ts
CHANGED
|
@@ -48,7 +48,11 @@ async function buildHookJsonInput(
|
|
|
48
48
|
};
|
|
49
49
|
|
|
50
50
|
// Add optional fields based on event type
|
|
51
|
-
if (
|
|
51
|
+
if (
|
|
52
|
+
context.event === "PreToolUse" ||
|
|
53
|
+
context.event === "PostToolUse" ||
|
|
54
|
+
context.event === "PermissionRequest"
|
|
55
|
+
) {
|
|
52
56
|
if (context.toolName) {
|
|
53
57
|
jsonInput.tool_name = context.toolName;
|
|
54
58
|
}
|
|
@@ -73,16 +77,6 @@ async function buildHookJsonInput(
|
|
|
73
77
|
jsonInput.subagent_type = context.subagentType;
|
|
74
78
|
}
|
|
75
79
|
|
|
76
|
-
// Add notification fields for Notification events
|
|
77
|
-
if (context.event === "Notification") {
|
|
78
|
-
if (context.message !== undefined) {
|
|
79
|
-
jsonInput.message = context.message;
|
|
80
|
-
}
|
|
81
|
-
if (context.notificationType !== undefined) {
|
|
82
|
-
jsonInput.notification_type = context.notificationType;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
80
|
// Add name field for WorktreeCreate events
|
|
87
81
|
if (context.event === "WorktreeCreate") {
|
|
88
82
|
if (context.worktreeName !== undefined) {
|
|
@@ -146,9 +146,9 @@ export class InitializationService {
|
|
|
146
146
|
configResult.configuration.permissions.deny,
|
|
147
147
|
);
|
|
148
148
|
}
|
|
149
|
-
if (configResult.configuration.permissions.
|
|
150
|
-
permissionManager.
|
|
151
|
-
configResult.configuration.permissions.
|
|
149
|
+
if (configResult.configuration.permissions.permissionMode) {
|
|
150
|
+
permissionManager.updateConfiguredPermissionMode(
|
|
151
|
+
configResult.configuration.permissions.permissionMode,
|
|
152
152
|
);
|
|
153
153
|
}
|
|
154
154
|
if (configResult.configuration.permissions.additionalDirectories) {
|
|
@@ -194,6 +194,10 @@ export class JsonlHandler {
|
|
|
194
194
|
for (let i = 0; i < messages.length; i++) {
|
|
195
195
|
const message = messages[i];
|
|
196
196
|
|
|
197
|
+
if (!message.id) {
|
|
198
|
+
throw new Error(`Message at index ${i} is missing required field: id`);
|
|
199
|
+
}
|
|
200
|
+
|
|
197
201
|
if (!message.role) {
|
|
198
202
|
throw new Error(
|
|
199
203
|
`Message at index ${i} is missing required field: role`,
|
|
@@ -6,11 +6,16 @@ import { FileSnapshot } from "../types/reversion.js";
|
|
|
6
6
|
|
|
7
7
|
export class ReversionService {
|
|
8
8
|
private historyBaseDir: string;
|
|
9
|
-
private
|
|
9
|
+
private rootSessionId: string;
|
|
10
10
|
|
|
11
|
-
constructor(
|
|
12
|
-
this.
|
|
13
|
-
this.historyBaseDir = join(
|
|
11
|
+
constructor(rootSessionId: string) {
|
|
12
|
+
this.rootSessionId = rootSessionId;
|
|
13
|
+
this.historyBaseDir = join(
|
|
14
|
+
homedir(),
|
|
15
|
+
".wave",
|
|
16
|
+
"file-history",
|
|
17
|
+
rootSessionId || "default",
|
|
18
|
+
);
|
|
14
19
|
}
|
|
15
20
|
|
|
16
21
|
private getFilePathHash(filePath: string): string {
|
package/src/services/session.ts
CHANGED
|
@@ -294,14 +294,21 @@ export async function loadSessionFromJsonl(
|
|
|
294
294
|
sessionType,
|
|
295
295
|
);
|
|
296
296
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
297
|
+
// Check if file exists
|
|
298
|
+
try {
|
|
299
|
+
await fs.access(filePath);
|
|
300
|
+
} catch (error) {
|
|
301
|
+
if ((error as NodeJS.ErrnoException).code === "ENOENT") {
|
|
302
|
+
return null;
|
|
303
|
+
}
|
|
304
|
+
throw error;
|
|
301
305
|
}
|
|
302
306
|
|
|
307
|
+
const messages = await jsonlHandler.read(filePath);
|
|
308
|
+
|
|
303
309
|
// Extract metadata from messages
|
|
304
|
-
const lastMessage =
|
|
310
|
+
const lastMessage =
|
|
311
|
+
messages.length > 0 ? messages[messages.length - 1] : null;
|
|
305
312
|
|
|
306
313
|
// Try to get rootSessionId and parentSessionId from index
|
|
307
314
|
let rootSessionId: string | undefined;
|
|
@@ -333,8 +340,10 @@ export async function loadSessionFromJsonl(
|
|
|
333
340
|
}),
|
|
334
341
|
metadata: {
|
|
335
342
|
workdir,
|
|
336
|
-
lastActiveAt: lastMessage
|
|
337
|
-
|
|
343
|
+
lastActiveAt: lastMessage
|
|
344
|
+
? lastMessage.timestamp
|
|
345
|
+
: new Date().toISOString(),
|
|
346
|
+
latestTotalTokens: lastMessage?.usage
|
|
338
347
|
? extractLatestTotalTokens([lastMessage])
|
|
339
348
|
: 0,
|
|
340
349
|
},
|
|
@@ -963,15 +972,13 @@ export async function handleSessionRestoration(
|
|
|
963
972
|
// Use only JSONL format - no legacy support
|
|
964
973
|
sessionToRestore = await loadSessionFromJsonl(restoreSessionId, workdir);
|
|
965
974
|
if (!sessionToRestore) {
|
|
966
|
-
|
|
967
|
-
process.exit(1);
|
|
975
|
+
throw new Error(`Session not found: ${restoreSessionId}`);
|
|
968
976
|
}
|
|
969
977
|
} else if (continueLastSession) {
|
|
970
978
|
// Use only JSONL format - no legacy support
|
|
971
979
|
sessionToRestore = await getLatestSessionFromJsonl(workdir);
|
|
972
980
|
if (!sessionToRestore) {
|
|
973
|
-
|
|
974
|
-
process.exit(1);
|
|
981
|
+
throw new Error(`No previous session found for workdir: ${workdir}`);
|
|
975
982
|
}
|
|
976
983
|
}
|
|
977
984
|
|
|
@@ -984,7 +991,7 @@ export async function handleSessionRestoration(
|
|
|
984
991
|
}
|
|
985
992
|
} catch (error) {
|
|
986
993
|
console.error("Failed to restore session:", error);
|
|
987
|
-
|
|
994
|
+
throw error;
|
|
988
995
|
}
|
|
989
996
|
}
|
|
990
997
|
|
package/src/tools/agentTool.ts
CHANGED
|
@@ -67,7 +67,7 @@ The Agent tool launches specialized agents (subprocesses) that autonomously hand
|
|
|
67
67
|
Available agent types and the tools they have access to:
|
|
68
68
|
${subagentList || "No agents configured"}
|
|
69
69
|
|
|
70
|
-
When using the Agent tool, you must specify a subagent_type parameter to select which agent type to use.
|
|
70
|
+
When using the Agent tool, you must specify a subagent_type parameter to select which agent type to use from the list above. Choose the agent whose description best matches the task you want to delegate.
|
|
71
71
|
|
|
72
72
|
- When doing file search, prefer to use the ${AGENT_TOOL_NAME} tool in order to reduce context usage.
|
|
73
73
|
- You should proactively use the ${AGENT_TOOL_NAME} tool with specialized agents when the task at hand matches the agent's description.
|
package/src/tools/bashTool.ts
CHANGED
|
@@ -377,11 +377,12 @@ Usage notes:
|
|
|
377
377
|
combinedOutput || `Command executed with exit code: ${exitCode}`;
|
|
378
378
|
const content = processOutput(finalOutput);
|
|
379
379
|
|
|
380
|
-
const
|
|
381
|
-
|
|
382
|
-
.
|
|
383
|
-
|
|
384
|
-
|
|
380
|
+
const lines = combinedOutput.trim().split("\n");
|
|
381
|
+
const shortResult =
|
|
382
|
+
lines.length <= 3
|
|
383
|
+
? lines.join("\n")
|
|
384
|
+
: lines.slice(0, 3).join("\n") +
|
|
385
|
+
`\n... +${lines.length - 3} lines`;
|
|
385
386
|
|
|
386
387
|
resolve({
|
|
387
388
|
success: exitCode === 0,
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { ToolPlugin, ToolResult, ToolContext } from "./types.js";
|
|
2
|
+
import { CRON_CREATE_TOOL_NAME } from "../constants/tools.js";
|
|
3
|
+
|
|
4
|
+
export const cronCreateTool: ToolPlugin = {
|
|
5
|
+
name: CRON_CREATE_TOOL_NAME,
|
|
6
|
+
config: {
|
|
7
|
+
type: "function",
|
|
8
|
+
function: {
|
|
9
|
+
name: CRON_CREATE_TOOL_NAME,
|
|
10
|
+
description:
|
|
11
|
+
"Schedule a prompt to be enqueued at a future time. Use for both recurring schedules and one-shot reminders.",
|
|
12
|
+
parameters: {
|
|
13
|
+
type: "object",
|
|
14
|
+
properties: {
|
|
15
|
+
cron: {
|
|
16
|
+
type: "string",
|
|
17
|
+
description:
|
|
18
|
+
'Standard 5-field cron expression in local time: "M H DoM Mon DoW"',
|
|
19
|
+
},
|
|
20
|
+
prompt: {
|
|
21
|
+
type: "string",
|
|
22
|
+
description: "The prompt to enqueue at each fire time",
|
|
23
|
+
},
|
|
24
|
+
recurring: {
|
|
25
|
+
type: "boolean",
|
|
26
|
+
description:
|
|
27
|
+
"Default: true. true = fire on every cron match until deleted or auto-expired after 7 days. false = fire once at the next match, then auto-delete",
|
|
28
|
+
default: true,
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
required: ["cron", "prompt"],
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
execute: async (
|
|
36
|
+
args: Record<string, unknown>,
|
|
37
|
+
context: ToolContext,
|
|
38
|
+
): Promise<ToolResult> => {
|
|
39
|
+
const {
|
|
40
|
+
cron,
|
|
41
|
+
prompt,
|
|
42
|
+
recurring = true,
|
|
43
|
+
} = args as { cron: string; prompt: string; recurring?: boolean };
|
|
44
|
+
|
|
45
|
+
if (!context.cronManager) {
|
|
46
|
+
return {
|
|
47
|
+
success: false,
|
|
48
|
+
content: "",
|
|
49
|
+
error: "CronManager not available",
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
try {
|
|
54
|
+
const job = context.cronManager.createJob({
|
|
55
|
+
cron,
|
|
56
|
+
prompt,
|
|
57
|
+
recurring,
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
return {
|
|
61
|
+
success: true,
|
|
62
|
+
content: JSON.stringify({ id: job.id }, null, 2),
|
|
63
|
+
shortResult: `Scheduled job ${job.id}`,
|
|
64
|
+
};
|
|
65
|
+
} catch (error) {
|
|
66
|
+
return {
|
|
67
|
+
success: false,
|
|
68
|
+
content: "",
|
|
69
|
+
error: error instanceof Error ? error.message : String(error),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { ToolPlugin, ToolResult, ToolContext } from "./types.js";
|
|
2
|
+
import { CRON_DELETE_TOOL_NAME } from "../constants/tools.js";
|
|
3
|
+
|
|
4
|
+
export const cronDeleteTool: ToolPlugin = {
|
|
5
|
+
name: CRON_DELETE_TOOL_NAME,
|
|
6
|
+
config: {
|
|
7
|
+
type: "function",
|
|
8
|
+
function: {
|
|
9
|
+
name: CRON_DELETE_TOOL_NAME,
|
|
10
|
+
description:
|
|
11
|
+
"Cancel a cron job previously scheduled with CronCreate. Removes it from the in-memory session store.",
|
|
12
|
+
parameters: {
|
|
13
|
+
type: "object",
|
|
14
|
+
properties: {
|
|
15
|
+
id: {
|
|
16
|
+
type: "string",
|
|
17
|
+
description: "Job ID returned by CronCreate",
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
required: ["id"],
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
execute: async (
|
|
25
|
+
args: Record<string, unknown>,
|
|
26
|
+
context: ToolContext,
|
|
27
|
+
): Promise<ToolResult> => {
|
|
28
|
+
const { id } = args as { id: string };
|
|
29
|
+
|
|
30
|
+
if (!context.cronManager) {
|
|
31
|
+
return {
|
|
32
|
+
success: false,
|
|
33
|
+
content: "",
|
|
34
|
+
error: "CronManager not available",
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const success = context.cronManager.deleteJob(id);
|
|
39
|
+
|
|
40
|
+
return {
|
|
41
|
+
success,
|
|
42
|
+
content: JSON.stringify({ success }, null, 2),
|
|
43
|
+
shortResult: success ? `Deleted job ${id}` : `Job ${id} not found`,
|
|
44
|
+
error: success ? undefined : `Job ${id} not found`,
|
|
45
|
+
};
|
|
46
|
+
},
|
|
47
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ToolPlugin, ToolResult, ToolContext } from "./types.js";
|
|
2
|
+
import { CRON_LIST_TOOL_NAME } from "../constants/tools.js";
|
|
3
|
+
|
|
4
|
+
export const cronListTool: ToolPlugin = {
|
|
5
|
+
name: CRON_LIST_TOOL_NAME,
|
|
6
|
+
config: {
|
|
7
|
+
type: "function",
|
|
8
|
+
function: {
|
|
9
|
+
name: CRON_LIST_TOOL_NAME,
|
|
10
|
+
description:
|
|
11
|
+
"List all cron jobs scheduled via CronCreate in this session.",
|
|
12
|
+
parameters: {
|
|
13
|
+
type: "object",
|
|
14
|
+
properties: {},
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
execute: async (
|
|
19
|
+
_args: Record<string, unknown>,
|
|
20
|
+
context: ToolContext,
|
|
21
|
+
): Promise<ToolResult> => {
|
|
22
|
+
if (!context.cronManager) {
|
|
23
|
+
return {
|
|
24
|
+
success: false,
|
|
25
|
+
content: "",
|
|
26
|
+
error: "CronManager not available",
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const jobs = context.cronManager.listJobs();
|
|
31
|
+
|
|
32
|
+
return {
|
|
33
|
+
success: true,
|
|
34
|
+
content: JSON.stringify({ jobs }, null, 2),
|
|
35
|
+
shortResult: `Found ${jobs.length} jobs`,
|
|
36
|
+
};
|
|
37
|
+
},
|
|
38
|
+
};
|
package/src/tools/skillTool.ts
CHANGED
|
@@ -11,14 +11,16 @@ import {
|
|
|
11
11
|
/**
|
|
12
12
|
* Skill tool plugin for invoking Wave skills
|
|
13
13
|
*/
|
|
14
|
+
const SKILL_TOOL_DESCRIPTION =
|
|
15
|
+
"Execute a skill within the main conversation. When users ask you to perform tasks, check if any of the available skills match. Skills provide specialized capabilities and domain knowledge.";
|
|
16
|
+
|
|
14
17
|
export const skillTool: ToolPlugin = {
|
|
15
18
|
name: SKILL_TOOL_NAME,
|
|
16
19
|
config: {
|
|
17
20
|
type: "function" as const,
|
|
18
21
|
function: {
|
|
19
22
|
name: SKILL_TOOL_NAME,
|
|
20
|
-
description:
|
|
21
|
-
"Invoke a Wave skill by name. Skills are user-defined automation templates that can be personal or project-specific.",
|
|
23
|
+
description: SKILL_TOOL_DESCRIPTION,
|
|
22
24
|
parameters: {
|
|
23
25
|
type: "object",
|
|
24
26
|
properties: {
|
|
@@ -41,7 +43,7 @@ export const skillTool: ToolPlugin = {
|
|
|
41
43
|
(skill) => !skill.disableModelInvocation,
|
|
42
44
|
);
|
|
43
45
|
if (!availableSkills || availableSkills.length === 0) {
|
|
44
|
-
return
|
|
46
|
+
return `${SKILL_TOOL_DESCRIPTION} No skills are currently available.`;
|
|
45
47
|
}
|
|
46
48
|
|
|
47
49
|
const skillList = availableSkills
|
|
@@ -50,7 +52,7 @@ export const skillTool: ToolPlugin = {
|
|
|
50
52
|
)
|
|
51
53
|
.join("\n");
|
|
52
54
|
|
|
53
|
-
return
|
|
55
|
+
return `${SKILL_TOOL_DESCRIPTION} Do not invoke the same skill repeatedly if it has already been called with the same arguments.\n\nAvailable skills:\n${skillList}`;
|
|
54
56
|
},
|
|
55
57
|
|
|
56
58
|
execute: async (
|
|
@@ -31,7 +31,7 @@ export const taskOutputTool: ToolPlugin = {
|
|
|
31
31
|
description: "Max wait time in ms",
|
|
32
32
|
},
|
|
33
33
|
},
|
|
34
|
-
required: ["task_id"],
|
|
34
|
+
required: ["task_id", "block", "timeout"],
|
|
35
35
|
},
|
|
36
36
|
},
|
|
37
37
|
},
|
|
@@ -87,8 +87,8 @@ export const taskOutputTool: ToolPlugin = {
|
|
|
87
87
|
|
|
88
88
|
if (finalContent.length > MAX_OUTPUT_LENGTH) {
|
|
89
89
|
processedContent =
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
"\n\n... (output truncated)\n" +
|
|
91
|
+
finalContent.substring(finalContent.length - MAX_OUTPUT_LENGTH);
|
|
92
92
|
isTruncated = true;
|
|
93
93
|
}
|
|
94
94
|
|
|
@@ -155,11 +155,17 @@ export const taskOutputTool: ToolPlugin = {
|
|
|
155
155
|
if (context.abortSignal) {
|
|
156
156
|
context.abortSignal.removeEventListener("abort", onAbort);
|
|
157
157
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}
|
|
158
|
+
const result = getResult();
|
|
159
|
+
if (result) {
|
|
160
|
+
result.shortResult = `${taskId}: timeout`;
|
|
161
|
+
resolve(result);
|
|
162
|
+
} else {
|
|
163
|
+
resolve({
|
|
164
|
+
success: true,
|
|
165
|
+
content: "Retrieval timed out",
|
|
166
|
+
shortResult: `${taskId}: timeout`,
|
|
167
|
+
});
|
|
168
|
+
}
|
|
163
169
|
return;
|
|
164
170
|
}
|
|
165
171
|
|
package/src/tools/types.ts
CHANGED
|
@@ -79,6 +79,8 @@ export interface ToolContext {
|
|
|
79
79
|
subagentManager?: import("../managers/subagentManager.js").SubagentManager;
|
|
80
80
|
/** Skill manager instance for skill invocation */
|
|
81
81
|
skillManager?: import("../managers/skillManager.js").SkillManager;
|
|
82
|
+
/** Cron manager instance for scheduling tasks */
|
|
83
|
+
cronManager?: import("../managers/cronManager.js").CronManager;
|
|
82
84
|
/** Current session ID */
|
|
83
85
|
sessionId?: string;
|
|
84
86
|
/** The ID of the current tool call */
|
package/src/types/agent.ts
CHANGED
|
@@ -67,6 +67,16 @@ export interface AgentOptions {
|
|
|
67
67
|
isNewWorktree?: boolean;
|
|
68
68
|
/**Whether to watch for skill changes - defaults to true */
|
|
69
69
|
watchSkills?: boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Optional list of tool names to always allow.
|
|
72
|
+
* These rules follow the standard permission rule syntax: `ToolName` or `ToolName(pattern)`.
|
|
73
|
+
*/
|
|
74
|
+
allowedTools?: string[];
|
|
75
|
+
/**
|
|
76
|
+
* Optional list of tool names to always disallow.
|
|
77
|
+
* These rules follow the standard permission rule syntax: `ToolName` or `ToolName(pattern)`.
|
|
78
|
+
*/
|
|
79
|
+
disallowedTools?: string[];
|
|
70
80
|
}
|
|
71
81
|
|
|
72
82
|
export interface AgentCallbacks
|
|
@@ -21,7 +21,7 @@ export interface WaveConfiguration {
|
|
|
21
21
|
permissions?: {
|
|
22
22
|
allow?: string[];
|
|
23
23
|
deny?: string[];
|
|
24
|
-
|
|
24
|
+
permissionMode?: PermissionMode; // Default permission mode for restricted tools
|
|
25
25
|
/**
|
|
26
26
|
* List of directories that are considered part of the Safe Zone.
|
|
27
27
|
* File operations within these directories can be auto-accepted.
|