clay-server 2.26.0-beta.13 → 2.26.0-beta.15

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/lib/sdk-bridge.js +23 -2
  2. package/package.json +1 -1
package/lib/sdk-bridge.js CHANGED
@@ -437,7 +437,12 @@ function createSDKBridge(opts) {
437
437
  session.pendingAskUser = {};
438
438
  session.activeTaskToolIds = {};
439
439
  session.taskIdMap = {};
440
- session.rateLimitResetsAt = null; // clear on success
440
+ // Only clear rateLimitResetsAt on genuine success (non-zero cost).
441
+ // When rate-limited, the SDK sends result with zero cost right after
442
+ // rate_limit_event; clearing here would prevent auto-continue scheduling.
443
+ if (parsed.total_cost_usd && parsed.total_cost_usd > 0) {
444
+ session.rateLimitResetsAt = null;
445
+ }
441
446
 
442
447
  // Handle SDK execution errors: show the error to the user instead of
443
448
  // silently swallowing it. These have subtype "error_during_execution".
@@ -1267,7 +1272,23 @@ function createSDKBridge(opts) {
1267
1272
  sm.broadcastSessionList();
1268
1273
  }
1269
1274
  cleanupSessionWorker(session, worker);
1270
- if (session.onQueryComplete) {
1275
+ // Mark session as done so late rate_limit_event can detect race condition
1276
+ session.isProcessing = false;
1277
+ // Auto-continue on rate limit (scheduler sessions, or user setting)
1278
+ var doneDidScheduleAC = false;
1279
+ var doneACEnabled = session.onQueryComplete || (typeof opts.getAutoContinueSetting === "function" && opts.getAutoContinueSetting(session));
1280
+ if (session.rateLimitResetsAt && session.rateLimitResetsAt > Date.now()
1281
+ && doneACEnabled && !session.destroying) {
1282
+ var doneResetsAt = session.rateLimitResetsAt;
1283
+ session.rateLimitResetsAt = null;
1284
+ session.rateLimitAutoContinuePending = true;
1285
+ doneDidScheduleAC = true;
1286
+ console.log("[sdk-bridge] Rate limited (worker/query_done), scheduling auto-continue for session " + session.localId);
1287
+ if (typeof opts.scheduleMessage === "function") {
1288
+ opts.scheduleMessage(session, "continue", doneResetsAt);
1289
+ }
1290
+ }
1291
+ if (session.onQueryComplete && !doneDidScheduleAC) {
1271
1292
  try { session.onQueryComplete(session); } catch (err) {
1272
1293
  console.error("[sdk-bridge] onQueryComplete error:", err.message || err);
1273
1294
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clay-server",
3
- "version": "2.26.0-beta.13",
3
+ "version": "2.26.0-beta.15",
4
4
  "description": "Self-hosted Claude Code in your browser. Multi-session, multi-user, push notifications.",
5
5
  "bin": {
6
6
  "clay-server": "./bin/cli.js",