wave-agent-sdk 0.2.1 → 0.5.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 +66 -20
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +156 -83
- package/dist/constants/prompts.d.ts +7 -2
- package/dist/constants/prompts.d.ts.map +1 -1
- package/dist/constants/prompts.js +41 -5
- package/dist/constants/tools.d.ts +2 -2
- package/dist/constants/tools.js +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/managers/MemoryRuleManager.d.ts.map +1 -1
- package/dist/managers/MemoryRuleManager.js +16 -2
- package/dist/managers/aiManager.d.ts +14 -4
- package/dist/managers/aiManager.d.ts.map +1 -1
- package/dist/managers/aiManager.js +61 -9
- package/dist/managers/backgroundBashManager.d.ts.map +1 -1
- package/dist/managers/backgroundBashManager.js +1 -0
- package/dist/managers/backgroundTaskManager.d.ts +35 -0
- package/dist/managers/backgroundTaskManager.d.ts.map +1 -0
- package/dist/managers/backgroundTaskManager.js +249 -0
- package/dist/managers/bashManager.d.ts.map +1 -1
- package/dist/managers/bashManager.js +0 -3
- package/dist/managers/foregroundTaskManager.d.ts +9 -0
- package/dist/managers/foregroundTaskManager.d.ts.map +1 -0
- package/dist/managers/foregroundTaskManager.js +20 -0
- package/dist/managers/liveConfigManager.d.ts +1 -1
- package/dist/managers/liveConfigManager.d.ts.map +1 -1
- package/dist/managers/lspManager.d.ts.map +1 -1
- package/dist/managers/lspManager.js +3 -1
- package/dist/managers/messageManager.d.ts +34 -4
- package/dist/managers/messageManager.d.ts.map +1 -1
- package/dist/managers/messageManager.js +104 -13
- package/dist/managers/permissionManager.d.ts.map +1 -1
- package/dist/managers/permissionManager.js +11 -13
- package/dist/managers/pluginManager.d.ts.map +1 -1
- package/dist/managers/pluginManager.js +3 -2
- package/dist/managers/pluginScopeManager.d.ts +13 -2
- package/dist/managers/pluginScopeManager.d.ts.map +1 -1
- package/dist/managers/pluginScopeManager.js +38 -0
- package/dist/managers/reversionManager.d.ts +39 -0
- package/dist/managers/reversionManager.d.ts.map +1 -0
- package/dist/managers/reversionManager.js +118 -0
- package/dist/managers/slashCommandManager.d.ts +4 -1
- package/dist/managers/slashCommandManager.d.ts.map +1 -1
- package/dist/managers/slashCommandManager.js +16 -6
- package/dist/managers/subagentManager.d.ts +13 -2
- package/dist/managers/subagentManager.d.ts.map +1 -1
- package/dist/managers/subagentManager.js +144 -35
- package/dist/managers/toolManager.d.ts +11 -1
- package/dist/managers/toolManager.d.ts.map +1 -1
- package/dist/managers/toolManager.js +11 -3
- package/dist/services/GitService.d.ts.map +1 -1
- package/dist/services/GitService.js +6 -2
- package/dist/services/MarketplaceService.d.ts +14 -1
- package/dist/services/MarketplaceService.d.ts.map +1 -1
- package/dist/services/MarketplaceService.js +72 -4
- package/dist/services/MemoryRuleService.d.ts +1 -1
- package/dist/services/MemoryRuleService.d.ts.map +1 -1
- package/dist/services/MemoryRuleService.js +13 -2
- package/dist/services/aiService.js +1 -1
- package/dist/services/configurationService.d.ts +18 -2
- package/dist/services/configurationService.d.ts.map +1 -1
- package/dist/services/configurationService.js +62 -0
- package/dist/services/fileWatcher.d.ts +0 -5
- package/dist/services/fileWatcher.d.ts.map +1 -1
- package/dist/services/fileWatcher.js +0 -11
- package/dist/services/memory.js +1 -1
- package/dist/services/pluginLoader.d.ts.map +1 -1
- package/dist/services/pluginLoader.js +6 -1
- package/dist/services/reversionService.d.ts +24 -0
- package/dist/services/reversionService.d.ts.map +1 -0
- package/dist/services/reversionService.js +76 -0
- package/dist/services/session.d.ts +7 -0
- package/dist/services/session.d.ts.map +1 -1
- package/dist/services/session.js +126 -3
- package/dist/tools/bashTool.d.ts +0 -8
- package/dist/tools/bashTool.d.ts.map +1 -1
- package/dist/tools/bashTool.js +52 -174
- package/dist/tools/deleteFileTool.d.ts.map +1 -1
- package/dist/tools/deleteFileTool.js +9 -0
- package/dist/tools/editTool.d.ts.map +1 -1
- package/dist/tools/editTool.js +15 -4
- package/dist/tools/multiEditTool.d.ts.map +1 -1
- package/dist/tools/multiEditTool.js +16 -5
- package/dist/tools/taskOutputTool.d.ts +3 -0
- package/dist/tools/taskOutputTool.d.ts.map +1 -0
- package/dist/tools/taskOutputTool.js +149 -0
- package/dist/tools/taskStopTool.d.ts +3 -0
- package/dist/tools/taskStopTool.d.ts.map +1 -0
- package/dist/tools/taskStopTool.js +65 -0
- package/dist/tools/taskTool.d.ts.map +1 -1
- package/dist/tools/taskTool.js +105 -63
- package/dist/tools/types.d.ts +7 -0
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/writeTool.d.ts.map +1 -1
- package/dist/tools/writeTool.js +9 -0
- package/dist/types/commands.d.ts +1 -0
- package/dist/types/commands.d.ts.map +1 -1
- package/dist/types/configuration.d.ts +3 -0
- package/dist/types/configuration.d.ts.map +1 -1
- package/dist/types/environment.d.ts +2 -1
- package/dist/types/environment.d.ts.map +1 -1
- package/dist/types/environment.js +0 -6
- package/dist/types/history.d.ts +5 -0
- package/dist/types/history.d.ts.map +1 -0
- package/dist/types/history.js +1 -0
- 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/marketplace.d.ts +4 -0
- package/dist/types/marketplace.d.ts.map +1 -1
- package/dist/types/messaging.d.ts +7 -1
- package/dist/types/messaging.d.ts.map +1 -1
- package/dist/types/processes.d.ts +24 -4
- package/dist/types/processes.d.ts.map +1 -1
- package/dist/types/reversion.d.ts +29 -0
- package/dist/types/reversion.d.ts.map +1 -0
- package/dist/types/reversion.js +1 -0
- package/dist/utils/builtinSubagents.d.ts.map +1 -1
- package/dist/utils/builtinSubagents.js +16 -0
- package/dist/utils/constants.d.ts +2 -2
- package/dist/utils/constants.d.ts.map +1 -1
- package/dist/utils/constants.js +2 -2
- package/dist/utils/editUtils.d.ts +4 -9
- package/dist/utils/editUtils.d.ts.map +1 -1
- package/dist/utils/editUtils.js +54 -55
- package/dist/utils/messageOperations.d.ts +3 -1
- package/dist/utils/messageOperations.d.ts.map +1 -1
- package/dist/utils/messageOperations.js +8 -1
- package/dist/utils/openaiClient.d.ts.map +1 -1
- package/dist/utils/openaiClient.js +56 -26
- package/dist/utils/promptHistory.d.ts +20 -0
- package/dist/utils/promptHistory.d.ts.map +1 -0
- package/dist/utils/promptHistory.js +117 -0
- package/package.json +5 -3
- package/src/agent.ts +193 -109
- package/src/constants/prompts.ts +45 -5
- package/src/constants/tools.ts +2 -2
- package/src/index.ts +1 -1
- package/src/managers/MemoryRuleManager.ts +18 -2
- package/src/managers/aiManager.ts +87 -18
- package/src/managers/backgroundBashManager.ts +1 -0
- package/src/managers/backgroundTaskManager.ts +306 -0
- package/src/managers/bashManager.ts +0 -4
- package/src/managers/foregroundTaskManager.ts +26 -0
- package/src/managers/liveConfigManager.ts +2 -1
- package/src/managers/lspManager.ts +3 -1
- package/src/managers/messageManager.ts +136 -18
- package/src/managers/permissionManager.ts +11 -13
- package/src/managers/pluginManager.ts +4 -3
- package/src/managers/pluginScopeManager.ts +57 -8
- package/src/managers/reversionManager.ts +152 -0
- package/src/managers/slashCommandManager.ts +30 -7
- package/src/managers/subagentManager.ts +176 -31
- package/src/managers/toolManager.ts +23 -4
- package/src/services/GitService.ts +6 -2
- package/src/services/MarketplaceService.ts +100 -4
- package/src/services/MemoryRuleService.ts +18 -6
- package/src/services/aiService.ts +1 -1
- package/src/services/configurationService.ts +79 -1
- package/src/services/fileWatcher.ts +0 -13
- package/src/services/memory.ts +1 -1
- package/src/services/pluginLoader.ts +7 -1
- package/src/services/reversionService.ts +94 -0
- package/src/services/session.ts +161 -3
- package/src/tools/bashTool.ts +73 -200
- package/src/tools/deleteFileTool.ts +15 -0
- package/src/tools/editTool.ts +20 -10
- package/src/tools/multiEditTool.ts +21 -11
- package/src/tools/taskOutputTool.ts +174 -0
- package/src/tools/taskStopTool.ts +72 -0
- package/src/tools/taskTool.ts +130 -74
- package/src/tools/types.ts +7 -0
- package/src/tools/writeTool.ts +14 -0
- package/src/types/commands.ts +3 -0
- package/src/types/configuration.ts +4 -0
- package/src/types/environment.ts +3 -1
- package/src/types/history.ts +4 -0
- package/src/types/index.ts +1 -0
- package/src/types/marketplace.ts +5 -0
- package/src/types/messaging.ts +9 -1
- package/src/types/processes.ts +33 -4
- package/src/types/reversion.ts +29 -0
- package/src/utils/builtinSubagents.ts +18 -0
- package/src/utils/constants.ts +2 -2
- package/src/utils/editUtils.ts +66 -58
- package/src/utils/messageOperations.ts +10 -0
- package/src/utils/openaiClient.ts +69 -35
- package/src/utils/promptHistory.ts +133 -0
- package/dist/utils/bashHistory.d.ts +0 -50
- package/dist/utils/bashHistory.d.ts.map +0 -1
- package/dist/utils/bashHistory.js +0 -256
- package/src/utils/bashHistory.ts +0 -320
|
@@ -27,13 +27,32 @@ export const SUBAGENT_POLICY = `
|
|
|
27
27
|
- When doing file search, prefer to use the ${TASK_TOOL_NAME} tool in order to reduce context usage.
|
|
28
28
|
- You should proactively use the ${TASK_TOOL_NAME} tool with specialized agents when the task at hand matches the agent's description.
|
|
29
29
|
- VERY IMPORTANT: When exploring the codebase to gather context or to answer a question that is not a needle query for a specific file/class/function, it is CRITICAL that you use the ${TASK_TOOL_NAME} tool with subagent_type=Explore instead of running search commands directly.`;
|
|
30
|
-
export const
|
|
31
|
-
|
|
30
|
+
export const FILE_TOOL_POLICY_PREFIX = `\n- Use specialized tools instead of bash commands when possible, as this provides a better user experience. For file operations, use dedicated tools:`;
|
|
31
|
+
export const READ_FILE_POLICY = ` ${READ_TOOL_NAME} for reading files instead of cat/head/tail`;
|
|
32
|
+
export const EDIT_FILE_POLICY = ` ${EDIT_TOOL_NAME}/${MULTI_EDIT_TOOL_NAME} for editing instead of sed/awk`;
|
|
33
|
+
export const WRITE_FILE_POLICY = ` ${WRITE_TOOL_NAME} for creating files instead of cat with heredoc or echo redirection`;
|
|
34
|
+
export const SEARCH_FILE_POLICY = ` ${LS_TOOL_NAME}/${GLOB_TOOL_NAME}/${GREP_TOOL_NAME} for searching and listing files instead of find/ls/grep`;
|
|
32
35
|
export const BASH_POLICY = `
|
|
33
36
|
- Reserve bash tools exclusively for actual system commands and terminal operations that require shell execution. NEVER use bash echo or other command-line tools to communicate thoughts, explanations, or instructions to the user. Output all communication directly in your response text instead.
|
|
34
37
|
- When making multiple bash tool calls, you MUST send a single message with multiple tools calls to run the calls in parallel. For example, if you need to run "git status" and "git diff", send a single message with two tool calls to run the calls in parallel.`;
|
|
35
38
|
export const DEFAULT_SYSTEM_PROMPT = BASE_SYSTEM_PROMPT;
|
|
36
|
-
export const
|
|
39
|
+
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.
|
|
40
|
+
|
|
41
|
+
Your strengths:
|
|
42
|
+
- Searching for code, configurations, and patterns across large codebases
|
|
43
|
+
- Analyzing multiple files to understand system architecture
|
|
44
|
+
- Investigating complex questions that require exploring many files
|
|
45
|
+
- Performing multi-step research tasks
|
|
46
|
+
|
|
47
|
+
Guidelines:
|
|
48
|
+
- For file searches: Use Grep or Glob when you need to search broadly. Use Read when you know the specific file path.
|
|
49
|
+
- For analysis: Start broad and narrow down. Use multiple search strategies if the first doesn't yield results.
|
|
50
|
+
- Be thorough: Check multiple locations, consider different naming conventions, look for related files.
|
|
51
|
+
- NEVER create files unless they're absolutely necessary for achieving your goal. ALWAYS prefer editing an existing file to creating a new one.
|
|
52
|
+
- NEVER proactively create documentation files (*.md) or README files. Only create documentation files if explicitly requested.
|
|
53
|
+
- 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.
|
|
54
|
+
- For clear communication, avoid using emojis.`;
|
|
55
|
+
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.
|
|
37
56
|
|
|
38
57
|
What to add:
|
|
39
58
|
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.
|
|
@@ -52,7 +71,7 @@ Usage notes:
|
|
|
52
71
|
\`\`\`
|
|
53
72
|
# AGENTS.md
|
|
54
73
|
|
|
55
|
-
This file provides guidance to
|
|
74
|
+
This file provides guidance to Agent when working with code in this repository.
|
|
56
75
|
\`\`\``;
|
|
57
76
|
export function buildSystemPrompt(basePrompt, tools) {
|
|
58
77
|
let prompt = basePrompt;
|
|
@@ -73,7 +92,24 @@ export function buildSystemPrompt(basePrompt, tools) {
|
|
|
73
92
|
toolNames.has(LS_TOOL_NAME) ||
|
|
74
93
|
toolNames.has(GLOB_TOOL_NAME) ||
|
|
75
94
|
toolNames.has(GREP_TOOL_NAME)) {
|
|
76
|
-
|
|
95
|
+
const parts = [];
|
|
96
|
+
if (toolNames.has(READ_TOOL_NAME)) {
|
|
97
|
+
parts.push(READ_FILE_POLICY);
|
|
98
|
+
}
|
|
99
|
+
if (toolNames.has(EDIT_TOOL_NAME) || toolNames.has(MULTI_EDIT_TOOL_NAME)) {
|
|
100
|
+
parts.push(EDIT_FILE_POLICY);
|
|
101
|
+
}
|
|
102
|
+
if (toolNames.has(WRITE_TOOL_NAME)) {
|
|
103
|
+
parts.push(WRITE_FILE_POLICY);
|
|
104
|
+
}
|
|
105
|
+
if (toolNames.has(LS_TOOL_NAME) ||
|
|
106
|
+
toolNames.has(GLOB_TOOL_NAME) ||
|
|
107
|
+
toolNames.has(GREP_TOOL_NAME)) {
|
|
108
|
+
parts.push(SEARCH_FILE_POLICY);
|
|
109
|
+
}
|
|
110
|
+
if (parts.length > 0) {
|
|
111
|
+
prompt += FILE_TOOL_POLICY_PREFIX + parts.join(",") + ".";
|
|
112
|
+
}
|
|
77
113
|
}
|
|
78
114
|
if (toolNames.has(BASH_TOOL_NAME)) {
|
|
79
115
|
prompt += BASH_POLICY;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export declare const ASK_USER_QUESTION_TOOL_NAME = "AskUserQuestion";
|
|
2
2
|
export declare const BASH_TOOL_NAME = "Bash";
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const
|
|
3
|
+
export declare const TASK_OUTPUT_TOOL_NAME = "TaskOutput";
|
|
4
|
+
export declare const TASK_STOP_TOOL_NAME = "TaskStop";
|
|
5
5
|
export declare const DELETE_FILE_TOOL_NAME = "Delete";
|
|
6
6
|
export declare const EDIT_TOOL_NAME = "Edit";
|
|
7
7
|
export declare const EXIT_PLAN_MODE_TOOL_NAME = "ExitPlanMode";
|
package/dist/constants/tools.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export const ASK_USER_QUESTION_TOOL_NAME = "AskUserQuestion";
|
|
2
2
|
export const BASH_TOOL_NAME = "Bash";
|
|
3
|
-
export const
|
|
4
|
-
export const
|
|
3
|
+
export const TASK_OUTPUT_TOOL_NAME = "TaskOutput";
|
|
4
|
+
export const TASK_STOP_TOOL_NAME = "TaskStop";
|
|
5
5
|
export const DELETE_FILE_TOOL_NAME = "Delete";
|
|
6
6
|
export const EDIT_TOOL_NAME = "Edit";
|
|
7
7
|
export const EXIT_PLAN_MODE_TOOL_NAME = "ExitPlanMode";
|
package/dist/index.d.ts
CHANGED
|
@@ -9,7 +9,6 @@ export * from "./constants/tools.js";
|
|
|
9
9
|
export * from "./managers/pluginManager.js";
|
|
10
10
|
export * from "./managers/pluginScopeManager.js";
|
|
11
11
|
export * from "./agent.js";
|
|
12
|
-
export * from "./utils/bashHistory.js";
|
|
13
12
|
export * from "./utils/bashParser.js";
|
|
14
13
|
export * from "./utils/convertMessagesForAPI.js";
|
|
15
14
|
export * from "./utils/fileFilter.js";
|
|
@@ -18,6 +17,7 @@ export * from "./utils/globalLogger.js";
|
|
|
18
17
|
export * from "./utils/mcpUtils.js";
|
|
19
18
|
export * from "./utils/messageOperations.js";
|
|
20
19
|
export * from "./utils/path.js";
|
|
20
|
+
export * from "./utils/promptHistory.js";
|
|
21
21
|
export * from "./utils/stringUtils.js";
|
|
22
22
|
export * from "./utils/customCommands.js";
|
|
23
23
|
export * from "./utils/hookMatcher.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oCAAoC,CAAC;AACnD,cAAc,kCAAkC,CAAC;AAGjD,cAAc,sBAAsB,CAAC;AAGrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kCAAkC,CAAC;AAGjD,cAAc,YAAY,CAAC;AAG3B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oCAAoC,CAAC;AACnD,cAAc,kCAAkC,CAAC;AAGjD,cAAc,sBAAsB,CAAC;AAGrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kCAAkC,CAAC;AAGjD,cAAc,YAAY,CAAC;AAG3B,cAAc,uBAAuB,CAAC;AACtC,cAAc,kCAAkC,CAAC;AACjD,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AAGvC,cAAc,kBAAkB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -14,7 +14,6 @@ export * from "./managers/pluginScopeManager.js";
|
|
|
14
14
|
// Export main agent
|
|
15
15
|
export * from "./agent.js";
|
|
16
16
|
// Export all utilities
|
|
17
|
-
export * from "./utils/bashHistory.js";
|
|
18
17
|
export * from "./utils/bashParser.js";
|
|
19
18
|
export * from "./utils/convertMessagesForAPI.js";
|
|
20
19
|
export * from "./utils/fileFilter.js";
|
|
@@ -23,6 +22,7 @@ export * from "./utils/globalLogger.js";
|
|
|
23
22
|
export * from "./utils/mcpUtils.js";
|
|
24
23
|
export * from "./utils/messageOperations.js";
|
|
25
24
|
export * from "./utils/path.js";
|
|
25
|
+
export * from "./utils/promptHistory.js";
|
|
26
26
|
export * from "./utils/stringUtils.js";
|
|
27
27
|
export * from "./utils/customCommands.js";
|
|
28
28
|
export * from "./utils/hookMatcher.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MemoryRuleManager.d.ts","sourceRoot":"","sources":["../../src/managers/MemoryRuleManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAOzD,MAAM,WAAW,uBAAuB;IACtC,0CAA0C;IAC1C,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IAClC,0DAA0D;IAC1D,aAAa,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAC5B;AAED,MAAM,WAAW,wBAAwB;IACvC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,KAAK,CAGX;IAEF,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,OAAO,CAAoB;gBAEvB,OAAO,EAAE,wBAAwB;IAK7C;;OAEG;IACG,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"MemoryRuleManager.d.ts","sourceRoot":"","sources":["../../src/managers/MemoryRuleManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAOzD,MAAM,WAAW,uBAAuB;IACtC,0CAA0C;IAC1C,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IAClC,0DAA0D;IAC1D,aAAa,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAC5B;AAED,MAAM,WAAW,wBAAwB;IACvC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,KAAK,CAGX;IAEF,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,OAAO,CAAoB;gBAEvB,OAAO,EAAE,wBAAwB;IAK7C;;OAEG;IACG,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;YA8BtB,aAAa;YAyDb,YAAY;IAsB1B;;OAEG;IACH,cAAc,CAAC,cAAc,EAAE,MAAM,EAAE,GAAG,UAAU,EAAE;IAUtD;;OAEG;IACG,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;CAG9B"}
|
|
@@ -18,13 +18,26 @@ export class MemoryRuleManager {
|
|
|
18
18
|
async discoverRules() {
|
|
19
19
|
const projectRulesDir = path.join(this.workdir, ".wave", "rules");
|
|
20
20
|
const userRulesDir = path.join(os.homedir(), ".wave", "rules");
|
|
21
|
+
logger.debug(`Scanning for modular memory rules...`);
|
|
22
|
+
logger.debug(` User rules directory: ${userRulesDir}`);
|
|
23
|
+
logger.debug(` Project rules directory: ${projectRulesDir}`);
|
|
21
24
|
const newRules = {};
|
|
22
25
|
// Discover user rules first, then project rules so project rules can override if needed
|
|
23
26
|
// (though IDs are based on file path, so they shouldn't collide unless same path)
|
|
24
27
|
await this.scanDirectory(userRulesDir, "user", newRules);
|
|
25
28
|
await this.scanDirectory(projectRulesDir, "project", newRules);
|
|
26
29
|
this.state.rules = newRules;
|
|
27
|
-
|
|
30
|
+
const ruleCount = Object.keys(newRules).length;
|
|
31
|
+
logger.debug(`Discovered ${ruleCount} modular memory rules`);
|
|
32
|
+
if (ruleCount > 0) {
|
|
33
|
+
logger.debug("Loaded memory rules:");
|
|
34
|
+
for (const [id, rule] of Object.entries(newRules)) {
|
|
35
|
+
const pathInfo = rule.metadata.paths
|
|
36
|
+
? `paths: ${JSON.stringify(rule.metadata.paths)}`
|
|
37
|
+
: "global (no path restriction)";
|
|
38
|
+
logger.debug(` - ${id} (${rule.source}): ${pathInfo}`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
28
41
|
}
|
|
29
42
|
async scanDirectory(dir, source, registry, visited = new Set()) {
|
|
30
43
|
const realDir = await fs.realpath(dir).catch(() => dir);
|
|
@@ -84,6 +97,7 @@ export class MemoryRuleManager {
|
|
|
84
97
|
const relativeId = path.relative(rulesRoot, filePath);
|
|
85
98
|
rule.id = relativeId;
|
|
86
99
|
registry[rule.id] = rule;
|
|
100
|
+
logger.debug(`Loaded memory rule: ${relativeId} from ${filePath}`);
|
|
87
101
|
}
|
|
88
102
|
catch (error) {
|
|
89
103
|
logger.error(`Failed to parse memory rule at ${filePath}:`, error);
|
|
@@ -95,7 +109,7 @@ export class MemoryRuleManager {
|
|
|
95
109
|
getActiveRules(filesInContext) {
|
|
96
110
|
const activeRules = [];
|
|
97
111
|
for (const rule of Object.values(this.state.rules)) {
|
|
98
|
-
if (this.service.isRuleActive(rule, filesInContext)) {
|
|
112
|
+
if (this.service.isRuleActive(rule, filesInContext, this.workdir)) {
|
|
99
113
|
activeRules.push(rule);
|
|
100
114
|
}
|
|
101
115
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Logger, GatewayConfig, ModelConfig, Usage } from "../types/index.js";
|
|
2
2
|
import type { ToolManager } from "./toolManager.js";
|
|
3
3
|
import type { MessageManager } from "./messageManager.js";
|
|
4
|
-
import type {
|
|
4
|
+
import type { BackgroundTaskManager } from "./backgroundTaskManager.js";
|
|
5
5
|
import type { HookManager } from "./hookManager.js";
|
|
6
6
|
import type { PermissionManager } from "./permissionManager.js";
|
|
7
7
|
export interface AIManagerCallbacks {
|
|
@@ -12,18 +12,20 @@ export interface AIManagerOptions {
|
|
|
12
12
|
messageManager: MessageManager;
|
|
13
13
|
toolManager: ToolManager;
|
|
14
14
|
logger?: Logger;
|
|
15
|
-
|
|
15
|
+
backgroundTaskManager?: BackgroundTaskManager;
|
|
16
16
|
hookManager?: HookManager;
|
|
17
17
|
permissionManager?: PermissionManager;
|
|
18
18
|
callbacks?: AIManagerCallbacks;
|
|
19
19
|
workdir: string;
|
|
20
20
|
systemPrompt?: string;
|
|
21
21
|
subagentType?: string;
|
|
22
|
+
reversionManager?: import("./reversionManager.js").ReversionManager;
|
|
22
23
|
/**Whether to use streaming mode for AI responses - defaults to true */
|
|
23
24
|
stream?: boolean;
|
|
24
25
|
getGatewayConfig: () => GatewayConfig;
|
|
25
26
|
getModelConfig: () => ModelConfig;
|
|
26
27
|
getMaxInputTokens: () => number;
|
|
28
|
+
getLanguage: () => string | undefined;
|
|
27
29
|
getEnvironmentVars?: () => Record<string, string>;
|
|
28
30
|
}
|
|
29
31
|
export declare class AIManager {
|
|
@@ -33,8 +35,9 @@ export declare class AIManager {
|
|
|
33
35
|
private logger?;
|
|
34
36
|
private toolManager;
|
|
35
37
|
private messageManager;
|
|
36
|
-
private
|
|
38
|
+
private backgroundTaskManager?;
|
|
37
39
|
private hookManager?;
|
|
40
|
+
private reversionManager?;
|
|
38
41
|
private permissionManager?;
|
|
39
42
|
private workdir;
|
|
40
43
|
private systemPrompt?;
|
|
@@ -43,11 +46,13 @@ export declare class AIManager {
|
|
|
43
46
|
private getGatewayConfigFn;
|
|
44
47
|
private getModelConfigFn;
|
|
45
48
|
private getMaxInputTokensFn;
|
|
49
|
+
private getLanguageFn;
|
|
46
50
|
private getEnvironmentVarsFn?;
|
|
47
51
|
constructor(options: AIManagerOptions);
|
|
48
52
|
getGatewayConfig(): GatewayConfig;
|
|
49
53
|
getModelConfig(): ModelConfig;
|
|
50
54
|
getMaxInputTokens(): number;
|
|
55
|
+
getLanguage(): string | undefined;
|
|
51
56
|
private isCompressing;
|
|
52
57
|
private callbacks;
|
|
53
58
|
/**
|
|
@@ -56,6 +61,11 @@ export declare class AIManager {
|
|
|
56
61
|
private getFilteredToolsConfig;
|
|
57
62
|
setIsLoading(isLoading: boolean): void;
|
|
58
63
|
abortAIMessage(): void;
|
|
64
|
+
/**
|
|
65
|
+
* Abort the AI recursion loop immediately.
|
|
66
|
+
* This is used when a tool is backgrounded via Ctrl-B, even if no foreground task was active.
|
|
67
|
+
*/
|
|
68
|
+
abortRecursion(): void;
|
|
59
69
|
private generateCompactParams;
|
|
60
70
|
private handleTokenUsageAndCompression;
|
|
61
71
|
getIsCompressing(): boolean;
|
|
@@ -63,7 +73,7 @@ export declare class AIManager {
|
|
|
63
73
|
sendAIMessage(options?: {
|
|
64
74
|
recursionDepth?: number;
|
|
65
75
|
model?: string;
|
|
66
|
-
/** Rules for automatic tool approval (e.g., "Bash(git status
|
|
76
|
+
/** Rules for automatic tool approval (e.g., "Bash(git status*)") */
|
|
67
77
|
allowedRules?: string[];
|
|
68
78
|
/** List of tools available to the AI (e.g., ["Bash", "Read"]) */
|
|
69
79
|
tools?: string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aiManager.d.ts","sourceRoot":"","sources":["../../src/managers/aiManager.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"aiManager.d.ts","sourceRoot":"","sources":["../../src/managers/aiManager.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACV,MAAM,EACN,aAAa,EACb,WAAW,EACX,KAAK,EACN,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAExE,OAAO,KAAK,EAA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;;;OAIG;YACW,gBAAgB;IAiE9B;;;OAGG;YACW,sBAAsB;IA6DpC;;OAEG;YACW,uBAAuB;CAwDtC"}
|
|
@@ -2,7 +2,6 @@ import { callAgent, compressMessages, } from "../services/aiService.js";
|
|
|
2
2
|
import { getMessagesToCompress } from "../utils/messageOperations.js";
|
|
3
3
|
import { convertMessagesForAPI } from "../utils/convertMessagesForAPI.js";
|
|
4
4
|
import { calculateComprehensiveTotalTokens } from "../utils/tokenCalculation.js";
|
|
5
|
-
import * as memory from "../services/memory.js";
|
|
6
5
|
import * as fs from "node:fs/promises";
|
|
7
6
|
import { DEFAULT_SYSTEM_PROMPT, buildSystemPrompt, } from "../constants/prompts.js";
|
|
8
7
|
export class AIManager {
|
|
@@ -13,8 +12,9 @@ export class AIManager {
|
|
|
13
12
|
this.isCompressing = false;
|
|
14
13
|
this.messageManager = options.messageManager;
|
|
15
14
|
this.toolManager = options.toolManager;
|
|
16
|
-
this.
|
|
15
|
+
this.backgroundTaskManager = options.backgroundTaskManager;
|
|
17
16
|
this.hookManager = options.hookManager;
|
|
17
|
+
this.reversionManager = options.reversionManager;
|
|
18
18
|
this.permissionManager = options.permissionManager;
|
|
19
19
|
this.logger = options.logger;
|
|
20
20
|
this.workdir = options.workdir;
|
|
@@ -26,6 +26,7 @@ export class AIManager {
|
|
|
26
26
|
this.getGatewayConfigFn = options.getGatewayConfig;
|
|
27
27
|
this.getModelConfigFn = options.getModelConfig;
|
|
28
28
|
this.getMaxInputTokensFn = options.getMaxInputTokens;
|
|
29
|
+
this.getLanguageFn = options.getLanguage;
|
|
29
30
|
this.getEnvironmentVarsFn = options.getEnvironmentVars;
|
|
30
31
|
}
|
|
31
32
|
// Getter methods for accessing dynamic configuration
|
|
@@ -38,6 +39,9 @@ export class AIManager {
|
|
|
38
39
|
getMaxInputTokens() {
|
|
39
40
|
return this.getMaxInputTokensFn();
|
|
40
41
|
}
|
|
42
|
+
getLanguage() {
|
|
43
|
+
return this.getLanguageFn();
|
|
44
|
+
}
|
|
41
45
|
/**
|
|
42
46
|
* Get filtered tool configuration based on tools list
|
|
43
47
|
*/
|
|
@@ -74,6 +78,14 @@ export class AIManager {
|
|
|
74
78
|
}
|
|
75
79
|
this.setIsLoading(false);
|
|
76
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* Abort the AI recursion loop immediately.
|
|
83
|
+
* This is used when a tool is backgrounded via Ctrl-B, even if no foreground task was active.
|
|
84
|
+
*/
|
|
85
|
+
abortRecursion() {
|
|
86
|
+
this.logger?.info("Aborting AI recursion loop");
|
|
87
|
+
this.abortAIMessage();
|
|
88
|
+
}
|
|
77
89
|
// Helper method to generate compactParams
|
|
78
90
|
generateCompactParams(toolName, toolArgs) {
|
|
79
91
|
try {
|
|
@@ -164,8 +176,6 @@ export class AIManager {
|
|
|
164
176
|
if (recursionDepth === 0 && this.isLoading) {
|
|
165
177
|
return;
|
|
166
178
|
}
|
|
167
|
-
// Save session in each recursion to ensure message persistence
|
|
168
|
-
await this.messageManager.saveSession();
|
|
169
179
|
// Only create new AbortControllers for the initial call (recursionDepth === 0)
|
|
170
180
|
// For recursive calls, reuse existing controllers to maintain abort signal
|
|
171
181
|
let abortController;
|
|
@@ -179,9 +189,12 @@ export class AIManager {
|
|
|
179
189
|
}
|
|
180
190
|
else {
|
|
181
191
|
// Reuse existing controllers for recursive calls
|
|
182
|
-
|
|
183
|
-
|
|
192
|
+
// Fallback to new controllers if they were cleared (should not happen in normal flow but good for tests)
|
|
193
|
+
abortController = this.abortController || new AbortController();
|
|
194
|
+
toolAbortController = this.toolAbortController || new AbortController();
|
|
184
195
|
}
|
|
196
|
+
// Save session in each recursion to ensure message persistence
|
|
197
|
+
await this.messageManager.saveSession();
|
|
185
198
|
// Only set loading state for the initial call
|
|
186
199
|
if (recursionDepth === 0) {
|
|
187
200
|
this.setIsLoading(true);
|
|
@@ -193,7 +206,7 @@ export class AIManager {
|
|
|
193
206
|
const recentMessages = convertMessagesForAPI(this.messageManager.getMessages());
|
|
194
207
|
try {
|
|
195
208
|
// Get combined memory content
|
|
196
|
-
const combinedMemory = await
|
|
209
|
+
const combinedMemory = await this.messageManager.getCombinedMemory();
|
|
197
210
|
// Track if assistant message has been created
|
|
198
211
|
let assistantMessageCreated = false;
|
|
199
212
|
this.logger?.debug("modelConfig in sendAIMessage", this.getModelConfig());
|
|
@@ -201,6 +214,12 @@ export class AIManager {
|
|
|
201
214
|
const currentMode = this.permissionManager?.getCurrentEffectiveMode(this.getModelConfig().permissionMode);
|
|
202
215
|
const toolsConfig = this.getFilteredToolsConfig(tools);
|
|
203
216
|
let effectiveSystemPrompt = buildSystemPrompt(this.systemPrompt || DEFAULT_SYSTEM_PROMPT, toolsConfig);
|
|
217
|
+
// Inject language prompt if configured
|
|
218
|
+
const language = this.getLanguage();
|
|
219
|
+
if (language) {
|
|
220
|
+
const languagePrompt = `\n\n# Language\nAlways respond in ${language}. Technical terms (e.g., code, tool names, file paths) should remain in their original language or English where appropriate.`;
|
|
221
|
+
effectiveSystemPrompt = (effectiveSystemPrompt || "") + languagePrompt;
|
|
222
|
+
}
|
|
204
223
|
if (currentMode === "plan") {
|
|
205
224
|
const planFilePath = this.permissionManager?.getPlanFilePath();
|
|
206
225
|
if (planFilePath) {
|
|
@@ -409,11 +428,22 @@ export class AIManager {
|
|
|
409
428
|
// Create tool execution context
|
|
410
429
|
const context = {
|
|
411
430
|
abortSignal: toolAbortController.signal,
|
|
412
|
-
|
|
431
|
+
backgroundTaskManager: this.backgroundTaskManager,
|
|
413
432
|
workdir: this.workdir,
|
|
433
|
+
messageId: this.messageManager.getMessages().slice(-1)[0]?.id,
|
|
414
434
|
};
|
|
415
435
|
// Execute tool
|
|
416
436
|
const toolResult = await this.toolManager.execute(functionToolCall.function?.name || "", toolArgs, context);
|
|
437
|
+
// Check if the tool was backgrounded via Ctrl-B
|
|
438
|
+
// If it was backgrounded, we should abort the AI recursion
|
|
439
|
+
if (toolResult.success &&
|
|
440
|
+
toolResult.content.includes("Command was manually backgrounded by user")) {
|
|
441
|
+
this.logger?.info(`Tool ${toolName} was backgrounded via Ctrl-B, aborting AI recursion`);
|
|
442
|
+
// Use abortAIMessage directly instead of abortRecursion to avoid double logging
|
|
443
|
+
// and ensure we don't trigger the "Request was aborted" error block
|
|
444
|
+
this.abortAIMessage();
|
|
445
|
+
return;
|
|
446
|
+
}
|
|
417
447
|
// Update message state - tool execution completed
|
|
418
448
|
this.messageManager.updateToolBlock({
|
|
419
449
|
id: toolId,
|
|
@@ -452,6 +482,13 @@ export class AIManager {
|
|
|
452
482
|
await this.handleTokenUsageAndCompression(result.usage, abortController, model);
|
|
453
483
|
// Check if there are tool operations, if so automatically initiate next AI service call
|
|
454
484
|
if (toolCalls.length > 0) {
|
|
485
|
+
// Record committed snapshots to message history
|
|
486
|
+
if (this.reversionManager) {
|
|
487
|
+
const snapshots = this.reversionManager.getAndClearCommittedSnapshots();
|
|
488
|
+
if (snapshots.length > 0) {
|
|
489
|
+
this.messageManager.addFileHistoryBlock(snapshots);
|
|
490
|
+
}
|
|
491
|
+
}
|
|
455
492
|
// Check interruption status
|
|
456
493
|
const isCurrentlyAborted = abortController.signal.aborted || toolAbortController.signal.aborted;
|
|
457
494
|
if (!isCurrentlyAborted) {
|
|
@@ -467,7 +504,15 @@ export class AIManager {
|
|
|
467
504
|
}
|
|
468
505
|
}
|
|
469
506
|
catch (error) {
|
|
470
|
-
|
|
507
|
+
// Check if the error is an abort error
|
|
508
|
+
// Use the local variables to avoid null reference if this.abortController was cleared
|
|
509
|
+
const isCurrentlyAborted = abortController.signal.aborted || toolAbortController.signal.aborted;
|
|
510
|
+
if (isCurrentlyAborted) {
|
|
511
|
+
this.logger?.info("AI message processing was aborted");
|
|
512
|
+
}
|
|
513
|
+
else {
|
|
514
|
+
this.messageManager.addErrorBlock(error instanceof Error ? error.message : "Unknown error occurred");
|
|
515
|
+
}
|
|
471
516
|
}
|
|
472
517
|
finally {
|
|
473
518
|
// Only execute cleanup and hooks for the initial call
|
|
@@ -484,6 +529,13 @@ export class AIManager {
|
|
|
484
529
|
// Execute Stop/SubagentStop hooks only if the operation was not aborted
|
|
485
530
|
const isCurrentlyAborted = abortController.signal.aborted || toolAbortController.signal.aborted;
|
|
486
531
|
if (!isCurrentlyAborted) {
|
|
532
|
+
// Record committed snapshots to message history for the final turn
|
|
533
|
+
if (this.reversionManager) {
|
|
534
|
+
const snapshots = this.reversionManager.getAndClearCommittedSnapshots();
|
|
535
|
+
if (snapshots.length > 0) {
|
|
536
|
+
this.messageManager.addFileHistoryBlock(snapshots);
|
|
537
|
+
}
|
|
538
|
+
}
|
|
487
539
|
const shouldContinue = await this.executeStopHooks();
|
|
488
540
|
// If Stop/SubagentStop hooks indicate we should continue (due to blocking errors),
|
|
489
541
|
// restart the AI conversation cycle
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"backgroundBashManager.d.ts","sourceRoot":"","sources":["../../src/managers/backgroundBashManager.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD,MAAM,WAAW,8BAA8B;IAC7C,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,eAAe,EAAE,KAAK,IAAI,CAAC;CACtD;AAED,MAAM,WAAW,4BAA4B;IAC3C,SAAS,CAAC,EAAE,8BAA8B,CAAC;IAC3C,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,qBAAqB;IAChC,OAAO,CAAC,MAAM,CAAsC;IACpD,OAAO,CAAC,MAAM,CAAK;IACnB,OAAO,CAAC,SAAS,CAAiC;IAClD,OAAO,CAAC,OAAO,CAAS;gBAEZ,OAAO,EAAE,4BAA4B;IAKjD,OAAO,CAAC,kBAAkB;IAInB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM;
|
|
1
|
+
{"version":3,"file":"backgroundBashManager.d.ts","sourceRoot":"","sources":["../../src/managers/backgroundBashManager.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD,MAAM,WAAW,8BAA8B;IAC7C,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,eAAe,EAAE,KAAK,IAAI,CAAC;CACtD;AAED,MAAM,WAAW,4BAA4B;IAC3C,SAAS,CAAC,EAAE,8BAA8B,CAAC;IAC3C,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,qBAAqB;IAChC,OAAO,CAAC,MAAM,CAAsC;IACpD,OAAO,CAAC,MAAM,CAAK;IACnB,OAAO,CAAC,SAAS,CAAiC;IAClD,OAAO,CAAC,OAAO,CAAS;gBAEZ,OAAO,EAAE,4BAA4B;IAKjD,OAAO,CAAC,kBAAkB;IAInB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM;IAuErD,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS;IAIjD,YAAY,IAAI,eAAe,EAAE;IAIjC,SAAS,CACd,EAAE,EAAE,MAAM,EACV,MAAM,CAAC,EAAE,MAAM,GACd;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;IAiCrD,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;IAmD9B,OAAO,IAAI,IAAI;CAUvB"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type ChildProcess } from "child_process";
|
|
2
|
+
import { BackgroundTask } from "../types/processes.js";
|
|
3
|
+
export interface BackgroundTaskManagerCallbacks {
|
|
4
|
+
onTasksChange?: (tasks: BackgroundTask[]) => void;
|
|
5
|
+
}
|
|
6
|
+
export interface BackgroundTaskManagerOptions {
|
|
7
|
+
callbacks?: BackgroundTaskManagerCallbacks;
|
|
8
|
+
workdir: string;
|
|
9
|
+
}
|
|
10
|
+
export declare class BackgroundTaskManager {
|
|
11
|
+
private tasks;
|
|
12
|
+
private nextId;
|
|
13
|
+
private callbacks;
|
|
14
|
+
private workdir;
|
|
15
|
+
constructor(options: BackgroundTaskManagerOptions);
|
|
16
|
+
private notifyTasksChange;
|
|
17
|
+
generateId(): string;
|
|
18
|
+
addTask(task: BackgroundTask): void;
|
|
19
|
+
getTask(id: string): BackgroundTask | undefined;
|
|
20
|
+
getAllTasks(): BackgroundTask[];
|
|
21
|
+
startShell(command: string, timeout?: number): {
|
|
22
|
+
id: string;
|
|
23
|
+
child: ChildProcess;
|
|
24
|
+
detach: () => void;
|
|
25
|
+
};
|
|
26
|
+
adoptProcess(child: ChildProcess, command: string, initialStdout?: string, initialStderr?: string): string;
|
|
27
|
+
getOutput(id: string, filter?: string): {
|
|
28
|
+
stdout: string;
|
|
29
|
+
stderr: string;
|
|
30
|
+
status: string;
|
|
31
|
+
} | null;
|
|
32
|
+
stopTask(id: string): boolean;
|
|
33
|
+
cleanup(): void;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=backgroundTaskManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"backgroundTaskManager.d.ts","sourceRoot":"","sources":["../../src/managers/backgroundTaskManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,cAAc,EAAmB,MAAM,uBAAuB,CAAC;AAIxE,MAAM,WAAW,8BAA8B;IAC7C,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,EAAE,KAAK,IAAI,CAAC;CACnD;AAED,MAAM,WAAW,4BAA4B;IAC3C,SAAS,CAAC,EAAE,8BAA8B,CAAC;IAC3C,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,qBAAqB;IAChC,OAAO,CAAC,KAAK,CAAqC;IAClD,OAAO,CAAC,MAAM,CAAK;IACnB,OAAO,CAAC,SAAS,CAAiC;IAClD,OAAO,CAAC,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