@love-moon/ai-sdk 0.17.0 → 0.17.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @love-moon/ai-sdk
2
2
 
3
+ ## 0.17.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 7e92c0f: When a task's model quota runs out ("You've hit your session limit · resets
8
+ 1:20am"), fire no longer stops there. It reads the reset time, schedules a
9
+ one-off Conductor scheduled message to continue a minute or few after the
10
+ reset, and posts a single notice. Messages that arrive while waiting are queued
11
+ and handed to the resume turn together instead of each failing with another
12
+ "处理失败". The resume shows up in the task's scheduled-message list, where it
13
+ can be canceled. This also covers a quota hit while Claude works on its own
14
+ between user turns: ai-sdk now reports such a background turn that ends in an
15
+ error result (or a process exit after it) as a failed turn.
16
+
3
17
  ## 0.17.0
4
18
 
5
19
  ### Patch Changes
@@ -553,6 +553,8 @@ export class ClaudeAgentSdkSession extends EventEmitter {
553
553
  status_done_line: payload?.status_done_line,
554
554
  reply_preview: payload?.reply_preview,
555
555
  thread_id: this.sessionId || undefined,
556
+ // A turn claude ran on its own, between user turns (see dispatchLiveMessage).
557
+ ...(payload?.background === true ? { background: true } : {}),
556
558
  };
557
559
  this.updateCurrentTurnStatus(normalized);
558
560
  const snapshot = this.getCurrentTurnStatus();
@@ -1123,6 +1125,17 @@ export class ClaudeAgentSdkSession extends EventEmitter {
1123
1125
  if (backgroundTurn) {
1124
1126
  await this.finishBackgroundTurn(backgroundTurn, null, failure);
1125
1127
  }
1128
+ else if (failure && !this.closeRequested && !this.currentTurn) {
1129
+ // The process died after a background turn's result, e.g. an error
1130
+ // result (quota hit) makes claude exit right after reporting it. No turn
1131
+ // is left to own the failure, so report it as a background one.
1132
+ await this.emitWorkingStatus({
1133
+ phase: "turn_failed",
1134
+ status_done_line: failure?.message || String(failure),
1135
+ reply_in_progress: false,
1136
+ background: true,
1137
+ });
1138
+ }
1126
1139
  }
1127
1140
  /**
1128
1141
  * Routes the long-lived query's output. A result ends the pending turn when it
@@ -1155,9 +1168,13 @@ export class ClaudeAgentSdkSession extends EventEmitter {
1155
1168
  await this.finishBackgroundTurn(target, message);
1156
1169
  }
1157
1170
  async finishBackgroundTurn(backgroundTurn, resultMessage, failure = null) {
1158
- const failed = Boolean(failure) || (resultMessage && resultMessage.subtype !== "success");
1171
+ // An error result (e.g. "You've hit your session limit") can carry subtype
1172
+ // "success"; `is_error` is what marks it.
1173
+ const errorResult = Boolean(resultMessage && (resultMessage.subtype !== "success" || resultMessage.is_error === true));
1174
+ const failed = Boolean(failure) || errorResult;
1159
1175
  const text = normalizeText(resultMessage?.result);
1160
- if (!failed && text && !backgroundTurn.emittedAssistantMessage) {
1176
+ // An error result's text still reaches the chat, as it always has.
1177
+ if (!failure && resultMessage?.subtype === "success" && text && !backgroundTurn.emittedAssistantMessage) {
1161
1178
  await this.emitAssistantMessage(text);
1162
1179
  }
1163
1180
  // A pending user turn owns the working status.
@@ -1167,9 +1184,11 @@ export class ClaudeAgentSdkSession extends EventEmitter {
1167
1184
  await this.emitTerminalWorkingStatus(backgroundTurn, failed
1168
1185
  ? {
1169
1186
  phase: "turn_failed",
1170
- status_done_line: failure?.message || extractResultErrorMessage(resultMessage),
1187
+ status_done_line: failure?.message ||
1188
+ (resultMessage?.is_error === true && text ? text : extractResultErrorMessage(resultMessage)),
1189
+ background: true,
1171
1190
  }
1172
- : { phase: "turn_completed", status_done_line: "claude finished" });
1191
+ : { phase: "turn_completed", status_done_line: "claude finished", background: true });
1173
1192
  }
1174
1193
  async runTurn(promptText, { useInitialImages = false, media: mediaInput, contextFiles, onProgress = null, jsonSchema = null, suppressReply = false } = {}) {
1175
1194
  if (this.closeRequested) {
@@ -1262,8 +1281,11 @@ export class ClaudeAgentSdkSession extends EventEmitter {
1262
1281
  reason: "missing_result",
1263
1282
  });
1264
1283
  }
1265
- if (resultMessage.subtype !== "success") {
1266
- const errorMessage = extractResultErrorMessage(resultMessage);
1284
+ // An error result (e.g. "You've hit your session limit") can carry subtype
1285
+ // "success"; `is_error` is what marks it.
1286
+ if (resultMessage.subtype !== "success" || resultMessage.is_error === true) {
1287
+ const errorText = resultMessage.is_error === true ? normalizeText(resultMessage.result) : "";
1288
+ const errorMessage = errorText || extractResultErrorMessage(resultMessage);
1267
1289
  this.maybeEmitAuthRequired(errorMessage, errorMessage);
1268
1290
  await this.emitTerminalWorkingStatus(currentTurn, {
1269
1291
  phase: "turn_failed",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@love-moon/ai-sdk",
3
- "version": "0.17.0",
3
+ "version": "0.17.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/lovemoon-ai/conductor.git"
@@ -53,12 +53,12 @@
53
53
  "zod": "^4.1.5"
54
54
  },
55
55
  "optionalDependencies": {
56
- "@love-moon/chat-web": "^0.17.0"
56
+ "@love-moon/chat-web": "^0.17.1"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@types/node": "^22.10.2",
60
60
  "tsx": "^4.20.6",
61
61
  "typescript": "^5.6.3"
62
62
  },
63
- "gitCommitId": "2799bc0"
63
+ "gitCommitId": "e3dbbad"
64
64
  }