{"modulePath":"github.com/utmstack/UTMStack/plugins/soc-ai","version":"v0.0.0-20261126134315-738f65073a40","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package agent\n\n## Constants\n\n```go\nconst EscalateSentinel = \"NEEDS_INVESTIGATION:\"\n```\nEscalateSentinel is the exact reply FastTriagePrompt asks for when the alert and its deterministic score aren't enough to classify confidently. The queue checks for this literal prefix to decide whether to fall back to the full agentic TriagePrompt (which has investigation tools).\n\n## Variables\n\n```go\nvar ErrLLMRateLimited = errors.New(\"rate limit reached — upgrade to Enterprise for higher usage limits\")\n```\n\n## Functions\n\n```go\nfunc FastTriagePrompt() string\n```\nFastTriagePrompt is the default triage path: one completion, no tools. The deterministic score is computed in Go before this prompt ever runs (see the queue's ScoreAlert call) and handed over as plain context, not as something the model decides whether to fetch — that decision was never really a choice, so it shouldn't cost a round trip. Writing the resulting note is also done in Go from this reply, not via a tool call. The only way this path costs more than one LLM call is the model asking to escalate, which is exactly the case where more calls are warranted.\n\n```go\nfunc OpsPrompt(page, lang string, enabledGroups []string) string\n```\n\n```go\nfunc SetBuilder(build func(tenantID string) *Agent)\n```\n\n```go\nfunc TriagePrompt() string\n```\nTriagePrompt is the escalation path: a full agentic pass with investigation tools, used only when FastTriagePrompt asked to escalate. The score is still handed over as pre-computed context here too — it is never a tool call in either path.\n\n## Types\n\n```go\ntype Agent struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc For(tenantID string) *Agent\n```\n\n```go\nfunc New(llm LLMClient, broker *ToolBroker, model string, maxTokens, contextWindow int) *Agent\n```\n\n```go\nfunc (a *Agent) Broker() *ToolBroker\n```\n\n```go\nfunc (a *Agent) QuickComplete(ctx context.Context, system, input string) (string, error)\n```\nQuickComplete runs a single, tool-free LLM completion — the non-agentic fast path for a task that doesn't need investigation, like classifying an alert that already carries its deterministic score. It never loops and never offers tools, so it costs exactly one LLM call no matter what the model answers.\n\n```go\nfunc (a *Agent) Run(ctx context.Context, task RunTask, sink EventSink) (RunResult, error)\n```\n\n```go\ntype CapabilityGroup struct {\n\tID       string\n\tLabel    string // English description, used in the agent's permission prompt\n\tPrefixes []string\n}\n```\n\n```go\ntype CompletionRequest struct {\n\tSystem      string\n\tMessages    []Message\n\tTools       []ToolSpec\n\tModel       string\n\tMaxTokens   int\n\tTemperature float64 // 0 = provider default; ops path sets it low to curb exploratory tool use\n}\n```\n\n```go\ntype CompletionResponse struct {\n\tContent   string\n\tToolCalls []ToolCall\n\tStop      string // provider stop/finish reason\n}\n```\n\n```go\ntype Event struct {\n\tKind    EventKind       `json:\"kind\"`\n\tStep    int             `json:\"step,omitempty\"`\n\tTool    string          `json:\"tool,omitempty\"`\n\tArgs    json.RawMessage `json:\"args,omitempty\"`\n\tOutput  string          `json:\"output,omitempty\"`\n\tIsError bool            `json:\"isError,omitempty\"`\n\tText    string          `json:\"text,omitempty\"`\n}\n```\n\n```go\ntype EventKind string\n```\n\n```go\nconst (\n\tEventToolCall   EventKind = \"tool_call\"\n\tEventToolResult EventKind = \"tool_result\"\n\tEventFinal      EventKind = \"final\"\n\tEventError      EventKind = \"error\"\n\tEventCompaction EventKind = \"compaction\"\n)\n```\n\n```go\ntype EventSink func(Event)\n```\n\n```go\ntype LLMClient interface {\n\tComplete(ctx context.Context, req CompletionRequest) (CompletionResponse, error)\n\tProvider() string\n}\n```\n\n```go\nfunc NewLLMClient(cfg LLMConfig) LLMClient\n```\n\n```go\ntype LLMConfig struct {\n\tProvider       string // \"anthropic\" → Anthropic wire format; anything else → OpenAI-compatible\n\tURL            string // full endpoint\n\tModel          string\n\tAPIKey         string\n\tAuthType       string // bearer | header | none\n\tAuthHeaderName string // header name when AuthType == \"header\"\n\tCustomHeaders  map[string]string\n}\n```\n\n```go\ntype Message struct {\n\tRole       Role\n\tContent    string\n\tToolCalls  []ToolCall  // set on assistant turns that call tools\n\tToolResult *ToolResult // set on tool turns (one per message)\n}\n```\n\n```go\ntype Role string\n```\n\n```go\nconst (\n\tRoleUser      Role = \"user\"\n\tRoleAssistant Role = \"assistant\"\n\tRoleTool      Role = \"tool\"\n)\n```\n\n```go\ntype RunResult struct {\n\tFinal     string\n\tSteps     int\n\tToolCalls int\n}\n```\n\n```go\ntype RunTask struct {\n\tSystem        string // system prompt\n\tInput         string // the user turn (alert JSON for triage, free task for ops)\n\tHistory       []Message\n\tEnabledGroups []string\n\tAlwaysAllow   []string\n\tMaxIters      int\n\tTemperature   float64 // 0 = provider default\n}\n```\n\n```go\ntype ToolBroker struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewToolBroker(backendURL, internalKey, tenantID string) *ToolBroker\n```\n\n```go\nfunc (b *ToolBroker) Call(ctx context.Context, name string, args json.RawMessage) (string, bool, error)\n```\n\n```go\nfunc (b *ToolBroker) Close()\n```\n\n```go\nfunc (b *ToolBroker) ListSpecs(ctx context.Context) ([]ToolSpec, error)\n```\n\n```go\ntype ToolCall struct {\n\tID   string\n\tName string\n\tArgs json.RawMessage\n}\n```\n\n```go\ntype ToolResult struct {\n\tID      string // matches ToolCall.ID\n\tName    string\n\tContent string\n\tIsError bool\n}\n```\n\n```go\ntype ToolSpec struct {\n\tName        string\n\tDescription string\n\tInputSchema map[string]any\n\tReadOnly    bool\n}\n```\n\n","path":"github.com/utmstack/UTMStack/plugins/soc-ai/internal/agent","name":"agent","synopsis":"","isRedistributable":true}
