arisa 4.0.4 → 4.0.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arisa",
3
- "version": "4.0.4",
3
+ "version": "4.0.5",
4
4
  "description": "Telegram + Pi Agent modular assistant",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -3,6 +3,7 @@ import { ArtifactStore } from "../core/artifacts/artifact-store.js";
3
3
  import { ToolRegistry } from "../core/tools/tool-registry.js";
4
4
  import { TaskStore } from "../core/tasks/task-store.js";
5
5
  import { AgentManager } from "../core/agent/agent-manager.js";
6
+ import { getErrorMessage, getPiAuthIssue } from "../core/agent/auth-flow.js";
6
7
  import { createTelegramBot } from "../transport/telegram/bot.js";
7
8
  import { createToolProcessSupervisor } from "./tool-process-supervisor.js";
8
9
 
@@ -64,16 +65,22 @@ export async function createApp({ logger, runtimeOverrides, webhookUrl, setHttpR
64
65
  return {
65
66
  async start() {
66
67
  logger?.log("app", `validating Pi model ${config.pi.provider}/${config.pi.model}`);
68
+ let skipAgentStartupPrompts = false;
67
69
  try {
68
70
  await agentManager.validatePiAgent();
69
71
  } catch (error) {
72
+ const issue = getPiAuthIssue(error);
73
+ if (!issue) {
74
+ throw error;
75
+ }
76
+ skipAgentStartupPrompts = true;
77
+ logger?.error("app", `Pi auth validation failed; starting Telegram in auth recovery mode: ${getErrorMessage(error)}`);
70
78
  await bot.notifyPiAuthIssue?.(error);
71
- throw error;
72
79
  }
73
80
  await toolProcessSupervisor.start();
74
81
  logger?.log("app", "starting Telegram bot");
75
82
  try {
76
- await bot.start();
83
+ await bot.start({ skipAgentStartupPrompts });
77
84
  } catch (error) {
78
85
  await toolProcessSupervisor.stop();
79
86
  throw error;
@@ -562,26 +562,30 @@ export async function createTelegramBot({ config, artifactStore, toolRegistry, t
562
562
  });
563
563
 
564
564
  return {
565
- async start() {
565
+ async start({ skipAgentStartupPrompts = false } = {}) {
566
566
  config.telegram.chatMeta ||= {};
567
- for (const chatId of config.telegram.authorizedChatIds || []) {
568
- try {
569
- logger?.log("telegram", `generating startup message for chat ${chatId}`);
570
- const chatMeta = config.telegram.chatMeta[chatId] || {};
571
- const welcomePrompt = [
572
- "System event: Arisa has just started.",
573
- `chatId: ${chatId}`,
574
- `preferredTelegramLanguageCode: ${chatMeta.languageCode || "unknown"}`,
575
- chatMeta.username ? `username: ${chatMeta.username}` : null,
576
- chatMeta.firstName ? `firstName: ${chatMeta.firstName}` : null,
577
- "Send a short welcome-back message for Telegram.",
578
- "Keep it brief, warm, and natural.",
579
- "Use the user's Telegram language when possible.",
580
- "Do not mention internal implementation details."
581
- ].filter(Boolean).join("\n");
582
- await enqueuePrompt({ chatId, prompt: welcomePrompt, label: "startup message" });
583
- } catch (error) {
584
- logger?.log("telegram", `startup message failed for chat ${chatId}: ${error instanceof Error ? error.message : String(error)}`);
567
+ if (skipAgentStartupPrompts) {
568
+ logger?.log("telegram", "skipping agent startup messages because Pi auth needs attention");
569
+ } else {
570
+ for (const chatId of config.telegram.authorizedChatIds || []) {
571
+ try {
572
+ logger?.log("telegram", `generating startup message for chat ${chatId}`);
573
+ const chatMeta = config.telegram.chatMeta[chatId] || {};
574
+ const welcomePrompt = [
575
+ "System event: Arisa has just started.",
576
+ `chatId: ${chatId}`,
577
+ `preferredTelegramLanguageCode: ${chatMeta.languageCode || "unknown"}`,
578
+ chatMeta.username ? `username: ${chatMeta.username}` : null,
579
+ chatMeta.firstName ? `firstName: ${chatMeta.firstName}` : null,
580
+ "Send a short welcome-back message for Telegram.",
581
+ "Keep it brief, warm, and natural.",
582
+ "Use the user's Telegram language when possible.",
583
+ "Do not mention internal implementation details."
584
+ ].filter(Boolean).join("\n");
585
+ await enqueuePrompt({ chatId, prompt: welcomePrompt, label: "startup message" });
586
+ } catch (error) {
587
+ logger?.log("telegram", `startup message failed for chat ${chatId}: ${error instanceof Error ? error.message : String(error)}`);
588
+ }
585
589
  }
586
590
  }
587
591
  await bot.api.setMyCommands([