agentclient

package
v0.19.1236 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 8, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package agentclient identifies a coding agent that launched the CLI. The detected name is safe to print and to send as the X-Nuon-Agent header.

Index

Constants

View Source
const (
	// Header is the request header carrying the detected agent name.
	Header = "X-Nuon-Agent"
	// CommandHeader is the request header carrying the CLI command path, without arguments.
	CommandHeader = "X-Nuon-Command"
	// EnvVar overrides detection. "off" disables it. "cursor" and "claude" force a name.
	EnvVar = "NUON_AGENT_CLIENT"
	// AIAgentEnvVar is the general agent name. The value is a slug, optionally
	// with @version: amp, claude-code, cursor-cli@1.2.3.
	AIAgentEnvVar = "AI_AGENT"

	Amp         = "amp"
	Cursor      = "cursor"
	Gemini      = "gemini"
	Codex       = "codex"
	Antigravity = "antigravity"
	Augment     = "augment-cli"
	OpenCode    = "opencode"
	Cowork      = "cowork"
	Claude      = "claude"
	Replit      = "replit"
	Copilot     = "github-copilot"
)

Variables

This section is empty.

Functions

func Dir

func Dir(home string) string

Dir is ~/.nuon.agents for the given home directory.

func FirstRunGuide

func FirstRunGuide(agent string) string

FirstRunGuide is the one-time stderr notice printed the first time an agent runs the CLI.

func ProductEnvKeys

func ProductEnvKeys() []string

ProductEnvKeys are the variables detectProduct reads. Tests clear them so a developer shell does not leak into a "no agent" case.

func Touch

func Touch(dir string, rec Record, now time.Time) (created bool, err error)

Touch creates or updates the YAML file for rec.Agent. created is true only the first time that file is written. now is stored as UTC.

func UserAgent

func UserAgent(version, agent string) string

UserAgent is the HTTP User-Agent for an agent-driven CLI request. It contains "nuon-cli" so control-plane CLI detection still matches.

Types

type Client

type Client struct {
	// Name is the attribution value, such as "cursor", "claude", or "amp".
	Name string
}

Client is a detected coding agent.

func Detect

func Detect() (Client, bool)

Detect reports the coding agent that started this process, if any.

func DetectEnv

func DetectEnv(env []string) (Client, bool)

DetectEnv reports the coding agent described by env. Entries are KEY=VALUE. NUON_AGENT_CLIENT wins, then product variables, then a named AI_AGENT. Amp is checked before Claude Code because Amp also sets CLAUDECODE.

type Record

type Record struct {
	Agent      string    `yaml:"agent"`
	CLIVersion string    `yaml:"cli_version"`
	AppID      string    `yaml:"app_id"`
	FirstSeen  time.Time `yaml:"first_seen"`
	LastSeen   time.Time `yaml:"last_seen"`
}

Record is the per-agent file stored under ~/.nuon.agents.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL