wave-agent-sdk 0.13.1 → 0.13.3

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 (66) hide show
  1. package/dist/agent.d.ts +7 -0
  2. package/dist/agent.d.ts.map +1 -1
  3. package/dist/agent.js +37 -0
  4. package/dist/index.d.ts +1 -0
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +1 -0
  7. package/dist/managers/aiManager.d.ts.map +1 -1
  8. package/dist/managers/aiManager.js +65 -33
  9. package/dist/managers/backgroundTaskManager.d.ts +1 -0
  10. package/dist/managers/backgroundTaskManager.d.ts.map +1 -1
  11. package/dist/managers/backgroundTaskManager.js +49 -0
  12. package/dist/managers/forkedAgentManager.d.ts +49 -0
  13. package/dist/managers/forkedAgentManager.d.ts.map +1 -0
  14. package/dist/managers/forkedAgentManager.js +111 -0
  15. package/dist/managers/messageManager.d.ts +8 -1
  16. package/dist/managers/messageManager.d.ts.map +1 -1
  17. package/dist/managers/messageManager.js +14 -1
  18. package/dist/managers/notificationQueue.d.ts +8 -0
  19. package/dist/managers/notificationQueue.d.ts.map +1 -0
  20. package/dist/managers/notificationQueue.js +17 -0
  21. package/dist/managers/permissionManager.d.ts.map +1 -1
  22. package/dist/managers/permissionManager.js +2 -0
  23. package/dist/managers/subagentManager.d.ts +7 -9
  24. package/dist/managers/subagentManager.d.ts.map +1 -1
  25. package/dist/managers/subagentManager.js +101 -21
  26. package/dist/services/autoMemoryService.d.ts +1 -1
  27. package/dist/services/autoMemoryService.d.ts.map +1 -1
  28. package/dist/services/autoMemoryService.js +7 -8
  29. package/dist/services/interactionService.d.ts.map +1 -1
  30. package/dist/services/interactionService.js +12 -0
  31. package/dist/types/agent.d.ts +1 -0
  32. package/dist/types/agent.d.ts.map +1 -1
  33. package/dist/types/messaging.d.ts +9 -1
  34. package/dist/types/messaging.d.ts.map +1 -1
  35. package/dist/utils/containerSetup.d.ts.map +1 -1
  36. package/dist/utils/containerSetup.js +6 -0
  37. package/dist/utils/convertMessagesForAPI.d.ts.map +1 -1
  38. package/dist/utils/convertMessagesForAPI.js +8 -0
  39. package/dist/utils/messageOperations.d.ts +9 -0
  40. package/dist/utils/messageOperations.d.ts.map +1 -1
  41. package/dist/utils/messageOperations.js +17 -0
  42. package/dist/utils/notificationXml.d.ts +4 -0
  43. package/dist/utils/notificationXml.d.ts.map +1 -0
  44. package/dist/utils/notificationXml.js +40 -0
  45. package/dist/utils/pathEncoder.d.ts +0 -1
  46. package/dist/utils/pathEncoder.d.ts.map +1 -1
  47. package/dist/utils/pathEncoder.js +1 -5
  48. package/package.json +1 -1
  49. package/src/agent.ts +44 -0
  50. package/src/index.ts +1 -0
  51. package/src/managers/aiManager.ts +76 -41
  52. package/src/managers/backgroundTaskManager.ts +72 -1
  53. package/src/managers/forkedAgentManager.ts +193 -0
  54. package/src/managers/messageManager.ts +25 -0
  55. package/src/managers/notificationQueue.ts +19 -0
  56. package/src/managers/permissionManager.ts +2 -0
  57. package/src/managers/subagentManager.ts +135 -41
  58. package/src/services/autoMemoryService.ts +11 -17
  59. package/src/services/interactionService.ts +18 -0
  60. package/src/types/agent.ts +1 -0
  61. package/src/types/messaging.ts +11 -1
  62. package/src/utils/containerSetup.ts +8 -0
  63. package/src/utils/convertMessagesForAPI.ts +9 -0
  64. package/src/utils/messageOperations.ts +42 -1
  65. package/src/utils/notificationXml.ts +52 -0
  66. package/src/utils/pathEncoder.ts +1 -6
@@ -1,6 +1,7 @@
1
1
  import { Container } from "./container.js";
2
2
  import { ForegroundTaskManager } from "../managers/foregroundTaskManager.js";
3
3
  import { BackgroundTaskManager } from "../managers/backgroundTaskManager.js";
4
+ import { NotificationQueue } from "../managers/notificationQueue.js";
4
5
  import { TaskManager } from "../services/taskManager.js";
5
6
  import { MessageManager } from "../managers/messageManager.js";
6
7
  import { AIManager } from "../managers/aiManager.js";
@@ -18,6 +19,7 @@ import { CronManager } from "../managers/cronManager.js";
18
19
  import { MemoryRuleManager } from "../managers/MemoryRuleManager.js";
19
20
  import { ReversionManager } from "../managers/reversionManager.js";
20
21
  import { SubagentManager } from "../managers/subagentManager.js";
22
+ import { ForkedAgentManager } from "../managers/forkedAgentManager.js";
21
23
  import { LiveConfigManager } from "../managers/liveConfigManager.js";
22
24
  import { ConfigurationService } from "../services/configurationService.js";
23
25
  import { ReversionService } from "../services/reversionService.js";
@@ -75,6 +77,9 @@ export function setupAgentContainer(
75
77
  const container = new Container();
76
78
  container.register("AgentOptions", options);
77
79
 
80
+ const notificationQueue = new NotificationQueue();
81
+ container.register("NotificationQueue", notificationQueue);
82
+
78
83
  const foregroundTaskManager = new ForegroundTaskManager(container);
79
84
  container.register("ForegroundTaskManager", foregroundTaskManager);
80
85
  container.register("ConfigurationService", configurationService);
@@ -283,6 +288,9 @@ export function setupAgentContainer(
283
288
  });
284
289
  container.register("SubagentManager", subagentManager);
285
290
 
291
+ const forkedAgentManager = new ForkedAgentManager(container);
292
+ container.register("ForkedAgentManager", forkedAgentManager);
293
+
286
294
  const aiManager = new AIManager(container, {
287
295
  callbacks: {
288
296
  ...callbacks,
@@ -1,5 +1,6 @@
1
1
  import type { Message } from "../types/index.js";
2
2
  import { convertImageToBase64 } from "./messageOperations.js";
3
+ import { taskNotificationToXml } from "./notificationXml.js";
3
4
  import { ChatCompletionMessageToolCall } from "openai/resources";
4
5
  import { stripAnsiColors } from "./stringUtils.js";
5
6
  import {
@@ -239,6 +240,14 @@ export function convertMessagesForAPI(
239
240
  text: `<local-command-stdout>\n${stripAnsiColors(block.result)}\n</local-command-stdout>`,
240
241
  });
241
242
  }
243
+
244
+ // If there is a task notification block, convert it back to XML
245
+ if (block.type === "task_notification") {
246
+ contentParts.push({
247
+ type: "text",
248
+ text: taskNotificationToXml(block),
249
+ });
250
+ }
242
251
  });
243
252
 
244
253
  // Only add user message if there is meaningful content
@@ -1,5 +1,10 @@
1
1
  import { randomUUID } from "crypto";
2
- import type { Message, Usage, ToolBlock } from "../types/index.js";
2
+ import type {
3
+ Message,
4
+ Usage,
5
+ ToolBlock,
6
+ TaskNotificationBlock,
7
+ } from "../types/index.js";
3
8
  import { MessageSource } from "../types/index.js";
4
9
  import { readFileSync } from "fs";
5
10
  import { extname } from "path";
@@ -135,6 +140,7 @@ export const addUserMessageToMessages = ({
135
140
  const textBlock = {
136
141
  type: "text" as const,
137
142
  content,
143
+ stage: "end" as const,
138
144
  ...(customCommandContent && { customCommandContent }),
139
145
  ...(source && { source }),
140
146
  };
@@ -584,3 +590,38 @@ export function getMessageContent(message: Message): string {
584
590
 
585
591
  return "";
586
592
  }
593
+
594
+ export interface AddNotificationMessageParams {
595
+ messages: Message[];
596
+ taskId: string;
597
+ taskType: "shell" | "agent";
598
+ status: "completed" | "failed" | "killed";
599
+ summary: string;
600
+ outputFile?: string;
601
+ }
602
+
603
+ export const addNotificationMessageToMessages = ({
604
+ messages,
605
+ taskId,
606
+ taskType,
607
+ status,
608
+ summary,
609
+ outputFile,
610
+ }: AddNotificationMessageParams): Message[] => {
611
+ const block: TaskNotificationBlock = {
612
+ type: "task_notification",
613
+ taskId,
614
+ taskType,
615
+ status,
616
+ summary,
617
+ ...(outputFile !== undefined && { outputFile }),
618
+ };
619
+
620
+ const notificationMessage: Message = {
621
+ id: generateMessageId(),
622
+ role: "user",
623
+ blocks: [block],
624
+ };
625
+
626
+ return [...messages, notificationMessage];
627
+ };
@@ -0,0 +1,52 @@
1
+ import type { TaskNotificationBlock } from "../types/messaging.js";
2
+
3
+ export function taskNotificationToXml(block: TaskNotificationBlock): string {
4
+ let xml = `<task-notification>\n`;
5
+ xml += `<task-id>${block.taskId}</task-id>\n`;
6
+ xml += `<task-type>${block.taskType}</task-type>\n`;
7
+ if (block.outputFile) {
8
+ xml += `<output-file>${block.outputFile}</output-file>\n`;
9
+ }
10
+ xml += `<status>${block.status}</status>\n`;
11
+ xml += `<summary>${block.summary}</summary>\n`;
12
+ xml += `</task-notification>`;
13
+ return xml;
14
+ }
15
+
16
+ function extractTag(xml: string, tag: string): string | null {
17
+ const regex = new RegExp(`<${tag}>(.*?)</${tag}>`, "s");
18
+ const match = xml.match(regex);
19
+ return match ? match[1] : null;
20
+ }
21
+
22
+ export function parseTaskNotificationXml(
23
+ xml: string,
24
+ ): TaskNotificationBlock | null {
25
+ try {
26
+ const taskId = extractTag(xml, "task-id");
27
+ const taskType = extractTag(xml, "task-type") as "shell" | "agent" | null;
28
+ const status = extractTag(xml, "status") as
29
+ | "completed"
30
+ | "failed"
31
+ | "killed"
32
+ | null;
33
+ const summary = extractTag(xml, "summary");
34
+
35
+ if (!taskId || !taskType || !status || !summary) {
36
+ return null;
37
+ }
38
+
39
+ const outputFile = extractTag(xml, "output-file") || undefined;
40
+
41
+ return {
42
+ type: "task_notification",
43
+ taskId,
44
+ taskType,
45
+ status,
46
+ summary,
47
+ ...(outputFile && { outputFile }),
48
+ };
49
+ } catch {
50
+ return null;
51
+ }
52
+ }
@@ -27,7 +27,6 @@ export interface PathEncodingOptions {
27
27
  pathSeparatorReplacement?: string; // Default: '-'
28
28
  spaceReplacement?: string; // Default: '_'
29
29
  invalidCharReplacement?: string; // Default: '_'
30
- preserveCase?: boolean; // Default: false (convert to lowercase)
31
30
  hashLength?: number; // Default: 8 characters
32
31
  }
33
32
 
@@ -65,7 +64,6 @@ export class PathEncoder {
65
64
  pathSeparatorReplacement: options.pathSeparatorReplacement ?? "-",
66
65
  spaceReplacement: options.spaceReplacement ?? "_",
67
66
  invalidCharReplacement: options.invalidCharReplacement ?? "_",
68
- preserveCase: options.preserveCase ?? false,
69
67
  hashLength: options.hashLength ?? 8,
70
68
  };
71
69
  this.constraints = this.getFilesystemConstraints();
@@ -109,10 +107,7 @@ export class PathEncoder {
109
107
  this.options.invalidCharReplacement,
110
108
  );
111
109
 
112
- // Convert to lowercase unless preserveCase is true
113
- if (!this.options.preserveCase) {
114
- encoded = encoded.toLowerCase();
115
- }
110
+ // Case is preserved
116
111
 
117
112
  // Handle length limit with hash
118
113
  if (encoded.length > this.options.maxLength) {