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/agent_config.rb
CHANGED
|
@@ -162,7 +162,7 @@ module Clacky
|
|
|
162
162
|
:enable_compression, :enable_idle_compression, :enable_prompt_caching,
|
|
163
163
|
:compression_threshold, :message_count_threshold,
|
|
164
164
|
:models, :current_model_index, :current_model_id,
|
|
165
|
-
:memory_update_enabled, :
|
|
165
|
+
:memory_update_enabled, :skill_evolution,
|
|
166
166
|
:max_running_agents, :max_idle_agents,
|
|
167
167
|
:default_working_dir, :pid_dir,
|
|
168
168
|
:proxy_url,
|
|
@@ -208,7 +208,7 @@ module Clacky
|
|
|
208
208
|
|
|
209
209
|
# Memory and skill evolution configuration
|
|
210
210
|
@memory_update_enabled = options[:memory_update_enabled].nil? ? true : options[:memory_update_enabled]
|
|
211
|
-
@
|
|
211
|
+
@shared_settings = { "memory_inject_enabled" => options[:memory_inject_enabled] == true }
|
|
212
212
|
# Agent used when a session is created without an explicit profile
|
|
213
213
|
# (New Session page, sidebar quick-create, channel and cron sessions).
|
|
214
214
|
self.default_agent = options[:default_agent]
|
|
@@ -396,7 +396,7 @@ module Clacky
|
|
|
396
396
|
|
|
397
397
|
def deep_copy
|
|
398
398
|
# dup gives us a new AgentConfig with independent scalar ivars but
|
|
399
|
-
# the same @models
|
|
399
|
+
# the same @models and @shared_settings references — exactly what we want.
|
|
400
400
|
copy = dup
|
|
401
401
|
# But @virtual_model_overlay must be independent: a forked subagent
|
|
402
402
|
# setting/clearing its own overlay must NOT leak into the parent.
|
|
@@ -477,6 +477,16 @@ module Clacky
|
|
|
477
477
|
proxy_url clacky_license_server
|
|
478
478
|
].freeze
|
|
479
479
|
|
|
480
|
+
# Settings every live session must observe at once. A session config is a
|
|
481
|
+
# deep_copy snapshot, so these live in @shared_settings, which dup shares by
|
|
482
|
+
# reference like @models.
|
|
483
|
+
SHARED_SETTINGS_KEYS = %w[memory_inject_enabled].freeze
|
|
484
|
+
|
|
485
|
+
SHARED_SETTINGS_KEYS.each do |key|
|
|
486
|
+
define_method(key) { @shared_settings[key] }
|
|
487
|
+
define_method("#{key}=") { |value| @shared_settings[key] = value }
|
|
488
|
+
end
|
|
489
|
+
|
|
480
490
|
# Serialize the current agent configuration to YAML.
|
|
481
491
|
# Outputs a hash with "settings" and "models" keys (new format).
|
|
482
492
|
# Backward compatibility: old flat-array format is still readable by .load.
|
|
@@ -493,7 +503,7 @@ module Clacky
|
|
|
493
503
|
"compression_threshold" => @compression_threshold,
|
|
494
504
|
"message_count_threshold" => @message_count_threshold,
|
|
495
505
|
"memory_update_enabled" => @memory_update_enabled,
|
|
496
|
-
"memory_inject_enabled" =>
|
|
506
|
+
"memory_inject_enabled" => memory_inject_enabled,
|
|
497
507
|
"default_agent" => @default_agent,
|
|
498
508
|
"skill_evolution" => @skill_evolution,
|
|
499
509
|
"max_running_agents" => @max_running_agents,
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Clacky
|
|
4
|
+
module Billing
|
|
5
|
+
# Media calls (image / video / TTS / STT) are billed per request rather than
|
|
6
|
+
# per agent turn, and every caller needs the same log line plus ledger row.
|
|
7
|
+
# Kept in one place so a new media path cannot silently skip billing the way
|
|
8
|
+
# meeting transcription did.
|
|
9
|
+
module MediaUsage
|
|
10
|
+
module_function
|
|
11
|
+
|
|
12
|
+
# @param result [Hash] media generator result (contains "usage" / "cost_usd")
|
|
13
|
+
# @param kind [String, nil] "image" / "video" / "audio" / "stt"; inferred when nil
|
|
14
|
+
def record(result, prompt: nil, session_id: nil, kind: nil)
|
|
15
|
+
return unless result.is_a?(Hash)
|
|
16
|
+
|
|
17
|
+
usage = result["usage"]
|
|
18
|
+
cost = result["cost_usd"]
|
|
19
|
+
return if usage.nil? && cost.nil?
|
|
20
|
+
|
|
21
|
+
kind ||= infer_kind(result)
|
|
22
|
+
log(result, usage, cost, prompt, kind)
|
|
23
|
+
append(result, usage, cost, session_id)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def infer_kind(result)
|
|
27
|
+
return "video" if result.key?("video")
|
|
28
|
+
return "audio" if result.key?("audio")
|
|
29
|
+
return "stt" if result.key?("text")
|
|
30
|
+
|
|
31
|
+
"image"
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def log(result, usage, cost, prompt, kind)
|
|
35
|
+
parts = []
|
|
36
|
+
parts << "model=#{result["model"]}"
|
|
37
|
+
parts << "provider=#{result["provider"]}"
|
|
38
|
+
if usage.is_a?(Hash)
|
|
39
|
+
parts << "prompt_tokens=#{usage["prompt_tokens"]}" unless usage["prompt_tokens"].nil?
|
|
40
|
+
parts << "completion_tokens=#{usage["completion_tokens"]}" unless usage["completion_tokens"].nil?
|
|
41
|
+
parts << "cache_read=#{usage["cache_read_tokens"]}" if usage["cache_read_tokens"].to_i > 0
|
|
42
|
+
parts << "cache_write=#{usage["cache_write_tokens"]}" if usage["cache_write_tokens"].to_i > 0
|
|
43
|
+
parts << format("audio_seconds=%.2f", usage["audio_seconds"].to_f) unless usage["audio_seconds"].nil?
|
|
44
|
+
end
|
|
45
|
+
parts << format("cost_usd=%.6f", cost.to_f) unless cost.nil?
|
|
46
|
+
parts << "prompt=#{prompt[0, 60].inspect}" if prompt
|
|
47
|
+
Clacky::Logger.info("[Media] #{kind} generated #{parts.join(" ")}")
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def append(result, usage, cost, session_id)
|
|
51
|
+
require_relative "billing_store"
|
|
52
|
+
require_relative "billing_record"
|
|
53
|
+
|
|
54
|
+
record = Clacky::Billing::BillingRecord.new(
|
|
55
|
+
session_id: session_id,
|
|
56
|
+
model: result["model"].to_s,
|
|
57
|
+
provider: result["provider"].to_s,
|
|
58
|
+
prompt_tokens: usage.is_a?(Hash) ? usage["prompt_tokens"].to_i : 0,
|
|
59
|
+
completion_tokens: usage.is_a?(Hash) ? usage["completion_tokens"].to_i : 0,
|
|
60
|
+
cache_read_tokens: usage.is_a?(Hash) ? usage["cache_read_tokens"].to_i : 0,
|
|
61
|
+
cache_write_tokens: usage.is_a?(Hash) ? usage["cache_write_tokens"].to_i : 0,
|
|
62
|
+
cost_usd: cost.to_f,
|
|
63
|
+
cost_source: (result["cost_source"] || "api").to_sym
|
|
64
|
+
)
|
|
65
|
+
Clacky::Billing::BillingStore.new.append(record)
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
@@ -62,6 +62,9 @@ module Clacky
|
|
|
62
62
|
"oc-grok-4.7" => "oc-grok-4.7",
|
|
63
63
|
# gemini chat (or-)
|
|
64
64
|
"or-gemini-4-argon" => "gemini-4-argon",
|
|
65
|
+
"or-gemini-4-neon" => "gemini-4-neon",
|
|
66
|
+
"or-gemini-4-carbon" => "gemini-4-carbon",
|
|
67
|
+
"or-gemini-4-hydrogen" => "gemini-4-hydrogen",
|
|
65
68
|
"or-gemini-3-1-pro" => "gemini-3.1-pro-preview",
|
|
66
69
|
"or-gemini-3-8-flash" => "gemini-3.8-flash",
|
|
67
70
|
"or-gemini-3-7-flash" => "gemini-3.7-flash",
|
|
@@ -85,7 +88,9 @@ module Clacky
|
|
|
85
88
|
# text-to-speech (or-)
|
|
86
89
|
"or-tts-gemini-2-5-flash" => "gemini-2.5-flash-tts",
|
|
87
90
|
"or-tts-gemini-2-5-pro" => "gemini-2.5-pro-tts",
|
|
91
|
+
"dsk-deepseek-tts" => "deepseek-tts",
|
|
88
92
|
# speech-to-text (or-)
|
|
93
|
+
"dsk-deepseek-asr" => "deepseek-asr",
|
|
89
94
|
"or-stt-gemini-3-8-flash" => "gemini-3.8-flash",
|
|
90
95
|
"or-stt-gemini-3-7-flash" => "gemini-3.7-flash",
|
|
91
96
|
"or-stt-gemini-3-6-flash" => "gemini-3.6-flash",
|
data/lib/clacky/brand_config.rb
CHANGED
|
@@ -506,41 +506,6 @@ module Clacky
|
|
|
506
506
|
install_brand_skill!(skill_info, encrypted: false)
|
|
507
507
|
end
|
|
508
508
|
|
|
509
|
-
# Synchronise free skills in the background for unactivated branded installs.
|
|
510
|
-
#
|
|
511
|
-
# Mirrors sync_brand_skills_async! but uses the public free_skills endpoint
|
|
512
|
-
# so no license is required. Only runs when the install is branded and NOT
|
|
513
|
-
# activated — once a license is activated the regular brand-skill sync
|
|
514
|
-
# takes over (and may include additional encrypted skills).
|
|
515
|
-
#
|
|
516
|
-
# @return [Thread, nil]
|
|
517
|
-
def sync_free_skills_async!(on_complete: nil)
|
|
518
|
-
return nil unless branded?
|
|
519
|
-
return nil if activated?
|
|
520
|
-
return nil if ENV["CLACKY_TEST"] == "1"
|
|
521
|
-
|
|
522
|
-
Clacky::ThreadRegistry.spawn(name: "brand-fetch-free-skills") do
|
|
523
|
-
Thread.current.abort_on_exception = false
|
|
524
|
-
|
|
525
|
-
begin
|
|
526
|
-
result = fetch_free_skills!
|
|
527
|
-
next unless result[:success]
|
|
528
|
-
|
|
529
|
-
remote_skill_names = result[:skills].map { |s| s["name"] }
|
|
530
|
-
installed_brand_skills.each_key do |local_name|
|
|
531
|
-
send(:delete_brand_skill!, local_name) unless remote_skill_names.include?(local_name)
|
|
532
|
-
end
|
|
533
|
-
|
|
534
|
-
installed = installed_brand_skills
|
|
535
|
-
to_install = result[:skills].select { |s| installed[s["name"]].nil? || s["needs_update"] }
|
|
536
|
-
results = to_install.map { |skill_info| install_free_skill!(skill_info) }
|
|
537
|
-
|
|
538
|
-
on_complete&.call(results)
|
|
539
|
-
rescue StandardError
|
|
540
|
-
# Background sync failures are intentionally swallowed.
|
|
541
|
-
end
|
|
542
|
-
end
|
|
543
|
-
end
|
|
544
509
|
|
|
545
510
|
# Upload (publish) a custom skill ZIP to the OpenClacky Cloud API.
|
|
546
511
|
# Calls POST /api/v1/client/skills (system-license endpoint).
|
|
@@ -893,12 +858,13 @@ module Clacky
|
|
|
893
858
|
|
|
894
859
|
# Extensions bundled into the activated license's distribution are free and
|
|
895
860
|
# unencrypted. They are fetched over the same license-HMAC scheme as brand
|
|
896
|
-
# skills
|
|
861
|
+
# skills, but are never installed automatically — the user picks them from
|
|
862
|
+
# the extension panel.
|
|
897
863
|
|
|
898
864
|
# Fetch the extensions bundled into the activated license's distribution.
|
|
899
865
|
# Requires an activated license. Returns { success:, extensions: [], error: }.
|
|
900
|
-
# Each extension carries name + latest_version.download_url so
|
|
901
|
-
#
|
|
866
|
+
# Each extension carries name + latest_version.download_url so the panel can
|
|
867
|
+
# install it on demand.
|
|
902
868
|
def fetch_brand_extensions!(sort: nil)
|
|
903
869
|
return { success: false, error: "License not activated", extensions: [] } unless activated?
|
|
904
870
|
|
|
@@ -921,14 +887,14 @@ module Clacky
|
|
|
921
887
|
|
|
922
888
|
if response[:success]
|
|
923
889
|
body = response[:data]
|
|
924
|
-
installed =
|
|
890
|
+
installed = installed_extension_versions
|
|
925
891
|
extensions = (body["extensions"] || []).map do |ext|
|
|
926
892
|
slug = ext["name"].to_s
|
|
927
|
-
|
|
893
|
+
local_ver = installed[slug]
|
|
928
894
|
latest_ver = (ext["latest_version"] || {})["version"] || ext["version"]
|
|
929
895
|
ext.merge(
|
|
930
|
-
"installed_version" =>
|
|
931
|
-
"needs_update" =>
|
|
896
|
+
"installed_version" => local_ver,
|
|
897
|
+
"needs_update" => local_ver ? version_older?(local_ver, latest_ver) : true
|
|
932
898
|
)
|
|
933
899
|
end
|
|
934
900
|
{ success: true, extensions: extensions, expires_at: body["expires_at"] }
|
|
@@ -937,110 +903,20 @@ module Clacky
|
|
|
937
903
|
end
|
|
938
904
|
end
|
|
939
905
|
|
|
940
|
-
#
|
|
941
|
-
#
|
|
942
|
-
#
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
url = (ext_info["latest_version"] || {})["download_url"]
|
|
948
|
-
|
|
949
|
-
return { success: false, error: "Missing extension name" } if slug.empty?
|
|
950
|
-
return { success: false, error: "No download URL" } if url.nil? || url.strip.empty?
|
|
951
|
-
|
|
952
|
-
Clacky::ExtensionPackager.install(url, force: true)
|
|
953
|
-
record_installed_extension(slug, version)
|
|
954
|
-
{ success: true, name: slug, version: version }
|
|
955
|
-
rescue StandardError => e
|
|
956
|
-
{ success: false, error: e.message }
|
|
957
|
-
end
|
|
958
|
-
|
|
959
|
-
# Synchronise brand extensions in the background for activated consumer
|
|
960
|
-
# installs. Brand administrators manage extensions through ext-studio and
|
|
961
|
-
# must not auto-install the extensions they publish for consumers.
|
|
962
|
-
# Mirrors sync_brand_skills_async! but installs into the extension layer.
|
|
963
|
-
#
|
|
964
|
-
# @return [Thread, nil]
|
|
965
|
-
def sync_brand_extensions_async!(on_complete: nil)
|
|
966
|
-
return nil unless activated?
|
|
967
|
-
return nil if user_licensed?
|
|
968
|
-
return nil if ENV["CLACKY_TEST"] == "1"
|
|
969
|
-
|
|
970
|
-
Clacky::ThreadRegistry.spawn(name: "brand-fetch-extensions") do
|
|
971
|
-
Thread.current.abort_on_exception = false
|
|
972
|
-
|
|
973
|
-
begin
|
|
974
|
-
result = fetch_brand_extensions!
|
|
975
|
-
next unless result[:success]
|
|
976
|
-
|
|
977
|
-
remote_names = result[:extensions].map { |e| e["name"] }
|
|
978
|
-
installed_brand_extensions.each_key do |local_name|
|
|
979
|
-
delete_brand_extension!(local_name) unless remote_names.include?(local_name)
|
|
980
|
-
end
|
|
981
|
-
|
|
982
|
-
to_install = result[:extensions].select { |e| e["needs_update"] }
|
|
983
|
-
results = to_install.map { |ext_info| install_brand_extension!(ext_info) }
|
|
984
|
-
|
|
985
|
-
Clacky::ExtensionLoader.invalidate_cache! unless results.empty?
|
|
986
|
-
on_complete&.call(results)
|
|
987
|
-
rescue StandardError
|
|
988
|
-
# Background sync failures are intentionally swallowed.
|
|
989
|
-
end
|
|
990
|
-
end
|
|
991
|
-
end
|
|
992
|
-
|
|
993
|
-
# Path to the JSON registry tracking installed brand extension versions.
|
|
994
|
-
def brand_extensions_registry_path
|
|
995
|
-
File.join(File.expand_path(Clacky::ExtensionLoader::INSTALLED_DIR), "brand_extensions.json")
|
|
996
|
-
end
|
|
997
|
-
|
|
998
|
-
# Installed brand extensions keyed by ext_id => { "version" => "..." }.
|
|
999
|
-
# Entries whose on-disk container no longer exists are pruned.
|
|
1000
|
-
def installed_brand_extensions
|
|
1001
|
-
path = brand_extensions_registry_path
|
|
1002
|
-
return {} unless File.exist?(path)
|
|
906
|
+
# Versions of the extensions present in the on-disk `installed` layer, keyed
|
|
907
|
+
# by ext_id. Read from disk rather than a side registry so a manual install
|
|
908
|
+
# is reflected immediately.
|
|
909
|
+
private def installed_extension_versions
|
|
910
|
+
result = Clacky::ExtensionLoader.load_all
|
|
911
|
+
Array(result&.containers).each_with_object({}) do |(id, container), acc|
|
|
912
|
+
next unless container[:layer] == :installed
|
|
1003
913
|
|
|
1004
|
-
|
|
1005
|
-
valid = {}
|
|
1006
|
-
changed = false
|
|
1007
|
-
raw.each do |name, meta|
|
|
1008
|
-
if Dir.exist?(File.join(File.dirname(path), name))
|
|
1009
|
-
valid[name] = meta
|
|
1010
|
-
else
|
|
1011
|
-
changed = true
|
|
1012
|
-
end
|
|
914
|
+
acc[id.to_s] = container[:version].to_s
|
|
1013
915
|
end
|
|
1014
|
-
File.write(path, JSON.generate(valid)) if changed
|
|
1015
|
-
valid
|
|
1016
916
|
rescue StandardError
|
|
1017
917
|
{}
|
|
1018
918
|
end
|
|
1019
919
|
|
|
1020
|
-
# Remove a single installed brand extension by id (files + registry entry).
|
|
1021
|
-
def delete_brand_extension!(ext_id)
|
|
1022
|
-
ext_dir = File.join(File.expand_path(Clacky::ExtensionLoader::INSTALLED_DIR), ext_id)
|
|
1023
|
-
FileUtils.rm_rf(ext_dir) if Dir.exist?(ext_dir)
|
|
1024
|
-
|
|
1025
|
-
path = brand_extensions_registry_path
|
|
1026
|
-
if File.exist?(path)
|
|
1027
|
-
registry = JSON.parse(File.read(path))
|
|
1028
|
-
registry.delete(ext_id)
|
|
1029
|
-
File.write(path, JSON.generate(registry))
|
|
1030
|
-
end
|
|
1031
|
-
Clacky::ExtensionLoader.invalidate_cache!
|
|
1032
|
-
rescue StandardError
|
|
1033
|
-
# Deletion errors are non-fatal.
|
|
1034
|
-
end
|
|
1035
|
-
|
|
1036
|
-
private def record_installed_extension(ext_id, version)
|
|
1037
|
-
path = brand_extensions_registry_path
|
|
1038
|
-
FileUtils.mkdir_p(File.dirname(path))
|
|
1039
|
-
registry = File.exist?(path) ? (JSON.parse(File.read(path)) rescue {}) : {}
|
|
1040
|
-
registry[ext_id] = { "version" => version.to_s }
|
|
1041
|
-
File.write(path, JSON.generate(registry))
|
|
1042
|
-
end
|
|
1043
|
-
|
|
1044
920
|
public
|
|
1045
921
|
|
|
1046
922
|
# Fetch the public store skills list from the OpenClacky Cloud API.
|
|
@@ -1331,81 +1207,6 @@ module Clacky
|
|
|
1331
1207
|
{ success: false, error: e.message }
|
|
1332
1208
|
end
|
|
1333
1209
|
|
|
1334
|
-
# Synchronise brand skills in the background.
|
|
1335
|
-
#
|
|
1336
|
-
# Fetches the remote skills list and installs every skill that is missing
|
|
1337
|
-
# locally or has a newer remote version — skills the brand publishes after
|
|
1338
|
-
# this install was activated therefore arrive without user action. The work
|
|
1339
|
-
# runs in a daemon Thread so it never blocks the caller (typically Agent
|
|
1340
|
-
# startup).
|
|
1341
|
-
#
|
|
1342
|
-
# If the license is not activated the method returns immediately without
|
|
1343
|
-
# spawning a thread.
|
|
1344
|
-
#
|
|
1345
|
-
# @param on_complete [Proc, nil] Optional callback called with the sync
|
|
1346
|
-
# results array once all downloads finish (useful for tests / UI feedback).
|
|
1347
|
-
# @return [Thread, nil] The background thread, or nil if skipped.
|
|
1348
|
-
def sync_brand_skills_async!(on_complete: nil)
|
|
1349
|
-
return nil unless activated?
|
|
1350
|
-
return nil if ENV["CLACKY_TEST"] == "1"
|
|
1351
|
-
|
|
1352
|
-
Clacky::ThreadRegistry.spawn(name: "brand-fetch-skills") do
|
|
1353
|
-
Thread.current.abort_on_exception = false
|
|
1354
|
-
|
|
1355
|
-
begin
|
|
1356
|
-
result = fetch_brand_skills!
|
|
1357
|
-
next unless result[:success]
|
|
1358
|
-
|
|
1359
|
-
# Remove locally installed skills that have been deleted on the remote.
|
|
1360
|
-
# Compare the set of remote skill names against what is installed locally
|
|
1361
|
-
# and delete any skill that no longer exists in the remote catalogue.
|
|
1362
|
-
remote_skill_names = result[:skills].map { |s| s["name"] }
|
|
1363
|
-
installed_brand_skills.each_key do |local_name|
|
|
1364
|
-
delete_brand_skill!(local_name) unless remote_skill_names.include?(local_name)
|
|
1365
|
-
end
|
|
1366
|
-
|
|
1367
|
-
# Install every remote skill that is missing locally or has a newer
|
|
1368
|
-
# version available, so the local catalogue converges on the brand's
|
|
1369
|
-
# without the user clicking Install in the Brand Skills panel.
|
|
1370
|
-
installed = installed_brand_skills
|
|
1371
|
-
skills_to_install = result[:skills].select do |s|
|
|
1372
|
-
s["needs_update"] || !installed.key?(s["name"])
|
|
1373
|
-
end
|
|
1374
|
-
results = skills_to_install.map do |skill_info|
|
|
1375
|
-
install_brand_skill!(skill_info)
|
|
1376
|
-
end
|
|
1377
|
-
|
|
1378
|
-
# Even when the version hasn't changed, display metadata (name_zh,
|
|
1379
|
-
# description_zh, description) may have been updated on the platform.
|
|
1380
|
-
# Patch brand_skills.json in-place without re-downloading the ZIP.
|
|
1381
|
-
result[:skills].each do |skill_info|
|
|
1382
|
-
name = skill_info["name"]
|
|
1383
|
-
next unless installed.key?(name)
|
|
1384
|
-
next if skill_info["needs_update"] # already being reinstalled above
|
|
1385
|
-
|
|
1386
|
-
local = installed[name]
|
|
1387
|
-
next if local["name_zh"] == skill_info["name_zh"].to_s &&
|
|
1388
|
-
local["description_zh"] == skill_info["description_zh"].to_s &&
|
|
1389
|
-
local["description"] == skill_info["description"].to_s
|
|
1390
|
-
|
|
1391
|
-
# Metadata changed — update brand_skills.json without reinstalling.
|
|
1392
|
-
record_installed_skill(
|
|
1393
|
-
name,
|
|
1394
|
-
local["version"],
|
|
1395
|
-
skill_info["description"].to_s,
|
|
1396
|
-
encrypted: local["encrypted"] != false,
|
|
1397
|
-
description_zh: skill_info["description_zh"].to_s,
|
|
1398
|
-
name_zh: skill_info["name_zh"].to_s
|
|
1399
|
-
)
|
|
1400
|
-
end
|
|
1401
|
-
|
|
1402
|
-
on_complete&.call(results)
|
|
1403
|
-
rescue StandardError
|
|
1404
|
-
# Background sync failures are intentionally swallowed — the agent
|
|
1405
|
-
# continues to work with whatever skills are already installed.
|
|
1406
|
-
end
|
|
1407
|
-
end
|
|
1408
|
-
end
|
|
1409
1210
|
|
|
1410
1211
|
# Path to the directory where brand skills are installed.
|
|
1411
1212
|
def brand_skills_dir
|
|
@@ -1,83 +1,5 @@
|
|
|
1
|
-
You are Extension Developer, an AI expert who helps users build, debug, and
|
|
2
|
-
when requested, publish OpenClacky extensions through conversation.
|
|
1
|
+
You are Extension Developer, an AI expert who helps users build, debug, and publish OpenClacky extensions through conversation.
|
|
3
2
|
|
|
4
3
|
## How you work
|
|
5
4
|
|
|
6
|
-
First call `invoke_skill` for `ext-develop
|
|
7
|
-
the workflow and reference index; linked articles own interface contracts. Behavior-only
|
|
8
|
-
discussion needs no API inventory. Read only the current decision's reference, reuse it
|
|
9
|
-
while in context, and never rely on remembered fields, endpoints, or reload behavior.
|
|
10
|
-
|
|
11
|
-
Discuss the smallest behavior and wait for approval before scaffolding or editing. Before
|
|
12
|
-
approval, call no tool after the skill. Unless internals are requested, send exactly four
|
|
13
|
-
short sections in the user's language—Visible result, Will do, Won't do, Confirm (with at
|
|
14
|
-
most one material choice)—and nothing else. Never include paths, files, commands, fields,
|
|
15
|
-
mount points, APIs, code symbols, ids, frontend/backend (前端/后端), agent/智能体 types,
|
|
16
|
-
parenthetical internal translations, implementation, or verification details.
|
|
17
|
-
After approval, edit real files and verify relevant tests plus the actual result; manifest
|
|
18
|
-
success alone is insufficient. Report missing evidence plainly.
|
|
19
|
-
|
|
20
|
-
## Extension engineering rules
|
|
21
|
-
|
|
22
|
-
These are requirements for every design and implementation, even when the skill or
|
|
23
|
-
online documentation is unavailable. Do not defer them to a later documentation lookup.
|
|
24
|
-
|
|
25
|
-
- **Security and scope.** Refuse credential theft or unauthorized private-data access/
|
|
26
|
-
export; never bypass host permissions or expose secrets in client code/logs. Limit file
|
|
27
|
-
and session access to the approved purpose. Destruction and private-data transfer need
|
|
28
|
-
explicit approval of data and destination. Read-only/no-file-change also forbids helper
|
|
29
|
-
files and scripts, including `/tmp`; a tool cache grants no write permission.
|
|
30
|
-
- **Performance.** OpenClacky's host is single-process, so request volume is a safety
|
|
31
|
-
boundary: prefer events and cached reads, and never create unbounded polling, retries,
|
|
32
|
-
workers, or overlapping requests.
|
|
33
|
-
- **Lifecycle.** Clean up listeners, timers, and requests across rerenders; hidden panels
|
|
34
|
-
may stay mounted, so use the documented visibility and unsubscribe behavior instead of
|
|
35
|
-
assuming a tab or session switch disposes them. Ignore stale async results, and never
|
|
36
|
-
replay external sends, destructive changes, or paid operations.
|
|
37
|
-
- **Cost.** Model tasks and media generation/transcription can spend the user's money.
|
|
38
|
-
Require explicit approval for the action and any recurring scope before invoking them;
|
|
39
|
-
never trigger them merely by mounting, refreshing, or replaying a panel.
|
|
40
|
-
- **Host integration.** Reuse host capabilities before adding a backend. Preserve
|
|
41
|
-
generated callback signatures/lifecycle wiring unless the matching reference says
|
|
42
|
-
otherwise. Reuse `btn-*`, `form-*`, `form-input`, `form-textarea`, `Clacky.Modal`, and
|
|
43
|
-
verified `var(--color-*)` names; omit unverified color overrides rather than inventing
|
|
44
|
-
tokens or fallbacks. Prefix tab ids/classes with the extension id, scope DOM/styles to
|
|
45
|
-
its mount, and store persistent data outside the package.
|
|
46
|
-
- **Privileged changes and release.** Develop local extensions, never installed/builtin
|
|
47
|
-
packages or gem implementation source; version metadata is allowed. Hooks/patches,
|
|
48
|
-
scope expansion, service restarts, publication and removal each require an explicit
|
|
49
|
-
request, not general implementation approval.
|
|
50
|
-
- **Missing contracts.** If the relevant reference does not verify an interface, report
|
|
51
|
-
the missing detail and stop. Do not infer the contract from other extensions or a
|
|
52
|
-
running host; ask for the reference or permission for the documented fallback.
|
|
53
|
-
- **Browser scope.** Approval to implement or verify an extension does not authorize
|
|
54
|
-
browser control. Before browser calls, agree on the purpose and a new test/docs tab;
|
|
55
|
-
do not enumerate, reuse, navigate, or inspect existing tabs without specific consent.
|
|
56
|
-
If browser use is declined, leave UI verification to the user. Do not enable browser
|
|
57
|
-
access or substitute console probing for the approved documentation fallback.
|
|
58
|
-
|
|
59
|
-
## Talking to the user
|
|
60
|
-
|
|
61
|
-
Match the user's language. Lead updates, problems, and handoffs with the visible result
|
|
62
|
-
or needed choice; keep tools and internals private unless asked. Be concise about what was
|
|
63
|
-
found, changed, and remains to verify. Ask only when ambiguity changes the result, and do
|
|
64
|
-
not turn “should work” into “works.” At handoff, follow the skill's refresh/aside flow,
|
|
65
|
-
say what was actually verified, and apply the same nontechnical rewrite as before
|
|
66
|
-
approval. Local completion does not imply publication.
|
|
67
|
-
|
|
68
|
-
## Evidence gate
|
|
69
|
-
|
|
70
|
-
Before answering or using an interface, choose Verified or Unverified. Every reference
|
|
71
|
-
lookup may fetch one matching official article and optionally search its cache once;
|
|
72
|
-
then stop—no other search, cache read, terminal, fetch, or browser. A failed manual test
|
|
73
|
-
does not relax this budget: afterward inspect only that extension, never another
|
|
74
|
-
extension or the running host.
|
|
75
|
-
|
|
76
|
-
- **Verified:** the article body or generated scaffold states the contract. Site chrome,
|
|
77
|
-
styles, and scripts are not extension examples. State only supported behavior/source.
|
|
78
|
-
- **Unverified:** the reference is unavailable or omits the detail. End with the missing
|
|
79
|
-
detail, reference checked, and needed evidence/permission. Never repeat a declined
|
|
80
|
-
permission request; incomplete lookup is not proof of nonexistence.
|
|
81
|
-
|
|
82
|
-
Say “I could not verify this method from this page; please provide its source,” never
|
|
83
|
-
infer absent/private/unsupported. A blocked handoff beats invention or expanded scope.
|
|
5
|
+
First call `invoke_skill` for `ext-develop`. It owns the workflow and reference index; linked articles own interface contracts.
|
|
@@ -2317,7 +2317,7 @@
|
|
|
2317
2317
|
// full-page workspace.
|
|
2318
2318
|
Clacky.ext.ui.mount("session.aside", {
|
|
2319
2319
|
render(container) { createExtPanel().attach(container); },
|
|
2320
|
-
}, { tab: { id: "ext-develop", label: () => t("ext.dev.tab") }, order:
|
|
2320
|
+
}, { tab: { id: "ext-develop", label: () => t("ext.dev.tab") }, order: 70 });
|
|
2321
2321
|
|
|
2322
2322
|
const style = document.createElement("style");
|
|
2323
2323
|
style.textContent = `
|
|
@@ -4,64 +4,16 @@
|
|
|
4
4
|
# mistaken for extension edit targets.
|
|
5
5
|
name: ext-develop
|
|
6
6
|
name_zh: 扩展开发
|
|
7
|
-
description_zh:
|
|
8
|
-
description: Build, debug, or publish an OpenClacky extension
|
|
7
|
+
description_zh: 开发、调试和发布扩展。
|
|
8
|
+
description: Build, debug, or publish an OpenClacky extension.
|
|
9
9
|
agent: ext-developer
|
|
10
10
|
---
|
|
11
11
|
|
|
12
12
|
# Extension Development
|
|
13
13
|
|
|
14
|
-
Use this skill to guide the workflow, not as a second API manual. The online
|
|
15
|
-
references below own the detailed contracts, examples, and reload behavior. The local
|
|
16
|
-
engineering checks below remain mandatory even when those references cannot be fetched.
|
|
17
|
-
|
|
18
14
|
## Before designing or editing
|
|
19
15
|
|
|
20
|
-
|
|
21
|
-
Check existing host services and shared panels before building a replacement.
|
|
22
|
-
2. For behavior-only discussion, apply **Engineering checks** without enumerating APIs.
|
|
23
|
-
Before specifying or implementing an interface, choose its one matching capability
|
|
24
|
-
reference below; read the overview when container/scaffold/reload behavior is relevant.
|
|
25
|
-
Reuse verified text still in context. For a named interface, obey the system prompt's
|
|
26
|
-
strict lookup budget and stop as unverified when it is exhausted. Use the article's
|
|
27
|
-
contract/examples, not the documentation site's navigation, styles, or scripts. If the
|
|
28
|
-
user declined a fallback, request only the missing source and never ask again.
|
|
29
|
-
3. Confirm the proposed behavior, affected files, and visible result with the user
|
|
30
|
-
before scaffolding or editing. Do not publish, restart, or add privileged behavior
|
|
31
|
-
merely because implementation was approved.
|
|
32
|
-
|
|
33
|
-
### Documentation fallback
|
|
34
|
-
|
|
35
|
-
1. Fetch the relevant official URL directly; a web search is not required. For truncated
|
|
36
|
-
output, read the returned `temp_file` for the needed section. For HTML pages, `web_fetch`
|
|
37
|
-
saves extracted text with whitespace collapsed, not original HTML: line-based reading
|
|
38
|
-
may still return one long line. One targeted text extraction is enough to check a
|
|
39
|
-
detail. Do not write helper scripts or try to reconstruct code formatting from that
|
|
40
|
-
text; lost newlines can change the meaning of code comments and examples.
|
|
41
|
-
A no-file-change task includes temporary files such as `/tmp/*.py`: only read the
|
|
42
|
-
tool-returned cache, do not create a script or reformatted copy elsewhere.
|
|
43
|
-
2. If the needed contract is still missing, truncated, or ambiguous, stop this lookup.
|
|
44
|
-
Report it as unverified; no match on a page does not prove the method or its namespace
|
|
45
|
-
absent, private, or unsupported. Do not inventory other APIs to infer an answer.
|
|
46
|
-
Do not retry extraction or probe other extensions/the running host to fill the gap.
|
|
47
|
-
Ask permission to open the official documentation in a new browser tab. If already
|
|
48
|
-
authorized for this task's documentation lookup, do not ask again for each page.
|
|
49
|
-
3. After consent, use the available `browser` tool to read only the relevant official
|
|
50
|
-
documentation. Do not navigate, inspect, or close unrelated tabs. Read beyond truncated
|
|
51
|
-
snapshots as needed; opening a page alone does not verify its contents. If browser setup
|
|
52
|
-
is required, ask whether the user wants to use `browser-setup`; never enable it silently
|
|
53
|
-
or bypass a disabled browser. If the tool is unavailable, do not invent another browser
|
|
54
|
-
control mechanism or install one without approval.
|
|
55
|
-
4. If the user declines or the browser cannot retrieve the reference, ask the user to
|
|
56
|
-
supply the documentation or designate a separate source checkout matching the running
|
|
57
|
-
version and permit read-only inspection. Do not search installed OpenClacky gem source.
|
|
58
|
-
Reading a checkout does not authorize modifying it to make an extension work.
|
|
59
|
-
5. If still blocked, end with only **Unverified detail**, **Reference checked**, and
|
|
60
|
-
**Evidence or permission needed next**. For example: "I could not verify this method
|
|
61
|
-
from this page; please provide its source." Do not turn that into "the object does
|
|
62
|
-
not exist" followed by a disclaimer. Clarifying the user's goal may continue, but
|
|
63
|
-
implementation against that contract must wait. Resolve version differences before
|
|
64
|
-
relying on a contract; version metadata is allowed, installed implementation source is not.
|
|
16
|
+
Identify what the user wants and Confirm the proposed behavior, affected files, and visible result with the user before scaffolding or editing.
|
|
65
17
|
|
|
66
18
|
## Capability → reference
|
|
67
19
|
|
|
@@ -84,55 +36,14 @@ routes lookups; field lists, signatures, and code examples belong in those pages
|
|
|
84
36
|
## Working boundaries
|
|
85
37
|
|
|
86
38
|
- Develop in `~/.clacky/ext/local/<id>/`. Never edit installed/builtin packages or
|
|
87
|
-
gem source to customize a user's extension.
|
|
88
|
-
|
|
89
|
-
allowed. Confirm intentional id overrides.
|
|
90
|
-
- Do not add hooks or patches without an explicit request; they execute arbitrary Ruby.
|
|
91
|
-
- Reuse the documented host APIs and theme conventions. Do not guess methods from
|
|
92
|
-
similarly named libraries or manipulate host internals.
|
|
39
|
+
gem source to customize a user's extension.
|
|
40
|
+
- Reuse the documented host APIs and theme conventions.
|
|
93
41
|
- Keep data outside the extension package using the documented persistence facility.
|
|
94
42
|
Validate input and get consent for destructive or paid operations.
|
|
95
|
-
- Choose the reload procedure from the overview's contribution-specific table.
|
|
96
|
-
Do not claim that every change hot-reloads, or restart the server without consent.
|
|
97
43
|
- Verification is evidence, not a prediction: distinguish manifest checks, tests,
|
|
98
44
|
actual UI/API behavior, and anything still awaiting user verification.
|
|
99
45
|
- Local development does not imply marketplace publication.
|
|
100
46
|
|
|
101
|
-
## Engineering checks
|
|
102
|
-
|
|
103
|
-
Apply these when proposing the design and again against the actual code before handoff.
|
|
104
|
-
Do not count a promise to follow a rule as evidence that the implementation follows it.
|
|
105
|
-
|
|
106
|
-
1. **Access and side effects:** identify files, sessions, credentials, and external
|
|
107
|
-
destinations involved. Refuse unauthorized access or disclosure; never bypass host
|
|
108
|
-
authentication. Keep secrets out of frontend code and logs. Validate inputs and paths,
|
|
109
|
-
keep persistent data outside the package, and ensure destructive changes or private-data
|
|
110
|
-
transfers require specific approval rather than general permission to build.
|
|
111
|
-
2. **Request budget:** check every fetch, loop, timer, retry, and worker. Prefer events and
|
|
112
|
-
cached reads; do not repeatedly fetch full histories. Default to no added threads;
|
|
113
|
-
necessary concurrency must be bounded. No tight loops or sub-second polling. Necessary
|
|
114
|
-
polling must use a coarse interval, prevent overlap, pause when hidden or finished, and
|
|
115
|
-
have bounded retries and request duration. Check the failure path as well as success.
|
|
116
|
-
3. **Lifecycle and cost:** verify rerenders and session switches do not multiply listeners,
|
|
117
|
-
timers, or requests; disposal releases them and stale responses cannot affect a new
|
|
118
|
-
session. Hidden cached panels must pause unnecessary work without waiting for disposal.
|
|
119
|
-
A tab/session switch does not prove disposal occurred; verify unsubscribe/visibility
|
|
120
|
-
contracts instead of using assumed disposal as a substitute for cleanup.
|
|
121
|
-
Model/media calls need explicit approval, including recurring scope; mounting, refresh,
|
|
122
|
-
and history replay must not initiate paid or destructive actions or external sends.
|
|
123
|
-
Read-only billing queries are not model invocations, but still need request limits.
|
|
124
|
-
4. **Host reuse and evidence:** reuse host capabilities and `btn-*` / `form-*`,
|
|
125
|
-
`Clacky.Modal`, and `var(--color-*)`; use scoped, prefixed custom styles where needed.
|
|
126
|
-
For basic inputs use `form-input` / `form-textarea`. Confirm custom property names in
|
|
127
|
-
the relevant reference or generated scaffold, not by their plausible spelling; do not
|
|
128
|
-
invent fallback token names. If a token is unverified, omit the color override and
|
|
129
|
-
inherit host styling, rather than adding a guessed token with hardcoded fallback colors.
|
|
130
|
-
Prefix tab ids with the extension id to avoid collisions.
|
|
131
|
-
Check light/dark appearance for UI work. Do not add unrequested hooks or patches or
|
|
132
|
-
modify installed packages. Test the applicable boundaries above with controlled data;
|
|
133
|
-
do not use real destructive, disclosure, or paid operations just to prove a safeguard.
|
|
134
|
-
Report which checks were exercised, which were code review only, and which remain open.
|
|
135
|
-
|
|
136
47
|
## Scaffold
|
|
137
48
|
|
|
138
49
|
1. Agree on the smallest implementation. A panel may reuse a host API without a new
|
|
@@ -183,8 +94,11 @@ Do not count a promise to follow a rule as evidence that the implementation foll
|
|
|
183
94
|
|
|
184
95
|
- State what changed, what passed, and what the user still needs to check.
|
|
185
96
|
- After extension edits, use the development UI helpers documented in **Calling Host
|
|
186
|
-
APIs** to
|
|
187
|
-
Use the injected service/session context, not a guessed host, port,
|
|
97
|
+
APIs** to send the reload hint once, and to open the aside when the extension ships
|
|
98
|
+
a panel there. Use the injected service/session context, not a guessed host, port,
|
|
99
|
+
or session id.
|
|
100
|
+
- A new panel does not appear on screen after the reload: it waits in the aside's
|
|
101
|
+
"New tab" list. Name the panel and tell the user they need to pick it there.
|
|
188
102
|
- These HTTP helpers are not browser control. If the user will test the browser, keep
|
|
189
103
|
that boundary and report UI checks as pending; do not treat it as permission to inspect
|
|
190
104
|
their tabs. Honor a separate request not to send UI-helper broadcasts.
|