openclacky 1.2.6 → 1.2.7

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.
@@ -18,7 +18,6 @@
18
18
 
19
19
 
20
20
  WS.onEvent(ev => {
21
- console.log("[DEBUG] WS event received:", ev.type, ev);
22
21
  switch (ev.type) {
23
22
 
24
23
  // ── Internal WS lifecycle ──────────────────────────────────────────
@@ -273,11 +272,28 @@ WS.onEvent(ev => {
273
272
  break;
274
273
 
275
274
  case "error":
276
- if (!ev.session_id || ev.session_id === Sessions.activeId)
277
- Sessions.appendMsg("error", escapeHtml(ev.message));
275
+ if (!ev.session_id || ev.session_id === Sessions.activeId) {
276
+ renderErrorEvent(ev);
277
+ }
278
278
  break;
279
279
  }
280
280
  });
281
281
 
282
+ // ── Error rendering ────────────────────────────────────────────────────────
283
+
284
+ function renderErrorEvent(ev) {
285
+ if (ev.code === "insufficient_credit") {
286
+ const body = escapeHtml(I18n.t("error.insufficient_credit"));
287
+ const action = ev.top_up_url
288
+ ? ` <a href="${escapeHtml(ev.top_up_url)}" target="_blank" rel="noopener noreferrer">${escapeHtml(I18n.t("error.insufficient_credit.action"))} →</a>`
289
+ : "";
290
+ Sessions.appendMsg("error", `<span>${body}${action}</span>`);
291
+ return;
292
+ }
293
+ Sessions.appendMsg("error", escapeHtml(ev.message));
294
+ }
295
+
296
+ window.renderErrorEvent = renderErrorEvent;
297
+
282
298
 
283
299
  })();
data/lib/clacky.rb CHANGED
@@ -136,6 +136,15 @@ module Clacky
136
136
  class AgentInterrupted < Exception; end # Inherit from Exception to bypass rescue StandardError
137
137
  class AgentError < StandardError; end
138
138
  class BadRequestError < AgentError; end # 400 errors — our request was malformed, history should be rolled back
139
+ class InsufficientCreditError < AgentError
140
+ attr_reader :error_code, :provider_id
141
+
142
+ def initialize(message, error_code: nil, provider_id: nil)
143
+ super(message)
144
+ @error_code = error_code
145
+ @provider_id = provider_id
146
+ end
147
+ end
139
148
  class RetryableError < StandardError; end # Transient errors that should be retried (5xx, HTML response, rate limit)
140
149
  # Upstream (model/router like OpenRouter/Bedrock) returned finish_reason="stop" together with
141
150
  # one or more tool_calls whose `arguments` JSON was truncated (empty, "{}" placeholder, or
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openclacky
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.6
4
+ version: 1.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - windy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-05-28 00:00:00.000000000 Z
11
+ date: 2026-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -570,6 +570,7 @@ files:
570
570
  - lib/clacky/web/vendor/katex/katex.min.js
571
571
  - lib/clacky/web/version.js
572
572
  - lib/clacky/web/weixin-qr.html
573
+ - lib/clacky/web/workspace.js
573
574
  - lib/clacky/web/ws-dispatcher.js
574
575
  - lib/clacky/web/ws.js
575
576
  - scripts/build/build.sh