openclacky 1.2.1 → 1.2.2
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 +5 -0
- data/lib/clacky/agent/cost_tracker.rb +2 -0
- data/lib/clacky/agent.rb +12 -2
- data/lib/clacky/client.rb +2 -0
- data/lib/clacky/telemetry.rb +29 -3
- data/lib/clacky/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cfaa1f45ce6ab05b0a101571f59e809d92430ee862196b21a714ceb56c3ec8b5
|
|
4
|
+
data.tar.gz: 6d76cd4d7bf8568fd8229dc9770f23fb027296c660ad0ba3d514be61df69c5ce
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: aa5e444bc28d570022df63172027028d99224191f6d2a0b26537cb5c1597c523b165b35efd58747312586aa01f133c522b5c9cae46b5f25d06501b1a083b6e31
|
|
7
|
+
data.tar.gz: ae1d58c07b9a24937b1c4182e19a093394565fdc972c5caf72cba66f3bf0419cbdd0874f7b2d741d7b00b8efdd8fe83a2efee767f7df1a3e8e6656b237631721
|
data/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.2.2] - 2026-05-25
|
|
9
|
+
|
|
10
|
+
### More
|
|
11
|
+
- Add telemetry for task cost and model tracking
|
|
12
|
+
|
|
8
13
|
## [1.2.1] - 2026-05-25
|
|
9
14
|
|
|
10
15
|
### Fixed
|
|
@@ -86,6 +86,8 @@ module Clacky
|
|
|
86
86
|
# Track cache usage for current task
|
|
87
87
|
if @task_cache_stats
|
|
88
88
|
@task_cache_stats[:total_requests] += 1
|
|
89
|
+
@task_cache_stats[:prompt_tokens] += usage[:prompt_tokens].to_i
|
|
90
|
+
@task_cache_stats[:completion_tokens] += usage[:completion_tokens].to_i
|
|
89
91
|
|
|
90
92
|
if usage[:cache_creation_input_tokens]
|
|
91
93
|
@task_cache_stats[:cache_creation_input_tokens] += usage[:cache_creation_input_tokens]
|
data/lib/clacky/agent.rb
CHANGED
|
@@ -218,6 +218,11 @@ module Clacky
|
|
|
218
218
|
@config.effective_model_name
|
|
219
219
|
end
|
|
220
220
|
|
|
221
|
+
private def current_provider
|
|
222
|
+
return nil unless @client.respond_to?(:provider_id)
|
|
223
|
+
@client.provider_id
|
|
224
|
+
end
|
|
225
|
+
|
|
221
226
|
# Rename this session. Called by auto-naming (first message) or user explicit rename.
|
|
222
227
|
def rename(new_name)
|
|
223
228
|
@name = new_name.to_s.strip
|
|
@@ -248,6 +253,8 @@ module Clacky
|
|
|
248
253
|
@task_cache_stats = {
|
|
249
254
|
cache_creation_input_tokens: 0,
|
|
250
255
|
cache_read_input_tokens: 0,
|
|
256
|
+
prompt_tokens: 0,
|
|
257
|
+
completion_tokens: 0,
|
|
251
258
|
total_requests: 0,
|
|
252
259
|
cache_hit_requests: 0
|
|
253
260
|
}
|
|
@@ -381,6 +388,7 @@ module Clacky
|
|
|
381
388
|
|
|
382
389
|
@hooks.trigger(:on_start, user_input)
|
|
383
390
|
|
|
391
|
+
result = nil
|
|
384
392
|
begin
|
|
385
393
|
# Track if request_user_feedback was called
|
|
386
394
|
awaiting_user_feedback = false
|
|
@@ -583,7 +591,7 @@ module Clacky
|
|
|
583
591
|
@pending_error_rollback = true if e.is_a?(Clacky::BadRequestError)
|
|
584
592
|
|
|
585
593
|
# Build error result for session data, but let CLI handle error display
|
|
586
|
-
result = build_result(:error, error: e.message)
|
|
594
|
+
result = build_result(:error, error: e.message)
|
|
587
595
|
raise
|
|
588
596
|
ensure
|
|
589
597
|
# Safety net: ensure any lingering progress spinner is stopped.
|
|
@@ -598,7 +606,7 @@ module Clacky
|
|
|
598
606
|
|
|
599
607
|
# Fire-and-forget telemetry after every agent run.
|
|
600
608
|
# Tracks daily active users (distinct devices per day) and task volume.
|
|
601
|
-
Clacky::Telemetry.task!
|
|
609
|
+
Clacky::Telemetry.task!(result: result)
|
|
602
610
|
end
|
|
603
611
|
end
|
|
604
612
|
|
|
@@ -1117,6 +1125,8 @@ module Clacky
|
|
|
1117
1125
|
{
|
|
1118
1126
|
status: status,
|
|
1119
1127
|
session_id: @session_id,
|
|
1128
|
+
model: current_model,
|
|
1129
|
+
provider: current_provider,
|
|
1120
1130
|
iterations: task_iterations,
|
|
1121
1131
|
duration_seconds: Time.now - @start_time,
|
|
1122
1132
|
total_cost_usd: task_cost.round(4),
|
data/lib/clacky/client.rb
CHANGED
data/lib/clacky/telemetry.rb
CHANGED
|
@@ -46,7 +46,10 @@ module Clacky
|
|
|
46
46
|
# Tracks usage activity and daily task volume.
|
|
47
47
|
# No client-side dedup — the server keeps every event for task counting,
|
|
48
48
|
# and derives DAU from distinct devices per day.
|
|
49
|
-
|
|
49
|
+
#
|
|
50
|
+
# @param result [Hash, nil] optional build_result hash from Agent#run.
|
|
51
|
+
# When present, enriches the payload with model/provider/tokens/cost/duration/status.
|
|
52
|
+
def task!(result: nil)
|
|
50
53
|
return unless enabled?
|
|
51
54
|
|
|
52
55
|
brand = Clacky::BrandConfig.load
|
|
@@ -54,9 +57,10 @@ module Clacky
|
|
|
54
57
|
device_id: resolve_device_id(brand),
|
|
55
58
|
version: Clacky::VERSION,
|
|
56
59
|
brand: brand.branded? ? brand.package_name : nil
|
|
57
|
-
}
|
|
60
|
+
}
|
|
61
|
+
payload.merge!(extract_task_metrics(result)) if result.is_a?(Hash)
|
|
58
62
|
|
|
59
|
-
fire_and_forget("/api/v1/telemetry/task", payload)
|
|
63
|
+
fire_and_forget("/api/v1/telemetry/task", payload.compact)
|
|
60
64
|
end
|
|
61
65
|
|
|
62
66
|
# ── private helpers ────────────────────────────────────────────────
|
|
@@ -70,6 +74,28 @@ module Clacky
|
|
|
70
74
|
brand.device_id
|
|
71
75
|
end
|
|
72
76
|
|
|
77
|
+
private def extract_task_metrics(result)
|
|
78
|
+
cache = result[:cache_stats] || {}
|
|
79
|
+
duration = result[:duration_seconds]
|
|
80
|
+
error = result[:error]
|
|
81
|
+
{
|
|
82
|
+
model: result[:model],
|
|
83
|
+
provider: result[:provider],
|
|
84
|
+
status: result[:status],
|
|
85
|
+
iterations: result[:iterations],
|
|
86
|
+
duration_ms: duration ? (duration * 1000).round : nil,
|
|
87
|
+
cost_usd: result[:total_cost_usd],
|
|
88
|
+
cost_source: result[:cost_source],
|
|
89
|
+
prompt_tokens: cache[:prompt_tokens],
|
|
90
|
+
completion_tokens: cache[:completion_tokens],
|
|
91
|
+
cache_creation_tokens: cache[:cache_creation_input_tokens],
|
|
92
|
+
cache_read_tokens: cache[:cache_read_input_tokens],
|
|
93
|
+
cache_total_requests: cache[:total_requests],
|
|
94
|
+
cache_hit_requests: cache[:cache_hit_requests],
|
|
95
|
+
error_kind: error.is_a?(String) ? error[0, 64] : error&.class&.name
|
|
96
|
+
}
|
|
97
|
+
end
|
|
98
|
+
|
|
73
99
|
# Send a POST to the telemetry endpoint in a background thread.
|
|
74
100
|
# Fire-and-forget: no retry, no error surfacing, no blocking.
|
|
75
101
|
#
|
data/lib/clacky/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: openclacky
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.2.
|
|
4
|
+
version: 1.2.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- windy
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-05-
|
|
11
|
+
date: 2026-05-25 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faraday
|