Class: ClaudeAgentSDK::CompactMetadata

Inherits:
Object
  • Object
show all
Defined in:
lib/claude_agent_sdk/types.rb

Overview

Metadata about a compaction event

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pre_tokens: nil, post_tokens: nil, trigger: nil, custom_instructions: nil, preserved_segment: nil) ⇒ CompactMetadata

Returns a new instance of CompactMetadata.



205
206
207
208
209
210
211
# File 'lib/claude_agent_sdk/types.rb', line 205

def initialize(pre_tokens: nil, post_tokens: nil, trigger: nil, custom_instructions: nil, preserved_segment: nil)
  @pre_tokens = pre_tokens
  @post_tokens = post_tokens
  @trigger = trigger # "manual" or "auto"
  @custom_instructions = custom_instructions
  @preserved_segment = preserved_segment # Hash with head_uuid, anchor_uuid, tail_uuid
end

Instance Attribute Details

#custom_instructionsObject

Returns the value of attribute custom_instructions.



203
204
205
# File 'lib/claude_agent_sdk/types.rb', line 203

def custom_instructions
  @custom_instructions
end

#post_tokensObject

Returns the value of attribute post_tokens.



203
204
205
# File 'lib/claude_agent_sdk/types.rb', line 203

def post_tokens
  @post_tokens
end

#pre_tokensObject

Returns the value of attribute pre_tokens.



203
204
205
# File 'lib/claude_agent_sdk/types.rb', line 203

def pre_tokens
  @pre_tokens
end

#preserved_segmentObject

Returns the value of attribute preserved_segment.



203
204
205
# File 'lib/claude_agent_sdk/types.rb', line 203

def preserved_segment
  @preserved_segment
end

#triggerObject

Returns the value of attribute trigger.



203
204
205
# File 'lib/claude_agent_sdk/types.rb', line 203

def trigger
  @trigger
end

Class Method Details

.from_hash(hash) ⇒ Object



213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
# File 'lib/claude_agent_sdk/types.rb', line 213

def self.from_hash(hash)
  return nil unless hash.is_a?(Hash)

  preserved = hash[:preserved_segment] || hash['preserved_segment'] ||
              hash[:preservedSegment] || hash['preservedSegment']

  new(
    pre_tokens: hash[:pre_tokens] || hash['pre_tokens'] || hash[:preTokens] || hash['preTokens'],
    post_tokens: hash[:post_tokens] || hash['post_tokens'] || hash[:postTokens] || hash['postTokens'],
    trigger: hash[:trigger] || hash['trigger'],
    custom_instructions: hash[:custom_instructions] || hash['custom_instructions'] ||
                         hash[:customInstructions] || hash['customInstructions'],
    preserved_segment: preserved
  )
end