openclacky 1.5.25 → 1.5.26
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +61 -0
- data/lib/clacky/agent/chunk_index.rb +2 -1
- data/lib/clacky/agent/message_compressor_helper.rb +20 -2
- data/lib/clacky/agent/session_serializer.rb +28 -1
- data/lib/clacky/agent/skill_manager.rb +2 -8
- data/lib/clacky/agent/time_machine.rb +108 -127
- data/lib/clacky/agent/tool_executor.rb +2 -11
- data/lib/clacky/agent.rb +15 -19
- data/lib/clacky/agent_config.rb +14 -4
- data/lib/clacky/billing/media_usage.rb +69 -0
- data/lib/clacky/billing/platform_billing.rb +5 -0
- data/lib/clacky/brand_config.rb +16 -215
- data/lib/clacky/default_extensions/ext-studio/agents/ext-developer/system_prompt.md +2 -80
- data/lib/clacky/default_extensions/ext-studio/panels/studio/view.js +1 -1
- data/lib/clacky/default_extensions/ext-studio/skills/ext-develop/SKILL.md +10 -96
- data/lib/clacky/default_extensions/git/panels/git/view.js +208 -69
- data/lib/clacky/default_extensions/knowledge/README.md +1 -1
- data/lib/clacky/default_extensions/knowledge/README.zh.md +1 -1
- data/lib/clacky/default_extensions/knowledge/lib/importer.rb +1 -1
- data/lib/clacky/default_extensions/knowledge/panels/kb/view.js +3 -3
- data/lib/clacky/default_extensions/meeting/api/handler.rb +23 -2
- data/lib/clacky/default_extensions/meeting/panels/meeting/view.js +194 -36
- data/lib/clacky/default_extensions/preview/icon.svg +3 -2
- data/lib/clacky/default_extensions/secretary/panels/work/view.js +108 -33
- data/lib/clacky/default_extensions/side-chat/README.md +40 -0
- data/lib/clacky/default_extensions/side-chat/README.zh.md +40 -0
- data/lib/clacky/default_extensions/side-chat/api/handler.rb +90 -0
- data/lib/clacky/default_extensions/side-chat/api/runtime.rb +411 -0
- data/lib/clacky/default_extensions/side-chat/ext.yml +16 -0
- data/lib/clacky/default_extensions/side-chat/icon.svg +14 -0
- data/lib/clacky/default_extensions/side-chat/panels/side-chat/view.js +779 -0
- data/lib/clacky/default_extensions/terminal/README.md +36 -0
- data/lib/clacky/default_extensions/terminal/README.zh.md +36 -0
- data/lib/clacky/default_extensions/terminal/api/handler.rb +121 -0
- data/lib/clacky/default_extensions/terminal/api/runtime.rb +397 -0
- data/lib/clacky/default_extensions/terminal/ext.yml +16 -0
- data/lib/clacky/default_extensions/terminal/icon.svg +13 -0
- data/lib/clacky/default_extensions/terminal/panels/terminal/view.js +351 -0
- data/lib/clacky/default_extensions/terminal/vendor/LICENSE +21 -0
- data/lib/clacky/default_extensions/terminal/vendor/addon-fit.js +2 -0
- data/lib/clacky/default_extensions/terminal/vendor/xterm.css +218 -0
- data/lib/clacky/default_extensions/terminal/vendor/xterm.js +2 -0
- data/lib/clacky/default_skills/media-gen/SKILL.md +30 -9
- data/lib/clacky/extension/api_extension.rb +12 -0
- data/lib/clacky/locales/en.rb +14 -11
- data/lib/clacky/locales/i18n.rb +25 -0
- data/lib/clacky/locales/zh.rb +14 -11
- data/lib/clacky/media/base.rb +11 -1
- data/lib/clacky/media/openai_compat.rb +271 -3
- data/lib/clacky/message_format/open_ai.rb +17 -0
- data/lib/clacky/prompts/base.md +3 -0
- data/lib/clacky/providers.rb +33 -20
- data/lib/clacky/reasoning_levels.rb +75 -0
- data/lib/clacky/server/channel/channel_ui_controller.rb +12 -5
- data/lib/clacky/server/git_panel.rb +40 -18
- data/lib/clacky/server/http_server.rb +62 -71
- data/lib/clacky/server/session_registry.rb +3 -0
- data/lib/clacky/ui2/markdown_renderer.rb +153 -0
- data/lib/clacky/ui2/strings_cjk_patch.rb +134 -124
- data/lib/clacky/utils/file_link_normalizer.rb +30 -3
- data/lib/clacky/utils/frontmatter.rb +63 -0
- data/lib/clacky/utils/model_pricing.rb +67 -9
- data/lib/clacky/version.rb +1 -1
- data/lib/clacky/web/app.css +722 -274
- data/lib/clacky/web/app.js +2 -0
- data/lib/clacky/web/components/chat-composer.js +504 -0
- data/lib/clacky/web/components/chat-navigator.js +1 -1
- data/lib/clacky/web/components/model-picker.js +319 -20
- data/lib/clacky/web/components/quote-select.js +97 -39
- data/lib/clacky/web/core/aside.js +137 -27
- data/lib/clacky/web/core/ext.js +658 -81
- data/lib/clacky/web/features/brand/store.js +0 -4
- data/lib/clacky/web/features/brand/view.js +2 -99
- data/lib/clacky/web/features/extensions/store.js +3 -1
- data/lib/clacky/web/features/extensions/view.js +14 -15
- data/lib/clacky/web/features/new-session/store.js +4 -0
- data/lib/clacky/web/features/new-session/view.js +27 -4
- data/lib/clacky/web/features/skills/store.js +7 -5
- data/lib/clacky/web/features/skills/view.js +65 -16
- data/lib/clacky/web/features/version/view.js +1 -1
- data/lib/clacky/web/features/workspace/store.js +7 -3
- data/lib/clacky/web/features/workspace/view.js +46 -5
- data/lib/clacky/web/i18n.js +104 -58
- data/lib/clacky/web/index.html +21 -22
- data/lib/clacky/web/lib/box-diagram.js +239 -0
- data/lib/clacky/web/sessions.js +117 -151
- data/lib/clacky/web/settings.js +23 -16
- data/lib/clacky/web/ws-dispatcher.js +4 -1
- data/lib/clacky.rb +2 -0
- metadata +24 -1
data/lib/clacky/providers.rb
CHANGED
|
@@ -38,6 +38,19 @@ module Clacky
|
|
|
38
38
|
"auto",
|
|
39
39
|
"dsk-deepseek-v4.1-flash",
|
|
40
40
|
"dsk-deepseek-v4-pro",
|
|
41
|
+
"or-gemini-4-hydrogen",
|
|
42
|
+
"or-gemini-4-argon",
|
|
43
|
+
"or-gemini-3-1-pro",
|
|
44
|
+
"or-gemini-3-8-flash",
|
|
45
|
+
"abs-gpt-6.2-astra",
|
|
46
|
+
"abs-gpt-6.2-sol",
|
|
47
|
+
"abs-gpt-6.1-sol",
|
|
48
|
+
"abs-gpt-6-astra",
|
|
49
|
+
"abs-gpt-6-sol",
|
|
50
|
+
"abs-gpt-6-luna",
|
|
51
|
+
"abs-gpt-5.6-sol",
|
|
52
|
+
"abs-gpt-5.6-terra",
|
|
53
|
+
"abs-gpt-5.6-luna",
|
|
41
54
|
"abs-claude-fable-5-2",
|
|
42
55
|
"abs-claude-fable-5-1",
|
|
43
56
|
"abs-claude-fable-5",
|
|
@@ -50,18 +63,6 @@ module Clacky
|
|
|
50
63
|
"abs-claude-sonnet-4-6",
|
|
51
64
|
"abs-claude-haiku-5-5",
|
|
52
65
|
"abs-claude-haiku-4-5",
|
|
53
|
-
"abs-gpt-6.2-astra",
|
|
54
|
-
"abs-gpt-6.2-sol",
|
|
55
|
-
"abs-gpt-6.1-sol",
|
|
56
|
-
"abs-gpt-6-astra",
|
|
57
|
-
"abs-gpt-6-sol",
|
|
58
|
-
"abs-gpt-6-luna",
|
|
59
|
-
"abs-gpt-5.6-sol",
|
|
60
|
-
"abs-gpt-5.6-terra",
|
|
61
|
-
"abs-gpt-5.6-luna",
|
|
62
|
-
"or-gemini-4-argon",
|
|
63
|
-
"or-gemini-3-1-pro",
|
|
64
|
-
"or-gemini-3-8-flash",
|
|
65
66
|
"oc-glm-5.3",
|
|
66
67
|
"oc-kimi-k3"
|
|
67
68
|
],
|
|
@@ -109,30 +110,42 @@ module Clacky
|
|
|
109
110
|
"or-veo-3-1-lite" => "Veo 3.1 Lite"
|
|
110
111
|
},
|
|
111
112
|
"default_video_model" => "or-gemini-omni-flash",
|
|
112
|
-
# Text-to-speech models served by the openclacky gateway
|
|
113
|
-
#
|
|
114
|
-
#
|
|
113
|
+
# Text-to-speech models served by the openclacky gateway. or-tts-
|
|
114
|
+
# aliases relay to Vertex AI Gemini 2.5 (responseModalities=["AUDIO"],
|
|
115
|
+
# ~40 voices, no length cap); dsk-deepseek-tts answers from DeepSeek's
|
|
116
|
+
# own endpoint, which is ~6x realtime but bills per character — about
|
|
117
|
+
# 1.5x Gemini Flash for the same Chinese script — and offers two
|
|
118
|
+
# voices, no style cues, and a 10,000 billing-character cap per
|
|
119
|
+
# request (~5,000 hanzi, since a CJK character bills as two).
|
|
120
|
+
# DeepSeek is the default for latency: a short clip returns in a second
|
|
121
|
+
# or two, where Gemini TTS can take minutes.
|
|
115
122
|
"audio_models" => [
|
|
123
|
+
"dsk-deepseek-tts",
|
|
116
124
|
"or-tts-gemini-2-5-flash",
|
|
117
125
|
"or-tts-gemini-2-5-pro"
|
|
118
126
|
],
|
|
119
127
|
"audio_model_aliases" => {
|
|
128
|
+
"dsk-deepseek-tts" => "DeepSeek TTS (Fast)",
|
|
120
129
|
"or-tts-gemini-2-5-flash" => "Gemini 2.5 Flash TTS",
|
|
121
130
|
"or-tts-gemini-2-5-pro" => "Gemini 2.5 Pro TTS"
|
|
122
131
|
},
|
|
123
|
-
"default_audio_model" => "
|
|
124
|
-
# Speech-to-text models served by the openclacky gateway
|
|
125
|
-
#
|
|
126
|
-
#
|
|
132
|
+
"default_audio_model" => "dsk-deepseek-tts",
|
|
133
|
+
# Speech-to-text models served by the openclacky gateway. dsk- aliases
|
|
134
|
+
# are answered on the mainland gateway straight from DeepSeek's
|
|
135
|
+
# standalone speech API (~0.1-0.2x realtime, no prompt biasing); the
|
|
136
|
+
# or-stt- aliases relay to Vertex Gemini, which is slower but accepts
|
|
137
|
+
# any container and honours a terminology prompt.
|
|
127
138
|
"stt_models" => [
|
|
139
|
+
"dsk-deepseek-asr",
|
|
128
140
|
"or-stt-gemini-3-8-flash",
|
|
129
141
|
"or-stt-gemini-1-5-pro"
|
|
130
142
|
],
|
|
131
143
|
"stt_model_aliases" => {
|
|
144
|
+
"dsk-deepseek-asr" => "DeepSeek ASR (Fast)",
|
|
132
145
|
"or-stt-gemini-3-8-flash" => "Gemini 3.8 Flash STT",
|
|
133
146
|
"or-stt-gemini-1-5-pro" => "Gemini 1.5 Pro STT"
|
|
134
147
|
},
|
|
135
|
-
"default_stt_model" => "
|
|
148
|
+
"default_stt_model" => "dsk-deepseek-asr",
|
|
136
149
|
# Video understanding models served by the openclacky gateway, which
|
|
137
150
|
# routes video frames to Gemini (generateContent with inline image
|
|
138
151
|
# parts). The gateway returns analysis text.
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Clacky
|
|
4
|
+
# Which reasoning stops actually change the outgoing request for a model.
|
|
5
|
+
#
|
|
6
|
+
# The wire formats collapse many of our six stops onto far fewer provider
|
|
7
|
+
# values (GLM-5.3 accepts low/high/max only, MiniMax-M3 is a thinking on/off
|
|
8
|
+
# switch, ...). Offering all six everywhere means the picker shows stops that
|
|
9
|
+
# produce byte-identical requests, so the UI would react while the model does
|
|
10
|
+
# not. This table is the single source of truth for what each family can
|
|
11
|
+
# distinguish; MessageFormat adapters stay the source of truth for *how* a
|
|
12
|
+
# stop is encoded, and ReasoningLevels must never claim a stop that an adapter
|
|
13
|
+
# collapses into its neighbour.
|
|
14
|
+
#
|
|
15
|
+
# Invariant (enforced in spec/clacky/reasoning_levels_spec.rb): for the levels
|
|
16
|
+
# returned here, any two different levels produce different request fields on
|
|
17
|
+
# every transport the model can use.
|
|
18
|
+
module ReasoningLevels
|
|
19
|
+
ALL = %w[off low medium high xhigh max].freeze
|
|
20
|
+
|
|
21
|
+
# Matching is anchored and ordered: the first entry that matches wins, so a
|
|
22
|
+
# narrow family must come before the broader one it belongs to.
|
|
23
|
+
FAMILIES = [
|
|
24
|
+
# GLM-5.3 always thinks and accepts low/high/max only; the adapter maps
|
|
25
|
+
# off/low/medium onto "low".
|
|
26
|
+
[/\Aglm-5[-.]3/i, %w[low high max]],
|
|
27
|
+
# Older GLM accepts thinking on/off plus a high/max effort; low and medium
|
|
28
|
+
# both collapse onto "high".
|
|
29
|
+
[/\Aglm-[45]/i, %w[off high max]],
|
|
30
|
+
# Kimi K3 accepts low/high/max; a disabled thinking block is ignored, so
|
|
31
|
+
# "off" is indistinguishable from "low".
|
|
32
|
+
[/\A(kimi-)?k3/i, %w[low high max]],
|
|
33
|
+
# MiniMax-M3.1-Flash rejects "none" and maps off onto its lightest effort.
|
|
34
|
+
[/\Aminimax-m3[.]1-flash\z/i, %w[low medium high xhigh max]],
|
|
35
|
+
# MiniMax-M3 is a binary switch: off disables thinking, everything else is
|
|
36
|
+
# "adaptive" with no intensity.
|
|
37
|
+
[/\Aminimax-m3\z/i, %w[off medium]],
|
|
38
|
+
# MiMo-V2 is also binary ({type: enabled|disabled}).
|
|
39
|
+
[/\Amimo-v2/i, %w[off medium]],
|
|
40
|
+
# DeepSeek merges xhigh into max.
|
|
41
|
+
[/deepseek/i, %w[off low medium high max]],
|
|
42
|
+
# Gemini 4 always thinks, so there is no "off": Argon offers
|
|
43
|
+
# low/medium/high (default medium), Hydrogen adds xhigh (default high).
|
|
44
|
+
# Neither documents minimal, and Argon errors out on it. Matched without
|
|
45
|
+
# an anchor because platform aliases carry an "or-" prefix.
|
|
46
|
+
[/gemini-4-argon/i, %w[low medium high]],
|
|
47
|
+
[/gemini-4-hydrogen/i, %w[low medium high xhigh]]
|
|
48
|
+
].freeze
|
|
49
|
+
|
|
50
|
+
# Levels for a model, ascending. An empty array means the model has no
|
|
51
|
+
# reasoning control at all, and a host should hide the control entirely.
|
|
52
|
+
def self.for_model(model)
|
|
53
|
+
name = model.to_s
|
|
54
|
+
_, levels = FAMILIES.find { |pattern, _| name.match?(pattern) }
|
|
55
|
+
levels || ALL
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Nearest stop this model can express. Keeps a session on a meaningful
|
|
59
|
+
# level after it switches to a model with coarser granularity. A blank
|
|
60
|
+
# level means "never chosen, use the provider default" and is left alone
|
|
61
|
+
# (nil): for some models the default is the deepest level, so turning it
|
|
62
|
+
# into "off" would silently change behaviour.
|
|
63
|
+
def self.clamp(model, level)
|
|
64
|
+
key = level.to_s.downcase
|
|
65
|
+
return nil if key.empty?
|
|
66
|
+
|
|
67
|
+
levels = for_model(model)
|
|
68
|
+
return nil if levels.empty?
|
|
69
|
+
return key if levels.include?(key)
|
|
70
|
+
|
|
71
|
+
target = ALL.index(key) || 0
|
|
72
|
+
levels.min_by { |l| (ALL.index(l) - target).abs }
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
@@ -21,9 +21,6 @@ module Clacky
|
|
|
21
21
|
BUFFER_FLUSH_SIZE = 5 # flush early when buffer is large
|
|
22
22
|
PROCESS_STATUS_MAX_LENGTH = 240
|
|
23
23
|
TERMINAL_PROGRESS_STATES = %i[waiting success failed interrupted].freeze
|
|
24
|
-
PROGRESS_TOOLS = %w[
|
|
25
|
-
browser edit file_reader glob grep invoke_skill terminal todo_manager web_fetch web_search write
|
|
26
|
-
].freeze
|
|
27
24
|
|
|
28
25
|
attr_reader :platform, :chat_id
|
|
29
26
|
|
|
@@ -411,7 +408,11 @@ module Clacky
|
|
|
411
408
|
|
|
412
409
|
private def tool_progress_message(name)
|
|
413
410
|
tool = name.to_s.downcase
|
|
414
|
-
|
|
411
|
+
# Unknown tools (extension tools in particular) must not leak their
|
|
412
|
+
# name into an IM card, so they share one generic "working" status.
|
|
413
|
+
return progress_text("working") unless Clacky::I18n::PROGRESS_TOOLS.include?(tool)
|
|
414
|
+
|
|
415
|
+
Clacky::I18n.tool_progress_translations(tool)
|
|
415
416
|
end
|
|
416
417
|
|
|
417
418
|
private def progress_text(key)
|
|
@@ -508,7 +509,13 @@ module Clacky
|
|
|
508
509
|
private def sanitize_outbound_text(text, remove_file_links: false)
|
|
509
510
|
sanitized = text.to_s.gsub(/<think>[\s\S]*?<\/think>\n*/i, "")
|
|
510
511
|
if remove_file_links
|
|
511
|
-
|
|
512
|
+
# Balanced parentheses belong to the path, so a file named
|
|
513
|
+
# 备份(旧).pdf is removed whole instead of leaving "(旧).pdf)" behind;
|
|
514
|
+
# angle brackets are CommonMark's quoting for paths with spaces.
|
|
515
|
+
# Both forms must still carry the scheme: normalization leaves every
|
|
516
|
+
# other link untouched, so [site](<https://example.com>) is ordinary
|
|
517
|
+
# text here rather than a file to strip.
|
|
518
|
+
sanitized = sanitized.gsub(/!?\[[^\]]*\]\((?:<file:\/\/[^<>\n]+>|file:\/\/(?:[^()\n]|\([^()\n]*\))+)\)/, "")
|
|
512
519
|
end
|
|
513
520
|
sanitized.strip
|
|
514
521
|
end
|
|
@@ -82,9 +82,9 @@ module Clacky
|
|
|
82
82
|
# `context` overrides the default three lines of surrounding code; the
|
|
83
83
|
# changes panel passes a huge value to reveal the whole file behind a
|
|
84
84
|
# collapsed "N unmodified lines" gap.
|
|
85
|
-
def diff(dir, file: nil, context: nil, scope: "worktree", base: nil)
|
|
85
|
+
def diff(dir, file: nil, context: nil, scope: "worktree", base: nil, target: nil)
|
|
86
86
|
extra = context ? ["-U#{context.to_i.clamp(0, 1_000_000).to_s}"] : []
|
|
87
|
-
range = diff_range(dir, scope, base)
|
|
87
|
+
range = diff_range(dir, scope, base, target)
|
|
88
88
|
if file && !file.empty?
|
|
89
89
|
others, _e, _ok = git(dir, "ls-files", "--others", "--exclude-standard", "--", file)
|
|
90
90
|
if others.strip.empty?
|
|
@@ -102,9 +102,12 @@ module Clacky
|
|
|
102
102
|
|
|
103
103
|
# Baseline args for `git diff` in the given scope. `worktree` keeps the
|
|
104
104
|
# historical behaviour (HEAD); `committed` reviews a single commit the
|
|
105
|
-
# user picked (or the whole unpushed range); `branch`
|
|
106
|
-
#
|
|
107
|
-
|
|
105
|
+
# user picked (or the whole unpushed range); `branch` reviews the branch
|
|
106
|
+
# the user picked, from the shared root up to that branch. A branch that
|
|
107
|
+
# already landed has no work of its own left on top of the default
|
|
108
|
+
# branch, so diffing it against HEAD would answer "what did main grow
|
|
109
|
+
# since the fork" - thousands of lines that say nothing about the pick.
|
|
110
|
+
def diff_range(dir, scope, base, target = nil)
|
|
108
111
|
case scope.to_s
|
|
109
112
|
when "unstaged" then []
|
|
110
113
|
when "staged" then ["--cached", "HEAD"]
|
|
@@ -117,9 +120,14 @@ module Clacky
|
|
|
117
120
|
commit_range(dir, base_ref)
|
|
118
121
|
end
|
|
119
122
|
when "branch"
|
|
120
|
-
base_ref =
|
|
121
|
-
|
|
122
|
-
|
|
123
|
+
base_ref = default_branch(dir)
|
|
124
|
+
target_ref = target.to_s.strip
|
|
125
|
+
target_ref = "HEAD" if target_ref.empty?
|
|
126
|
+
if base_ref.empty? || !ref?(dir, base_ref) || !ref?(dir, target_ref)
|
|
127
|
+
[]
|
|
128
|
+
else
|
|
129
|
+
["#{base_ref}...#{target_ref}"]
|
|
130
|
+
end
|
|
123
131
|
else ["HEAD"]
|
|
124
132
|
end
|
|
125
133
|
end
|
|
@@ -141,7 +149,8 @@ module Clacky
|
|
|
141
149
|
# unstaged - index vs working tree
|
|
142
150
|
# staged - HEAD vs index
|
|
143
151
|
# committed - the branch's commits on top of its base (upstream)
|
|
144
|
-
# branch -
|
|
152
|
+
# branch - what one branch the user picked contributed, measured from
|
|
153
|
+
# its shared root with the default branch
|
|
145
154
|
# lastTurn - what the previous agent turn touched (served from the
|
|
146
155
|
# Time Machine snapshots by `last_turn_review`, not git)
|
|
147
156
|
SCOPES = %w[worktree unstaged staged committed branch lastTurn].freeze
|
|
@@ -155,7 +164,7 @@ module Clacky
|
|
|
155
164
|
# `max_lines` caps each file's diff so a minified bundle cannot stall the
|
|
156
165
|
# browser; `truncated` tells the UI to say so instead of rendering half a
|
|
157
166
|
# hunk silently.
|
|
158
|
-
def review(dir, max_lines: 4000, max_total_lines: DEFAULT_MAX_TOTAL_LINES, scope: nil, base: nil)
|
|
167
|
+
def review(dir, max_lines: 4000, max_total_lines: DEFAULT_MAX_TOTAL_LINES, scope: nil, base: nil, target: nil)
|
|
159
168
|
return { repo: false } unless repo?(dir)
|
|
160
169
|
|
|
161
170
|
scope = SCOPES.include?(scope.to_s) ? scope.to_s : "worktree"
|
|
@@ -191,13 +200,17 @@ module Clacky
|
|
|
191
200
|
end
|
|
192
201
|
end
|
|
193
202
|
when "branch"
|
|
194
|
-
base_ref =
|
|
195
|
-
|
|
203
|
+
base_ref = default_branch(dir)
|
|
204
|
+
target_ref = target.to_s.strip
|
|
205
|
+
target_ref = "HEAD" if target_ref.empty?
|
|
196
206
|
if base_ref.empty? || !ref?(dir, base_ref)
|
|
197
207
|
payload.merge!(files: [], add: 0, del: 0, note: "noBase")
|
|
208
|
+
elsif !ref?(dir, target_ref)
|
|
209
|
+
payload.merge!(files: [], add: 0, del: 0, note: "noTarget")
|
|
198
210
|
else
|
|
199
211
|
payload[:base] = base_ref
|
|
200
|
-
payload
|
|
212
|
+
payload[:target] = target_ref == "HEAD" ? st[:branch].to_s : target_ref
|
|
213
|
+
payload.merge!(range_review(dir, ["#{base_ref}...#{target_ref}"], max_lines: max_lines,
|
|
201
214
|
max_total_lines: max_total_lines))
|
|
202
215
|
end
|
|
203
216
|
else
|
|
@@ -282,13 +295,19 @@ module Clacky
|
|
|
282
295
|
end
|
|
283
296
|
|
|
284
297
|
# Upstream of the current branch is the natural base for "committed":
|
|
285
|
-
# it is exactly the commits that have not been pushed yet.
|
|
286
|
-
#
|
|
287
|
-
# branches without an upstream.
|
|
298
|
+
# it is exactly the commits that have not been pushed yet. Branches
|
|
299
|
+
# without one fall back to the repository's mainline.
|
|
288
300
|
def default_base(dir)
|
|
289
301
|
out, _err, ok = git(dir, "rev-parse", "--abbrev-ref", "--symbolic-full-name", "@{upstream}")
|
|
290
302
|
return out.strip if ok && !out.strip.empty?
|
|
291
303
|
|
|
304
|
+
default_branch(dir)
|
|
305
|
+
end
|
|
306
|
+
|
|
307
|
+
# The repository's mainline, ignoring the current branch's upstream: a
|
|
308
|
+
# pushed feature branch tracks itself, which would leave "branch" with
|
|
309
|
+
# nothing but its unpushed commits.
|
|
310
|
+
def default_branch(dir)
|
|
292
311
|
out, _err, ok = git(dir, "symbolic-ref", "--short", "refs/remotes/origin/HEAD")
|
|
293
312
|
return out.strip if ok && !out.strip.empty?
|
|
294
313
|
|
|
@@ -347,11 +366,14 @@ module Clacky
|
|
|
347
366
|
end
|
|
348
367
|
end
|
|
349
368
|
|
|
350
|
-
# [{ name:, current: bool, remote: bool }] from `git branch --all
|
|
369
|
+
# [{ name:, current: bool, remote: bool }] from `git branch --all`, most
|
|
370
|
+
# recently committed first. A branch list is a list of work in flight, so
|
|
371
|
+
# the branch just pushed belongs at the top rather than wherever its name
|
|
372
|
+
# falls in the alphabet.
|
|
351
373
|
# Remote HEAD pointers (`origin/HEAD` → `origin/main`) are dropped: they
|
|
352
374
|
# are aliases, not branches the user can compare against.
|
|
353
375
|
def branches(dir)
|
|
354
|
-
out, _err, ok = git(dir, "branch", "--all",
|
|
376
|
+
out, _err, ok = git(dir, "branch", "--all", "--sort=-committerdate",
|
|
355
377
|
"--format=%(refname)%00%(refname:short)%00%(HEAD)")
|
|
356
378
|
return [] unless ok
|
|
357
379
|
|
|
@@ -1132,6 +1132,9 @@ module Clacky
|
|
|
1132
1132
|
return json_response(res, 400, { error: "Model not found in configuration" })
|
|
1133
1133
|
end
|
|
1134
1134
|
|
|
1135
|
+
# Clamped below like the switch endpoint — a draft outlives model changes.
|
|
1136
|
+
reasoning_raw = body["reasoning_effort"].to_s.strip
|
|
1137
|
+
|
|
1135
1138
|
# Optional project association — validate the project exists if provided
|
|
1136
1139
|
project_id_override = body["project_id"].to_s.strip
|
|
1137
1140
|
project_id_override = nil if project_id_override.empty?
|
|
@@ -1153,14 +1156,23 @@ module Clacky
|
|
|
1153
1156
|
|
|
1154
1157
|
session_id = build_session(name: name, working_dir: working_dir, profile: profile, source: source, model_id: model_id_override)
|
|
1155
1158
|
|
|
1156
|
-
#
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1159
|
+
# Apply what build_session doesn't take as keywords, then save once.
|
|
1160
|
+
agent = nil
|
|
1161
|
+
@registry.with_session(session_id) { |s| agent = s[:agent] }
|
|
1162
|
+
if agent
|
|
1163
|
+
dirty = false
|
|
1164
|
+
if project_id_override
|
|
1161
1165
|
agent.project_id = project_id_override
|
|
1162
|
-
|
|
1166
|
+
dirty = true
|
|
1167
|
+
end
|
|
1168
|
+
unless reasoning_raw.empty?
|
|
1169
|
+
agent.reasoning_effort = reasoning_raw
|
|
1170
|
+
# Unreachable stops collapse to a neighbour; unknown input to the default.
|
|
1171
|
+
carried = Clacky::ReasoningLevels.clamp(agent.current_model_info&.dig(:model), agent.reasoning_effort)
|
|
1172
|
+
agent.reasoning_effort = carried || Clacky::Agent::REASONING_DEFAULT
|
|
1173
|
+
dirty = true
|
|
1163
1174
|
end
|
|
1175
|
+
@session_manager.save(agent.to_session_data(updated_at: Time.now)) if dirty
|
|
1164
1176
|
end
|
|
1165
1177
|
|
|
1166
1178
|
broadcast_session_update(session_id, created: true)
|
|
@@ -1429,7 +1441,9 @@ module Clacky
|
|
|
1429
1441
|
ext_id = "ext/#{unit.ext_id}/#{unit.id}"
|
|
1430
1442
|
panel_id = "#{unit.ext_id}/#{unit.id}"
|
|
1431
1443
|
src = "/ext_ui/#{unit.ext_id}/#{rel}"
|
|
1432
|
-
|
|
1444
|
+
# Layer rides along so the web UI can group panels into "tools"
|
|
1445
|
+
# (built-in) vs "extensions" (installed / self-made) in the picker.
|
|
1446
|
+
"<script>Clacky.ext._extBegin(#{ext_id.to_json}, #{nil.to_json}, #{panel_id.to_json}, #{unit.layer.to_s.to_json})</script>" \
|
|
1433
1447
|
"<script src=#{src.to_json} data-ext-id=#{ext_id.to_json}></script>" \
|
|
1434
1448
|
"<script>Clacky.ext._extEnd()</script>"
|
|
1435
1449
|
end.join("\n")
|
|
@@ -2019,12 +2033,15 @@ module Clacky
|
|
|
2019
2033
|
mime_type = body["mime_type"].to_s
|
|
2020
2034
|
mime_type = "audio/webm" if mime_type.empty?
|
|
2021
2035
|
|
|
2036
|
+
session_id = body["session_id"].to_s
|
|
2037
|
+
session_id = nil if session_id.empty?
|
|
2038
|
+
|
|
2022
2039
|
result = Clacky::Media::Generator.new(@agent_config).generate_transcription(
|
|
2023
2040
|
audio_base64: audio_b64,
|
|
2024
2041
|
mime_type: mime_type
|
|
2025
2042
|
)
|
|
2026
2043
|
if result["success"]
|
|
2027
|
-
|
|
2044
|
+
log_media_usage(result, prompt: nil, session_id: session_id)
|
|
2028
2045
|
end
|
|
2029
2046
|
status = result["success"] ? 200 : 422
|
|
2030
2047
|
json_response(res, status, result)
|
|
@@ -2061,41 +2078,8 @@ module Clacky
|
|
|
2061
2078
|
end
|
|
2062
2079
|
|
|
2063
2080
|
private def log_media_usage(result, prompt:, session_id: nil)
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
return if usage.nil? && cost.nil?
|
|
2067
|
-
|
|
2068
|
-
parts = []
|
|
2069
|
-
parts << "model=#{result["model"]}"
|
|
2070
|
-
parts << "provider=#{result["provider"]}"
|
|
2071
|
-
if usage.is_a?(Hash)
|
|
2072
|
-
parts << "prompt_tokens=#{usage["prompt_tokens"]}"
|
|
2073
|
-
parts << "completion_tokens=#{usage["completion_tokens"]}"
|
|
2074
|
-
parts << "cache_read=#{usage["cache_read_tokens"]}" if usage["cache_read_tokens"].to_i > 0
|
|
2075
|
-
parts << "cache_write=#{usage["cache_write_tokens"]}" if usage["cache_write_tokens"].to_i > 0
|
|
2076
|
-
end
|
|
2077
|
-
parts << format("cost_usd=%.6f", cost.to_f) if cost
|
|
2078
|
-
parts << "prompt=#{prompt[0, 60].inspect}"
|
|
2079
|
-
kind = if result.key?("video") then "video"
|
|
2080
|
-
elsif result.key?("audio") then "audio"
|
|
2081
|
-
else "image"
|
|
2082
|
-
end
|
|
2083
|
-
Clacky::Logger.info("[Media] #{kind} generated #{parts.join(" ")}")
|
|
2084
|
-
|
|
2085
|
-
require_relative "../billing/billing_store"
|
|
2086
|
-
require_relative "../billing/billing_record"
|
|
2087
|
-
record = Clacky::Billing::BillingRecord.new(
|
|
2088
|
-
session_id: session_id,
|
|
2089
|
-
model: result["model"].to_s,
|
|
2090
|
-
provider: result["provider"].to_s,
|
|
2091
|
-
prompt_tokens: usage.is_a?(Hash) ? usage["prompt_tokens"].to_i : 0,
|
|
2092
|
-
completion_tokens: usage.is_a?(Hash) ? usage["completion_tokens"].to_i : 0,
|
|
2093
|
-
cache_read_tokens: usage.is_a?(Hash) ? usage["cache_read_tokens"].to_i : 0,
|
|
2094
|
-
cache_write_tokens: usage.is_a?(Hash) ? usage["cache_write_tokens"].to_i : 0,
|
|
2095
|
-
cost_usd: cost.to_f,
|
|
2096
|
-
cost_source: :api
|
|
2097
|
-
)
|
|
2098
|
-
Clacky::Billing::BillingStore.new.append(record)
|
|
2081
|
+
require_relative "../billing/media_usage"
|
|
2082
|
+
Clacky::Billing::MediaUsage.record(result, prompt: prompt, session_id: session_id)
|
|
2099
2083
|
end
|
|
2100
2084
|
|
|
2101
2085
|
# GET /api/media/types
|
|
@@ -2715,9 +2699,8 @@ module Clacky
|
|
|
2715
2699
|
else
|
|
2716
2700
|
Clacky::Logger.debug("[Brand] async distribution refresh skipped/failed — #{result[:message]}")
|
|
2717
2701
|
end
|
|
2718
|
-
#
|
|
2719
|
-
#
|
|
2720
|
-
brand.sync_free_skills_async! if source_current.call
|
|
2702
|
+
# Brand skills are installed on demand from the skills panel — no
|
|
2703
|
+
# background sync here.
|
|
2721
2704
|
rescue StandardError => e
|
|
2722
2705
|
Clacky::Logger.warn("[Brand] async distribution refresh raised: #{e.class}: #{e.message}")
|
|
2723
2706
|
ensure
|
|
@@ -2848,12 +2831,9 @@ module Clacky
|
|
|
2848
2831
|
result = @brand_test ? brand.activate_mock!(key) : brand.activate!(key)
|
|
2849
2832
|
|
|
2850
2833
|
if result[:success]
|
|
2851
|
-
# Refresh skill_loader
|
|
2852
|
-
#
|
|
2834
|
+
# Refresh skill_loader so brand skills installed from the panel become
|
|
2835
|
+
# loadable. Installation itself is user-driven.
|
|
2853
2836
|
@skill_loader = Clacky::SkillLoader.new(working_dir: nil, brand_config: brand)
|
|
2854
|
-
# Sync brand skills in the background so they are available without
|
|
2855
|
-
# manual user action.
|
|
2856
|
-
brand.sync_brand_skills_async!
|
|
2857
2837
|
json_response(res, 200, {
|
|
2858
2838
|
ok: true,
|
|
2859
2839
|
product_name: result[:product_name] || brand.product_name,
|
|
@@ -2926,7 +2906,11 @@ module Clacky
|
|
|
2926
2906
|
# operations (uninstall) need the installed directory name.
|
|
2927
2907
|
"slug" => slug,
|
|
2928
2908
|
"installed" => !container.nil?,
|
|
2929
|
-
"installed_version" => container&.dig(:version)
|
|
2909
|
+
"installed_version" => container&.dig(:version),
|
|
2910
|
+
# A catalog row still shows the "disabled" badge: switching an
|
|
2911
|
+
# extension off does not remove it from the marketplace, and the
|
|
2912
|
+
# row's "+" (enable) affordance is driven by this flag.
|
|
2913
|
+
"disabled" => container ? container[:disabled] == true : false
|
|
2930
2914
|
)
|
|
2931
2915
|
end
|
|
2932
2916
|
json_response(res, 200, { ok: true, extensions: extensions, meta: result[:meta] })
|
|
@@ -2977,6 +2961,7 @@ module Clacky
|
|
|
2977
2961
|
"slug" => slug,
|
|
2978
2962
|
"installed" => !container.nil?,
|
|
2979
2963
|
"installed_version" => container&.dig(:version) || ext["installed_version"],
|
|
2964
|
+
"disabled" => container ? container[:disabled] == true : false,
|
|
2980
2965
|
**local_overrides
|
|
2981
2966
|
)
|
|
2982
2967
|
end
|
|
@@ -5648,6 +5633,10 @@ module Clacky
|
|
|
5648
5633
|
# Third-party extension skills (installed/local) are managed from the
|
|
5649
5634
|
# extension panel, not the skills panel.
|
|
5650
5635
|
@skill_loader.loaded_from[skill.identifier] == :extension
|
|
5636
|
+
end.reject do |skill|
|
|
5637
|
+
# Agent-internal skills (recall-memory, meeting-summarizer) are never
|
|
5638
|
+
# user-triggered, so this panel has no action to offer for them.
|
|
5639
|
+
!skill.user_invocable?
|
|
5651
5640
|
end.map do |skill|
|
|
5652
5641
|
source = @skill_loader.loaded_from[skill.identifier]
|
|
5653
5642
|
meta = upload_meta[skill.identifier] || {}
|
|
@@ -5663,6 +5652,7 @@ module Clacky
|
|
|
5663
5652
|
description_zh: skill.description_zh,
|
|
5664
5653
|
source: source,
|
|
5665
5654
|
always_show: skill.always_show,
|
|
5655
|
+
agents: skill.agents_scope,
|
|
5666
5656
|
enabled: !skill.disabled?,
|
|
5667
5657
|
invalid: skill.invalid?,
|
|
5668
5658
|
warnings: skill.warnings,
|
|
@@ -5809,14 +5799,14 @@ module Clacky
|
|
|
5809
5799
|
when "diff"
|
|
5810
5800
|
json_response(res, 200, { repo: true, diff: Clacky::Server::GitPanel.diff(
|
|
5811
5801
|
dir, file: query["file"], context: query["context"],
|
|
5812
|
-
scope: query["scope"], base: query["base"]
|
|
5802
|
+
scope: query["scope"], base: query["base"], target: query["target"]
|
|
5813
5803
|
) })
|
|
5814
5804
|
when "review"
|
|
5815
5805
|
if query["scope"].to_s == "lastTurn"
|
|
5816
5806
|
json_response(res, 200, Clacky::Server::GitPanel.last_turn_review(git_session_agent(session_id)))
|
|
5817
5807
|
else
|
|
5818
5808
|
json_response(res, 200, Clacky::Server::GitPanel.review(
|
|
5819
|
-
dir, scope: query["scope"], base: query["base"]
|
|
5809
|
+
dir, scope: query["scope"], base: query["base"], target: query["target"]
|
|
5820
5810
|
))
|
|
5821
5811
|
end
|
|
5822
5812
|
when "log"
|
|
@@ -6824,20 +6814,9 @@ module Clacky
|
|
|
6824
6814
|
description = ""
|
|
6825
6815
|
updated_at = stat.mtime.strftime("%Y-%m-%d")
|
|
6826
6816
|
|
|
6827
|
-
|
|
6828
|
-
|
|
6829
|
-
|
|
6830
|
-
begin
|
|
6831
|
-
# Legacy files may still carry `updated_at: 2026-05-01`; permit Date so
|
|
6832
|
-
# they parse instead of raising DisallowedClass. The value itself is ignored.
|
|
6833
|
-
fm = YAML.safe_load(m[1], permitted_classes: [Date, Time]) || {}
|
|
6834
|
-
topic = fm["topic"].to_s unless fm["topic"].to_s.strip.empty?
|
|
6835
|
-
description = fm["description"].to_s
|
|
6836
|
-
rescue StandardError
|
|
6837
|
-
# Bad frontmatter — fall back to defaults above.
|
|
6838
|
-
end
|
|
6839
|
-
end
|
|
6840
|
-
end
|
|
6817
|
+
fm = Utils::Frontmatter.parse(content)
|
|
6818
|
+
topic = fm["topic"].to_s unless fm["topic"].to_s.strip.empty?
|
|
6819
|
+
description = fm["description"].to_s
|
|
6841
6820
|
|
|
6842
6821
|
preview = content.sub(/\A---.*?---\s*\n/m, "").strip[0, 200]
|
|
6843
6822
|
|
|
@@ -7008,7 +6987,10 @@ module Clacky
|
|
|
7008
6987
|
# endpoint belongs to (same rule the session status bar uses), so
|
|
7009
6988
|
# the picker can offer the switcher on every row and not only on
|
|
7010
6989
|
# the session's current one.
|
|
7011
|
-
sub_models: provider_id ? Clacky::Providers.models(provider_id) : []
|
|
6990
|
+
sub_models: provider_id ? Clacky::Providers.models(provider_id) : [],
|
|
6991
|
+
# Stops this model can actually distinguish. The picker hides its
|
|
6992
|
+
# reasoning control when the list is empty.
|
|
6993
|
+
reasoning_levels: Clacky::ReasoningLevels.for_model(m["model"])
|
|
7012
6994
|
}
|
|
7013
6995
|
end
|
|
7014
6996
|
# Sidecar capability configs (media/ocr) and auto-injected entries are
|
|
@@ -8062,6 +8044,10 @@ module Clacky
|
|
|
8062
8044
|
unless agent.switch_model_by_id(model_id)
|
|
8063
8045
|
return json_response(res, 500, { error: "Failed to switch model" })
|
|
8064
8046
|
end
|
|
8047
|
+
# Coarser models collapse several stops onto one value, so carry the
|
|
8048
|
+
# session's intent across to a stop the new model can actually reach.
|
|
8049
|
+
carried = Clacky::ReasoningLevels.clamp(target_model["model"], agent.reasoning_effort)
|
|
8050
|
+
agent.reasoning_effort = carried if carried
|
|
8065
8051
|
end
|
|
8066
8052
|
return json_response(res, 404, { error: "Session not found" }) unless agent
|
|
8067
8053
|
|
|
@@ -8088,6 +8074,10 @@ module Clacky
|
|
|
8088
8074
|
return json_response(res, 404, { error: "Session not found" }) unless agent
|
|
8089
8075
|
|
|
8090
8076
|
agent.reasoning_effort = raw
|
|
8077
|
+
# A stop the current model cannot express would silently send the same
|
|
8078
|
+
# request as its neighbour, so store the reachable stop instead.
|
|
8079
|
+
carried = Clacky::ReasoningLevels.clamp(agent.current_model_info&.dig(:model), agent.reasoning_effort)
|
|
8080
|
+
agent.reasoning_effort = carried if carried
|
|
8091
8081
|
@session_manager.save(agent.to_session_data(updated_at: Time.now))
|
|
8092
8082
|
broadcast_session_update(session_id)
|
|
8093
8083
|
|
|
@@ -8135,6 +8125,8 @@ module Clacky
|
|
|
8135
8125
|
end
|
|
8136
8126
|
|
|
8137
8127
|
agent.set_session_sub_model(model_name)
|
|
8128
|
+
carried = Clacky::ReasoningLevels.clamp(agent.current_model_info&.dig(:model), agent.reasoning_effort)
|
|
8129
|
+
agent.reasoning_effort = carried if carried
|
|
8138
8130
|
end
|
|
8139
8131
|
return json_response(res, 404, { error: "Session not found" }) unless agent
|
|
8140
8132
|
@session_manager.save(agent.to_session_data(updated_at: Time.now))
|
|
@@ -8643,8 +8635,7 @@ module Clacky
|
|
|
8643
8635
|
conn.send_json(type: "pong")
|
|
8644
8636
|
|
|
8645
8637
|
else
|
|
8646
|
-
|
|
8647
|
-
extension = namespace && Clacky::ApiExtension.registry[namespace[1]]
|
|
8638
|
+
extension = Clacky::ApiExtension.ws_extension_for(type)
|
|
8648
8639
|
unless extension && extension.on_ws_event(conn, msg)
|
|
8649
8640
|
conn.send_json(type: "error", message: "Unknown message type: #{type}")
|
|
8650
8641
|
end
|
|
@@ -230,6 +230,7 @@ module Clacky
|
|
|
230
230
|
cost_source: live_cost_source,
|
|
231
231
|
permission_mode: s[:agent]&.permission_mode,
|
|
232
232
|
reasoning_effort: s[:agent]&.reasoning_effort,
|
|
233
|
+
reasoning_levels: Clacky::ReasoningLevels.for_model(model_info&.dig(:model)),
|
|
233
234
|
latest_latency: s[:agent]&.latest_latency,
|
|
234
235
|
card_model: model_info&.dig(:card_model),
|
|
235
236
|
sub_model: model_info&.dig(:sub_model),
|
|
@@ -349,6 +350,7 @@ module Clacky
|
|
|
349
350
|
total_cost: s[:agent]&.total_cost, cost_source: s[:agent]&.cost_source,
|
|
350
351
|
permission_mode: s[:agent]&.permission_mode,
|
|
351
352
|
reasoning_effort: s[:agent]&.reasoning_effort,
|
|
353
|
+
reasoning_levels: Clacky::ReasoningLevels.for_model(model_info&.dig(:model)),
|
|
352
354
|
latest_latency: s[:agent]&.latest_latency,
|
|
353
355
|
card_model: model_info&.dig(:card_model),
|
|
354
356
|
sub_model: model_info&.dig(:sub_model),
|
|
@@ -400,6 +402,7 @@ module Clacky
|
|
|
400
402
|
# sessions start with nil and get populated on the next LLM call.
|
|
401
403
|
latest_latency: ls&.dig(:latest_latency),
|
|
402
404
|
reasoning_effort: ls&.dig(:reasoning_effort) || s.dig(:config, :reasoning_effort),
|
|
405
|
+
reasoning_levels: ls&.dig(:reasoning_levels) || Clacky::ReasoningLevels.for_model(ls&.dig(:model)),
|
|
403
406
|
pinned: s[:pinned] || false,
|
|
404
407
|
archived_at: s[:archived_at],
|
|
405
408
|
channel_info: s[:channel_info],
|