wave-agent-sdk 1.0.5 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (202) hide show
  1. package/dist/agent.d.ts +34 -1
  2. package/dist/agent.js +49 -4
  3. package/dist/index.d.ts +3 -1
  4. package/dist/index.js +1 -1
  5. package/dist/managers/aiManager.d.ts +36 -0
  6. package/dist/managers/aiManager.js +240 -11
  7. package/dist/managers/messageManager.d.ts +2 -4
  8. package/dist/managers/messageManager.js +14 -7
  9. package/dist/managers/slashCommandManager.js +28 -0
  10. package/dist/managers/subagentManager.d.ts +0 -2
  11. package/dist/services/aiService.d.ts +2 -3
  12. package/dist/services/aiService.js +4 -18
  13. package/dist/services/configurationService.d.ts +7 -0
  14. package/dist/services/configurationService.js +10 -0
  15. package/dist/telemetry/instrumentation.d.ts +1 -1
  16. package/dist/telemetry/instrumentation.js +57 -28
  17. package/dist/tools/bashTool.js +16 -6
  18. package/dist/tools/grepTool.js +11 -3
  19. package/dist/types/core.d.ts +1 -34
  20. package/dist/types/index.d.ts +4 -0
  21. package/dist/types/messaging.d.ts +2 -0
  22. package/dist/utils/cacheControlUtils.d.ts +5 -27
  23. package/dist/utils/cacheControlUtils.js +12 -73
  24. package/dist/utils/containerSetup.js +0 -3
  25. package/dist/utils/messageOperations.d.ts +2 -1
  26. package/dist/utils/messageOperations.js +2 -1
  27. package/dist/utils/notificationXml.js +5 -0
  28. package/dist/utils/ripgrep.d.ts +4 -4
  29. package/dist/utils/ripgrep.js +4 -27
  30. package/package.json +20 -8
  31. package/bin/rg +0 -79
  32. package/dist/managers/forkedAgentManager.d.ts +0 -50
  33. package/dist/managers/forkedAgentManager.js +0 -130
  34. package/scripts/install_ripgrep.js +0 -111
  35. package/scripts/postinstall.js +0 -38
  36. package/src/agent.ts +0 -1271
  37. package/src/constants/subagents.ts +0 -4
  38. package/src/constants/toolLimits.ts +0 -15
  39. package/src/constants/tools.ts +0 -24
  40. package/src/core/plugin.ts +0 -237
  41. package/src/core/session.ts +0 -9
  42. package/src/index.ts +0 -38
  43. package/src/managers/MemoryRuleManager.ts +0 -198
  44. package/src/managers/aiManager.ts +0 -2429
  45. package/src/managers/backgroundTaskManager.ts +0 -480
  46. package/src/managers/bangManager.ts +0 -119
  47. package/src/managers/cronManager.ts +0 -401
  48. package/src/managers/foregroundTaskManager.ts +0 -30
  49. package/src/managers/forkedAgentManager.ts +0 -216
  50. package/src/managers/hookManager.ts +0 -1089
  51. package/src/managers/liveConfigManager.ts +0 -445
  52. package/src/managers/lspManager.ts +0 -470
  53. package/src/managers/mcpManager.ts +0 -1010
  54. package/src/managers/messageManager.ts +0 -1184
  55. package/src/managers/messageQueue.ts +0 -157
  56. package/src/managers/permissionManager.ts +0 -1140
  57. package/src/managers/planManager.ts +0 -112
  58. package/src/managers/pluginManager.ts +0 -330
  59. package/src/managers/pluginScopeManager.ts +0 -124
  60. package/src/managers/reversionManager.ts +0 -178
  61. package/src/managers/skillManager.ts +0 -578
  62. package/src/managers/slashCommandManager.ts +0 -564
  63. package/src/managers/subagentManager.ts +0 -915
  64. package/src/managers/toolManager.ts +0 -489
  65. package/src/managers/workflowManager.ts +0 -493
  66. package/src/prompts/autoMemory.ts +0 -33
  67. package/src/prompts/autoMemoryExtraction.ts +0 -146
  68. package/src/prompts/index.ts +0 -506
  69. package/src/prompts/planModeReminders.ts +0 -126
  70. package/src/services/GitService.ts +0 -131
  71. package/src/services/MarketplaceService.ts +0 -1052
  72. package/src/services/MemoryRuleService.ts +0 -71
  73. package/src/services/aiService.ts +0 -919
  74. package/src/services/authService.ts +0 -565
  75. package/src/services/autoMemoryService.ts +0 -280
  76. package/src/services/configurationService.ts +0 -1520
  77. package/src/services/fileWatcher.ts +0 -319
  78. package/src/services/hook.ts +0 -348
  79. package/src/services/initializationService.ts +0 -357
  80. package/src/services/interactionService.ts +0 -229
  81. package/src/services/jsonlHandler.ts +0 -295
  82. package/src/services/memory.ts +0 -234
  83. package/src/services/pluginLoader.ts +0 -252
  84. package/src/services/remoteSettingsService.ts +0 -366
  85. package/src/services/reversionService.ts +0 -122
  86. package/src/services/session.ts +0 -917
  87. package/src/services/taskManager.ts +0 -321
  88. package/src/telemetry/events.ts +0 -65
  89. package/src/telemetry/instrumentation.ts +0 -499
  90. package/src/telemetry/sessionTracing.ts +0 -348
  91. package/src/tools/agentTool.ts +0 -322
  92. package/src/tools/askUserQuestion.ts +0 -160
  93. package/src/tools/bashTool.ts +0 -621
  94. package/src/tools/buildTool.ts +0 -61
  95. package/src/tools/cronCreateTool.ts +0 -161
  96. package/src/tools/cronDeleteTool.ts +0 -51
  97. package/src/tools/cronListTool.ts +0 -47
  98. package/src/tools/editTool.ts +0 -313
  99. package/src/tools/enterPlanMode.ts +0 -124
  100. package/src/tools/enterWorktreeTool.ts +0 -190
  101. package/src/tools/exitPlanMode.ts +0 -139
  102. package/src/tools/exitWorktreeTool.ts +0 -236
  103. package/src/tools/globTool.ts +0 -167
  104. package/src/tools/grepTool.ts +0 -399
  105. package/src/tools/lspTool.ts +0 -883
  106. package/src/tools/readTool.ts +0 -426
  107. package/src/tools/skillTool.ts +0 -248
  108. package/src/tools/taskManagementTools.ts +0 -574
  109. package/src/tools/taskStopTool.ts +0 -78
  110. package/src/tools/types.ts +0 -137
  111. package/src/tools/webFetchTool.ts +0 -373
  112. package/src/tools/workflowTool.ts +0 -205
  113. package/src/tools/writeTool.ts +0 -267
  114. package/src/types/agent.ts +0 -128
  115. package/src/types/auth.ts +0 -19
  116. package/src/types/commands.ts +0 -30
  117. package/src/types/config.ts +0 -43
  118. package/src/types/configuration.ts +0 -168
  119. package/src/types/core.ts +0 -105
  120. package/src/types/cron.ts +0 -13
  121. package/src/types/environment.ts +0 -106
  122. package/src/types/fileSearch.ts +0 -4
  123. package/src/types/history.ts +0 -7
  124. package/src/types/hooks.ts +0 -256
  125. package/src/types/index.ts +0 -41
  126. package/src/types/lsp.ts +0 -98
  127. package/src/types/marketplace.ts +0 -71
  128. package/src/types/mcp.ts +0 -43
  129. package/src/types/memoryRule.ts +0 -31
  130. package/src/types/messaging.ts +0 -114
  131. package/src/types/permissions.ts +0 -80
  132. package/src/types/plugins.ts +0 -39
  133. package/src/types/processes.ts +0 -99
  134. package/src/types/reversion.ts +0 -29
  135. package/src/types/session.ts +0 -12
  136. package/src/types/skills.ts +0 -108
  137. package/src/types/tasks.ts +0 -13
  138. package/src/types/telemetry.ts +0 -98
  139. package/src/types/tools.ts +0 -44
  140. package/src/types/workflow.ts +0 -6
  141. package/src/utils/abortUtils.ts +0 -118
  142. package/src/utils/atomicWrite.ts +0 -61
  143. package/src/utils/bashParser.ts +0 -899
  144. package/src/utils/cacheControlUtils.ts +0 -426
  145. package/src/utils/commandArgumentParser.ts +0 -161
  146. package/src/utils/commandPathResolver.ts +0 -88
  147. package/src/utils/configPaths.ts +0 -220
  148. package/src/utils/configValidator.ts +0 -100
  149. package/src/utils/constants.ts +0 -39
  150. package/src/utils/container.ts +0 -92
  151. package/src/utils/containerSetup.ts +0 -371
  152. package/src/utils/convertMessagesForAPI.ts +0 -326
  153. package/src/utils/cronTasks.ts +0 -128
  154. package/src/utils/cronTasksLock.ts +0 -182
  155. package/src/utils/cronToHuman.ts +0 -99
  156. package/src/utils/customCommands.ts +0 -95
  157. package/src/utils/editUtils.ts +0 -20
  158. package/src/utils/fileFormat.ts +0 -40
  159. package/src/utils/fileSearch.ts +0 -151
  160. package/src/utils/fileUtils.ts +0 -223
  161. package/src/utils/gitUtils.ts +0 -315
  162. package/src/utils/globalLogger.ts +0 -128
  163. package/src/utils/groupMessagesByApiRound.ts +0 -121
  164. package/src/utils/hookMatcher.ts +0 -176
  165. package/src/utils/markdownParser.ts +0 -317
  166. package/src/utils/mcpUtils.ts +0 -138
  167. package/src/utils/messageOperations.ts +0 -659
  168. package/src/utils/modelCapabilities.ts +0 -30
  169. package/src/utils/nameGenerator.ts +0 -99
  170. package/src/utils/notificationXml.ts +0 -57
  171. package/src/utils/openaiClient.ts +0 -251
  172. package/src/utils/parseCronExpression.ts +0 -78
  173. package/src/utils/path.ts +0 -72
  174. package/src/utils/pathEncoder.ts +0 -400
  175. package/src/utils/pathSafety.ts +0 -40
  176. package/src/utils/promptHistory.ts +0 -168
  177. package/src/utils/ripgrep.ts +0 -35
  178. package/src/utils/shellResolver.ts +0 -190
  179. package/src/utils/skillParser.ts +0 -246
  180. package/src/utils/stringUtils.ts +0 -156
  181. package/src/utils/subagentParser.ts +0 -279
  182. package/src/utils/taskReminder.ts +0 -96
  183. package/src/utils/tokenCalculation.ts +0 -43
  184. package/src/utils/tokenEstimate.ts +0 -34
  185. package/src/utils/toolResultStorage.ts +0 -117
  186. package/src/utils/worktreeSession.ts +0 -26
  187. package/src/utils/worktreeUtils.ts +0 -786
  188. package/src/workflow/budgetTracker.ts +0 -34
  189. package/src/workflow/concurrencyLimiter.ts +0 -47
  190. package/src/workflow/journal.ts +0 -95
  191. package/src/workflow/progressReporter.ts +0 -141
  192. package/src/workflow/runState.ts +0 -65
  193. package/src/workflow/scriptRuntime.ts +0 -274
  194. package/src/workflow/structuredOutput.ts +0 -123
  195. package/src/workflow/types.ts +0 -101
  196. package/src/workflow/workflowApis.ts +0 -410
  197. package/vendor/ripgrep/linux-aarch64/rg +0 -0
  198. package/vendor/ripgrep/linux-x86_64/rg +0 -0
  199. package/vendor/ripgrep/macos-aarch64/rg +0 -0
  200. package/vendor/ripgrep/macos-x86_64/rg +0 -0
  201. package/vendor/ripgrep/windows-aarch64/rg.exe +0 -0
  202. package/vendor/ripgrep/windows-x86_64/rg.exe +0 -0
@@ -1,178 +0,0 @@
1
- import fs from "fs/promises";
2
- import { FileSnapshot } from "../types/reversion.js";
3
- import { ReversionService } from "../services/reversionService.js";
4
- import { Container } from "../utils/container.js";
5
-
6
- export class ReversionManager {
7
- private buffer: Map<string, FileSnapshot> = new Map();
8
-
9
- constructor(private container: Container) {}
10
-
11
- private get reversionService(): ReversionService {
12
- return this.container.get<ReversionService>("ReversionService")!;
13
- }
14
-
15
- /**
16
- * Records the current state of a file into a temporary buffer.
17
- * Returns a snapshotId.
18
- */
19
- async recordSnapshot(
20
- messageId: string,
21
- filePath: string,
22
- operation: "create" | "modify" | "delete",
23
- ): Promise<string> {
24
- let content: string | null = null;
25
- try {
26
- content = await fs.readFile(filePath, "utf-8");
27
- } catch {
28
- // File doesn't exist, which is expected for 'create' operation
29
- }
30
-
31
- const snapshot: FileSnapshot = {
32
- messageId,
33
- filePath,
34
- timestamp: Date.now(),
35
- operation,
36
- };
37
-
38
- // We temporarily store the content in the buffer, it will be saved to disk on commit
39
- const snapshotId = `${messageId}-${filePath}-${snapshot.timestamp}`;
40
- this.buffer.set(snapshotId, { ...snapshot, content } as FileSnapshot & {
41
- content: string | null;
42
- });
43
- return snapshotId;
44
- }
45
-
46
- /**
47
- * Records the current state of a file into a temporary buffer.
48
- * Returns a snapshotId.
49
- */
50
- async recordSnapshotWithId(
51
- messageId: string,
52
- filePath: string,
53
- operation: "create" | "modify" | "delete",
54
- ): Promise<string> {
55
- return this.recordSnapshot(messageId, filePath, operation);
56
- }
57
-
58
- /**
59
- * Moves the buffered snapshot to the permanent session log.
60
- * Called only if the tool succeeds.
61
- */
62
- async commitSnapshot(snapshotId: string): Promise<void> {
63
- const snapshotWithContent = this.buffer.get(snapshotId) as FileSnapshot & {
64
- content: string | null;
65
- };
66
- if (snapshotWithContent) {
67
- const { content, ...snapshot } = snapshotWithContent;
68
- const snapshotPath = await this.reversionService.saveSnapshot({
69
- ...snapshot,
70
- content,
71
- } as FileSnapshot);
72
- snapshot.snapshotPath = snapshotPath;
73
- this.buffer.delete(snapshotId);
74
-
75
- // We need to return the snapshot so it can be added to the message block
76
- // But the current API doesn't support it.
77
- // Let's store committed snapshots in another buffer for the current turn.
78
- this.committedSnapshots.push(snapshot);
79
- }
80
- }
81
-
82
- private committedSnapshots: FileSnapshot[] = [];
83
-
84
- /**
85
- * Gets and clears committed snapshots for the current turn.
86
- */
87
- getAndClearCommittedSnapshots(): FileSnapshot[] {
88
- const snapshots = [...this.committedSnapshots];
89
- this.committedSnapshots = [];
90
- return snapshots;
91
- }
92
-
93
- /**
94
- * Discards the buffered snapshot.
95
- * Called if the tool fails.
96
- */
97
- discardSnapshot(snapshotId: string): void {
98
- this.buffer.delete(snapshotId);
99
- }
100
-
101
- /**
102
- * Reverts all file changes associated with messages from the end of history
103
- * down to (and including) the specified message index.
104
- * This should be called by MessageManager.
105
- */
106
- async revertTo(
107
- messageIds: string[],
108
- allMessages: import("../types/index.js").Message[],
109
- ): Promise<number> {
110
- const messageIdSet = new Set(messageIds);
111
- const snapshots: FileSnapshot[] = [];
112
-
113
- for (const message of allMessages) {
114
- if (message.id && messageIdSet.has(message.id)) {
115
- const historyBlock = message.blocks.find(
116
- (b) => b.type === "file_history",
117
- ) as { type: "file_history"; snapshots: FileSnapshot[] } | undefined;
118
- if (historyBlock && historyBlock.snapshots) {
119
- snapshots.push(...historyBlock.snapshots);
120
- }
121
- }
122
- }
123
-
124
- // Revert in reverse chronological order (LIFO)
125
- const sortedSnapshots = snapshots.sort((a, b) => b.timestamp - a.timestamp);
126
-
127
- let revertedCount = 0;
128
- const affectedTaskListIds = new Set<string>();
129
-
130
- for (const snapshot of sortedSnapshots) {
131
- try {
132
- if (snapshot.operation === "create") {
133
- // For 'create' operations, we should hard delete the file upon reversion
134
- await fs.rm(snapshot.filePath, { force: true });
135
- } else if (!snapshot.snapshotPath) {
136
- // Fallback for older snapshots or if snapshotPath is missing
137
- await fs.rm(snapshot.filePath, { force: true });
138
- } else {
139
- // Restore previous content
140
- const content = await this.reversionService.readSnapshotContent(
141
- snapshot.snapshotPath,
142
- );
143
- if (content !== null) {
144
- await fs.writeFile(snapshot.filePath, content, "utf-8");
145
- } else {
146
- // If snapshotPath exists but content is null, it means the file should be deleted
147
- // (This handles the case where snapshotPath was set but content was null in saveSnapshot)
148
- await fs.rm(snapshot.filePath, { force: true });
149
- }
150
- }
151
-
152
- // Check if this is a task file and track the task list ID
153
- if (snapshot.filePath.includes("/.wave/tasks/")) {
154
- const parts = snapshot.filePath.split("/.wave/tasks/");
155
- if (parts.length > 1) {
156
- const taskListId = parts[1].split("/")[0];
157
- if (taskListId) {
158
- affectedTaskListIds.add(taskListId);
159
- }
160
- }
161
- }
162
-
163
- revertedCount++;
164
- } catch (error) {
165
- console.error(`Failed to revert file ${snapshot.filePath}:`, error);
166
- }
167
- }
168
-
169
- // Notify TaskManager if any task lists were affected
170
- // Note: In the current architecture, TaskManager is managed by Agent and
171
- // listens for file changes if it's a foreground process, or we might need
172
- // to explicitly trigger a refresh. Since ReversionManager doesn't have
173
- // a direct reference to TaskManager, we rely on the fact that TaskManager
174
- // will see the file system changes or be refreshed by the Agent/UI.
175
-
176
- return revertedCount;
177
- }
178
- }