useragent

package
v1.45.4 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package useragent builds User-Agent strings for Stripe API requests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DetectAIAgent added in v1.37.2

func DetectAIAgent(getEnv func(string) string) string

DetectAIAgent detects if the CLI was invoked by a coding agent, based on well-known env vars. It accepts an environment getter function to allow testing without modifying the actual environment.

func DetectAgentHostKind added in v1.45.4

func DetectAgentHostKind(getEnv func(string) string) string

DetectAgentHostKind reports where the agent ran: "desktop", "terminal", "ide", "remote", "sdk", "mcp", or "other", and "" when no agent reported a host.

Only the category is exposed. The underlying values are per-vendor spellings that every consumer would otherwise have to enumerate, and the vendor is already carried by DetectAIAgent.

func DetectAgentVersion added in v1.45.4

func DetectAgentVersion(getEnv func(string) string) string

DetectAgentVersion returns the agent's own version, parsed out of the identifier it reports through the AI_AGENT convention, or "" when absent or unparseable.

Claude Code encodes it as "claude-code_2-1-227_agent" (dots written as dashes) and has also used "claude-code/2.1.227". No other agent reports a version this way today. Both formats are undocumented, so this validates what it extracts and reports nothing rather than guessing: a wrong version is worse than a missing one.

func DetectInScreen added in v1.42.3

func DetectInScreen(getEnv func(string) string) bool

DetectInScreen detects whether the CLI was invoked from within a GNU Screen session.

func DetectInTmux added in v1.42.3

func DetectInTmux(getEnv func(string) string) bool

DetectInTmux detects whether the CLI was invoked from within a tmux session.

func DetectInstallMethod added in v1.42.2

func DetectInstallMethod(
	getEnv func(string) string,
	getExecutable func() (string, error),
	statFile func(string) error,
) string

DetectInstallMethod detects how the CLI was installed. Returns one of: "npm_global", "npm_run", "npx", "homebrew", "scoop", "apt", or "unknown".

func DetectTerminalProgram added in v1.42.3

func DetectTerminalProgram(getEnv func(string) string) string

DetectTerminalProgram detects the terminal program the CLI was invoked from, when available.

func GetEncodedStripeUserAgent

func GetEncodedStripeUserAgent() string

GetEncodedStripeUserAgent returns the string to be used as the value for the `X-Stripe-Client-User-Agent` HTTP header.

func GetEncodedUserAgent

func GetEncodedUserAgent() string

GetEncodedUserAgent returns the string to be used as the value for the `User-Agent` HTTP header.

Types

This section is empty.

Jump to

Keyboard shortcuts

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