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.
Files changed (194) hide show
  1. package/dist/agent.d.ts +66 -20
  2. package/dist/agent.d.ts.map +1 -1
  3. package/dist/agent.js +156 -83
  4. package/dist/constants/prompts.d.ts +7 -2
  5. package/dist/constants/prompts.d.ts.map +1 -1
  6. package/dist/constants/prompts.js +41 -5
  7. package/dist/constants/tools.d.ts +2 -2
  8. package/dist/constants/tools.js +2 -2
  9. package/dist/index.d.ts +1 -1
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +1 -1
  12. package/dist/managers/MemoryRuleManager.d.ts.map +1 -1
  13. package/dist/managers/MemoryRuleManager.js +16 -2
  14. package/dist/managers/aiManager.d.ts +14 -4
  15. package/dist/managers/aiManager.d.ts.map +1 -1
  16. package/dist/managers/aiManager.js +61 -9
  17. package/dist/managers/backgroundBashManager.d.ts.map +1 -1
  18. package/dist/managers/backgroundBashManager.js +1 -0
  19. package/dist/managers/backgroundTaskManager.d.ts +35 -0
  20. package/dist/managers/backgroundTaskManager.d.ts.map +1 -0
  21. package/dist/managers/backgroundTaskManager.js +249 -0
  22. package/dist/managers/bashManager.d.ts.map +1 -1
  23. package/dist/managers/bashManager.js +0 -3
  24. package/dist/managers/foregroundTaskManager.d.ts +9 -0
  25. package/dist/managers/foregroundTaskManager.d.ts.map +1 -0
  26. package/dist/managers/foregroundTaskManager.js +20 -0
  27. package/dist/managers/liveConfigManager.d.ts +1 -1
  28. package/dist/managers/liveConfigManager.d.ts.map +1 -1
  29. package/dist/managers/lspManager.d.ts.map +1 -1
  30. package/dist/managers/lspManager.js +3 -1
  31. package/dist/managers/messageManager.d.ts +34 -4
  32. package/dist/managers/messageManager.d.ts.map +1 -1
  33. package/dist/managers/messageManager.js +104 -13
  34. package/dist/managers/permissionManager.d.ts.map +1 -1
  35. package/dist/managers/permissionManager.js +11 -13
  36. package/dist/managers/pluginManager.d.ts.map +1 -1
  37. package/dist/managers/pluginManager.js +3 -2
  38. package/dist/managers/pluginScopeManager.d.ts +13 -2
  39. package/dist/managers/pluginScopeManager.d.ts.map +1 -1
  40. package/dist/managers/pluginScopeManager.js +38 -0
  41. package/dist/managers/reversionManager.d.ts +39 -0
  42. package/dist/managers/reversionManager.d.ts.map +1 -0
  43. package/dist/managers/reversionManager.js +118 -0
  44. package/dist/managers/slashCommandManager.d.ts +4 -1
  45. package/dist/managers/slashCommandManager.d.ts.map +1 -1
  46. package/dist/managers/slashCommandManager.js +16 -6
  47. package/dist/managers/subagentManager.d.ts +13 -2
  48. package/dist/managers/subagentManager.d.ts.map +1 -1
  49. package/dist/managers/subagentManager.js +144 -35
  50. package/dist/managers/toolManager.d.ts +11 -1
  51. package/dist/managers/toolManager.d.ts.map +1 -1
  52. package/dist/managers/toolManager.js +11 -3
  53. package/dist/services/GitService.d.ts.map +1 -1
  54. package/dist/services/GitService.js +6 -2
  55. package/dist/services/MarketplaceService.d.ts +14 -1
  56. package/dist/services/MarketplaceService.d.ts.map +1 -1
  57. package/dist/services/MarketplaceService.js +72 -4
  58. package/dist/services/MemoryRuleService.d.ts +1 -1
  59. package/dist/services/MemoryRuleService.d.ts.map +1 -1
  60. package/dist/services/MemoryRuleService.js +13 -2
  61. package/dist/services/aiService.js +1 -1
  62. package/dist/services/configurationService.d.ts +18 -2
  63. package/dist/services/configurationService.d.ts.map +1 -1
  64. package/dist/services/configurationService.js +62 -0
  65. package/dist/services/fileWatcher.d.ts +0 -5
  66. package/dist/services/fileWatcher.d.ts.map +1 -1
  67. package/dist/services/fileWatcher.js +0 -11
  68. package/dist/services/memory.js +1 -1
  69. package/dist/services/pluginLoader.d.ts.map +1 -1
  70. package/dist/services/pluginLoader.js +6 -1
  71. package/dist/services/reversionService.d.ts +24 -0
  72. package/dist/services/reversionService.d.ts.map +1 -0
  73. package/dist/services/reversionService.js +76 -0
  74. package/dist/services/session.d.ts +7 -0
  75. package/dist/services/session.d.ts.map +1 -1
  76. package/dist/services/session.js +126 -3
  77. package/dist/tools/bashTool.d.ts +0 -8
  78. package/dist/tools/bashTool.d.ts.map +1 -1
  79. package/dist/tools/bashTool.js +52 -174
  80. package/dist/tools/deleteFileTool.d.ts.map +1 -1
  81. package/dist/tools/deleteFileTool.js +9 -0
  82. package/dist/tools/editTool.d.ts.map +1 -1
  83. package/dist/tools/editTool.js +15 -4
  84. package/dist/tools/multiEditTool.d.ts.map +1 -1
  85. package/dist/tools/multiEditTool.js +16 -5
  86. package/dist/tools/taskOutputTool.d.ts +3 -0
  87. package/dist/tools/taskOutputTool.d.ts.map +1 -0
  88. package/dist/tools/taskOutputTool.js +149 -0
  89. package/dist/tools/taskStopTool.d.ts +3 -0
  90. package/dist/tools/taskStopTool.d.ts.map +1 -0
  91. package/dist/tools/taskStopTool.js +65 -0
  92. package/dist/tools/taskTool.d.ts.map +1 -1
  93. package/dist/tools/taskTool.js +105 -63
  94. package/dist/tools/types.d.ts +7 -0
  95. package/dist/tools/types.d.ts.map +1 -1
  96. package/dist/tools/writeTool.d.ts.map +1 -1
  97. package/dist/tools/writeTool.js +9 -0
  98. package/dist/types/commands.d.ts +1 -0
  99. package/dist/types/commands.d.ts.map +1 -1
  100. package/dist/types/configuration.d.ts +3 -0
  101. package/dist/types/configuration.d.ts.map +1 -1
  102. package/dist/types/environment.d.ts +2 -1
  103. package/dist/types/environment.d.ts.map +1 -1
  104. package/dist/types/environment.js +0 -6
  105. package/dist/types/history.d.ts +5 -0
  106. package/dist/types/history.d.ts.map +1 -0
  107. package/dist/types/history.js +1 -0
  108. package/dist/types/index.d.ts +1 -0
  109. package/dist/types/index.d.ts.map +1 -1
  110. package/dist/types/index.js +1 -0
  111. package/dist/types/marketplace.d.ts +4 -0
  112. package/dist/types/marketplace.d.ts.map +1 -1
  113. package/dist/types/messaging.d.ts +7 -1
  114. package/dist/types/messaging.d.ts.map +1 -1
  115. package/dist/types/processes.d.ts +24 -4
  116. package/dist/types/processes.d.ts.map +1 -1
  117. package/dist/types/reversion.d.ts +29 -0
  118. package/dist/types/reversion.d.ts.map +1 -0
  119. package/dist/types/reversion.js +1 -0
  120. package/dist/utils/builtinSubagents.d.ts.map +1 -1
  121. package/dist/utils/builtinSubagents.js +16 -0
  122. package/dist/utils/constants.d.ts +2 -2
  123. package/dist/utils/constants.d.ts.map +1 -1
  124. package/dist/utils/constants.js +2 -2
  125. package/dist/utils/editUtils.d.ts +4 -9
  126. package/dist/utils/editUtils.d.ts.map +1 -1
  127. package/dist/utils/editUtils.js +54 -55
  128. package/dist/utils/messageOperations.d.ts +3 -1
  129. package/dist/utils/messageOperations.d.ts.map +1 -1
  130. package/dist/utils/messageOperations.js +8 -1
  131. package/dist/utils/openaiClient.d.ts.map +1 -1
  132. package/dist/utils/openaiClient.js +56 -26
  133. package/dist/utils/promptHistory.d.ts +20 -0
  134. package/dist/utils/promptHistory.d.ts.map +1 -0
  135. package/dist/utils/promptHistory.js +117 -0
  136. package/package.json +5 -3
  137. package/src/agent.ts +193 -109
  138. package/src/constants/prompts.ts +45 -5
  139. package/src/constants/tools.ts +2 -2
  140. package/src/index.ts +1 -1
  141. package/src/managers/MemoryRuleManager.ts +18 -2
  142. package/src/managers/aiManager.ts +87 -18
  143. package/src/managers/backgroundBashManager.ts +1 -0
  144. package/src/managers/backgroundTaskManager.ts +306 -0
  145. package/src/managers/bashManager.ts +0 -4
  146. package/src/managers/foregroundTaskManager.ts +26 -0
  147. package/src/managers/liveConfigManager.ts +2 -1
  148. package/src/managers/lspManager.ts +3 -1
  149. package/src/managers/messageManager.ts +136 -18
  150. package/src/managers/permissionManager.ts +11 -13
  151. package/src/managers/pluginManager.ts +4 -3
  152. package/src/managers/pluginScopeManager.ts +57 -8
  153. package/src/managers/reversionManager.ts +152 -0
  154. package/src/managers/slashCommandManager.ts +30 -7
  155. package/src/managers/subagentManager.ts +176 -31
  156. package/src/managers/toolManager.ts +23 -4
  157. package/src/services/GitService.ts +6 -2
  158. package/src/services/MarketplaceService.ts +100 -4
  159. package/src/services/MemoryRuleService.ts +18 -6
  160. package/src/services/aiService.ts +1 -1
  161. package/src/services/configurationService.ts +79 -1
  162. package/src/services/fileWatcher.ts +0 -13
  163. package/src/services/memory.ts +1 -1
  164. package/src/services/pluginLoader.ts +7 -1
  165. package/src/services/reversionService.ts +94 -0
  166. package/src/services/session.ts +161 -3
  167. package/src/tools/bashTool.ts +73 -200
  168. package/src/tools/deleteFileTool.ts +15 -0
  169. package/src/tools/editTool.ts +20 -10
  170. package/src/tools/multiEditTool.ts +21 -11
  171. package/src/tools/taskOutputTool.ts +174 -0
  172. package/src/tools/taskStopTool.ts +72 -0
  173. package/src/tools/taskTool.ts +130 -74
  174. package/src/tools/types.ts +7 -0
  175. package/src/tools/writeTool.ts +14 -0
  176. package/src/types/commands.ts +3 -0
  177. package/src/types/configuration.ts +4 -0
  178. package/src/types/environment.ts +3 -1
  179. package/src/types/history.ts +4 -0
  180. package/src/types/index.ts +1 -0
  181. package/src/types/marketplace.ts +5 -0
  182. package/src/types/messaging.ts +9 -1
  183. package/src/types/processes.ts +33 -4
  184. package/src/types/reversion.ts +29 -0
  185. package/src/utils/builtinSubagents.ts +18 -0
  186. package/src/utils/constants.ts +2 -2
  187. package/src/utils/editUtils.ts +66 -58
  188. package/src/utils/messageOperations.ts +10 -0
  189. package/src/utils/openaiClient.ts +69 -35
  190. package/src/utils/promptHistory.ts +133 -0
  191. package/dist/utils/bashHistory.d.ts +0 -50
  192. package/dist/utils/bashHistory.d.ts.map +0 -1
  193. package/dist/utils/bashHistory.js +0 -256
  194. package/src/utils/bashHistory.ts +0 -320
@@ -0,0 +1,72 @@
1
+ import { TASK_STOP_TOOL_NAME } from "../constants/tools.js";
2
+ import { ToolContext, ToolPlugin, ToolResult } from "./types.js";
3
+
4
+ export const taskStopTool: ToolPlugin = {
5
+ name: TASK_STOP_TOOL_NAME,
6
+ config: {
7
+ type: "function",
8
+ function: {
9
+ name: TASK_STOP_TOOL_NAME,
10
+ description: "Stops a running background task",
11
+ parameters: {
12
+ type: "object",
13
+ properties: {
14
+ task_id: {
15
+ type: "string",
16
+ description: "The ID of the background task to stop",
17
+ },
18
+ },
19
+ required: ["task_id"],
20
+ },
21
+ },
22
+ },
23
+ execute: async (
24
+ args: Record<string, unknown>,
25
+ context: ToolContext,
26
+ ): Promise<ToolResult> => {
27
+ const taskId = args.task_id as string;
28
+
29
+ if (!taskId || typeof taskId !== "string") {
30
+ return {
31
+ success: false,
32
+ content: "",
33
+ error: "task_id parameter is required and must be a string",
34
+ };
35
+ }
36
+
37
+ const backgroundTaskManager = context?.backgroundTaskManager;
38
+ if (!backgroundTaskManager) {
39
+ return {
40
+ success: false,
41
+ content: "",
42
+ error: "Background task manager not available",
43
+ };
44
+ }
45
+
46
+ const stopped = backgroundTaskManager.stopTask(taskId);
47
+ if (stopped) {
48
+ return {
49
+ success: true,
50
+ content: `Task ${taskId} has been stopped`,
51
+ shortResult: `Stopped ${taskId}`,
52
+ };
53
+ } else {
54
+ const task = backgroundTaskManager.getTask(taskId);
55
+ if (!task) {
56
+ return {
57
+ success: false,
58
+ content: "",
59
+ error: `Task with ID ${taskId} not found`,
60
+ };
61
+ }
62
+ return {
63
+ success: false,
64
+ content: "",
65
+ error: `Failed to stop task ${taskId} (status: ${task.status})`,
66
+ };
67
+ }
68
+ },
69
+ formatCompactParams: (params: Record<string, unknown>) => {
70
+ return params.task_id as string;
71
+ },
72
+ };
@@ -46,6 +46,11 @@ export function createTaskTool(subagentManager: SubagentManager): ToolPlugin {
46
46
  type: "string",
47
47
  description: `The type or name of subagent to use. Available options: ${availableSubagents.map((c) => c.name).join(", ") || "none"}`,
48
48
  },
49
+ run_in_background: {
50
+ type: "boolean",
51
+ description:
52
+ "Set to true to run this command in the background. Use TaskOutput to read the output later.",
53
+ },
49
54
  },
50
55
  required: ["description", "prompt", "subagent_type"],
51
56
  },
@@ -57,80 +62,131 @@ export function createTaskTool(subagentManager: SubagentManager): ToolPlugin {
57
62
  args: Record<string, unknown>,
58
63
  context: ToolContext,
59
64
  ): Promise<ToolResult> => {
60
- // Input validation
61
- const description = args.description as string;
62
- const prompt = args.prompt as string;
63
- const subagent_type = args.subagent_type as string;
64
-
65
- if (!description || typeof description !== "string") {
66
- return {
67
- success: false,
68
- content: "",
69
- error: "description parameter is required and must be a string",
70
- shortResult: "Task delegation failed",
71
- };
72
- }
73
-
74
- if (!prompt || typeof prompt !== "string") {
75
- return {
76
- success: false,
77
- content: "",
78
- error: "prompt parameter is required and must be a string",
79
- shortResult: "Task delegation failed",
80
- };
81
- }
82
-
83
- if (!subagent_type || typeof subagent_type !== "string") {
84
- return {
85
- success: false,
86
- content: "",
87
- error: "subagent_type parameter is required and must be a string",
88
- shortResult: "Task delegation failed",
89
- };
90
- }
91
-
92
- try {
93
- // Subagent selection logic with explicit name matching only
94
- const configuration = await subagentManager.findSubagent(subagent_type);
95
-
96
- if (!configuration) {
97
- // Error handling for nonexistent subagents with available subagents listing
98
- const allConfigs = subagentManager.getConfigurations();
99
- const availableNames = allConfigs.map((c) => c.name).join(", ");
100
-
101
- return {
102
- success: false,
103
- content: "",
104
- error: `No subagent found matching "${subagent_type}". Available subagents: ${availableNames || "none"}`,
105
- shortResult: "Subagent not found",
106
- };
107
- }
108
-
109
- // Create subagent instance and execute task
110
- const instance = await subagentManager.createInstance(configuration, {
111
- description,
112
- prompt,
113
- subagent_type,
114
- });
115
- const response = await subagentManager.executeTask(
116
- instance,
117
- prompt,
118
- context.abortSignal,
119
- );
120
-
121
- return {
122
- success: true,
123
- content: response,
124
- shortResult: `Task completed by ${configuration.name}`,
125
- };
126
- } catch (error) {
127
- return {
128
- success: false,
129
- content: "",
130
- error: `Task delegation failed: ${error instanceof Error ? error.message : String(error)}`,
131
- shortResult: "Delegation error",
132
- };
133
- }
65
+ return new Promise((resolve) => {
66
+ (async () => {
67
+ // Input validation
68
+ const description = args.description as string;
69
+ const prompt = args.prompt as string;
70
+ const subagent_type = args.subagent_type as string;
71
+ const run_in_background = args.run_in_background as boolean;
72
+
73
+ if (!description || typeof description !== "string") {
74
+ return resolve({
75
+ success: false,
76
+ content: "",
77
+ error: "description parameter is required and must be a string",
78
+ shortResult: "Task delegation failed",
79
+ });
80
+ }
81
+
82
+ if (!prompt || typeof prompt !== "string") {
83
+ return resolve({
84
+ success: false,
85
+ content: "",
86
+ error: "prompt parameter is required and must be a string",
87
+ shortResult: "Task delegation failed",
88
+ });
89
+ }
90
+
91
+ if (!subagent_type || typeof subagent_type !== "string") {
92
+ return resolve({
93
+ success: false,
94
+ content: "",
95
+ error: "subagent_type parameter is required and must be a string",
96
+ shortResult: "Task delegation failed",
97
+ });
98
+ }
99
+
100
+ try {
101
+ // Subagent selection logic with explicit name matching only
102
+ const configuration =
103
+ await subagentManager.findSubagent(subagent_type);
104
+
105
+ if (!configuration) {
106
+ // Error handling for nonexistent subagents with available subagents listing
107
+ const allConfigs = subagentManager.getConfigurations();
108
+ const availableNames = allConfigs.map((c) => c.name).join(", ");
109
+
110
+ return resolve({
111
+ success: false,
112
+ content: "",
113
+ error: `No subagent found matching "${subagent_type}". Available subagents: ${availableNames || "none"}`,
114
+ shortResult: "Subagent not found",
115
+ });
116
+ }
117
+
118
+ // Create subagent instance and execute task
119
+ const instance = await subagentManager.createInstance(
120
+ configuration,
121
+ {
122
+ description,
123
+ prompt,
124
+ subagent_type,
125
+ },
126
+ run_in_background,
127
+ );
128
+
129
+ let isBackgrounded = false;
130
+
131
+ // Register for backgrounding if not already in background
132
+ if (!run_in_background && context.foregroundTaskManager) {
133
+ context.foregroundTaskManager.registerForegroundTask({
134
+ id: instance.subagentId,
135
+ backgroundHandler: async () => {
136
+ isBackgrounded = true;
137
+ const taskId = await subagentManager.backgroundInstance(
138
+ instance.subagentId,
139
+ );
140
+ // Resolve the tool execution early so the main agent can continue
141
+ resolve({
142
+ success: true,
143
+ content: `Task moved to background with ID: ${taskId}. Use TaskOutput to monitor progress.`,
144
+ shortResult: "Task backgrounded",
145
+ });
146
+ },
147
+ });
148
+ }
149
+
150
+ try {
151
+ const result = await subagentManager.executeTask(
152
+ instance,
153
+ prompt,
154
+ context.abortSignal,
155
+ run_in_background,
156
+ );
157
+
158
+ if (isBackgrounded) return;
159
+
160
+ if (run_in_background) {
161
+ return resolve({
162
+ success: true,
163
+ content: `Task started in background with ID: ${result}`,
164
+ shortResult: `Task started in background: ${result}`,
165
+ });
166
+ }
167
+
168
+ return resolve({
169
+ success: true,
170
+ content: result,
171
+ shortResult: `Task completed by ${configuration.name}`,
172
+ });
173
+ } finally {
174
+ if (!run_in_background && context.foregroundTaskManager) {
175
+ context.foregroundTaskManager.unregisterForegroundTask(
176
+ instance.subagentId,
177
+ );
178
+ }
179
+ }
180
+ } catch (error) {
181
+ return resolve({
182
+ success: false,
183
+ content: "",
184
+ error: `Task delegation failed: ${error instanceof Error ? error.message : String(error)}`,
185
+ shortResult: "Delegation error",
186
+ });
187
+ }
188
+ })();
189
+ });
134
190
  },
135
191
 
136
192
  formatCompactParams: (params: Record<string, unknown>) => {
@@ -39,6 +39,7 @@ export interface ToolResult {
39
39
  export interface ToolContext {
40
40
  abortSignal?: AbortSignal;
41
41
  backgroundBashManager?: import("../managers/backgroundBashManager.js").BackgroundBashManager;
42
+ backgroundTaskManager?: import("../managers/backgroundTaskManager.js").BackgroundTaskManager;
42
43
  workdir: string;
43
44
  /** Permission mode for this tool execution */
44
45
  permissionMode?: PermissionMode;
@@ -50,4 +51,10 @@ export interface ToolContext {
50
51
  mcpManager?: import("../managers/mcpManager.js").McpManager;
51
52
  /** LSP manager instance for code intelligence */
52
53
  lspManager?: import("../types/lsp.js").ILspManager;
54
+ /** Reversion manager instance for file snapshots */
55
+ reversionManager?: import("../managers/reversionManager.js").ReversionManager;
56
+ /** Current message ID for associating snapshots */
57
+ messageId?: string;
58
+ /** Foreground task manager for backgrounding tasks */
59
+ foregroundTaskManager?: import("../types/processes.js").IForegroundTaskManager;
53
60
  }
@@ -126,9 +126,23 @@ export const writeTool: ToolPlugin = {
126
126
  }
127
127
  }
128
128
 
129
+ // Record snapshot for reversion
130
+ let snapshotId: string | undefined;
131
+ if (context.reversionManager && context.messageId) {
132
+ snapshotId = await context.reversionManager.recordSnapshot(
133
+ context.messageId,
134
+ resolvedPath,
135
+ isExistingFile ? "modify" : "create",
136
+ );
137
+ }
138
+
129
139
  // Write file
130
140
  try {
131
141
  await writeFile(resolvedPath, content, "utf-8");
142
+ // Commit snapshot on success
143
+ if (context.reversionManager && snapshotId) {
144
+ await context.reversionManager.commitSnapshot(snapshotId);
145
+ }
132
146
  } catch (writeError) {
133
147
  return {
134
148
  success: false,
@@ -29,4 +29,7 @@ export interface CustomSlashCommand {
29
29
  isNested: boolean; // Whether command is in a subdirectory
30
30
  depth: number; // 0 = root, 1 = nested
31
31
  segments: string[]; // Path components for ID generation (e.g., ["openspec", "apply"])
32
+
33
+ // Plugin support
34
+ pluginPath?: string; // Absolute path to the plugin root directory (only set for plugin commands)
32
35
  }
@@ -9,6 +9,8 @@
9
9
  import type { HookEvent, HookEventConfig } from "./hooks.js";
10
10
  import type { PermissionMode } from "./permissions.js";
11
11
 
12
+ export type Scope = "user" | "project" | "local";
13
+
12
14
  /**
13
15
  * Root configuration structure for all Wave Agent settings including hooks and environment variables
14
16
  */
@@ -28,6 +30,8 @@ export interface WaveConfiguration {
28
30
  };
29
31
  /** New field for scoped plugin management */
30
32
  enabledPlugins?: Record<string, boolean>;
33
+ /** Preferred language for agent communication */
34
+ language?: string;
31
35
  }
32
36
 
33
37
  /**
@@ -1,3 +1,5 @@
1
+ import type { Scope } from "./configuration.js";
2
+
1
3
  /**
2
4
  * Environment Variable System Types
3
5
  *
@@ -100,5 +102,5 @@ export interface EnvironmentConflict {
100
102
  /** Final resolved value (which source won) */
101
103
  resolvedValue: string;
102
104
  /** Which source provided the final value */
103
- source: "user" | "project";
105
+ source: Scope;
104
106
  }
@@ -0,0 +1,4 @@
1
+ export interface PromptEntry {
2
+ prompt: string;
3
+ timestamp: number;
4
+ }
@@ -32,3 +32,4 @@ export * from "./lsp.js";
32
32
  export * from "./plugins.js";
33
33
  export * from "./marketplace.js";
34
34
  export * from "./memoryRule.js";
35
+ export * from "./history.js";
@@ -1,3 +1,5 @@
1
+ import { Scope } from "./configuration.js";
2
+
1
3
  export interface MarketplaceOwner {
2
4
  name: string;
3
5
  email?: string;
@@ -34,6 +36,7 @@ export type MarketplaceSource =
34
36
  export interface KnownMarketplace {
35
37
  name: string;
36
38
  source: MarketplaceSource;
39
+ isBuiltin?: boolean;
37
40
  }
38
41
 
39
42
  export interface KnownMarketplacesRegistry {
@@ -45,6 +48,8 @@ export interface InstalledPlugin {
45
48
  marketplace: string;
46
49
  version: string;
47
50
  cachePath: string;
51
+ scope?: Scope;
52
+ projectPath?: string;
48
53
  }
49
54
 
50
55
  export interface InstalledPluginsRegistry {
@@ -12,6 +12,7 @@ export enum MessageSource {
12
12
  }
13
13
 
14
14
  export interface Message {
15
+ id?: string; // Unique identifier for the message
15
16
  role: "user" | "assistant";
16
17
  blocks: MessageBlock[];
17
18
  usage?: Usage; // Usage data for this message's AI operation (assistant messages only)
@@ -27,7 +28,8 @@ export type MessageBlock =
27
28
  | CompressBlock
28
29
  | MemoryBlock
29
30
  | SubagentBlock
30
- | ReasoningBlock;
31
+ | ReasoningBlock
32
+ | FileHistoryBlock;
31
33
 
32
34
  export interface TextBlock {
33
35
  type: "text";
@@ -101,9 +103,15 @@ export interface SubagentBlock {
101
103
  status: "active" | "completed" | "error" | "aborted";
102
104
  sessionId: string;
103
105
  configuration: SubagentConfiguration;
106
+ runInBackground?: boolean;
104
107
  }
105
108
 
106
109
  export interface ReasoningBlock {
107
110
  type: "reasoning";
108
111
  content: string;
109
112
  }
113
+
114
+ export interface FileHistoryBlock {
115
+ type: "file_history";
116
+ snapshots: import("./reversion.js").FileSnapshot[];
117
+ }
@@ -5,14 +5,43 @@
5
5
 
6
6
  import type { ChildProcess } from "child_process";
7
7
 
8
- export interface BackgroundShell {
8
+ export type BackgroundTaskStatus =
9
+ | "running"
10
+ | "completed"
11
+ | "failed"
12
+ | "killed";
13
+ export type BackgroundTaskType = "shell" | "subagent";
14
+
15
+ export interface BackgroundTask {
9
16
  id: string;
10
- process: ChildProcess;
11
- command: string;
17
+ type: BackgroundTaskType;
18
+ status: BackgroundTaskStatus;
12
19
  startTime: number;
13
- status: "running" | "completed" | "killed";
20
+ endTime?: number;
21
+ command?: string; // for shell
22
+ description?: string; // for subagent
14
23
  stdout: string;
15
24
  stderr: string;
16
25
  exitCode?: number;
17
26
  runtime?: number;
18
27
  }
28
+
29
+ export interface BackgroundShell extends BackgroundTask {
30
+ type: "shell";
31
+ process: ChildProcess;
32
+ }
33
+
34
+ export interface ForegroundTask {
35
+ id: string;
36
+ backgroundHandler: () => Promise<void>;
37
+ }
38
+
39
+ export interface IForegroundTaskManager {
40
+ registerForegroundTask(task: ForegroundTask): void;
41
+ unregisterForegroundTask(id: string): void;
42
+ }
43
+
44
+ export interface IForegroundTaskManager {
45
+ registerForegroundTask(task: ForegroundTask): void;
46
+ unregisterForegroundTask(id: string): void;
47
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Represents the state of a file before an agent operation.
3
+ */
4
+ export interface FileSnapshot {
5
+ /** The ID of the message/turn this snapshot is associated with. */
6
+ messageId: string;
7
+ /** Absolute path to the file. */
8
+ filePath: string;
9
+ /** Path to the stored snapshot file. */
10
+ snapshotPath?: string;
11
+ /** When the snapshot was taken. */
12
+ timestamp: number;
13
+ /** The operation that triggered this snapshot. */
14
+ operation: "create" | "modify" | "delete";
15
+ }
16
+
17
+ /**
18
+ * A point in the conversation history that can be reverted to.
19
+ */
20
+ export interface Checkpoint {
21
+ /** The index of the user message in the history. */
22
+ index: number;
23
+ /** The unique ID of the user message. */
24
+ messageId: string;
25
+ /** A short snippet of the message content for the UI. */
26
+ preview: string;
27
+ /** When the message was sent. */
28
+ timestamp: number;
29
+ }
@@ -1,3 +1,4 @@
1
+ import { GENERAL_PURPOSE_SYSTEM_PROMPT } from "../constants/prompts.js";
1
2
  import type { SubagentConfiguration } from "./subagentParser.js";
2
3
 
3
4
  /**
@@ -7,10 +8,27 @@ import type { SubagentConfiguration } from "./subagentParser.js";
7
8
  export function getBuiltinSubagents(): SubagentConfiguration[] {
8
9
  return [
9
10
  createExploreSubagent(),
11
+ createGeneralPurposeSubagent(),
10
12
  // Add more built-in subagents here as needed
11
13
  ];
12
14
  }
13
15
 
16
+ /**
17
+ * Create the General-Purpose built-in subagent configuration
18
+ * Specialized for multi-step research and implementation tasks
19
+ */
20
+ function createGeneralPurposeSubagent(): SubagentConfiguration {
21
+ return {
22
+ name: "general-purpose",
23
+ description:
24
+ "General-purpose agent for researching complex questions, searching for code, and executing multi-step tasks. When you are searching for a keyword or file and are not confident that you will find the right match in the first few tries use this agent to perform the search for you.",
25
+ systemPrompt: GENERAL_PURPOSE_SYSTEM_PROMPT,
26
+ filePath: "<builtin:general-purpose>",
27
+ scope: "builtin",
28
+ priority: 3,
29
+ };
30
+ }
31
+
14
32
  /**
15
33
  * Create the Explore built-in subagent configuration
16
34
  * Specialized for codebase exploration and file search tasks
@@ -12,9 +12,9 @@ import os from "os";
12
12
  export const DATA_DIRECTORY = path.join(os.homedir(), ".wave");
13
13
 
14
14
  /**
15
- * Bash command history file path
15
+ * Prompt history file path
16
16
  */
17
- export const BASH_HISTORY_FILE = path.join(DATA_DIRECTORY, "bash-history.json");
17
+ export const PROMPT_HISTORY_FILE = path.join(DATA_DIRECTORY, "history.jsonl");
18
18
 
19
19
  /**
20
20
  * Error log directory path