openclacky 1.5.3 → 1.5.5

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 (67) hide show
  1. checksums.yaml +4 -4
  2. data/.dockerignore +13 -0
  3. data/CHANGELOG.md +57 -0
  4. data/Dockerfile +21 -1
  5. data/README.md +26 -7
  6. data/README_CN.md +26 -7
  7. data/README_JA.md +26 -7
  8. data/lib/clacky/agent/message_compressor.rb +4 -29
  9. data/lib/clacky/agent/message_compressor_helper.rb +17 -16
  10. data/lib/clacky/agent/session_serializer.rb +7 -0
  11. data/lib/clacky/agent.rb +14 -2
  12. data/lib/clacky/agent_config.rb +10 -5
  13. data/lib/clacky/agent_profile.rb +25 -3
  14. data/lib/clacky/brand_config.rb +32 -12
  15. data/lib/clacky/default_extensions/ext-studio/agents/ext-developer/system_prompt.md +15 -0
  16. data/lib/clacky/default_extensions/ext-studio/api/handler.rb +1 -5
  17. data/lib/clacky/default_extensions/ext-studio/ext.yml +2 -2
  18. data/lib/clacky/default_extensions/ext-studio/panels/studio/view.js +43 -34
  19. data/lib/clacky/default_extensions/ext-studio/skills/ext-develop/SKILL.md +9 -3
  20. data/lib/clacky/default_extensions/git/ext.yml +3 -0
  21. data/lib/clacky/default_extensions/meeting/ext.yml +3 -0
  22. data/lib/clacky/default_extensions/time_machine/ext.yml +4 -0
  23. data/lib/clacky/default_parsers/xlsx_parser.py +66 -0
  24. data/lib/clacky/default_skills/new/SKILL.md +17 -12
  25. data/lib/clacky/extension/api_extension.rb +5 -2
  26. data/lib/clacky/extension/loader.rb +1 -0
  27. data/lib/clacky/extension/packager.rb +60 -15
  28. data/lib/clacky/extension/verifier.rb +1 -1
  29. data/lib/clacky/message_format/anthropic.rb +1 -1
  30. data/lib/clacky/message_format/bedrock.rb +1 -1
  31. data/lib/clacky/message_format/open_ai.rb +34 -3
  32. data/lib/clacky/providers.rb +77 -8
  33. data/lib/clacky/server/http_server.rb +495 -39
  34. data/lib/clacky/server/project_manager.rb +150 -0
  35. data/lib/clacky/server/server_master.rb +7 -0
  36. data/lib/clacky/server/session_registry.rb +14 -1
  37. data/lib/clacky/server/web_ui_controller.rb +12 -2
  38. data/lib/clacky/session_manager.rb +6 -4
  39. data/lib/clacky/tools/file_reader.rb +2 -1
  40. data/lib/clacky/tools/terminal.rb +30 -3
  41. data/lib/clacky/utils/model_pricing.rb +69 -18
  42. data/lib/clacky/utils/parser_manager.rb +115 -7
  43. data/lib/clacky/version.rb +1 -1
  44. data/lib/clacky/web/app.css +1216 -318
  45. data/lib/clacky/web/app.js +27 -4
  46. data/lib/clacky/web/components/notify.js +139 -22
  47. data/lib/clacky/web/core/aside.js +21 -0
  48. data/lib/clacky/web/features/brand/store.js +3 -1
  49. data/lib/clacky/web/features/brand/view.js +29 -5
  50. data/lib/clacky/web/features/extensions/store.js +214 -9
  51. data/lib/clacky/web/features/extensions/view.js +156 -11
  52. data/lib/clacky/web/features/new-session/store.js +25 -3
  53. data/lib/clacky/web/features/new-session/view.js +339 -142
  54. data/lib/clacky/web/features/skills/view.js +1 -1
  55. data/lib/clacky/web/features/trash/store.js +23 -9
  56. data/lib/clacky/web/features/trash/view.js +51 -0
  57. data/lib/clacky/web/i18n.js +124 -15
  58. data/lib/clacky/web/index.html +105 -79
  59. data/lib/clacky/web/projects.js +1143 -0
  60. data/lib/clacky/web/sessions.js +320 -538
  61. data/lib/clacky/web/settings.js +138 -5
  62. data/lib/clacky/web/utils.js +1 -0
  63. data/lib/clacky/web/ws-dispatcher.js +98 -4
  64. data/scripts/build/src/install_system_deps.sh.cc +11 -3
  65. data/scripts/install_system_deps.sh +11 -3
  66. metadata +5 -2
  67. data/lib/clacky/default_parsers/xlsx_parser.rb +0 -121
@@ -506,11 +506,20 @@ const Modal = (() => {
506
506
  });
507
507
  }
508
508
 
509
- /** Show a rename dialog. Returns a Promise<string|null>. */
510
- function rename(currentName = "") {
509
+ /** Show a rename dialog. Returns a Promise<string|null>.
510
+ * @param {string} currentName - pre-filled value
511
+ * @param {string} [labelI18nKey] - i18n key for the field label (default: sessions.modal.name)
512
+ */
513
+ function rename(currentName = "", labelI18nKey = "sessions.modal.name") {
511
514
  return new Promise(resolve => {
512
515
  const overlay = $("rename-modal-overlay");
513
516
  const input = $("rename-modal-input");
517
+ // Update label text dynamically
518
+ const labelSpan = overlay.querySelector("label[for='rename-modal-input'] span[data-i18n]");
519
+ if (labelSpan) {
520
+ labelSpan.dataset.i18n = labelI18nKey;
521
+ labelSpan.textContent = I18n.t(labelI18nKey);
522
+ }
514
523
  input.value = currentName;
515
524
  input.classList.remove("input-error");
516
525
  // Re-attach to <body> end so it stacks above dynamically-appended overlays.
@@ -653,16 +662,23 @@ function showConfirmModal(confId, message) {
653
662
 
654
663
  // ── DOM event listeners ───────────────────────────────────────────────────
655
664
  // Sidebar toggle (with mobile overlay support)
665
+ // Persist the sidebar's visibility so a hard refresh keeps the user's last
666
+ // state instead of always snapping back to "open". (Matches the treatment
667
+ // already given to sidebar *width*, the aside panel, and the todo panel.)
668
+ const _SIDEBAR_HIDDEN_KEY = "clacky-sidebar-hidden";
669
+
656
670
  function _isMobile() { return window.innerWidth <= 768; }
657
671
 
658
672
  function _closeSidebar() {
659
673
  $("sidebar").classList.add("hidden");
660
674
  $("sidebar-overlay").classList.remove("active");
675
+ try { localStorage.setItem(_SIDEBAR_HIDDEN_KEY, "1"); } catch (_e) { /* ignore */ }
661
676
  }
662
677
 
663
678
  function _openSidebar() {
664
679
  $("sidebar").classList.remove("hidden");
665
680
  if (_isMobile()) $("sidebar-overlay").classList.add("active");
681
+ try { localStorage.setItem(_SIDEBAR_HIDDEN_KEY, "0"); } catch (_e) { /* ignore */ }
666
682
  }
667
683
 
668
684
  function _toggleSidebar() {
@@ -728,8 +744,15 @@ $("sidebar-overlay").addEventListener("click", _closeSidebar);
728
744
  });
729
745
  })();
730
746
 
731
- // On mobile: start with sidebar hidden
732
- if (_isMobile()) _closeSidebar();
747
+ // On mobile: start with sidebar hidden.
748
+ // On desktop: restore the user's last sidebar visibility (persisted).
749
+ if (_isMobile()) {
750
+ _closeSidebar();
751
+ } else {
752
+ try {
753
+ if (localStorage.getItem(_SIDEBAR_HIDDEN_KEY) === "1") _closeSidebar();
754
+ } catch (_e) { /* ignore */ }
755
+ }
733
756
 
734
757
  // On mobile: auto-close sidebar when switching sessions/pages
735
758
  function _mobileCloseSidebar() {
@@ -1,14 +1,15 @@
1
- // notify.js — Task-complete sound notification module
1
+ // notify.js — Task-complete sound + desktop notification module
2
2
  //
3
- // Plays a short sound when an agent task finishes, driven by the global
4
- // `task_finished` event the server broadcasts (broadcast_all) the moment a
5
- // task completes. We listen to this dedicated signal — rather than `complete`
6
- // (only delivered to subscribers of that session) — so a background session
7
- // finishing still reaches every browser. Whether a task *finished* is decided
8
- // on the backend; this module only decides whether the user is looking.
3
+ // Plays a short sound and (when permitted) shows a browser Notification when
4
+ // an agent task finishes, driven by the global `task_finished` event the
5
+ // server broadcasts (broadcast_all) the moment a task completes. We listen to
6
+ // this dedicated signal — rather than `complete` (only delivered to subscribers
7
+ // of that session) — so a background session finishing still reaches every
8
+ // browser. Whether a task *finished* is decided on the backend; this module
9
+ // only decides whether the user is looking.
9
10
  //
10
- // The chime only fires when the user is NOT actively looking at the
11
- // finished session. "Not looking" means ANY of:
11
+ // Alerts only fire when the user is NOT actively looking at the finished
12
+ // session. "Not looking" means ANY of:
12
13
  // 1. The finished session is not the currently open one
13
14
  // (sid !== Sessions.activeId)
14
15
  // 2. The browser window has lost focus (!document.hasFocus())
@@ -18,15 +19,20 @@
18
19
  // silent — they can already see the result.
19
20
  //
20
21
  // The feature is gated behind a header toggle (🔔/🔕) next to the theme
21
- // switcher. Default OFF; the choice is persisted to localStorage.
22
+ // switcher. Default OFF; the choice is persisted to localStorage. Enabling
23
+ // the toggle also requests browser Notification permission (must happen in
24
+ // the click gesture) so desktop toasts work when the tab is in the background.
22
25
  //
23
- // No history replay: a chime is a live cue, never re-fired on page refresh.
24
- // The audio file is served as a static asset (/notify.mp3) by WEBrick.
26
+ // No history replay: a chime/toast is a live cue, never re-fired on page
27
+ // refresh. The audio file is served as a static asset (/assets/notify.mp3).
25
28
  //
26
- // Depends on: Sessions (sessions.js) for activeId, I18n (i18n.js) for the
27
- // tooltip text. Both are optional — guarded with typeof checks.
29
+ // Depends on: Sessions (sessions.js) for activeId/find, Router (app.js) for
30
+ // focus-on-click navigation, I18n (i18n.js) for tooltip text.
31
+ // All are optional — guarded with typeof checks.
28
32
  // ─────────────────────────────────────────────────────────────────────────
29
33
  const Notify = (() => {
34
+ // Historical key name kept for existing installs; value now means
35
+ // "task alerts" (sound + desktop when permitted), not sound-only.
30
36
  const STORAGE_KEY = "clacky-notify-sound";
31
37
  const AUDIO_SRC = "/assets/notify.mp3";
32
38
 
@@ -41,13 +47,54 @@ const Notify = (() => {
41
47
  function setEnabled(on) {
42
48
  localStorage.setItem(STORAGE_KEY, on ? "on" : "off");
43
49
  _updateToggleIcon();
44
- // On enabling, "prime" the audio element within this user gesture so the
45
- // browser's autoplay policy lets later programmatic play() calls through.
46
- if (on) _prime();
47
50
  }
48
51
 
49
- function toggle() {
50
- setEnabled(!enabled());
52
+ async function toggle() {
53
+ const next = !enabled();
54
+ if (next) {
55
+ // Prime audio inside the click gesture first, then request permission.
56
+ // Awaiting permission before priming can drop the user-gesture token.
57
+ _prime();
58
+ const perm = await _ensurePermission();
59
+ setEnabled(true);
60
+ if (perm === "denied" && typeof Modal !== "undefined" && Modal.toast) {
61
+ Modal.toast(
62
+ (typeof I18n !== "undefined" && I18n.t("notify.toast.denied")) ||
63
+ "Sound alerts enabled. Desktop notifications are blocked in browser settings.",
64
+ "warning"
65
+ );
66
+ } else if (perm === "unsupported" && typeof Modal !== "undefined" && Modal.toast) {
67
+ Modal.toast(
68
+ (typeof I18n !== "undefined" && I18n.t("notify.toast.noDesktop")) ||
69
+ "Sound alerts enabled. This browser has no desktop notifications.",
70
+ "info"
71
+ );
72
+ }
73
+ } else {
74
+ setEnabled(false);
75
+ }
76
+ }
77
+
78
+ // ── Browser Notification permission ──────────────────────────────────
79
+ function _notificationsSupported() {
80
+ return typeof window !== "undefined" && "Notification" in window;
81
+ }
82
+
83
+ function permission() {
84
+ if (!_notificationsSupported()) return "unsupported";
85
+ return Notification.permission; // "granted" | "denied" | "default"
86
+ }
87
+
88
+ async function _ensurePermission() {
89
+ if (!_notificationsSupported()) return "unsupported";
90
+ if (Notification.permission === "granted") return "granted";
91
+ if (Notification.permission === "denied") return "denied";
92
+ try {
93
+ const result = await Notification.requestPermission();
94
+ return result;
95
+ } catch (_e) {
96
+ return Notification.permission;
97
+ }
51
98
  }
52
99
 
53
100
  // ── Audio ────────────────────────────────────────────────────────────
@@ -88,6 +135,46 @@ const Notify = (() => {
88
135
  } catch (_e) { /* ignore */ }
89
136
  }
90
137
 
138
+ // ── Desktop notification ─────────────────────────────────────────────
139
+ function _notifyDesktop(sid) {
140
+ if (!_notificationsSupported()) return;
141
+ if (Notification.permission !== "granted") return;
142
+
143
+ // Keep body generic on purpose — session names can be sensitive on shared
144
+ // screens. Click focuses the window and navigates to the session.
145
+ const title = typeof I18n !== "undefined"
146
+ ? I18n.t("notify.desktop.title")
147
+ : "Task complete";
148
+ const body = typeof I18n !== "undefined"
149
+ ? I18n.t("notify.desktop.body")
150
+ : "A background task finished. Click to open it.";
151
+
152
+ let n;
153
+ try {
154
+ n = new Notification(title, {
155
+ body,
156
+ tag: sid ? `clacky-task-${sid}` : "clacky-task",
157
+ renotify: true,
158
+ silent: true, // sound is handled by our own chime
159
+ });
160
+ } catch (_e) {
161
+ return;
162
+ }
163
+
164
+ n.onclick = () => {
165
+ try { window.focus(); } catch (_e) { /* ignore */ }
166
+ if (sid && typeof Router !== "undefined" && typeof Router.navigate === "function") {
167
+ Router.navigate("session", { id: sid });
168
+ }
169
+ try { n.close(); } catch (_e) { /* ignore */ }
170
+ };
171
+
172
+ // Auto-dismiss so toasts don't pile up forever.
173
+ setTimeout(() => {
174
+ try { n.close(); } catch (_e) { /* ignore */ }
175
+ }, 8000);
176
+ }
177
+
91
178
  // ── Trigger decision ───────────────────────────────────────────────────
92
179
  // Returns true when the user is NOT actively viewing the given session.
93
180
  function _userIsAway(sid) {
@@ -109,9 +196,19 @@ const Notify = (() => {
109
196
  if (!enabled()) return;
110
197
  if (!_userIsAway(sid)) return;
111
198
  _play();
199
+ _notifyDesktop(sid);
112
200
  }
113
201
 
114
202
  // ── Toggle button UI ───────────────────────────────────────────────────
203
+ function _tooltipKey(on) {
204
+ if (!on) return "notify.tooltip.off";
205
+ const perm = permission();
206
+ if (perm === "denied") return "notify.tooltip.onDenied";
207
+ if (perm === "unsupported") return "notify.tooltip.onNoDesktop";
208
+ if (perm === "default") return "notify.tooltip.onPending";
209
+ return "notify.tooltip.on";
210
+ }
211
+
115
212
  function _updateToggleIcon() {
116
213
  const btn = document.getElementById("notify-toggle-header");
117
214
  if (!btn) return;
@@ -130,9 +227,10 @@ const Notify = (() => {
130
227
  </svg>`;
131
228
  btn.classList.toggle("notify-on", on);
132
229
  if (typeof I18n !== "undefined") {
133
- const tip = I18n.t(on ? "notify.tooltip.on" : "notify.tooltip.off");
230
+ const tip = I18n.t(_tooltipKey(on));
134
231
  btn.title = tip;
135
232
  btn.setAttribute("aria-label", tip);
233
+ btn.setAttribute("data-i18n-title", _tooltipKey(on));
136
234
  }
137
235
  }
138
236
 
@@ -140,10 +238,29 @@ const Notify = (() => {
140
238
  function init() {
141
239
  _updateToggleIcon();
142
240
  const btn = document.getElementById("notify-toggle-header");
143
- if (btn) btn.addEventListener("click", toggle);
241
+ if (btn) {
242
+ btn.addEventListener("click", () => {
243
+ // Fire-and-forget; permission prompt is awaited inside toggle.
244
+ toggle().then(() => _updateToggleIcon()).catch(() => _updateToggleIcon());
245
+ });
246
+ }
247
+ // Permission may change outside the page (browser settings); refresh tip.
248
+ document.addEventListener("visibilitychange", () => {
249
+ if (!document.hidden) _updateToggleIcon();
250
+ });
251
+ if (typeof I18n !== "undefined") {
252
+ document.addEventListener("langchange", () => _updateToggleIcon());
253
+ }
144
254
  }
145
255
 
146
- return { init, toggle, enabled, setEnabled, onTaskFinished };
256
+ return {
257
+ init,
258
+ toggle,
259
+ enabled,
260
+ setEnabled,
261
+ permission,
262
+ onTaskFinished,
263
+ };
147
264
  })();
148
265
 
149
266
  Clacky.Notify = Notify;
@@ -42,6 +42,13 @@
42
42
  if (overlay) overlay.classList.toggle("active", open && !empty);
43
43
  }
44
44
 
45
+ function isOpen() {
46
+ try {
47
+ const stored = localStorage.getItem(OPEN_KEY);
48
+ return stored !== null && stored !== "0";
49
+ } catch (_e) { return false; }
50
+ }
51
+
45
52
  function setOpen(open) {
46
53
  try { localStorage.setItem(OPEN_KEY, open ? "1" : "0"); } catch (_e) { /* ignore */ }
47
54
  applyOpenState();
@@ -91,7 +98,21 @@
91
98
  });
92
99
  }
93
100
 
101
+ // ── Public API ────────────────────────────────────────────────────────
102
+ // Expose setOpen so external code (e.g. WS dispatcher) can open/close the
103
+ // aside panel programmatically without duplicating localStorage logic here.
104
+ // open() is a no-op when the panel is already open — safe to call unconditionally.
105
+ if (window.Clacky) Clacky.Aside = {
106
+ open: () => { if (!isOpen()) setOpen(true); },
107
+ close: () => setOpen(false),
108
+ };
109
+
94
110
  function init() {
111
+ // Re-assign in case Clacky was not yet defined when the IIFE ran.
112
+ if (window.Clacky) Clacky.Aside = {
113
+ open: () => { if (!isOpen()) setOpen(true); },
114
+ close: () => setOpen(false),
115
+ };
95
116
  const collapse = $("btn-aside-collapse");
96
117
  const opener = $("btn-aside-open");
97
118
  const overlay = $("workspace-overlay");
@@ -76,7 +76,7 @@ const BrandStore = (() => {
76
76
  return false;
77
77
  },
78
78
 
79
- // Re-fetch status to refresh flags only (no UI boot driving).
79
+ // Re-fetch status and notify views without driving the main boot sequence.
80
80
  async refresh() {
81
81
  try {
82
82
  const res = await fetch("/api/brand/status");
@@ -84,8 +84,10 @@ const BrandStore = (() => {
84
84
  _testMode = !!data.test_mode;
85
85
  _userLicensed = !!data.user_licensed;
86
86
  _branded = !!data.branded;
87
+ _emit("brand:status", data);
87
88
  return data;
88
89
  } catch (_) {
90
+ _emit("brand:status", null);
89
91
  return null;
90
92
  }
91
93
  },
@@ -15,7 +15,22 @@
15
15
  const BrandView = (() => {
16
16
 
17
17
  function _onStatus(data) {
18
- if (!data || !data.branded) return;
18
+ if (!data) return;
19
+ if (!data.branded) {
20
+ if (data.distribution_refresh_pending) {
21
+ _scheduleDistributionRefreshPoll();
22
+ return;
23
+ }
24
+ _applyBrandName("OpenClacky");
25
+ Brand.clearBrandCache();
26
+ _applyHeaderLogo();
27
+ const banner = document.getElementById("brand-activation-banner");
28
+ if (banner) banner.remove();
29
+ if (typeof Settings !== "undefined" && Settings.loadBrand) Settings.loadBrand();
30
+ return;
31
+ }
32
+
33
+ if (data.product_name) _applyBrandName(data.product_name);
19
34
 
20
35
  if (data.needs_activation) {
21
36
  if (data.theme_color) Settings.applyAccentColor(data.theme_color, { persist: true });
@@ -268,6 +283,7 @@ const BrandView = (() => {
268
283
  logoImg.alt = "OpenClacky";
269
284
  logoImg.style.display = "";
270
285
  if (brandWrap) brandWrap.classList.add("has-logo");
286
+ _applyFavicon("/favicon.svg");
271
287
  }
272
288
 
273
289
  function _applyFavicon(url) {
@@ -333,11 +349,19 @@ const BrandView = (() => {
333
349
  let attempt = 0;
334
350
 
335
351
  const poll = () => {
336
- Brand.clearBrandCache();
337
- Brand.fetchInfo().then(info => {
338
- const hasFullBrand = !!(info && info.logo_url && info.theme_color);
352
+ Brand.refresh().then(status => {
353
+ Brand.clearBrandCache();
354
+ return Brand.fetchInfo().then(info => ({ status, info }));
355
+ }).then(({ status, info }) => {
356
+ if (info && info.product_name) _applyBrandName(info.product_name);
339
357
  _applyHeaderLogo();
340
- if (hasFullBrand || attempt >= delays.length) {
358
+ const refreshSettled = !!(
359
+ status && status.branded && !status.distribution_refresh_pending
360
+ );
361
+ if (refreshSettled && typeof Settings !== "undefined" && Settings.loadBrand) {
362
+ Settings.loadBrand();
363
+ }
364
+ if (refreshSettled || attempt >= delays.length) {
341
365
  _distRefreshPolling = false;
342
366
  return;
343
367
  }