Documentation
¶
Index ¶
- Constants
- Variables
- func HostsEntries() string
- type AntUsage
- type AnthropicMessage
- type ChatChoice
- type ChatCompletion
- type ChatMessage
- type ContentBlock
- type FunctionCall
- type LogEntry
- type MockServer
- func (s *MockServer) CAPem() []byte
- func (s *MockServer) ClearLog()
- func (s *MockServer) Close()
- func (s *MockServer) Log() []LogEntry
- func (s *MockServer) LogCount() int
- func (s *MockServer) PrepareToolCall(name, args, path string)
- func (s *MockServer) ProxyAddr() string
- func (s *MockServer) SetResponse(text string)
- func (s *MockServer) Start() (string, error)
- func (s *MockServer) StartIntercept() (string, error)
- func (s *MockServer) StartProxy() (string, error)
- type ModelEntry
- type ModelList
- type ResponseItem
- type ResponseObject
- type ResponsePart
- type ToolCall
- type Usage
Constants ¶
const DefaultToolArgs = `{"file_path":"README.md"}`
const DefaultToolName = "Read"
Variables ¶
var LLMHosts = []string{
"api.openai.com",
"api.anthropic.com",
"generativelanguage.googleapis.com",
"api.x.ai",
"openrouter.ai",
"api.moonshot.cn",
"dashscope.aliyuncs.com",
"api.factory.ai",
"kilo.codes",
"opencode.ai",
"q.us-east-1.amazonaws.com",
"q.eu-central-1.amazonaws.com",
"runtime.us-east-1.kiro.dev",
"runtime.eu-central-1.kiro.dev",
"app.kiro.dev",
"prod.us-east-1.auth.desktop.kiro.dev",
"management.us-east-1.kiro.dev",
"cognito-identity.us-east-1.amazonaws.com",
"client-telemetry.us-east-1.amazonaws.com",
"prod.us-east-1.telemetry-v2.kiro.dev",
}
LLMHosts are API domains that agents call. Used by --intercept mode to map these to 127.0.0.1 via /etc/hosts so all LLM traffic hits the mock.
Functions ¶
func HostsEntries ¶
func HostsEntries() string
HostsEntries returns /etc/hosts lines mapping LLM API domains to 127.0.0.1.
Types ¶
type AnthropicMessage ¶
type ChatChoice ¶
type ChatChoice struct {
Index int `json:"index"`
Message *ChatMessage `json:"message,omitempty"`
Delta *ChatMessage `json:"delta,omitempty"`
FinishReason string `json:"finish_reason,omitempty"`
}
type ChatCompletion ¶
type ChatMessage ¶
type ContentBlock ¶
type FunctionCall ¶
type MockServer ¶
type MockServer struct {
// contains filtered or unexported fields
}
func New ¶
func New() *MockServer
func (*MockServer) CAPem ¶
func (s *MockServer) CAPem() []byte
CAPem returns the PEM-encoded CA certificate used by the MITM listener. Returns nil if StartIntercept hasn't been called.
func (*MockServer) ClearLog ¶
func (s *MockServer) ClearLog()
func (*MockServer) Close ¶
func (s *MockServer) Close()
func (*MockServer) Log ¶
func (s *MockServer) Log() []LogEntry
func (*MockServer) LogCount ¶
func (s *MockServer) LogCount() int
func (*MockServer) PrepareToolCall ¶
func (s *MockServer) PrepareToolCall(name, args, path string)
func (*MockServer) ProxyAddr ¶
func (s *MockServer) ProxyAddr() string
ProxyAddr returns the MITM proxy address (e.g. "http://127.0.0.1:34567") for use as HTTPS_PROXY. Returns empty if StartProxy hasn't been called.
func (*MockServer) SetResponse ¶
func (s *MockServer) SetResponse(text string)
func (*MockServer) Start ¶
func (s *MockServer) Start() (string, error)
func (*MockServer) StartIntercept ¶
func (s *MockServer) StartIntercept() (string, error)
StartIntercept starts both HTTP (random port) and HTTPS (port 443) listeners. Uses a CA cert to sign server certs for all LLM API domains. The CA PEM is available via CAPem() for injection into runtimes (NODE_EXTRA_CA_CERTS etc.).
func (*MockServer) StartProxy ¶
func (s *MockServer) StartProxy() (string, error)
StartProxy starts an HTTP CONNECT proxy on a random port. Agents that set HTTPS_PROXY to this address will have their TLS connections MITM'd: the proxy terminates TLS using the CA cert from StartIntercept, then routes the decrypted HTTP requests through the mock server's mux.
Must be called after StartIntercept (needs the CA-signed TLS cert).
type ModelEntry ¶
type ModelList ¶
type ModelList struct {
Data []ModelEntry `json:"data"`
}
type ResponseItem ¶
type ResponseItem struct {
Type string `json:"type"`
ID string `json:"id,omitempty"`
CallID string `json:"call_id,omitempty"`
Role string `json:"role,omitempty"`
Name string `json:"name,omitempty"`
Arguments string `json:"arguments,omitempty"`
Status string `json:"status,omitempty"`
Content []ResponsePart `json:"content,omitempty"`
}