wave-agent-sdk 0.12.0 → 0.12.2

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 (68) hide show
  1. package/README.md +0 -13
  2. package/builtin/skills/settings/ENV.md +4 -0
  3. package/builtin/skills/settings/HOOKS.md +4 -0
  4. package/builtin/skills/settings/MODELS.md +4 -0
  5. package/builtin/skills/settings/SKILL.md +5 -1
  6. package/builtin/skills/settings/SKILLS.md +13 -0
  7. package/dist/agent.d.ts +2 -2
  8. package/dist/agent.d.ts.map +1 -1
  9. package/dist/agent.js +3 -2
  10. package/dist/managers/aiManager.d.ts.map +1 -1
  11. package/dist/managers/aiManager.js +0 -4
  12. package/dist/managers/backgroundTaskManager.d.ts.map +1 -1
  13. package/dist/managers/backgroundTaskManager.js +9 -2
  14. package/dist/managers/cronManager.d.ts.map +1 -1
  15. package/dist/managers/cronManager.js +1 -0
  16. package/dist/managers/permissionManager.d.ts.map +1 -1
  17. package/dist/managers/permissionManager.js +9 -5
  18. package/dist/managers/slashCommandManager.d.ts.map +1 -1
  19. package/dist/managers/slashCommandManager.js +2 -0
  20. package/dist/prompts/index.d.ts +11 -3
  21. package/dist/prompts/index.d.ts.map +1 -1
  22. package/dist/prompts/index.js +97 -11
  23. package/dist/services/configurationService.d.ts +1 -1
  24. package/dist/services/configurationService.d.ts.map +1 -1
  25. package/dist/services/configurationService.js +26 -15
  26. package/dist/services/fileWatcher.d.ts.map +1 -1
  27. package/dist/services/fileWatcher.js +12 -2
  28. package/dist/services/hook.d.ts.map +1 -1
  29. package/dist/services/hook.js +6 -1
  30. package/dist/services/session.d.ts.map +1 -1
  31. package/dist/services/session.js +2 -14
  32. package/dist/tools/bashTool.d.ts.map +1 -1
  33. package/dist/tools/bashTool.js +30 -19
  34. package/dist/tools/webFetchTool.d.ts.map +1 -1
  35. package/dist/tools/webFetchTool.js +1 -1
  36. package/dist/tools/writeTool.d.ts.map +1 -1
  37. package/dist/tools/writeTool.js +6 -0
  38. package/dist/types/core.d.ts +2 -0
  39. package/dist/types/core.d.ts.map +1 -1
  40. package/dist/types/core.js +2 -0
  41. package/dist/utils/bashParser.d.ts +4 -0
  42. package/dist/utils/bashParser.d.ts.map +1 -1
  43. package/dist/utils/bashParser.js +23 -0
  44. package/dist/utils/messageOperations.d.ts +10 -0
  45. package/dist/utils/messageOperations.d.ts.map +1 -1
  46. package/dist/utils/messageOperations.js +51 -0
  47. package/dist/utils/stringUtils.d.ts +4 -0
  48. package/dist/utils/stringUtils.d.ts.map +1 -1
  49. package/dist/utils/stringUtils.js +21 -0
  50. package/package.json +1 -1
  51. package/src/agent.ts +3 -2
  52. package/src/managers/aiManager.ts +0 -6
  53. package/src/managers/backgroundTaskManager.ts +9 -2
  54. package/src/managers/cronManager.ts +1 -0
  55. package/src/managers/permissionManager.ts +9 -4
  56. package/src/managers/slashCommandManager.ts +2 -0
  57. package/src/prompts/index.ts +111 -9
  58. package/src/services/configurationService.ts +34 -20
  59. package/src/services/fileWatcher.ts +13 -2
  60. package/src/services/hook.ts +4 -1
  61. package/src/services/session.ts +2 -21
  62. package/src/tools/bashTool.ts +32 -22
  63. package/src/tools/webFetchTool.ts +3 -2
  64. package/src/tools/writeTool.ts +10 -0
  65. package/src/types/core.ts +4 -0
  66. package/src/utils/bashParser.ts +24 -0
  67. package/src/utils/messageOperations.ts +57 -0
  68. package/src/utils/stringUtils.ts +20 -0
@@ -614,6 +614,32 @@ export const removeLastUserMessage = (messages: Message[]): Message[] => {
614
614
  return newMessages;
615
615
  };
616
616
 
617
+ /**
618
+ * Efficiently clone a message for UI freezing.
619
+ * Clones the message object and its blocks array, but reuses string references.
620
+ */
621
+ export function cloneMessage(message: Message): Message {
622
+ return {
623
+ ...message,
624
+ blocks: message.blocks.map((block) => {
625
+ const clonedBlock = { ...block };
626
+ // Deep clone arrays/objects within blocks if they exist
627
+ if (clonedBlock.type === "tool" && clonedBlock.images) {
628
+ clonedBlock.images = clonedBlock.images.map((img) => ({ ...img }));
629
+ } else if (clonedBlock.type === "image" && clonedBlock.imageUrls) {
630
+ clonedBlock.imageUrls = [...clonedBlock.imageUrls];
631
+ } else if (clonedBlock.type === "file_history" && clonedBlock.snapshots) {
632
+ clonedBlock.snapshots = clonedBlock.snapshots.map((s) => ({ ...s }));
633
+ }
634
+ return clonedBlock;
635
+ }) as Message["blocks"],
636
+ // Clone additionalFields if it exists
637
+ ...(message.additionalFields
638
+ ? { additionalFields: { ...message.additionalFields } }
639
+ : {}),
640
+ };
641
+ }
642
+
617
643
  /**
618
644
  * Helper to format tool and token summary
619
645
  */
@@ -631,3 +657,34 @@ export function formatToolTokenSummary(
631
657
  summary += ")";
632
658
  return summary;
633
659
  }
660
+
661
+ /**
662
+ * Extracts displayable text from a Message object, handling various block types.
663
+ * Returns the first available content block.
664
+ */
665
+ export function getMessageContent(message: Message): string {
666
+ // Find first available content block
667
+ const textBlock = message.blocks.find((block) => block.type === "text");
668
+ if (textBlock && "content" in textBlock) {
669
+ return textBlock.content;
670
+ }
671
+
672
+ const slashBlock = message.blocks.find((block) => block.type === "slash");
673
+ if (slashBlock && "command" in slashBlock) {
674
+ return `/${slashBlock.command}${slashBlock.args ? ` ${slashBlock.args}` : ""}`;
675
+ }
676
+
677
+ const bangBlock = message.blocks.find((block) => block.type === "bang");
678
+ if (bangBlock && "command" in bangBlock) {
679
+ return `!${bangBlock.command}`;
680
+ }
681
+
682
+ const compressBlock = message.blocks.find(
683
+ (block) => block.type === "compress",
684
+ );
685
+ if (compressBlock && "content" in compressBlock) {
686
+ return compressBlock.content;
687
+ }
688
+
689
+ return "";
690
+ }
@@ -91,3 +91,23 @@ export const stripAnsiColors = (text: string): string => {
91
91
  export function formatLineNumberPrefix(lineNumber: number): string {
92
92
  return `${lineNumber.toString().padStart(6)}\t`;
93
93
  }
94
+
95
+ /**
96
+ * Efficiently get the last N lines of a string without splitting the whole string.
97
+ */
98
+ export function getLastLines(text: string, count: number): string {
99
+ if (!text || count <= 0) return "";
100
+ let pos = text.length;
101
+ let found = 0;
102
+ while (pos > 0 && found < count) {
103
+ const nextNewline = text.lastIndexOf("\n", pos - 1);
104
+ if (nextNewline === -1) {
105
+ pos = 0;
106
+ break;
107
+ } else {
108
+ pos = nextNewline;
109
+ found++;
110
+ }
111
+ }
112
+ return text.substring(pos === 0 && found < count ? 0 : pos + 1);
113
+ }