@madh-io/alfred-ai 0.3.2 → 0.3.4
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/bundle/index.js +30 -7
- package/package.json +1 -1
package/bundle/index.js
CHANGED
|
@@ -1662,15 +1662,37 @@ var init_prompt_builder = __esm({
|
|
|
1662
1662
|
"../llm/dist/prompt-builder.js"() {
|
|
1663
1663
|
"use strict";
|
|
1664
1664
|
PromptBuilder = class {
|
|
1665
|
-
buildSystemPrompt(memories) {
|
|
1666
|
-
|
|
1665
|
+
buildSystemPrompt(memories, skills) {
|
|
1666
|
+
const os = process.platform === "darwin" ? "macOS" : process.platform === "win32" ? "Windows" : "Linux";
|
|
1667
|
+
const homeDir = process.env["HOME"] || process.env["USERPROFILE"] || "~";
|
|
1668
|
+
let prompt = `You are Alfred, a personal AI assistant. You run on ${os} (home: ${homeDir}).
|
|
1669
|
+
|
|
1670
|
+
## How you work
|
|
1671
|
+
- You have tools (skills) that you MUST use proactively to help the user.
|
|
1672
|
+
- When a user asks you to do something, USE YOUR TOOLS. Do not just talk about what you could do \u2014 actually do it.
|
|
1673
|
+
- If the user asks about files, folders, documents, or anything on their computer: use the shell tool to look at the filesystem (ls, find, cat, etc.).
|
|
1674
|
+
- If the user asks for information you don't have: use web_search to look it up online.
|
|
1675
|
+
- If the user asks for the date/time: use system_info with category "datetime".
|
|
1676
|
+
- If the user asks you to remember something: use the memory tool immediately.
|
|
1677
|
+
- If a tool fails or is denied, explain why and suggest alternatives.
|
|
1678
|
+
- Be concise but thorough. Respond in the same language the user writes in.
|
|
1679
|
+
|
|
1680
|
+
## Common paths on ${os}
|
|
1681
|
+
${os === "macOS" ? "- Documents: ~/Documents\n- Desktop: ~/Desktop\n- Downloads: ~/Downloads" : os === "Windows" ? "- Documents: ~/Documents\n- Desktop: ~/Desktop\n- Downloads: ~/Downloads" : "- Documents: ~/Documents\n- Desktop: ~/Desktop\n- Downloads: ~/Downloads"}`;
|
|
1682
|
+
if (skills && skills.length > 0) {
|
|
1683
|
+
prompt += "\n\n## Available tools\n";
|
|
1684
|
+
for (const s of skills) {
|
|
1685
|
+
prompt += `- **${s.name}** (${s.riskLevel}): ${s.description}
|
|
1686
|
+
`;
|
|
1687
|
+
}
|
|
1688
|
+
}
|
|
1667
1689
|
if (memories && memories.length > 0) {
|
|
1668
|
-
prompt += "\n\
|
|
1690
|
+
prompt += "\n\n## Memories about this user\n";
|
|
1669
1691
|
for (const m of memories) {
|
|
1670
1692
|
prompt += `- [${m.category}] ${m.key}: ${m.value}
|
|
1671
1693
|
`;
|
|
1672
1694
|
}
|
|
1673
|
-
prompt += "\
|
|
1695
|
+
prompt += "\nUse these memories to personalize your responses. When the user tells you new facts or preferences, use the memory tool to save them.";
|
|
1674
1696
|
} else {
|
|
1675
1697
|
prompt += "\n\nWhen the user tells you facts about themselves or preferences, use the memory tool to save them for future reference.";
|
|
1676
1698
|
}
|
|
@@ -3884,11 +3906,12 @@ var init_message_pipeline = __esm({
|
|
|
3884
3906
|
} catch {
|
|
3885
3907
|
}
|
|
3886
3908
|
}
|
|
3887
|
-
const
|
|
3909
|
+
const skillMetas = this.skillRegistry ? this.skillRegistry.getAll().map((s) => s.metadata) : void 0;
|
|
3910
|
+
const tools = skillMetas ? this.promptBuilder.buildTools(skillMetas) : void 0;
|
|
3911
|
+
const system = this.promptBuilder.buildSystemPrompt(memories, skillMetas);
|
|
3888
3912
|
const allMessages = this.promptBuilder.buildMessages(history);
|
|
3889
3913
|
allMessages.push({ role: "user", content: message.text });
|
|
3890
3914
|
const messages = this.trimToContextWindow(system, allMessages);
|
|
3891
|
-
const tools = this.skillRegistry ? this.promptBuilder.buildTools(this.skillRegistry.getAll().map((s) => s.metadata)) : void 0;
|
|
3892
3915
|
let response;
|
|
3893
3916
|
let iteration = 0;
|
|
3894
3917
|
while (true) {
|
|
@@ -3921,7 +3944,7 @@ var init_message_pipeline = __esm({
|
|
|
3921
3944
|
const toolResultBlocks = [];
|
|
3922
3945
|
for (const toolCall of response.toolCalls) {
|
|
3923
3946
|
const result = await this.executeToolCall(toolCall, {
|
|
3924
|
-
userId:
|
|
3947
|
+
userId: message.userId,
|
|
3925
3948
|
chatId: message.chatId,
|
|
3926
3949
|
chatType: message.chatType,
|
|
3927
3950
|
platform: message.platform,
|