Module: TurnKit

Defined in:
lib/turnkit.rb,
lib/turnkit/id.rb,
lib/turnkit/run.rb,
lib/turnkit/cost.rb,
lib/turnkit/tool.rb,
lib/turnkit/turn.rb,
lib/turnkit/agent.rb,
lib/turnkit/clock.rb,
lib/turnkit/error.rb,
lib/turnkit/event.rb,
lib/turnkit/skill.rb,
lib/turnkit/store.rb,
lib/turnkit/usage.rb,
lib/turnkit/budget.rb,
lib/turnkit/client.rb,
lib/turnkit/record.rb,
lib/turnkit/result.rb,
lib/turnkit/message.rb,
lib/turnkit/version.rb,
lib/turnkit/workflow.rb,
lib/turnkit/tool_call.rb,
lib/turnkit/compaction.rb,
lib/turnkit/prompt_data.rb,
lib/turnkit/tool_runner.rb,
lib/turnkit/conversation.rb,
lib/turnkit/memory_store.rb,
lib/turnkit/output_audit.rb,
lib/turnkit/schema_check.rb,
lib/turnkit/model_request.rb,
lib/turnkit/output_policy.rb,
lib/turnkit/rails/railtie.rb,
lib/turnkit/system_prompt.rb,
lib/turnkit/adapters/codex.rb,
lib/turnkit/prompt_context.rb,
lib/turnkit/sub_agent_tool.rb,
lib/turnkit/tool_execution.rb,
lib/turnkit/load_skill_tool.rb,
lib/turnkit/adapters/ruby_llm.rb,
lib/turnkit/message_projection.rb,
lib/turnkit/prompt_contribution.rb,
lib/turnkit/stores/active_record_store.rb,
lib/turnkit/generators/turnkit/install_generator.rb

Defined Under Namespace

Modules: Adapters, Clock, Compaction, Generators, Id, PromptData, Record, SchemaCheck Classes: ActiveRecordStore, Agent, Budget, BudgetError, Client, CompactionError, ConfigError, Conversation, Cost, Error, Event, InputError, LiveContextContribution, LoadSkillTool, MemoryStore, Message, MessageProjection, ModelAccessError, ModelRequest, OutputAudit, OutputPolicy, PromptBuildContext, PromptContribution, Railtie, Result, Run, Skill, Store, StoreError, SubAgentTool, SystemPrompt, Tool, ToolCall, ToolContext, ToolError, ToolExecution, ToolRunner, ToolValidationError, Turn, Usage, Workflow

Constant Summary collapse

VERSION =
"0.3.0"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.available_skillsObject

Returns the value of attribute available_skills.



61
62
63
# File 'lib/turnkit.rb', line 61

def available_skills
  @available_skills
end

.clientObject

Returns the value of attribute client.



54
55
56
# File 'lib/turnkit.rb', line 54

def client
  @client
end

.compactionObject

Returns the value of attribute compaction.



58
59
60
# File 'lib/turnkit.rb', line 58

def compaction
  @compaction
end

.context_contributorsObject

Returns the value of attribute context_contributors.



62
63
64
# File 'lib/turnkit.rb', line 62

def context_contributors
  @context_contributors
end

.conversation_record_classObject

Returns the value of attribute conversation_record_class.



65
66
67
# File 'lib/turnkit.rb', line 65

def conversation_record_class
  @conversation_record_class
end

.cost_calculatorObject

Returns the value of attribute cost_calculator.



60
61
62
# File 'lib/turnkit.rb', line 60

def cost_calculator
  @cost_calculator
end

.cost_ratesObject

Returns the value of attribute cost_rates.



60
61
62
# File 'lib/turnkit.rb', line 60

def cost_rates
  @cost_rates
end

.default_modelObject

Returns the value of attribute default_model.



54
55
56
# File 'lib/turnkit.rb', line 54

def default_model
  @default_model
end

.loggerObject

Returns the value of attribute logger.



54
55
56
# File 'lib/turnkit.rb', line 54

def logger
  @logger
end

.max_depthObject

Returns the value of attribute max_depth.



55
56
57
# File 'lib/turnkit.rb', line 55

def max_depth
  @max_depth
end

.max_iterationsObject

Returns the value of attribute max_iterations.



55
56
57
# File 'lib/turnkit.rb', line 55

def max_iterations
  @max_iterations
end

.max_spendObject

Returns the value of attribute max_spend.



57
58
59
# File 'lib/turnkit.rb', line 57

def max_spend
  @max_spend
end

.max_tool_executionsObject

Returns the value of attribute max_tool_executions.



55
56
57
# File 'lib/turnkit.rb', line 55

def max_tool_executions
  @max_tool_executions
end

.max_tool_executions_by_nameObject

Returns the value of attribute max_tool_executions_by_name.



56
57
58
# File 'lib/turnkit.rb', line 56

def max_tool_executions_by_name
  @max_tool_executions_by_name
end

.message_record_classObject

Returns the value of attribute message_record_class.



66
67
68
# File 'lib/turnkit.rb', line 66

def message_record_class
  @message_record_class
end

.model_prompt_contributorsObject

Returns the value of attribute model_prompt_contributors.



63
64
65
# File 'lib/turnkit.rb', line 63

def model_prompt_contributors
  @model_prompt_contributors
end

.on_eventObject

Returns the value of attribute on_event.



64
65
66
# File 'lib/turnkit.rb', line 64

def on_event
  @on_event
end

.output_policy_modelObject

Returns the value of attribute output_policy_model.



59
60
61
# File 'lib/turnkit.rb', line 59

def output_policy_model
  @output_policy_model
end

.output_policy_thinkingObject

Returns the value of attribute output_policy_thinking.



59
60
61
# File 'lib/turnkit.rb', line 59

def output_policy_thinking
  @output_policy_thinking
end

.prompt_behaviorObject

Returns the value of attribute prompt_behavior.



61
62
63
# File 'lib/turnkit.rb', line 61

def prompt_behavior
  @prompt_behavior
end

.prompt_cacheObject

Returns the value of attribute prompt_cache.



57
58
59
# File 'lib/turnkit.rb', line 57

def prompt_cache
  @prompt_cache
end

.prompt_data_max_charsObject

Returns the value of attribute prompt_data_max_chars.



62
63
64
# File 'lib/turnkit.rb', line 62

def prompt_data_max_chars
  @prompt_data_max_chars
end

.prompt_sectionsObject

Returns the value of attribute prompt_sections.



61
62
63
# File 'lib/turnkit.rb', line 61

def prompt_sections
  @prompt_sections
end

.storeObject

Returns the value of attribute store.



54
55
56
# File 'lib/turnkit.rb', line 54

def store
  @store
end

.system_prompt_contributorsObject

Returns the value of attribute system_prompt_contributors.



63
64
65
# File 'lib/turnkit.rb', line 63

def system_prompt_contributors
  @system_prompt_contributors
end

.timeoutObject

Returns the value of attribute timeout.



55
56
57
# File 'lib/turnkit.rb', line 55

def timeout
  @timeout
end

.tool_execution_record_classObject

Returns the value of attribute tool_execution_record_class.



66
67
68
# File 'lib/turnkit.rb', line 66

def tool_execution_record_class
  @tool_execution_record_class
end

.turn_record_classObject

Returns the value of attribute turn_record_class.



65
66
67
# File 'lib/turnkit.rb', line 65

def turn_record_class
  @turn_record_class
end

Class Method Details

.check_output_policy(output, constraints: [], context: {}) ⇒ Object



109
110
111
# File 'lib/turnkit.rb', line 109

def self.check_output_policy(output, constraints: [], context: {})
  OutputAudit.check(output, constraints: constraints, context: context)
end

.configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

  • _self (TurnKit)

    the object that the method was called on



91
92
93
# File 'lib/turnkit.rb', line 91

def self.configure
  yield self
end

.modelObject



95
96
97
# File 'lib/turnkit.rb', line 95

def self.model
  default_model
end

.model=(value) ⇒ Object



99
100
101
# File 'lib/turnkit.rb', line 99

def self.model=(value)
  self.default_model = value
end

.reconcile_stale!(before: Clock.now - (timeout || 300)) ⇒ Object



103
104
105
106
107
# File 'lib/turnkit.rb', line 103

def self.reconcile_stale!(before: Clock.now - (timeout || 300))
  store.find_stale_turns(before: before).each do |turn|
    store.update_turn(turn.fetch("id"), "status" => "stale", "completed_at" => Clock.now)
  end
end