client

package
v2.38.6 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: AGPL-3.0 Imports: 6 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package client identifies AI clients and request correlation metadata.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GuessSessionID

func GuessSessionID(client Type, r *http.Request) *string

GuessSessionID attempts to retrieve a session ID which may have been sent by the client. If Claude Code has no usable session header, it reads and restores r.Body to inspect the payload. Other clients use only request headers.

func GuessSessionIDFromPayload

func GuessSessionIDFromPayload(client Type, r *http.Request, payload []byte) *string

GuessSessionIDFromPayload retrieves a session ID from recognized request headers and a pre-read payload, without reading, closing, or replacing r.Body. A nil or empty payload permits only header-based lookup.

Types

type Type

type Type string

Type identifies an AI client application.

const (
	// Possible values for the "client" field in interception records.
	// Must be kept in sync with documentation: https://github.com/coder/coder/blob/3cf867f84aa32d2febf7a26dc7e52be6beb8a2ac/docs/ai-coder/ai-gateway/monitoring.md?plain=1#L47-L57
	ClaudeCode  Type = "Claude Code"
	Codex       Type = "Codex"
	Zed         Type = "Zed"
	CopilotVSC  Type = "GitHub Copilot (VS Code)"
	CopilotCLI  Type = "GitHub Copilot (CLI)"
	Kilo        Type = "Kilo Code"
	CoderAgents Type = "Coder Agents"
	Crush       Type = "Charm Crush"
	Xum         Type = "Xum"
	Roo         Type = "Roo Code"
	Cursor      Type = "Cursor"
	OpenCode    Type = "OpenCode"
	Junie       Type = "Junie"
	Unknown     Type = "Unknown"
)

func GuessClient

func GuessClient(r *http.Request) Type

GuessClient attempts to guess the client application from the request headers. Not all clients set proper user agent headers, so this is a best-effort approach. Based on https://github.com/coder/aibridge/issues/20#issuecomment-3769444101.

Jump to

Keyboard shortcuts

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