From 27af03cb3540539f065334c199fdb42c48776fc5 Mon Sep 17 00:00:00 2001 From: Adam Malczewski Date: Wed, 29 Apr 2026 21:40:58 +0900 Subject: update to support claude --- lib/dispatch/adapter/interface/message.rb | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'lib/dispatch/adapter/interface/message.rb') diff --git a/lib/dispatch/adapter/interface/message.rb b/lib/dispatch/adapter/interface/message.rb index eb51c99..dfe7301 100644 --- a/lib/dispatch/adapter/interface/message.rb +++ b/lib/dispatch/adapter/interface/message.rb @@ -4,9 +4,14 @@ module Dispatch module Adapter Message = Struct.new(:role, :content, keyword_init: true) - TextBlock = Struct.new(:type, :text, keyword_init: true) do - def initialize(text:, type: "text") - super(type:, text:) + # +cache_control+ values: + # nil — no cache breakpoint (default) + # { type: :ephemeral } — provider default TTL + # { type: :ephemeral, ttl: :"5m" } — short-lived cache + # { type: :ephemeral, ttl: :"1h" } — long-lived cache + TextBlock = Struct.new(:type, :text, :cache_control, keyword_init: true) do + def initialize(text:, cache_control: nil, type: "text") + super(type:, text:, cache_control:) end end @@ -27,5 +32,17 @@ module Dispatch super(type:, tool_use_id:, content:, is_error:) end end + + ThinkingBlock = Struct.new(:type, :thinking, :signature, keyword_init: true) do + def initialize(thinking:, signature: nil, type: "thinking") + super(type:, thinking:, signature:) + end + end + + RedactedThinkingBlock = Struct.new(:type, :data, keyword_init: true) do + def initialize(data:, type: "redacted_thinking") + super(type:, data:) + end + end end end -- cgit v1.2.3