clientsignals

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package clientsignals computes coarse, privacy-safe signals that help estimate whether a CLI process is being driven by a human or an AI agent.

This package is intentionally self-contained (no imports of the parent fly-go module, and only golang.org/x/sys as an external dependency, used for syscall-based parent-process lookup on Darwin/Windows) so it can later be extracted into its own standalone library with minimal friction.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientSignalsTransport

type ClientSignalsTransport struct {
	InnerTransport http.RoundTripper
	// contains filtered or unexported fields
}

ClientSignalsTransport wraps an http.RoundTripper, attaching the Fly-Client-* headers and appending the client-signals token to the existing User-Agent header on every outgoing request.

Construct one via Signals.WrapTransport. RoundTrip does no detection work itself — it only applies the values already computed when the transport was built.

func (*ClientSignalsTransport) RoundTrip

func (t *ClientSignalsTransport) RoundTrip(req *http.Request) (*http.Response, error)

type Signals

type Signals struct {
	// Interactive is true if the process's stdout appears to be attached to
	// a terminal.
	Interactive bool

	// Parent is a coarse bucket describing the immediate parent process.
	// Always one of "node", "python", "shell", or "other" — never a raw
	// process name.
	Parent string

	// Agent is the cooperative agent marker, e.g. "claude-code". Empty if no
	// agent was declared or detected.
	Agent string

	// AgentSource identifies how Agent was determined, e.g.
	// "env:FLY_INVOKED_BY" or "env:CLAUDECODE" — the matched variable name,
	// never its value. Empty if and only if Agent is empty.
	AgentSource string

	// CI is true when a CI environment is detected.
	CI bool
}

Signals is the set of coarse, privacy-safe traffic-classification signals computed once per process.

func Detect

func Detect() Signals

Detect computes the current process's client signals fresh from the environment and file descriptors. It is pure and side-effect free (aside from reading process state); it does not cache its result — callers that want a single value for the lifetime of a process should cache it themselves.

func DetectOnce

func DetectOnce() Signals

DetectOnce returns the process-wide signals, computed once via Detect and cached for the lifetime of the process. Detection involves a parent-process lookup and environment scanning, so callers should fetch this once (e.g. at client-construction time) and reuse the result rather than calling it per request.

func (Signals) WrapTransport

func (s Signals) WrapTransport(inner http.RoundTripper) *ClientSignalsTransport

WrapTransport wraps inner in a *ClientSignalsTransport that attaches s to every request the returned transport forwards.

Directories

Path Synopsis
Command clientsignals prints the client signals that would be attached to outbound Fly API requests from the current process/environment.
Command clientsignals prints the client signals that would be attached to outbound Fly API requests from the current process/environment.

Jump to

Keyboard shortcuts

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