niahere 0.2.80 → 0.2.81

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/package.json +1 -1
  2. package/src/chat/engine.ts +23 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "niahere",
3
- "version": "0.2.80",
3
+ "version": "0.2.81",
4
4
  "description": "A personal AI assistant daemon — chat, scheduled jobs, persona system, extensible via skills.",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -29,6 +29,8 @@ const IDLE_TIMEOUT = 10 * 60 * 1000; // 10 minutes
29
29
  const LONG_RUNNING_WARN = 30 * 60 * 1000; // 30 minutes
30
30
  const MAX_SEND_RETRIES = 2;
31
31
  const SEND_RETRY_DELAYS = [3_000, 8_000];
32
+ const GENERIC_CHAT_ERROR =
33
+ "Claude/Anthropic returned an error without details. This is usually temporary; please try again shortly.";
32
34
 
33
35
  interface SDKUserMessage {
34
36
  type: "user";
@@ -93,6 +95,15 @@ export function buildContentBlocks(text: string, attachments?: Attachment[]): Me
93
95
  return blocks as MessageParam["content"];
94
96
  }
95
97
 
98
+ /** Convert SDK error text into a channel-safe chat response. */
99
+ export function formatChatError(rawError: string | null | undefined): string {
100
+ const error = rawError?.trim();
101
+ if (!error || error.toLowerCase() === "unknown error") {
102
+ return GENERIC_CHAT_ERROR;
103
+ }
104
+ return `[error] ${error}`;
105
+ }
106
+
96
107
  /**
97
108
  * Push-based async iterable for streaming user messages to the SDK.
98
109
  * Keeps the query subprocess alive between messages.
@@ -505,7 +516,18 @@ export async function createChatEngine(opts: EngineOptions): Promise<ChatEngine>
505
516
  retryPending.onActivity?.("retrying after API error...");
506
517
  stream!.push(retryPending.userMessage);
507
518
  } else {
508
- const errorText = `[error] ${rawError}`;
519
+ const errorText = formatChatError(rawError);
520
+ log.error(
521
+ {
522
+ room,
523
+ error: rawError,
524
+ errors,
525
+ subtype: msg.subtype,
526
+ terminal_reason: msg.terminal_reason,
527
+ session_id: msg.session_id,
528
+ },
529
+ "chat send failed with SDK result error",
530
+ );
509
531
  await ActiveEngine.unregister(room);
510
532
  clearLongRunningTimer();
511
533
  pending.resolve({ result: errorText, costUsd: 0, turns: 0 });