Class: AgentHarness::Providers::Pi
- Inherits:
-
Base
- Object
- Base
- AgentHarness::Providers::Pi
show all
- Defined in:
- lib/agent_harness/providers/pi.rb
Overview
Pi coding agent CLI provider
Provides integration with the Pi terminal coding agent.
Constant Summary
collapse
- CLI_PACKAGE =
"@mariozechner/pi-coding-agent"
- SUPPORTED_CLI_VERSION =
"0.73.0"
- SUPPORTED_CLI_REQUIREMENT =
Gem::Requirement.new("= #{SUPPORTED_CLI_VERSION}").freeze
Constants inherited
from Base
Base::COMMON_ERROR_PATTERNS, Base::DEFAULT_SMOKE_TEST_CONTRACT
Instance Attribute Summary
Attributes inherited from Base
#config, #executor, #logger
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#api_key_env_var_names, #api_key_unset_vars, #cli_env_overrides, #configure, #initialize, #parse_container_output, #parse_rate_limit_reset, #parse_test_error, #plan_execution, #preflight_check, #sandboxed_environment?, #send_chat_message, #send_message, #subscription_unset_vars, #test_command_overrides
Methods included from Adapter
#auth_lock_config, #build_mcp_flags, #chat_transport, #chat_transport_type, #config_file_content, #dangerous_mode_flags, #error_classification_patterns, #fetch_mcp_servers, #health_status, #heartbeat_integration, included, metadata_package_name, #noisy_error_patterns, normalize_metadata_installation, normalize_metadata_source_type, normalize_metadata_version_requirement, #notify_hook_content, #parse_rate_limit_reset, #plan_execution, #preflight_check, #send_message, #session_flags, #smoke_test, #smoke_test_contract, #supported_mcp_transports, #supports_activity_heartbeat?, #supports_chat?, #supports_dangerous_mode?, #supports_mcp?, #supports_sessions?, #supports_text_mode?, #supports_token_counting?, #token_usage_from_api_response, #translate_error, #validate_config, #validate_mcp_servers!
Class Method Details
.binary_name ⇒ Object
20
21
22
|
# File 'lib/agent_harness/providers/pi.rb', line 20
def binary_name
"pi"
end
|
.discover_models ⇒ Object
62
63
64
65
|
# File 'lib/agent_harness/providers/pi.rb', line 62
def discover_models
return [] unless available?
[]
end
|
.firewall_requirements ⇒ Object
38
39
40
41
42
43
44
45
|
# File 'lib/agent_harness/providers/pi.rb', line 38
def firewall_requirements
{
domains: [
"pi.dev"
],
ip_ranges: []
}
end
|
.installation_contract(version: SUPPORTED_CLI_VERSION) ⇒ Object
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
107
108
109
110
111
112
113
114
|
# File 'lib/agent_harness/providers/pi.rb', line 67
def installation_contract(version: SUPPORTED_CLI_VERSION)
version = version.strip if version.respond_to?(:strip)
unless version.is_a?(String) && !version.empty?
raise ArgumentError,
"Unsupported Pi CLI version #{version.inspect}; " \
"supported versions must satisfy #{SUPPORTED_CLI_REQUIREMENT}"
end
parsed_version = begin
Gem::Version.new(version)
rescue ArgumentError
raise ArgumentError,
"Unsupported Pi CLI version #{version.inspect}; " \
"supported versions must satisfy #{SUPPORTED_CLI_REQUIREMENT}"
end
unless SUPPORTED_CLI_REQUIREMENT.satisfied_by?(parsed_version)
raise ArgumentError,
"Unsupported Pi CLI version #{version.inspect}; " \
"supported versions must satisfy #{SUPPORTED_CLI_REQUIREMENT}"
end
package = "#{CLI_PACKAGE}@#{version}".freeze
install_command_prefix = ["npm", "install", "-g", "--ignore-scripts"].freeze
install_command = (install_command_prefix + [package]).freeze
supported_versions = [version].freeze
version_requirement = SUPPORTED_CLI_REQUIREMENT.requirements
.map { |op, ver| "#{op} #{ver}".freeze }
.freeze
contract = {
source: :npm,
package: package,
package_name: CLI_PACKAGE,
version: version,
version_requirement: version_requirement,
binary_name: binary_name,
install_command_prefix: install_command_prefix,
install_command: install_command,
supported_versions: supported_versions
}
contract.each_value do |value|
value.freeze if value.is_a?(String)
end
contract.freeze
end
|
.instruction_file_paths ⇒ Object
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/agent_harness/providers/pi.rb', line 47
def instruction_file_paths
[
{
path: "AGENTS.md",
description: "Pi agent instructions",
symlink: false
},
{
path: "SYSTEM.md",
description: "Pi system prompt override",
symlink: false
}
]
end
|
29
30
31
32
33
34
35
36
|
# File 'lib/agent_harness/providers/pi.rb', line 29
def provider_metadata_overrides
{
auth: {
service: :pi,
api_family: :multi_provider
}
}
end
|
.provider_name ⇒ Object
16
17
18
|
# File 'lib/agent_harness/providers/pi.rb', line 16
def provider_name
:pi
end
|
.smoke_test_contract ⇒ Object
Instance Method Details
#auth_type ⇒ Object
174
175
176
|
# File 'lib/agent_harness/providers/pi.rb', line 174
def auth_type
:oauth
end
|
#capabilities ⇒ Object
152
153
154
155
156
157
158
159
160
161
162
163
164
|
# File 'lib/agent_harness/providers/pi.rb', line 152
def capabilities
{
streaming: false,
file_upload: true,
vision: true,
tool_use: true,
json_mode: false,
mcp: false,
dangerous_mode: false
}
end
|
#configuration_schema ⇒ Object
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
# File 'lib/agent_harness/providers/pi.rb', line 129
def configuration_schema
{
fields: [
{
name: :model,
type: :string,
label: "Model",
required: false,
hint: "Pi model pattern or ID passed to --model"
},
{
name: :provider,
type: :string,
label: "Provider",
required: false,
hint: "Pi provider name passed to --provider"
}
],
auth_modes: %i[api_key oauth],
openai_compatible: false
}
end
|
#display_name ⇒ Object
125
126
127
|
# File 'lib/agent_harness/providers/pi.rb', line 125
def display_name
"Pi Coding Agent"
end
|
#error_patterns ⇒ Object
166
167
168
|
# File 'lib/agent_harness/providers/pi.rb', line 166
def error_patterns
COMMON_ERROR_PATTERNS
end
|
#execution_semantics ⇒ Object
178
179
180
181
182
183
184
185
186
187
188
189
|
# File 'lib/agent_harness/providers/pi.rb', line 178
def execution_semantics
{
prompt_delivery: :flag,
output_format: :text,
sandbox_aware: false,
uses_subcommand: false,
non_interactive_flag: "-p",
legitimate_exit_codes: [0],
stderr_is_diagnostic: true,
parses_rate_limit_reset: false
}
end
|
#name ⇒ Object
121
122
123
|
# File 'lib/agent_harness/providers/pi.rb', line 121
def name
"pi"
end
|
170
171
172
|
# File 'lib/agent_harness/providers/pi.rb', line 170
def supports_tool_control?
true
end
|