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.
- package/README.md +0 -13
- package/builtin/skills/settings/ENV.md +4 -0
- package/builtin/skills/settings/HOOKS.md +4 -0
- package/builtin/skills/settings/MODELS.md +4 -0
- package/builtin/skills/settings/SKILL.md +5 -1
- package/builtin/skills/settings/SKILLS.md +13 -0
- package/dist/agent.d.ts +2 -2
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +3 -2
- package/dist/managers/aiManager.d.ts.map +1 -1
- package/dist/managers/aiManager.js +0 -4
- package/dist/managers/backgroundTaskManager.d.ts.map +1 -1
- package/dist/managers/backgroundTaskManager.js +9 -2
- package/dist/managers/cronManager.d.ts.map +1 -1
- package/dist/managers/cronManager.js +1 -0
- package/dist/managers/permissionManager.d.ts.map +1 -1
- package/dist/managers/permissionManager.js +9 -5
- package/dist/managers/slashCommandManager.d.ts.map +1 -1
- package/dist/managers/slashCommandManager.js +2 -0
- package/dist/prompts/index.d.ts +11 -3
- package/dist/prompts/index.d.ts.map +1 -1
- package/dist/prompts/index.js +97 -11
- package/dist/services/configurationService.d.ts +1 -1
- package/dist/services/configurationService.d.ts.map +1 -1
- package/dist/services/configurationService.js +26 -15
- package/dist/services/fileWatcher.d.ts.map +1 -1
- package/dist/services/fileWatcher.js +12 -2
- package/dist/services/hook.d.ts.map +1 -1
- package/dist/services/hook.js +6 -1
- package/dist/services/session.d.ts.map +1 -1
- package/dist/services/session.js +2 -14
- package/dist/tools/bashTool.d.ts.map +1 -1
- package/dist/tools/bashTool.js +30 -19
- package/dist/tools/webFetchTool.d.ts.map +1 -1
- package/dist/tools/webFetchTool.js +1 -1
- package/dist/tools/writeTool.d.ts.map +1 -1
- package/dist/tools/writeTool.js +6 -0
- package/dist/types/core.d.ts +2 -0
- package/dist/types/core.d.ts.map +1 -1
- package/dist/types/core.js +2 -0
- package/dist/utils/bashParser.d.ts +4 -0
- package/dist/utils/bashParser.d.ts.map +1 -1
- package/dist/utils/bashParser.js +23 -0
- package/dist/utils/messageOperations.d.ts +10 -0
- package/dist/utils/messageOperations.d.ts.map +1 -1
- package/dist/utils/messageOperations.js +51 -0
- package/dist/utils/stringUtils.d.ts +4 -0
- package/dist/utils/stringUtils.d.ts.map +1 -1
- package/dist/utils/stringUtils.js +21 -0
- package/package.json +1 -1
- package/src/agent.ts +3 -2
- package/src/managers/aiManager.ts +0 -6
- package/src/managers/backgroundTaskManager.ts +9 -2
- package/src/managers/cronManager.ts +1 -0
- package/src/managers/permissionManager.ts +9 -4
- package/src/managers/slashCommandManager.ts +2 -0
- package/src/prompts/index.ts +111 -9
- package/src/services/configurationService.ts +34 -20
- package/src/services/fileWatcher.ts +13 -2
- package/src/services/hook.ts +4 -1
- package/src/services/session.ts +2 -21
- package/src/tools/bashTool.ts +32 -22
- package/src/tools/webFetchTool.ts +3 -2
- package/src/tools/writeTool.ts +10 -0
- package/src/types/core.ts +4 -0
- package/src/utils/bashParser.ts +24 -0
- package/src/utils/messageOperations.ts +57 -0
- 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
|
+
}
|
package/src/utils/stringUtils.ts
CHANGED
|
@@ -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
|
+
}
|