Repository navigation
Expand file tree
/
Copy pathoptions.rb
More file actions
106 lines (97 loc) · 2.81 KB
/
Copy pathoptions.rb
File metadata and controls
106 lines (97 loc) · 2.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# frozen_string_literal: true
module CodexSDK
# Constructor options for CodexSDK::Client.
Options = Data.define(
:codex_path, # Override path to codex binary
:base_url, # OpenAI API base URL
:api_key, # API key (set as CODEX_API_KEY env var)
:config, # Arbitrary --config key=value overrides (Hash)
:env # Full env replacement (no ENV inheritance when set)
) do
def initialize(codex_path: nil, base_url: nil, api_key: nil, config: {}, env: nil)
super
end
def inspect
redacted_key = api_key ? "[REDACTED]" : "nil"
"#<#{self.class} codex_path=#{codex_path.inspect} base_url=#{base_url.inspect} " \
"api_key=#{redacted_key} config=#{config.inspect} env=#{env ? "[SET]" : "nil"}>"
end
end
# Per-thread options controlling model, sandbox, and behavior.
ThreadOptions = Data.define(
:model,
:sandbox_mode,
:working_directory,
:approval_policy,
:dangerously_bypass_approvals_and_sandbox,
:reasoning_effort,
:network_access,
:web_search,
:additional_directories,
:skip_git_repo_check
) do
def initialize(
model: nil,
sandbox_mode: nil,
working_directory: nil,
approval_policy: nil,
dangerously_bypass_approvals_and_sandbox: false,
reasoning_effort: nil,
network_access: nil,
web_search: nil,
additional_directories: [],
skip_git_repo_check: false
)
super
end
end
# Per-turn options (output schema, abort).
TurnOptions = Data.define(:output_schema) do
def initialize(output_schema: nil)
super
end
end
# Token usage from a completed turn.
Usage = Data.define(:input_tokens, :cached_input_tokens, :output_tokens) do
def initialize(input_tokens: 0, cached_input_tokens: 0, output_tokens: 0)
super
end
end
# Detailed token usage from rollout token_count snapshots.
TokenUsage = Data.define(
:input_tokens,
:cached_input_tokens,
:output_tokens,
:reasoning_output_tokens,
:total_tokens
) do
def initialize(
input_tokens: 0,
cached_input_tokens: 0,
output_tokens: 0,
reasoning_output_tokens: 0,
total_tokens: 0
)
super
end
end
# Final context snapshot derived from Codex rollout logs.
ContextSnapshot = Data.define(:model_context_window, :last_token_usage, :total_token_usage) do
def initialize(
model_context_window: 0,
last_token_usage: TokenUsage.new,
total_token_usage: TokenUsage.new
)
super
end
def context_tokens
last_token_usage.total_tokens
end
end
# Result of a blocking Thread#run call.
Turn = Data.define(:items, :final_response, :usage, :context_snapshot) do
def initialize(items: [], final_response: "", usage: nil, context_snapshot: nil)
super
end
end
end