openclacky 1.1.2 → 1.1.4

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 (58) hide show
  1. checksums.yaml +4 -4
  2. data/.clacky/skills/gem-release/SKILL.md +27 -31
  3. data/CHANGELOG.md +30 -0
  4. data/Dockerfile +28 -0
  5. data/README.md +4 -0
  6. data/README_CN.md +198 -0
  7. data/docs/engineering-article.md +343 -0
  8. data/lib/clacky/agent/llm_caller.rb +2 -5
  9. data/lib/clacky/agent/session_serializer.rb +4 -0
  10. data/lib/clacky/agent.rb +22 -1
  11. data/lib/clacky/brand_config.rb +87 -5
  12. data/lib/clacky/cli.rb +1 -1
  13. data/lib/clacky/client.rb +15 -11
  14. data/lib/clacky/message_format/anthropic.rb +30 -2
  15. data/lib/clacky/message_format/bedrock.rb +13 -1
  16. data/lib/clacky/message_format/open_ai.rb +5 -1
  17. data/lib/clacky/providers.rb +34 -0
  18. data/lib/clacky/server/channel/adapters/dingtalk/adapter.rb +142 -5
  19. data/lib/clacky/server/channel/adapters/dingtalk/api_client.rb +309 -0
  20. data/lib/clacky/server/http_server.rb +130 -15
  21. data/lib/clacky/server/session_registry.rb +9 -6
  22. data/lib/clacky/ui2/ui_controller.rb +14 -0
  23. data/lib/clacky/ui_interface.rb +14 -0
  24. data/lib/clacky/utils/model_pricing.rb +96 -25
  25. data/lib/clacky/version.rb +1 -1
  26. data/lib/clacky/web/app.css +1286 -1116
  27. data/lib/clacky/web/brand.js +20 -5
  28. data/lib/clacky/web/i18n.js +42 -0
  29. data/lib/clacky/web/index.html +26 -7
  30. data/lib/clacky/web/onboard.js +6 -0
  31. data/lib/clacky/web/sessions.js +194 -11
  32. data/lib/clacky/web/settings.js +51 -10
  33. data/lib/clacky/web/skills.js +53 -31
  34. data/lib/clacky/web/vendor/hljs/highlight.min.js +1244 -0
  35. data/lib/clacky/web/vendor/hljs/hljs-theme.css +95 -0
  36. data/scripts/build/lib/apt.sh +30 -10
  37. data/scripts/build/lib/network.sh +3 -2
  38. data/scripts/install.sh +30 -9
  39. data/scripts/install_browser.sh +2 -1
  40. data/scripts/install_full.sh +2 -1
  41. data/scripts/install_rails_deps.sh +30 -9
  42. data/scripts/install_system_deps.sh +30 -9
  43. metadata +7 -17
  44. data/docs/HOW-TO-USE-CN.md +0 -96
  45. data/docs/HOW-TO-USE.md +0 -94
  46. data/docs/browser-cdp-native-design.md +0 -195
  47. data/docs/c-end-user-positioning.md +0 -64
  48. data/docs/config.example.yml +0 -27
  49. data/docs/deploy-architecture.md +0 -619
  50. data/docs/deploy_subagent_design.md +0 -540
  51. data/docs/install-script-simplification.md +0 -89
  52. data/docs/memory-architecture.md +0 -343
  53. data/docs/openclacky_cloud_api_reference.md +0 -584
  54. data/docs/security-design.md +0 -109
  55. data/docs/session-management-redesign.md +0 -202
  56. data/docs/system-skill-authoring-guide.md +0 -47
  57. data/docs/why-developer.md +0 -371
  58. data/docs/why-openclacky.md +0 -266
@@ -22,7 +22,7 @@ module Clacky
22
22
  read: 0.50 # $0.50/MTok cache read
23
23
  }
24
24
  },
25
-
25
+
26
26
  "claude-sonnet-4.5" => {
27
27
  input: {
28
28
  default: 3.00, # $3/MTok for prompts ≤ 200K tokens
@@ -39,7 +39,7 @@ module Clacky
39
39
  read_over_200k: 0.60 # $0.60/MTok cache read (> 200K)
40
40
  }
41
41
  },
42
-
42
+
43
43
  "claude-haiku-4.5" => {
44
44
  input: {
45
45
  default: 1.00, # $1/MTok
@@ -122,7 +122,7 @@ module Clacky
122
122
  },
123
123
  cache: {
124
124
  write: 0.14, # DeepSeek doesn't charge extra for writes; bill at miss rate
125
- read: 0.028 # $0.028/MTok cache hit
125
+ read: 0.0028 # $0.0028/MTok cache hit
126
126
  }
127
127
  },
128
128
 
@@ -137,7 +137,7 @@ module Clacky
137
137
  },
138
138
  cache: {
139
139
  write: 1.74, # no separate write charge; bill at miss rate
140
- read: 0.145 # $0.145/MTok cache hit
140
+ read: 0.0145 # $0.0145/MTok cache hit
141
141
  }
142
142
  },
143
143
 
@@ -352,6 +352,58 @@ module Clacky
352
352
  cache: { write: 0.30, read: 0.06 }
353
353
  },
354
354
 
355
+ # Qwen (Alibaba DashScope) — USD per 1M tokens, Singapore region list price.
356
+ # Source: Alibaba Cloud Model Studio international pricing.
357
+ # Cache convention (mirrors DeepSeek/Kimi/GLM "displayed ≤ actual"):
358
+ # - DashScope has two cache modes; implicit is auto-on, explicit is opt-in.
359
+ # Implicit: write @ 100% input, read @ 20% input (no setup, no guarantee)
360
+ # Explicit: write @ 125% input, read @ 10% input (cache_control marker)
361
+ # - We bill writes at the regular input rate (matches implicit, and avoids
362
+ # surprising users with the explicit 25% surcharge).
363
+ # - We bill reads at 20% (implicit rate) — the conservative side; users on
364
+ # explicit caching will see real bills slightly *lower* than displayed.
365
+ "qwen3.6-plus" => {
366
+ input: { default: 0.40, over_200k: 0.40 },
367
+ output: { default: 2.40, over_200k: 2.40 },
368
+ cache: { write: 0.40, read: 0.08 }
369
+ },
370
+
371
+ "qwen3.6-max" => {
372
+ input: { default: 1.20, over_200k: 1.20 },
373
+ output: { default: 6.00, over_200k: 6.00 },
374
+ cache: { write: 1.20, read: 0.24 }
375
+ },
376
+
377
+ "qwen3.6-27b" => {
378
+ input: { default: 0.20, over_200k: 0.20 },
379
+ output: { default: 0.80, over_200k: 0.80 },
380
+ cache: { write: 0.20, read: 0.04 }
381
+ },
382
+
383
+ "qwen3.6-flash" => {
384
+ input: { default: 0.15, over_200k: 0.15 },
385
+ output: { default: 0.90, over_200k: 0.90 },
386
+ cache: { write: 0.15, read: 0.03 }
387
+ },
388
+
389
+ "qwen-plus-latest" => {
390
+ input: { default: 0.40, over_200k: 0.40 },
391
+ output: { default: 1.20, over_200k: 1.20 },
392
+ cache: { write: 0.40, read: 0.08 }
393
+ },
394
+
395
+ "qwen-vl-plus" => {
396
+ input: { default: 0.14, over_200k: 0.14 },
397
+ output: { default: 0.41, over_200k: 0.41 },
398
+ cache: { write: 0.14, read: 0.028 }
399
+ },
400
+
401
+ "qwen-vl-max" => {
402
+ input: { default: 0.52, over_200k: 0.52 },
403
+ output: { default: 2.08, over_200k: 2.08 },
404
+ cache: { write: 0.52, read: 0.104 }
405
+ },
406
+
355
407
  }.freeze
356
408
 
357
409
  # Threshold for tiered pricing (200K tokens)
@@ -361,7 +413,7 @@ module Clacky
361
413
 
362
414
  class << self
363
415
  # Calculate cost for the given model and usage
364
- #
416
+ #
365
417
  # @param model [String] Model identifier
366
418
  # @param usage [Hash] Usage statistics containing:
367
419
  # - prompt_tokens: number of input tokens
@@ -384,24 +436,24 @@ module Clacky
384
436
  completion_tokens = usage[:completion_tokens] || 0
385
437
  cache_write_tokens = usage[:cache_creation_input_tokens] || 0
386
438
  cache_read_tokens = usage[:cache_read_input_tokens] || 0
387
-
439
+
388
440
  # Determine if we're in the over_200k tier
389
441
  # Note: prompt_tokens includes cache_read_tokens but NOT cache_write_tokens
390
442
  # cache_write_tokens are additional tokens that were written to cache
391
443
  total_input_tokens = prompt_tokens + cache_write_tokens
392
444
  over_threshold = total_input_tokens > TIERED_PRICING_THRESHOLD
393
-
445
+
394
446
  # Calculate regular input cost (non-cached tokens)
395
447
  # prompt_tokens already includes cache_read_tokens, so we need to subtract them
396
448
  # cache_write_tokens are not part of prompt_tokens, so they're handled separately in cache_cost
397
449
  regular_input_tokens = prompt_tokens - cache_read_tokens
398
450
  input_rate = over_threshold ? pricing[:input][:over_200k] : pricing[:input][:default]
399
451
  input_cost = (regular_input_tokens / 1_000_000.0) * input_rate
400
-
452
+
401
453
  # Calculate output cost
402
454
  output_rate = over_threshold ? pricing[:output][:over_200k] : pricing[:output][:default]
403
455
  output_cost = (completion_tokens / 1_000_000.0) * output_rate
404
-
456
+
405
457
  # Calculate cache costs
406
458
  cache_cost = calculate_cache_cost(
407
459
  pricing: pricing,
@@ -409,24 +461,24 @@ module Clacky
409
461
  cache_read_tokens: cache_read_tokens,
410
462
  over_threshold: over_threshold
411
463
  )
412
-
464
+
413
465
  {
414
466
  cost: input_cost + output_cost + cache_cost,
415
467
  source: source
416
468
  }
417
469
  end
418
-
470
+
419
471
  # Get pricing for a specific model
420
472
  # Falls back to default pricing if model not found
421
- #
473
+ #
422
474
  # @param model [String] Model identifier
423
475
  # @return [Hash] Pricing structure for the model
424
476
  def get_pricing(model)
425
477
  get_pricing_with_source(model)[:pricing]
426
478
  end
427
-
479
+
428
480
  # Get pricing with source information
429
- #
481
+ #
430
482
  # @param model [String] Model identifier
431
483
  # @return [Hash] Hash containing:
432
484
  # - pricing: Pricing structure or nil if model is unknown
@@ -446,18 +498,18 @@ module Clacky
446
498
  { pricing: nil, source: nil }
447
499
  end
448
500
  end
449
-
450
-
501
+
502
+
451
503
  # Normalize model name to match pricing table keys.
452
504
  # Returns the canonical key on match, or nil when no pricing is available.
453
505
  def normalize_model_name(model)
454
506
  return nil if model.nil? || model.empty?
455
-
507
+
456
508
  model = model.downcase.strip
457
-
509
+
458
510
  # Direct match
459
511
  return model if PRICING_TABLE.key?(model)
460
-
512
+
461
513
  # Check for Claude model variations
462
514
  # Support both dot and dash separators (e.g., "4.5", "4-5", "4-6")
463
515
  # Also handles Bedrock cross-region prefixes (e.g. "jp.anthropic.claude-sonnet-4-6")
@@ -514,6 +566,25 @@ module Clacky
514
566
  when /^minimax-m2\.7$/i
515
567
  "minimax-m2.7"
516
568
 
569
+ # Qwen (Alibaba DashScope) — strict anchored match per registered
570
+ # model id in providers.rb. qwen3.6-* are the new flagship line;
571
+ # qwen-plus-latest is the rolling alias for the latest Qwen-Plus
572
+ # release; qwen-vl-* are the multimodal SKUs.
573
+ when /^qwen3\.6-plus$/i
574
+ "qwen3.6-plus"
575
+ when /^qwen3\.6-max$/i
576
+ "qwen3.6-max"
577
+ when /^qwen3\.6-27b$/i
578
+ "qwen3.6-27b"
579
+ when /^qwen3\.6-flash$/i
580
+ "qwen3.6-flash"
581
+ when /^qwen-plus-latest$/i
582
+ "qwen-plus-latest"
583
+ when /^qwen-vl-plus$/i
584
+ "qwen-vl-plus"
585
+ when /^qwen-vl-max$/i
586
+ "qwen-vl-max"
587
+
517
588
  # OpenAI GPT-5.x models — match various dashed/dotted/compact forms
518
589
  # (e.g. "gpt-5.5", "gpt-5-5", "gpt5.5", "gpt55")
519
590
  when /^gpt-?5\.?5$/i, /^gpt-?5[\.-]?5$/i
@@ -533,11 +604,11 @@ module Clacky
533
604
  nil # No pricing available for this model — cost will show as N/A
534
605
  end
535
606
  end
536
-
607
+
537
608
  # Calculate cache-related costs
538
609
  def calculate_cache_cost(pricing:, cache_write_tokens:, cache_read_tokens:, over_threshold:)
539
610
  cache_cost = 0.0
540
-
611
+
541
612
  # Cache write cost
542
613
  if cache_write_tokens > 0
543
614
  write_rate = if pricing[:cache].key?(:write)
@@ -549,10 +620,10 @@ module Clacky
549
620
  else
550
621
  pricing[:cache][:write_default]
551
622
  end
552
-
623
+
553
624
  cache_cost += (cache_write_tokens / 1_000_000.0) * write_rate
554
625
  end
555
-
626
+
556
627
  # Cache read cost
557
628
  if cache_read_tokens > 0
558
629
  read_rate = if pricing[:cache].key?(:read)
@@ -564,10 +635,10 @@ module Clacky
564
635
  else
565
636
  pricing[:cache][:read_default]
566
637
  end
567
-
638
+
568
639
  cache_cost += (cache_read_tokens / 1_000_000.0) * read_rate
569
640
  end
570
-
641
+
571
642
  cache_cost
572
643
  end
573
644
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Clacky
4
- VERSION = "1.1.2"
4
+ VERSION = "1.1.4"
5
5
  end