heartcode 0.1.44 → 0.1.45

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
@@ -2,6 +2,14 @@
2
2
 
3
3
  What changed in each version of HeartCode, newest first.
4
4
 
5
+ ## 0.1.45 (2026-11-03)
6
+
7
+ - **Rate limits hand the work on**: a helper whose model answers 429 goes to your next model at
8
+ once, instead of waiting a minute and asking the same one again (and again). When the provider
9
+ says its quota is out for longer than a minute (Gemini: "retry in 13 hours"), HeartCode doesn't
10
+ wait at all, remembers it until then, tries that model last, and tells the orchestrator it's out
11
+ of quota so it picks another.
12
+
5
13
  ## 0.1.44 (2026-11-03)
6
14
 
7
15
  - **Orchestrators first**: with Pick on "an orchestrator hands it out", the model shown (status bar,
package/bin/heartcode.js CHANGED
@@ -225,6 +225,7 @@ class App {
225
225
  this.director = new Director(this) // the manage tool: skills, MCP servers and settings by asking
226
226
  this.later = [] // setting changes that wait until the current message is done
227
227
  this.failures = {} // "provider model" → failed requests this session (engine: onFail)
228
+ this.resting = {} // "provider model" → until when it's out of quota (the server said so: engine: onFail)
228
229
  this.loadProjectModels() // the model(s) you last chose for this folder (.heartcode/models.json)
229
230
  }
230
231
 
@@ -342,6 +343,7 @@ class App {
342
343
  if (e.name === 'AbortError') return
343
344
  const k = `${t.provider} ${t.model}`
344
345
  this.failures[k] = (this.failures[k] ?? 0) + 1
346
+ if (Number(e.retryAfter) > 60) this.resting[k] = Date.now() + Number(e.retryAfter) * 1000
345
347
  }
346
348
  // the model list (settings page): another model answered
347
349
  client.onSwitch = (t) => {
@@ -792,6 +794,7 @@ class App {
792
794
  }
793
795
  }
794
796
  this.s.failures = this.failures
797
+ this.s.resting = this.resting
795
798
  if (this.allowTools?.length) this.s.allowTools = toolNames(this.allowTools) // headless --allowedTools
796
799
  if (this.denyTools?.length) this.s.denyTools = toolNames(this.denyTools)
797
800
  if (this.cfg.maxTurns) this.s.maxTurns = this.cfg.maxTurns
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "heartcode",
3
- "version": "0.1.44",
3
+ "version": "0.1.45",
4
4
  "description": "A coding CLI for any local or OpenAI-compatible model, including small models without tool calling.",
5
5
  "keywords": [
6
6
  "ai",
package/src/agent.js CHANGED
@@ -254,7 +254,8 @@ export class Session {
254
254
  // tools first, then the ones that failed least this session, in your list's order
255
255
  const able = (t) => !images.length || t.images
256
256
  const fails = (t) => this.failures?.[name(t)] ?? 0
257
- const order = [first, ...all.filter((t) => t !== first).sort((a, b) => b.tools - a.tools || fails(a) - fails(b))].filter(able)
257
+ const rests = (t) => (this.resting?.[name(t)] ?? 0) > Date.now() // out of quota: tried last
258
+ const order = [first, ...all.filter((t) => t !== first).sort((a, b) => b.tools - a.tools || fails(a) - fails(b))].filter(able).sort((a, b) => rests(a) - rests(b))
258
259
  if (!order.length) return 'error: none of your models can see images'
259
260
  const failed = []
260
261
  for (const [i, t] of order.entries()) {
@@ -283,7 +284,7 @@ export class Session {
283
284
  if (this.engineFor) {
284
285
  ;({ client, profile, strat } = await this.engineFor(t))
285
286
  const was = client.retryIf
286
- client.retryIf = (e, attempt) => attempt < 3 && !e.notStarted && (!was || was(e, attempt)) // not answering in time: the next model, not another wait
287
+ client.retryIf = (e, attempt) => attempt < 3 && !e.notStarted && e.status !== 429 && (!was || was(e, attempt)) // not answering in time or rate-limited: the next model, not another wait
287
288
  }
288
289
  const label = clip(`${client.model}: ${String(description ?? '').trim() || task.split('\n')[0]}`, 60)
289
290
  const helper = new Session({ client, profile, strat, root: this.root, ui: helperUI(this.ui, label), chat: newChat(this.root) })
@@ -580,7 +581,8 @@ const teamOf = (s, team = s.team?.() ?? []) => {
580
581
  const ranks = (t) => (data ? Object.entries(RANKED_AS).map(([k, list]) => ((r) => r && `${k} #${r.rank}`)(rankIn(t.model, list, data))).filter(Boolean).join(' ') : '')
581
582
  const line = (t) => {
582
583
  const failed = s.failures?.[`${t.provider} ${t.model}`]
583
- const facts = [t.tools === false && 'no tool calls', t.images && 'images', t.thinking && 'thinking', ranks(t) && `ranked ${ranks(t)}`, failed && `failed ${failed}× this session`].filter(Boolean)
584
+ const rest = Math.ceil(((s.resting?.[`${t.provider} ${t.model}`] ?? 0) - Date.now()) / 60_000)
585
+ const facts = [t.tools === false && 'no tool calls', t.images && 'images', t.thinking && 'thinking', ranks(t) && `ranked ${ranks(t)}`, failed && `failed ${failed}× this session`, rest > 0 && `out of quota for ${rest < 120 ? `${rest} min` : `${Math.round(rest / 60)} h`}`].filter(Boolean)
584
586
  return `- ${t.provider} ${t.model}${facts.length ? `: ${facts.join(', ')}` : ''}`
585
587
  }
586
588
  const you = [s.strat.vision ? 'images' : 'no images', s.strat.thinking && 'thinking', ranks(s.client) && `ranked ${ranks(s.client)}`].filter(Boolean).join(', ')
package/src/client.js CHANGED
@@ -520,7 +520,9 @@ export class Client {
520
520
  continue
521
521
  }
522
522
  // a server error or no connection, again and again: waited out like a rate limit (the wait
523
- // grows to a minute), until it comes back or Esc — never given up on
523
+ // grows to a minute), until it comes back or Esc — never given up on; unless the server
524
+ // says it's out for longer than that (a day's quota used up): no use waiting a minute
525
+ if (Number(e.retryAfter) > 60) throw e
524
526
  const wait = Math.min(Number(e.retryAfter) * 1000 || this.retryBase * 2 ** (tries - 1), 60_000)
525
527
  log('retry', `attempt ${attempt + 1} failed, waiting ${wait}ms: ${e.message}`)
526
528
  this.onRetry(e, wait, attempt + 1)