@madh-io/alfred-ai 0.3.3 → 0.3.5

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 (2) hide show
  1. package/bundle/index.js +20 -2
  2. package/package.json +1 -1
package/bundle/index.js CHANGED
@@ -3914,6 +3914,7 @@ var init_message_pipeline = __esm({
3914
3914
  const messages = this.trimToContextWindow(system, allMessages);
3915
3915
  let response;
3916
3916
  let iteration = 0;
3917
+ const toolLog = [];
3917
3918
  while (true) {
3918
3919
  response = await this.llm.complete({
3919
3920
  messages,
@@ -3944,7 +3945,7 @@ var init_message_pipeline = __esm({
3944
3945
  const toolResultBlocks = [];
3945
3946
  for (const toolCall of response.toolCalls) {
3946
3947
  const result = await this.executeToolCall(toolCall, {
3947
- userId: user.id,
3948
+ userId: message.userId,
3948
3949
  chatId: message.chatId,
3949
3950
  chatType: message.chatType,
3950
3951
  platform: message.platform,
@@ -3956,11 +3957,28 @@ var init_message_pipeline = __esm({
3956
3957
  content: result.content,
3957
3958
  is_error: result.isError
3958
3959
  });
3960
+ toolLog.push({
3961
+ tool: toolCall.name,
3962
+ input: toolCall.input,
3963
+ output: result.content,
3964
+ isError: result.isError
3965
+ });
3959
3966
  }
3960
3967
  messages.push({ role: "user", content: toolResultBlocks });
3961
3968
  }
3962
3969
  const responseText = response.content || "(no response)";
3963
- this.conversationManager.addMessage(conversation.id, "assistant", responseText, response.toolCalls ? JSON.stringify(response.toolCalls) : void 0);
3970
+ let savedContent = responseText;
3971
+ if (toolLog.length > 0) {
3972
+ const toolSummary = toolLog.map((t) => {
3973
+ const inputStr = Object.entries(t.input).map(([k, v]) => `${k}=${v}`).join(", ");
3974
+ const outputPreview = String(t.output).slice(0, 500);
3975
+ return `[${t.tool}(${inputStr}) \u2192 ${outputPreview}]`;
3976
+ }).join("\n");
3977
+ savedContent = `${toolSummary}
3978
+
3979
+ ${responseText}`;
3980
+ }
3981
+ this.conversationManager.addMessage(conversation.id, "assistant", savedContent);
3964
3982
  const duration = Date.now() - startTime;
3965
3983
  this.logger.info({ duration, tokens: response.usage, stopReason: response.stopReason, toolIterations: iteration }, "Message processed");
3966
3984
  return responseText;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@madh-io/alfred-ai",
3
- "version": "0.3.3",
3
+ "version": "0.3.5",
4
4
  "description": "Alfred — Personal AI Assistant across Telegram, Discord, WhatsApp, Matrix & Signal",
5
5
  "type": "module",
6
6
  "bin": {