Documentation
¶
Overview ¶
Package probe verifies connectivity to aiscan's external dependencies (cyberhub, recon providers, search, IOA, and the LLM) using a supplied config. Probe failures are reported inside the result structs rather than as returned errors; a returned error only signals an unknown/untestable section.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( FofaInfoEndpoint = "https://fofa.info/api/v1/info/my" HunterSearchEndpoint = "https://hunter.qianxin.com/openApi/search" )
Recon provider endpoints. Declared as vars (not consts) so tests can point them at a local stub server.
Functions ¶
This section is empty.
Types ¶
type ConnCheck ¶
type ConnCheck struct {
Name string `json:"name"` // fofa, hunter, cyberhub, tavily, ioa
OK bool `json:"ok"`
LatencyMs int64 `json:"latency_ms"`
Detail string `json:"detail,omitempty"`
Error string `json:"error,omitempty"`
}
ConnCheck is the outcome of probing one external dependency. A single settings section may run more than one check (Recon probes FOFA and Hunter independently), so callers always receive a list and the UI renders each row.
func TestConn ¶
func TestConn(ctx context.Context, section string, in, stored webproto.DistributeConfig) ([]ConnCheck, error)
TestConn probes the external dependencies of one settings section using the supplied (possibly partial) config. Secret fields left blank fall back to the value already stored on the server (stored), mirroring the settings UI convention where a configured secret is left empty to keep it unchanged. Like TestLLM, probe failures are reported inside ConnCheck rather than as a returned error; a non-nil error only signals an unknown/untestable section.
type LLMModelsResult ¶
type LLMModelsResult struct {
OK bool `json:"ok"`
Models []string `json:"models,omitempty"`
Error string `json:"error,omitempty"`
}
LLMModelsResult reports the model IDs discovered at the endpoint. ok=false carries the reason (unsupported provider, auth failure, unreachable, …).
func ListLLMModels ¶
func ListLLMModels(ctx context.Context, req LLMProbeRequest, storedAPIKey string) (LLMModelsResult, error)
ListLLMModels asks the configured endpoint for its model catalog so the settings UI can offer a picklist instead of requiring the model to be typed by hand. Like TestLLM it never returns a transport error — failures are captured inside LLMModelsResult. When req.APIKey is blank, storedAPIKey is used (the settings UI leaves a configured key blank to keep it unchanged).
type LLMProbeRequest ¶
type LLMProbeRequest struct {
Provider string `json:"provider"`
BaseURL string `json:"base_url"`
APIKey string `json:"api_key"`
Model string `json:"model,omitempty"`
Proxy string `json:"proxy"`
}
LLMProbeRequest carries the connection parameters the user wants to verify or use for model enumeration. It mirrors the LLM section of webproto.DistributeConfig. An empty APIKey means "use the key already stored in the config" (matching the settings UI where a configured key is left blank to keep it unchanged). Model is only required for TestLLM; ListLLMModels ignores it.
type LLMTestResult ¶
type LLMTestResult struct {
OK bool `json:"ok"`
Provider string `json:"provider"`
Model string `json:"model"`
LatencyMs int64 `json:"latency_ms"`
Reply string `json:"reply,omitempty"`
Error string `json:"error,omitempty"`
}
LLMTestResult reports whether a probe request reached the provider and returned a usable completion.
func TestLLM ¶
func TestLLM(ctx context.Context, req LLMProbeRequest, storedAPIKey string) (LLMTestResult, error)
TestLLM issues a minimal chat completion against the supplied LLM settings and reports the outcome. It never returns a transport error to the caller — failures are captured inside LLMTestResult so the UI can render them. A nil error only signals the request was well-formed enough to attempt. When req.APIKey is blank, storedAPIKey is used (the settings UI leaves a configured key blank to keep it unchanged).