wave-agent-sdk 0.5.0 → 0.6.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.
Files changed (152) hide show
  1. package/dist/agent.d.ts +14 -6
  2. package/dist/agent.d.ts.map +1 -1
  3. package/dist/agent.js +65 -88
  4. package/dist/constants/prompts.d.ts +18 -14
  5. package/dist/constants/prompts.d.ts.map +1 -1
  6. package/dist/constants/prompts.js +130 -54
  7. package/dist/constants/tools.d.ts +4 -1
  8. package/dist/constants/tools.d.ts.map +1 -1
  9. package/dist/constants/tools.js +4 -1
  10. package/dist/index.d.ts +1 -0
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +1 -0
  13. package/dist/managers/aiManager.d.ts +2 -5
  14. package/dist/managers/aiManager.d.ts.map +1 -1
  15. package/dist/managers/aiManager.js +59 -48
  16. package/dist/managers/backgroundTaskManager.d.ts.map +1 -1
  17. package/dist/managers/backgroundTaskManager.js +59 -53
  18. package/dist/managers/foregroundTaskManager.d.ts.map +1 -1
  19. package/dist/managers/foregroundTaskManager.js +3 -2
  20. package/dist/managers/mcpManager.d.ts.map +1 -1
  21. package/dist/managers/messageManager.d.ts +14 -10
  22. package/dist/managers/messageManager.d.ts.map +1 -1
  23. package/dist/managers/messageManager.js +102 -62
  24. package/dist/managers/permissionManager.d.ts.map +1 -1
  25. package/dist/managers/permissionManager.js +25 -15
  26. package/dist/managers/planManager.d.ts +1 -1
  27. package/dist/managers/planManager.d.ts.map +1 -1
  28. package/dist/managers/planManager.js +2 -2
  29. package/dist/managers/slashCommandManager.d.ts +3 -0
  30. package/dist/managers/slashCommandManager.d.ts.map +1 -1
  31. package/dist/managers/slashCommandManager.js +7 -2
  32. package/dist/managers/subagentManager.d.ts +4 -0
  33. package/dist/managers/subagentManager.d.ts.map +1 -1
  34. package/dist/managers/subagentManager.js +22 -14
  35. package/dist/managers/toolManager.d.ts +11 -0
  36. package/dist/managers/toolManager.d.ts.map +1 -1
  37. package/dist/managers/toolManager.js +20 -2
  38. package/dist/services/aiService.d.ts +0 -1
  39. package/dist/services/aiService.d.ts.map +1 -1
  40. package/dist/services/aiService.js +4 -140
  41. package/dist/services/memory.d.ts +0 -3
  42. package/dist/services/memory.d.ts.map +1 -1
  43. package/dist/services/memory.js +0 -59
  44. package/dist/services/session.d.ts +15 -1
  45. package/dist/services/session.d.ts.map +1 -1
  46. package/dist/services/session.js +57 -1
  47. package/dist/services/taskManager.d.ts +21 -0
  48. package/dist/services/taskManager.d.ts.map +1 -0
  49. package/dist/services/taskManager.js +158 -0
  50. package/dist/tools/askUserQuestion.d.ts.map +1 -1
  51. package/dist/tools/askUserQuestion.js +39 -25
  52. package/dist/tools/bashTool.d.ts.map +1 -1
  53. package/dist/tools/bashTool.js +7 -9
  54. package/dist/tools/editTool.d.ts.map +1 -1
  55. package/dist/tools/editTool.js +2 -1
  56. package/dist/tools/exitPlanMode.d.ts.map +1 -1
  57. package/dist/tools/exitPlanMode.js +25 -1
  58. package/dist/tools/globTool.d.ts.map +1 -1
  59. package/dist/tools/globTool.js +8 -2
  60. package/dist/tools/grepTool.d.ts.map +1 -1
  61. package/dist/tools/grepTool.js +17 -6
  62. package/dist/tools/lsTool.d.ts.map +1 -1
  63. package/dist/tools/lsTool.js +3 -1
  64. package/dist/tools/readTool.d.ts.map +1 -1
  65. package/dist/tools/readTool.js +16 -1
  66. package/dist/tools/taskManagementTools.d.ts +6 -0
  67. package/dist/tools/taskManagementTools.d.ts.map +1 -0
  68. package/dist/tools/taskManagementTools.js +453 -0
  69. package/dist/tools/taskOutputTool.d.ts.map +1 -1
  70. package/dist/tools/taskOutputTool.js +32 -8
  71. package/dist/tools/taskStopTool.d.ts.map +1 -1
  72. package/dist/tools/taskStopTool.js +7 -1
  73. package/dist/tools/taskTool.d.ts.map +1 -1
  74. package/dist/tools/taskTool.js +6 -1
  75. package/dist/tools/types.d.ts +9 -0
  76. package/dist/tools/types.d.ts.map +1 -1
  77. package/dist/tools/writeTool.d.ts.map +1 -1
  78. package/dist/tools/writeTool.js +9 -1
  79. package/dist/types/index.d.ts +1 -0
  80. package/dist/types/index.d.ts.map +1 -1
  81. package/dist/types/index.js +1 -0
  82. package/dist/types/messaging.d.ts +2 -8
  83. package/dist/types/messaging.d.ts.map +1 -1
  84. package/dist/types/processes.d.ts +11 -6
  85. package/dist/types/processes.d.ts.map +1 -1
  86. package/dist/types/tasks.d.ts +13 -0
  87. package/dist/types/tasks.d.ts.map +1 -0
  88. package/dist/types/tasks.js +1 -0
  89. package/dist/types/tools.d.ts +4 -1
  90. package/dist/types/tools.d.ts.map +1 -1
  91. package/dist/utils/builtinSubagents.d.ts.map +1 -1
  92. package/dist/utils/builtinSubagents.js +38 -1
  93. package/dist/utils/cacheControlUtils.d.ts.map +1 -1
  94. package/dist/utils/cacheControlUtils.js +18 -12
  95. package/dist/utils/constants.d.ts +0 -4
  96. package/dist/utils/constants.d.ts.map +1 -1
  97. package/dist/utils/constants.js +0 -4
  98. package/dist/utils/convertMessagesForAPI.js +2 -2
  99. package/dist/utils/messageOperations.d.ts +2 -35
  100. package/dist/utils/messageOperations.d.ts.map +1 -1
  101. package/dist/utils/messageOperations.js +4 -97
  102. package/dist/utils/nameGenerator.d.ts +1 -1
  103. package/dist/utils/nameGenerator.d.ts.map +1 -1
  104. package/dist/utils/nameGenerator.js +19 -3
  105. package/package.json +1 -1
  106. package/src/agent.ts +90 -101
  107. package/src/constants/prompts.ts +156 -65
  108. package/src/constants/tools.ts +4 -1
  109. package/src/index.ts +1 -0
  110. package/src/managers/aiManager.ts +79 -70
  111. package/src/managers/backgroundTaskManager.ts +53 -54
  112. package/src/managers/foregroundTaskManager.ts +3 -2
  113. package/src/managers/mcpManager.ts +6 -3
  114. package/src/managers/messageManager.ts +137 -73
  115. package/src/managers/permissionManager.ts +32 -21
  116. package/src/managers/planManager.ts +2 -2
  117. package/src/managers/slashCommandManager.ts +11 -2
  118. package/src/managers/subagentManager.ts +33 -14
  119. package/src/managers/toolManager.ts +32 -2
  120. package/src/services/aiService.ts +3 -145
  121. package/src/services/memory.ts +0 -72
  122. package/src/services/session.ts +73 -0
  123. package/src/services/taskManager.ts +188 -0
  124. package/src/tools/askUserQuestion.ts +51 -29
  125. package/src/tools/bashTool.ts +9 -15
  126. package/src/tools/editTool.ts +3 -1
  127. package/src/tools/exitPlanMode.ts +26 -2
  128. package/src/tools/globTool.ts +10 -2
  129. package/src/tools/grepTool.ts +17 -6
  130. package/src/tools/lsTool.ts +3 -1
  131. package/src/tools/readTool.ts +17 -1
  132. package/src/tools/taskManagementTools.ts +498 -0
  133. package/src/tools/taskOutputTool.ts +34 -12
  134. package/src/tools/taskStopTool.ts +7 -1
  135. package/src/tools/taskTool.ts +7 -1
  136. package/src/tools/types.ts +10 -0
  137. package/src/tools/writeTool.ts +9 -2
  138. package/src/types/index.ts +1 -0
  139. package/src/types/messaging.ts +1 -9
  140. package/src/types/processes.ts +13 -7
  141. package/src/types/tasks.ts +13 -0
  142. package/src/types/tools.ts +4 -1
  143. package/src/utils/builtinSubagents.ts +47 -1
  144. package/src/utils/cacheControlUtils.ts +26 -18
  145. package/src/utils/constants.ts +0 -5
  146. package/src/utils/convertMessagesForAPI.ts +2 -2
  147. package/src/utils/messageOperations.ts +5 -136
  148. package/src/utils/nameGenerator.ts +20 -3
  149. package/dist/tools/todoWriteTool.d.ts +0 -6
  150. package/dist/tools/todoWriteTool.d.ts.map +0 -1
  151. package/dist/tools/todoWriteTool.js +0 -220
  152. package/src/tools/todoWriteTool.ts +0 -257
package/dist/agent.d.ts CHANGED
@@ -46,7 +46,9 @@ export interface AgentOptions {
46
46
  }
47
47
  export interface AgentCallbacks extends MessageManagerCallbacks, BackgroundTaskManagerCallbacks, McpManagerCallbacks, SubagentManagerCallbacks {
48
48
  onTasksChange?: (tasks: BackgroundTask[]) => void;
49
+ onSessionTasksChange?: (tasks: import("./types/tasks.js").Task[]) => void;
49
50
  onPermissionModeChange?: (mode: PermissionMode) => void;
51
+ onSubagentLatestTotalTokensChange?: (subagentId: string, tokens: number) => void;
50
52
  onBackgroundCurrentTask?: () => void;
51
53
  }
52
54
  export declare class Agent {
@@ -68,6 +70,7 @@ export declare class Agent {
68
70
  private reversionManager;
69
71
  private memoryRuleManager;
70
72
  private liveConfigManager;
73
+ private taskManager;
71
74
  private foregroundTaskManager;
72
75
  private configurationService;
73
76
  private workdir;
@@ -106,7 +109,6 @@ export declare class Agent {
106
109
  */
107
110
  private addUsage;
108
111
  get latestTotalTokens(): number;
109
- get userInputHistory(): string[];
110
112
  /** Get working directory */
111
113
  get workingDirectory(): string;
112
114
  /** Get project memory content */
@@ -199,12 +201,9 @@ export declare class Agent {
199
201
  abortAIMessage(): void;
200
202
  /** Execute bash command */
201
203
  executeBashCommand(command: string): Promise<void>;
202
- /** Clear messages and input history */
203
204
  clearMessages(): void;
204
205
  /** Unified interrupt method, interrupts both AI messages and command execution */
205
206
  abortMessage(): void;
206
- /** Add to input history */
207
- private addToInputHistory;
208
207
  /** Interrupt bash command execution */
209
208
  abortBashCommand(): void;
210
209
  /** Interrupt slash command execution */
@@ -262,8 +261,6 @@ export declare class Agent {
262
261
  path: string;
263
262
  mimeType: string;
264
263
  }>): Promise<void>;
265
- /** Save memory to project or user memory file */
266
- saveMemory(message: string, type: "project" | "user"): Promise<void>;
267
264
  /** Get all MCP server status */
268
265
  getMcpServers(): McpServerStatus[];
269
266
  /** Connect MCP server */
@@ -298,6 +295,13 @@ export declare class Agent {
298
295
  * @param index - The index of the user message to truncate to.
299
296
  */
300
297
  truncateHistory(index: number): Promise<void>;
298
+ /**
299
+ * Get the full message thread including parent sessions
300
+ */
301
+ getFullMessageThread(): Promise<{
302
+ messages: Message[];
303
+ sessionIds: string[];
304
+ }>;
301
305
  /**
302
306
  * Get the current plan file path (for testing and UI)
303
307
  */
@@ -320,5 +324,9 @@ export declare class Agent {
320
324
  * @param mode - The current effective permission mode
321
325
  */
322
326
  private handlePlanModeTransition;
327
+ /**
328
+ * Get the current task list ID
329
+ */
330
+ get taskListId(): string;
323
331
  }
324
332
  //# sourceMappingURL=agent.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,uBAAuB,EAC7B,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EAEL,KAAK,wBAAwB,EAC9B,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAc,KAAK,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAGhF,OAAO,EAEL,KAAK,8BAA8B,EACpC,MAAM,qCAAqC,CAAC;AAQ7C,OAAO,KAAK,EACV,YAAY,EACZ,kBAAkB,EAClB,WAAW,EACX,YAAY,EACb,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EACV,OAAO,EACP,MAAM,EACN,eAAe,EACf,aAAa,EACb,WAAW,EACX,KAAK,EACL,cAAc,EACd,kBAAkB,EAClB,cAAc,EACd,cAAc,EACf,MAAM,kBAAkB,CAAC;AAe1B,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAEvC;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAE3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxC,YAAY,CAAC,EAAE,aAAa,CAAC,cAAc,CAAC,CAAC;IAC7C,KAAK,CAAC,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;IAC/B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iDAAiD;IACjD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAGlB,SAAS,CAAC,EAAE,cAAc,CAAC;IAC3B,gBAAgB,CAAC,EA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G;IACH,IAAW,UAAU,IAAI,MAAM,CAE9B;CACF"}
package/dist/agent.js CHANGED
@@ -3,7 +3,6 @@ import { MessageManager, } from "./managers/messageManager.js";
3
3
  import { AIManager } from "./managers/aiManager.js";
4
4
  import { ToolManager } from "./managers/toolManager.js";
5
5
  import { SubagentManager, } from "./managers/subagentManager.js";
6
- import * as memory from "./services/memory.js";
7
6
  import { McpManager } from "./managers/mcpManager.js";
8
7
  import { LspManager } from "./managers/lspManager.js";
9
8
  import { BashManager } from "./managers/bashManager.js";
@@ -19,6 +18,7 @@ import { MemoryRuleManager } from "./managers/MemoryRuleManager.js";
19
18
  import { LiveConfigManager } from "./managers/liveConfigManager.js";
20
19
  import { configValidator } from "./utils/configValidator.js";
21
20
  import { SkillManager } from "./managers/skillManager.js";
21
+ import { TaskManager } from "./services/taskManager.js";
22
22
  import { loadSessionFromJsonl, handleSessionRestoration, } from "./services/session.js";
23
23
  import { setGlobalLogger } from "./utils/globalLogger.js";
24
24
  import { ConfigurationService } from "./services/configurationService.js";
@@ -65,6 +65,39 @@ export class Agent {
65
65
  // Store options for dynamic configuration resolution
66
66
  this.options = options;
67
67
  this.foregroundTaskManager = new ForegroundTaskManager();
68
+ // Initialize memory rule manager
69
+ this.memoryRuleManager = new MemoryRuleManager({
70
+ workdir: this.workdir,
71
+ });
72
+ // Initialize MessageManager
73
+ this.messageManager = new MessageManager({
74
+ callbacks: {
75
+ ...callbacks,
76
+ onSessionIdChange: (sessionId) => {
77
+ // When session ID changes (e.g. due to compression),
78
+ // we update the task manager to use the root session ID
79
+ // to ensure the task list remains consistent.
80
+ this.taskManager.setTaskListId(this.messageManager.getRootSessionId());
81
+ callbacks.onSessionIdChange?.(sessionId);
82
+ },
83
+ onSubagentTaskStopRequested: (subagentId) => {
84
+ this.backgroundTaskManager.stopTask(subagentId);
85
+ },
86
+ },
87
+ workdir: this.workdir,
88
+ logger: this.logger,
89
+ memoryRuleManager: this.memoryRuleManager,
90
+ });
91
+ // Resolve taskListId once during construction to ensure stability
92
+ const resolvedTaskListId = this.configurationService.getEnvironmentVars().WAVE_TASK_LIST_ID ||
93
+ process.env.WAVE_TASK_LIST_ID ||
94
+ this.messageManager.getRootSessionId();
95
+ this.taskManager = new TaskManager(resolvedTaskListId);
96
+ this.taskManager.on("tasksChange", async () => {
97
+ const tasks = await this.taskManager.listTasks();
98
+ this.options.callbacks?.onSessionTasksChange?.(tasks);
99
+ });
100
+ // Initialize BackgroundTaskManager
68
101
  this.backgroundTaskManager = new BackgroundTaskManager({
69
102
  callbacks: {
70
103
  ...callbacks,
@@ -95,18 +128,7 @@ export class Agent {
95
128
  logger: this.logger,
96
129
  workdir: this.workdir,
97
130
  });
98
- // Initialize memory rule manager
99
- this.memoryRuleManager = new MemoryRuleManager({
100
- workdir: this.workdir,
101
- });
102
- // Initialize MessageManager
103
- this.messageManager = new MessageManager({
104
- callbacks,
105
- workdir: this.workdir,
106
- logger: this.logger,
107
- memoryRuleManager: this.memoryRuleManager,
108
- });
109
- // Initialize ReversionManager
131
+ // ReversionManager depends on MessageManager
110
132
  this.reversionManager = new ReversionManager(new ReversionService(this.messageManager.getTranscriptPath()));
111
133
  // Create a wrapper for canUseTool that triggers notification hooks
112
134
  const canUseToolWithNotification = options.canUseTool
@@ -154,6 +176,7 @@ export class Agent {
154
176
  reversionManager: this.reversionManager,
155
177
  permissionMode: options.permissionMode, // Let PermissionManager handle defaultMode resolution
156
178
  canUseToolCallback: canUseToolWithNotification,
179
+ taskManager: this.taskManager,
157
180
  backgroundTaskManager: this.backgroundTaskManager,
158
181
  foregroundTaskManager: this.foregroundTaskManager,
159
182
  }); // Initialize tool registry with permission support
@@ -177,6 +200,7 @@ export class Agent {
177
200
  onSubagentAssistantReasoningUpdated: callbacks.onSubagentAssistantReasoningUpdated,
178
201
  onSubagentToolBlockUpdated: callbacks.onSubagentToolBlockUpdated,
179
202
  onSubagentMessagesChange: callbacks.onSubagentMessagesChange,
203
+ onSubagentLatestTotalTokensChange: callbacks.onSubagentLatestTotalTokensChange,
180
204
  }, // Pass subagent callbacks for forwarding
181
205
  logger: this.logger,
182
206
  getGatewayConfig: () => this.getGatewayConfig(),
@@ -186,12 +210,14 @@ export class Agent {
186
210
  hookManager: this.hookManager,
187
211
  onUsageAdded: (usage) => this.addUsage(usage),
188
212
  backgroundTaskManager: this.backgroundTaskManager,
213
+ taskManager: this.taskManager,
189
214
  memoryRuleManager: this.memoryRuleManager,
190
215
  });
191
216
  // Initialize AI manager with resolved configuration
192
217
  this.aiManager = new AIManager({
193
218
  messageManager: this.messageManager,
194
219
  toolManager: this.toolManager,
220
+ taskManager: this.taskManager,
195
221
  logger: this.logger,
196
222
  backgroundTaskManager: this.backgroundTaskManager,
197
223
  hookManager: this.hookManager,
@@ -217,6 +243,7 @@ export class Agent {
217
243
  messageManager: this.messageManager,
218
244
  aiManager: this.aiManager,
219
245
  backgroundTaskManager: this.backgroundTaskManager,
246
+ taskManager: this.taskManager,
220
247
  workdir: this.workdir,
221
248
  logger: this.logger,
222
249
  });
@@ -279,9 +306,6 @@ export class Agent {
279
306
  get latestTotalTokens() {
280
307
  return this.messageManager.getlatestTotalTokens();
281
308
  }
282
- get userInputHistory() {
283
- return this.messageManager.getUserInputHistory();
284
- }
285
309
  /** Get working directory */
286
310
  get workingDirectory() {
287
311
  return this.workdir;
@@ -527,8 +551,14 @@ export class Agent {
527
551
  this.rebuildUsageFromMessages(sessionToRestore?.messages || []);
528
552
  // After main session is restored, restore any associated subagent sessions
529
553
  await this.restoreSubagentSessions(sessionToRestore?.messages || []);
530
- if (sessionToRestore)
554
+ if (sessionToRestore) {
531
555
  this.messageManager.initializeFromSession(sessionToRestore);
556
+ // Update task manager with the root session ID to ensure continuity across compressions
557
+ this.taskManager.setTaskListId(sessionToRestore.rootSessionId || sessionToRestore.id);
558
+ // After session is initialized, load tasks for the session
559
+ const tasks = await this.taskManager.listTasks();
560
+ this.options.callbacks?.onSessionTasksChange?.(tasks);
561
+ }
532
562
  }
533
563
  }
534
564
  /**
@@ -620,17 +650,19 @@ export class Agent {
620
650
  await this.restoreSubagentSessions(sessionData.messages);
621
651
  // 6. Initialize session state last
622
652
  this.messageManager.initializeFromSession(sessionData);
653
+ // Update task manager with the root session ID to ensure continuity across compressions
654
+ this.taskManager.setTaskListId(sessionData.rootSessionId || sessionData.id);
655
+ // 7. Load tasks for the restored session
656
+ const tasks = await this.taskManager.listTasks();
657
+ this.options.callbacks?.onSessionTasksChange?.(tasks);
623
658
  }
624
659
  abortAIMessage() {
625
660
  this.aiManager.abortAIMessage();
626
661
  }
627
662
  /** Execute bash command */
628
663
  async executeBashCommand(command) {
629
- // Add user message to history (but not displayed in UI)
630
- this.addToInputHistory(`!${command}`);
631
664
  await this.bashManager?.executeCommand(command);
632
665
  }
633
- /** Clear messages and input history */
634
666
  clearMessages() {
635
667
  this.messageManager.clearMessages();
636
668
  }
@@ -640,10 +672,6 @@ export class Agent {
640
672
  this.abortBashCommand();
641
673
  this.abortSlashCommand();
642
674
  }
643
- /** Add to input history */
644
- addToInputHistory(input) {
645
- this.messageManager.addToInputHistory(input);
646
- }
647
675
  /** Interrupt bash command execution */
648
676
  abortBashCommand() {
649
677
  this.bashManager?.abortCommand();
@@ -670,11 +698,6 @@ export class Agent {
670
698
  async backgroundCurrentTask() {
671
699
  await this.foregroundTaskManager.backgroundCurrentTask();
672
700
  this.options.callbacks?.onBackgroundCurrentTask?.();
673
- // If there was no foreground task (e.g. a tool that doesn't register one),
674
- // or even if there was, we should stop the AI recursion loop.
675
- if (!this.foregroundTaskManager.hasActiveTasks()) {
676
- this.aiManager.abortRecursion();
677
- }
678
701
  }
679
702
  /** Destroy managers, clean up resources */
680
703
  async destroy() {
@@ -752,16 +775,12 @@ export class Agent {
752
775
  if (isValid && commandId !== undefined) {
753
776
  // Execute valid slash command
754
777
  await this.slashCommandManager.executeCommand(commandId, args);
755
- // Add slash command to history
756
- this.addToInputHistory(command);
757
778
  return;
758
779
  }
759
780
  // If command doesn't exist, continue as normal message processing
760
781
  // Don't add to history, let normal message processing logic below handle it
761
782
  }
762
783
  // Handle normal AI message
763
- // Add user message to history
764
- this.addToInputHistory(content);
765
784
  // Add user message first, will automatically sync to UI
766
785
  this.messageManager.addUserMessage({
767
786
  content,
@@ -805,60 +824,6 @@ export class Agent {
805
824
  // Loading state will be automatically updated by the useEffect that watches messages
806
825
  }
807
826
  }
808
- /** Save memory to project or user memory file */
809
- async saveMemory(message, type) {
810
- try {
811
- // Ensure the message starts with # for memory functions
812
- const formattedMessage = message.startsWith("#")
813
- ? message
814
- : `#${message}`;
815
- if (type === "project") {
816
- await memory.addMemory(formattedMessage, this.workdir);
817
- // Update internal state after successful save
818
- this._projectMemoryContent = await memory.readMemoryFile(this.workdir);
819
- }
820
- else {
821
- await memory.addUserMemory(formattedMessage);
822
- // Update internal state after successful save
823
- this._userMemoryContent = await memory.getUserMemoryContent();
824
- }
825
- // Add successful MemoryBlock to the last assistant message
826
- const memoryText = message.substring(1).trim();
827
- const typeLabel = type === "project" ? "Project Memory" : "User Memory";
828
- const storagePath = "AGENTS.md";
829
- const messages = this.messageManager.getMessages();
830
- const lastMessage = messages[messages.length - 1];
831
- if (lastMessage && lastMessage.role === "assistant") {
832
- lastMessage.blocks.push({
833
- type: "memory",
834
- content: `${typeLabel}: ${memoryText}`,
835
- isSuccess: true,
836
- memoryType: type,
837
- storagePath,
838
- });
839
- this.messageManager.setMessages(messages);
840
- }
841
- }
842
- catch (error) {
843
- // Add failed MemoryBlock to the last assistant message
844
- const memoryText = message.substring(1).trim();
845
- const typeLabel = type === "project" ? "Project Memory" : "User Memory";
846
- const storagePath = "AGENTS.md";
847
- const errorMessage = error instanceof Error ? error.message : String(error);
848
- const messages = this.messageManager.getMessages();
849
- const lastMessage = messages[messages.length - 1];
850
- if (lastMessage && lastMessage.role === "assistant") {
851
- lastMessage.blocks.push({
852
- type: "memory",
853
- content: `${typeLabel}: ${memoryText} - Error: ${errorMessage}`,
854
- isSuccess: false,
855
- memoryType: type,
856
- storagePath,
857
- });
858
- this.messageManager.setMessages(messages);
859
- }
860
- }
861
- }
862
827
  // ========== MCP Management Methods ==========
863
828
  /** Get all MCP server status */
864
829
  getMcpServers() {
@@ -922,6 +887,12 @@ export class Agent {
922
887
  async truncateHistory(index) {
923
888
  await this.messageManager.truncateHistory(index, this.reversionManager);
924
889
  }
890
+ /**
891
+ * Get the full message thread including parent sessions
892
+ */
893
+ async getFullMessageThread() {
894
+ return this.messageManager.getFullMessageThread();
895
+ }
925
896
  /**
926
897
  * Get the current plan file path (for testing and UI)
927
898
  */
@@ -980,7 +951,7 @@ export class Agent {
980
951
  handlePlanModeTransition(mode) {
981
952
  if (mode === "plan") {
982
953
  this.planManager
983
- .getOrGeneratePlanFilePath()
954
+ .getOrGeneratePlanFilePath(this.messageManager.getRootSessionId())
984
955
  .then(({ path }) => {
985
956
  this.logger?.debug("Plan file path generated", { path });
986
957
  this.permissionManager.setPlanFilePath(path);
@@ -993,4 +964,10 @@ export class Agent {
993
964
  this.permissionManager.setPlanFilePath(undefined);
994
965
  }
995
966
  }
967
+ /**
968
+ * Get the current task list ID
969
+ */
970
+ get taskListId() {
971
+ return this.taskManager.getTaskListId();
972
+ }
996
973
  }
@@ -1,20 +1,24 @@
1
+ import { ToolPlugin } from "../tools/types.js";
1
2
  export declare const BASE_SYSTEM_PROMPT = "You are an interactive CLI tool that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user.\n\n# Doing tasks\nThe user will primarily request you perform software engineering tasks. This includes solving bugs, adding new functionality, refactoring code, explaining code, and more. For these tasks the following steps are recommended:\n- NEVER propose changes to code you haven't read. If a user asks about or wants you to modify a file, read it first. Understand existing code before suggesting modifications.\n- Be careful not to introduce security vulnerabilities such as command injection, XSS, SQL injection, and other OWASP top 10 vulnerabilities. If you notice that you wrote insecure code, immediately fix it.\n- Avoid over-engineering. Only make changes that are directly requested or clearly necessary. Keep solutions simple and focused.\n - Don't add features, refactor code, or make \"improvements\" beyond what was asked. A bug fix doesn't need surrounding code cleaned up. A simple feature doesn't need extra configurability. Don't add docstrings, comments, or type annotations to code you didn't change. Only add comments where the logic isn't self-evident.\n - Don't add error handling, fallbacks, or validation for scenarios that can't happen. Trust internal code and framework guarantees. Only validate at system boundaries (user input, external APIs). Don't use feature flags or backwards-compatibility shims when you can just change the code.\n - Don't create helpers, utilities, or abstractions for one-time operations. Don't design for hypothetical future requirements. The right amount of complexity is the minimum needed for the current task\u2014three similar lines of code is better than a premature abstraction.\n- Avoid backwards-compatibility hacks like renaming unused `_vars`, re-exporting types, adding `// removed` comments for removed code, etc. If something is unused, delete it completely.\n\n# Tool usage policy\n- You can call multiple tools in a single response. If you intend to call multiple tools and there are no dependencies between them, make all independent tool calls in parallel. Maximize use of parallel tool calls where possible to increase efficiency.\n- However, if some tool calls depend on previous calls to inform dependent values, do NOT call these tools in parallel and instead call them sequentially. For instance, if one operation must complete before another starts, run these operations sequentially instead. Never use placeholders or guess missing parameters in tool calls.\n- If the user specifies that they want you to run tools \"in parallel\", you MUST send a single message with multiple tool use content blocks.";
2
- export declare const TASK_MANAGEMENT_POLICY = "\n# Task Management\nYou have access to the TodoWrite tools to help you manage and plan tasks. Use these tools VERY frequently to ensure that you are tracking your tasks and giving the user visibility into your progress.\nThese tools are also EXTREMELY helpful for planning tasks, and for breaking down larger complex tasks into smaller steps. If you do not use this tool when planning, you may forget to do important tasks - and that is unacceptable.\nIt is critical that you mark todos as completed as soon as you are done with a task. Do not batch up multiple tasks before marking them as completed.";
3
- export declare const ASK_USER_POLICY = "\n# Asking questions as you work\nYou have access to the AskUserQuestion tool to ask the user questions when you need clarification, want to validate assumptions, or need to make a decision you're unsure about. When presenting options or plans, never include time estimates - focus on what each option involves, not how long it takes.";
4
- export declare const SUBAGENT_POLICY = "\n- When doing file search, prefer to use the Task tool in order to reduce context usage.\n- You should proactively use the Task tool with specialized agents when the task at hand matches the agent's description.\n- 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 with subagent_type=Explore instead of running search commands directly.";
5
- export declare 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:";
6
- export declare const READ_FILE_POLICY = " Read for reading files instead of cat/head/tail";
7
- export declare const EDIT_FILE_POLICY = " Edit/MultiEdit for editing instead of sed/awk";
8
- export declare const WRITE_FILE_POLICY = " Write for creating files instead of cat with heredoc or echo redirection";
9
- export declare const SEARCH_FILE_POLICY = " LS/Glob/Grep for searching and listing files instead of find/ls/grep";
10
- export declare const BASH_POLICY = "\n- 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.\n- 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.";
3
+ export declare const TASK_MANAGEMENT_POLICY = "\n# Task Management\nYou have access to the TaskCreate, TaskGet, TaskUpdate, and TaskList tools to help you manage and plan tasks. Use these tools VERY frequently to ensure that you are tracking your tasks and giving the user visibility into your progress.\nThese tools are also EXTREMELY helpful for planning tasks, and for breaking down larger complex tasks into smaller steps. If you do not use this tool when planning, you may forget to do important tasks - and that is unacceptable.\nIt is critical that you mark tasks as completed as soon as you are done with a task. Do not batch up multiple tasks before marking them as completed.";
4
+ export declare function buildPlanModePrompt(planFilePath: string, planExists: boolean): string;
11
5
  export declare const DEFAULT_SYSTEM_PROMPT = "You are an interactive CLI tool that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user.\n\n# Doing tasks\nThe user will primarily request you perform software engineering tasks. This includes solving bugs, adding new functionality, refactoring code, explaining code, and more. For these tasks the following steps are recommended:\n- NEVER propose changes to code you haven't read. If a user asks about or wants you to modify a file, read it first. Understand existing code before suggesting modifications.\n- Be careful not to introduce security vulnerabilities such as command injection, XSS, SQL injection, and other OWASP top 10 vulnerabilities. If you notice that you wrote insecure code, immediately fix it.\n- Avoid over-engineering. Only make changes that are directly requested or clearly necessary. Keep solutions simple and focused.\n - Don't add features, refactor code, or make \"improvements\" beyond what was asked. A bug fix doesn't need surrounding code cleaned up. A simple feature doesn't need extra configurability. Don't add docstrings, comments, or type annotations to code you didn't change. Only add comments where the logic isn't self-evident.\n - Don't add error handling, fallbacks, or validation for scenarios that can't happen. Trust internal code and framework guarantees. Only validate at system boundaries (user input, external APIs). Don't use feature flags or backwards-compatibility shims when you can just change the code.\n - Don't create helpers, utilities, or abstractions for one-time operations. Don't design for hypothetical future requirements. The right amount of complexity is the minimum needed for the current task\u2014three similar lines of code is better than a premature abstraction.\n- Avoid backwards-compatibility hacks like renaming unused `_vars`, re-exporting types, adding `// removed` comments for removed code, etc. If something is unused, delete it completely.\n\n# Tool usage policy\n- You can call multiple tools in a single response. If you intend to call multiple tools and there are no dependencies between them, make all independent tool calls in parallel. Maximize use of parallel tool calls where possible to increase efficiency.\n- However, if some tool calls depend on previous calls to inform dependent values, do NOT call these tools in parallel and instead call them sequentially. For instance, if one operation must complete before another starts, run these operations sequentially instead. Never use placeholders or guess missing parameters in tool calls.\n- If the user specifies that they want you to run tools \"in parallel\", you MUST send a single message with multiple tool use content blocks.";
6
+ export declare const BASH_SUBAGENT_SYSTEM_PROMPT = "You are a command execution specialist. Your role is to execute bash commands efficiently and safely.\n\nGuidelines:\n- Execute commands precisely as instructed\n- For git operations, follow git safety protocols\n- Report command output clearly and concisely\n- If a command fails, explain the error and suggest solutions\n- Use command chaining (&&) for dependent operations\n- Quote paths with spaces properly\n- For clear communication, avoid using emojis\n\nComplete the requested operations efficiently.";
12
7
  export declare 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.\n\nYour strengths:\n- Searching for code, configurations, and patterns across large codebases\n- Analyzing multiple files to understand system architecture\n- Investigating complex questions that require exploring many files\n- Performing multi-step research tasks\n\nGuidelines:\n- For file searches: Use Grep or Glob when you need to search broadly. Use Read when you know the specific file path.\n- For analysis: Start broad and narrow down. Use multiple search strategies if the first doesn't yield results.\n- Be thorough: Check multiple locations, consider different naming conventions, look for related files.\n- NEVER create files unless they're absolutely necessary for achieving your goal. ALWAYS prefer editing an existing file to creating a new one.\n- NEVER proactively create documentation files (*.md) or README files. Only create documentation files if explicitly requested.\n- 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.\n- For clear communication, avoid using emojis.";
8
+ export declare const PLAN_SUBAGENT_SYSTEM_PROMPT = "You are a software architect and planning specialist. Your role is to explore the codebase and design implementation plans.\n\n=== CRITICAL: READ-ONLY MODE - NO FILE MODIFICATIONS ===\nThis is a READ-ONLY planning task. You are STRICTLY PROHIBITED from:\n- Creating new files (no Write, touch, or file creation of any kind)\n- Modifying existing files (no Edit operations)\n- Deleting files (no rm or deletion)\n- Moving or copying files (no mv or cp)\n- Creating temporary files anywhere, including /tmp\n- Using redirect operators (>, >>, |) or heredocs to write to files\n- Running ANY commands that change system state\n\nYour 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.\n\nYou will be provided with a set of requirements and optionally a perspective on how to approach the design process.\n\n## Your Process\n\n1. **Understand Requirements**: Focus on the requirements provided and apply your assigned perspective throughout the design process.\n\n2. **Explore Thoroughly**:\n - Read any files provided to you in the initial prompt\n - Find existing patterns and conventions using Glob, Grep, and Read\n - Understand the current architecture\n - Identify similar features as reference\n - Trace through relevant code paths\n - Use Bash ONLY for read-only operations (ls, git status, git log, git diff, find, cat, head, tail)\n - NEVER use Bash for: mkdir, touch, rm, cp, mv, git add, git commit, npm install, pip install, or any file creation/modification\n\n3. **Design Solution**:\n - Create implementation approach based on your assigned perspective\n - Consider trade-offs and architectural decisions\n - Follow existing patterns where appropriate\n\n4. **Detail the Plan**:\n - Provide step-by-step implementation strategy\n - Identify dependencies and sequencing\n - Anticipate potential challenges\n\n## Required Output\n\nEnd your response with:\n\n### Critical Files for Implementation\nList 3-5 files most critical for implementing this plan:\n- path/to/file1.ts - [Brief reason: e.g., \"Core logic to modify\"]\n- path/to/file2.ts - [Brief reason: e.g., \"Interfaces to implement\"]\n- path/to/file3.ts - [Brief reason: e.g., \"Pattern to follow\"]\n\nREMEMBER: 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.";
13
9
  export declare 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.\n\nWhat to add:\n1. 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.\n2. 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.\n\nUsage notes:\n- If there's already a AGENTS.md, suggest improvements to it.\n- 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\".\n- Avoid listing every component or file structure that can be easily discovered.\n- Don't include generic development practices.\n- 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.\n- If there is a README.md, make sure to include the important parts.\n- 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.\n- Be sure to prefix the file with the following text:\n\n```\n# AGENTS.md\n\nThis file provides guidance to Agent when working with code in this repository.\n```";
14
- export declare function buildSystemPrompt(basePrompt: string, tools: {
15
- name?: string;
16
- function?: {
17
- name: string;
10
+ export declare 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:\n1. Task Overview\nThe user's core request and success criteria\nAny clarifications or constraints they specified\n2. Current State\nWhat has been completed so far\nFiles created, modified, or analyzed (with paths if relevant)\nKey outputs or artifacts produced\n3. Important Discoveries\nTechnical constraints or requirements uncovered\nDecisions made and their rationale\nErrors encountered and how they were resolved\nWhat approaches were tried that didn't work (and why)\n4. Next Steps\nSpecific actions needed to complete the task\nAny blockers or open questions to resolve\nPriority order if multiple steps remain\n5. Context to Preserve\nUser preferences or style requirements\nDomain-specific details that aren't obvious\nAny promises made to the user\nBe concise but complete\u2014err on the side of including information that would prevent duplicate work or repeated mistakes. Write in a way that enables immediate resumption of the task.\nWrap your summary in <summary></summary> tags.";
11
+ export declare function buildSystemPrompt(basePrompt: string | undefined, tools: ToolPlugin[], options?: {
12
+ workdir?: string;
13
+ isGitRepo?: string;
14
+ platform?: string;
15
+ osVersion?: string;
16
+ today?: string;
17
+ memory?: string;
18
+ language?: string;
19
+ planMode?: {
20
+ planFilePath: string;
21
+ planExists: boolean;
18
22
  };
19
- }[]): string;
23
+ }): string;
20
24
  //# sourceMappingURL=prompts.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../src/constants/prompts.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,kBAAkB,ksFAe8G,CAAC;AAE9I,eAAO,MAAM,sBAAsB,+lBAImH,CAAC;AAEvJ,eAAO,MAAM,eAAe,mVAEgS,CAAC;AAE7T,eAAO,MAAM,eAAe,meAG0P,CAAC;AAEvR,eAAO,MAAM,uBAAuB,2JAA2J,CAAC;AAChM,eAAO,MAAM,gBAAgB,qDAAkE,CAAC;AAChG,eAAO,MAAM,gBAAgB,mDAA8E,CAAC;AAC5G,eAAO,MAAM,iBAAiB,8EAA2F,CAAC;AAC1H,eAAO,MAAM,kBAAkB,0EAAiH,CAAC;AAEjJ,eAAO,MAAM,WAAW,sjBAE4O,CAAC;AAErQ,eAAO,MAAM,qBAAqB,ksFAAqB,CAAC;AAExD,eAAO,MAAM,6BAA6B,izCAeK,CAAC;AAEhD,eAAO,MAAM,WAAW,kkDAoBjB,CAAC;AAER,wBAAgB,i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