Documentation
¶
Overview ¶
Package metaid parses and builds the identifier Anthropic clients put in metadata.user_id. It is a leaf package so both the protocol converters and the vendor ops layer can read a request's session identity without either depending on the other.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatMetadataUserID ¶
func FormatMetadataUserID(m *MetadataUserID) string
FormatMetadataUserID formats a MetadataUserID to JSON string. Returns empty string for nil input.
Types ¶
type MetadataUserID ¶
type MetadataUserID struct {
DeviceID string `json:"device_id"`
AccountUUID string `json:"account_uuid"`
SessionID string `json:"session_id"`
}
MetadataUserID represents the JSON structure for metadata.user_id This matches Claude Code's format (>= 2.1.78)
func BuildMetadataUserID ¶
func BuildMetadataUserID(extra map[string]any) *MetadataUserID
BuildMetadataUserID builds a MetadataUserID from extra map. Returns nil if all fields are empty after fixing.
func FixMetadataUserID ¶
func FixMetadataUserID(raw string) *MetadataUserID
FixMetadataUserID parses and fixes a metadata user ID string. Returns a new MetadataUserID with generated fields for missing values.
func ParseMetadataUserID ¶
func ParseMetadataUserID(raw string) *MetadataUserID
ParseMetadataUserID parses a metadata.user_id string in either JSON or legacy format. Returns nil if the input cannot be parsed.
func (*MetadataUserID) Fix ¶
func (m *MetadataUserID) Fix(extras map[string]any)
func (*MetadataUserID) Format ¶
func (m *MetadataUserID) Format() string
Format converts MetadataUserID to string for metadata.
func (*MetadataUserID) IsEmpty ¶
func (m *MetadataUserID) IsEmpty() bool
IsEmpty checks if the MetadataUserID is effectively empty.
func (*MetadataUserID) IsValid ¶
func (m *MetadataUserID) IsValid() bool
IsValid checks if the MetadataUserID has required fields.