@madh-io/alfred-ai 0.3.1 → 0.3.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.
- package/bundle/index.js +51 -9
- 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
|
}
|
|
@@ -2239,8 +2261,8 @@ var init_system_info = __esm({
|
|
|
2239
2261
|
properties: {
|
|
2240
2262
|
category: {
|
|
2241
2263
|
type: "string",
|
|
2242
|
-
enum: ["general", "memory", "uptime"],
|
|
2243
|
-
description: "Category of system info"
|
|
2264
|
+
enum: ["general", "memory", "uptime", "datetime"],
|
|
2265
|
+
description: "Category of system info (use datetime for current date/time)"
|
|
2244
2266
|
}
|
|
2245
2267
|
},
|
|
2246
2268
|
required: ["category"]
|
|
@@ -2255,6 +2277,8 @@ var init_system_info = __esm({
|
|
|
2255
2277
|
return this.getMemoryInfo();
|
|
2256
2278
|
case "uptime":
|
|
2257
2279
|
return this.getUptimeInfo();
|
|
2280
|
+
case "datetime":
|
|
2281
|
+
return this.getDateTimeInfo();
|
|
2258
2282
|
default:
|
|
2259
2283
|
return {
|
|
2260
2284
|
success: false,
|
|
@@ -2304,6 +2328,21 @@ var init_system_info = __esm({
|
|
|
2304
2328
|
display: `Uptime: ${info.formatted}`
|
|
2305
2329
|
};
|
|
2306
2330
|
}
|
|
2331
|
+
getDateTimeInfo() {
|
|
2332
|
+
const now = /* @__PURE__ */ new Date();
|
|
2333
|
+
const info = {
|
|
2334
|
+
iso: now.toISOString(),
|
|
2335
|
+
date: now.toLocaleDateString("de-DE", { weekday: "long", year: "numeric", month: "long", day: "numeric" }),
|
|
2336
|
+
time: now.toLocaleTimeString("de-DE"),
|
|
2337
|
+
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
2338
|
+
timestamp: now.getTime()
|
|
2339
|
+
};
|
|
2340
|
+
return {
|
|
2341
|
+
success: true,
|
|
2342
|
+
data: info,
|
|
2343
|
+
display: `${info.date}, ${info.time} (${info.timezone})`
|
|
2344
|
+
};
|
|
2345
|
+
}
|
|
2307
2346
|
};
|
|
2308
2347
|
}
|
|
2309
2348
|
});
|
|
@@ -3867,11 +3906,12 @@ var init_message_pipeline = __esm({
|
|
|
3867
3906
|
} catch {
|
|
3868
3907
|
}
|
|
3869
3908
|
}
|
|
3870
|
-
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);
|
|
3871
3912
|
const allMessages = this.promptBuilder.buildMessages(history);
|
|
3872
3913
|
allMessages.push({ role: "user", content: message.text });
|
|
3873
3914
|
const messages = this.trimToContextWindow(system, allMessages);
|
|
3874
|
-
const tools = this.skillRegistry ? this.promptBuilder.buildTools(this.skillRegistry.getAll().map((s) => s.metadata)) : void 0;
|
|
3875
3915
|
let response;
|
|
3876
3916
|
let iteration = 0;
|
|
3877
3917
|
while (true) {
|
|
@@ -3906,6 +3946,7 @@ var init_message_pipeline = __esm({
|
|
|
3906
3946
|
const result = await this.executeToolCall(toolCall, {
|
|
3907
3947
|
userId: user.id,
|
|
3908
3948
|
chatId: message.chatId,
|
|
3949
|
+
chatType: message.chatType,
|
|
3909
3950
|
platform: message.platform,
|
|
3910
3951
|
conversationId: conversation.id
|
|
3911
3952
|
});
|
|
@@ -3940,7 +3981,8 @@ var init_message_pipeline = __esm({
|
|
|
3940
3981
|
action: toolCall.name,
|
|
3941
3982
|
riskLevel: skill.metadata.riskLevel,
|
|
3942
3983
|
platform: context.platform,
|
|
3943
|
-
chatId: context.chatId
|
|
3984
|
+
chatId: context.chatId,
|
|
3985
|
+
chatType: context.chatType
|
|
3944
3986
|
});
|
|
3945
3987
|
if (!evaluation.allowed) {
|
|
3946
3988
|
this.logger.warn({ tool: toolCall.name, reason: evaluation.reason, rule: evaluation.matchedRule?.id }, "Skill execution denied by security rules");
|