id

package
v1.10.1 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package id defines TypeID-based identity types for all Cortex entities.

Every entity in Cortex uses a single ID struct with a prefix that identifies the entity type. IDs are K-sortable (UUIDv7-based), globally unique, and URL-safe in the format "prefix_suffix".

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentID

type AgentID = ID

AgentID is a type-safe identifier for agents (prefix: "agt").

type AgentRunID

type AgentRunID = ID

AgentRunID is a type-safe identifier for agent runs (prefix: "arun").

type AnyID

type AnyID = ID

AnyID is a type alias that accepts any valid prefix.

type BehaviorID

type BehaviorID = ID

BehaviorID is a type-safe identifier for behaviors (prefix: "bhv").

type CheckpointID

type CheckpointID = ID

CheckpointID is a type-safe identifier for checkpoints (prefix: "acp").

type ConversationID

type ConversationID = ID

ConversationID is a type-safe identifier for a2a conversations (prefix: "conv").

type DeliveryID

type DeliveryID = ID

DeliveryID is a type-safe identifier for a2a deliveries (prefix: "dlv").

type ID

type ID struct {
	// contains filtered or unexported fields
}

ID is the primary identifier type for all Cortex entities. It wraps a TypeID providing a prefix-qualified, globally unique, sortable, URL-safe identifier in the format "prefix_suffix".

var Nil ID

Nil is the zero-value ID.

func MustParse

func MustParse(s string) ID

MustParse is like Parse but panics on error. Use for hardcoded ID values.

func MustParseWithPrefix

func MustParseWithPrefix(s string, expected Prefix) ID

MustParseWithPrefix is like ParseWithPrefix but panics on error.

func New

func New(prefix Prefix) ID

New generates a new globally unique ID with the given prefix. It panics if prefix is not a valid TypeID prefix (programming error).

func NewAgentID

func NewAgentID() ID

NewAgentID generates a new unique agent ID.

func NewAgentRunID

func NewAgentRunID() ID

NewAgentRunID generates a new unique agent run ID.

func NewBehaviorID

func NewBehaviorID() ID

NewBehaviorID generates a new unique behavior ID.

func NewCheckpointID

func NewCheckpointID() ID

NewCheckpointID generates a new unique checkpoint ID.

func NewConversationID

func NewConversationID() ID

NewConversationID generates a new unique a2a conversation ID.

func NewDeliveryID

func NewDeliveryID() ID

NewDeliveryID generates a new unique a2a delivery ID.

func NewMemoryID

func NewMemoryID() ID

NewMemoryID generates a new unique memory ID.

func NewMessageID

func NewMessageID() ID

NewMessageID generates a new unique a2a message ID.

func NewOrchestrationConfigID

func NewOrchestrationConfigID() ID

NewOrchestrationConfigID generates a new unique orchestration config ID.

func NewOrchestrationID

func NewOrchestrationID() ID

NewOrchestrationID generates a new unique orchestration ID.

func NewOverlayID

func NewOverlayID() ID

NewOverlayID generates a new unique overlay ID.

func NewPersonaID

func NewPersonaID() ID

NewPersonaID generates a new unique persona ID.

func NewSessionID

func NewSessionID() ID

NewSessionID generates a new unique session ID.

func NewSkillID

func NewSkillID() ID

NewSkillID generates a new unique skill ID.

func NewStepID

func NewStepID() ID

NewStepID generates a new unique step ID.

func NewSuspensionID

func NewSuspensionID() ID

NewSuspensionID generates a new unique suspension ID.

func NewToolCallID

func NewToolCallID() ID

NewToolCallID generates a new unique tool call ID.

func NewToolID

func NewToolID() ID

NewToolID generates a new unique tool ID.

func NewTraitID

func NewTraitID() ID

NewTraitID generates a new unique trait ID.

func Parse

func Parse(s string) (ID, error)

Parse parses a TypeID string (e.g., "agt_01h2xcejqtf2nbrexx3vqjhp41") into an ID. Returns an error if the string is not valid.

func ParseAgentID

func ParseAgentID(s string) (ID, error)

ParseAgentID parses a string and validates the "agt" prefix.

func ParseAgentRunID

func ParseAgentRunID(s string) (ID, error)

ParseAgentRunID parses a string and validates the "arun" prefix.

func ParseAny

func ParseAny(s string) (ID, error)

ParseAny parses a string into an ID without type checking the prefix.

func ParseBehaviorID

func ParseBehaviorID(s string) (ID, error)

ParseBehaviorID parses a string and validates the "bhv" prefix.

func ParseCheckpointID

func ParseCheckpointID(s string) (ID, error)

ParseCheckpointID parses a string and validates the "acp" prefix.

func ParseMemoryID

func ParseMemoryID(s string) (ID, error)

ParseMemoryID parses a string and validates the "mem" prefix.

func ParseOptionalSessionID

func ParseOptionalSessionID(s string) (ID, error)

ParseOptionalSessionID parses s as a session ID, returning the zero ID (rather than an error) when s is empty. Run and memory rows written before session_id existed carry an empty column, and the store layer reconstructing those rows into structs needs a nil session id there, not a parse failure.

func ParseOrchestrationConfigID

func ParseOrchestrationConfigID(s string) (ID, error)

ParseOrchestrationConfigID parses a string and validates the "orchcfg" prefix.

func ParseOrchestrationID

func ParseOrchestrationID(s string) (ID, error)

ParseOrchestrationID parses a string and validates the "orch" prefix.

func ParseOverlayID

func ParseOverlayID(s string) (ID, error)

ParseOverlayID parses a string and validates the "ovl" prefix.

func ParsePersonaID

func ParsePersonaID(s string) (ID, error)

ParsePersonaID parses a string and validates the "prs" prefix.

func ParseSessionID

func ParseSessionID(s string) (ID, error)

ParseSessionID parses a string and validates the "ses" prefix.

func ParseSkillID

func ParseSkillID(s string) (ID, error)

ParseSkillID parses a string and validates the "skl" prefix.

func ParseStepID

func ParseStepID(s string) (ID, error)

ParseStepID parses a string and validates the "astp" prefix.

func ParseSuspensionID

func ParseSuspensionID(s string) (ID, error)

ParseSuspensionID parses a string and validates the "sus" prefix.

func ParseToolCallID

func ParseToolCallID(s string) (ID, error)

ParseToolCallID parses a string and validates the "tcall" prefix.

func ParseToolID

func ParseToolID(s string) (ID, error)

ParseToolID parses a string and validates the "tool" prefix.

func ParseTraitID

func ParseTraitID(s string) (ID, error)

ParseTraitID parses a string and validates the "trt" prefix.

func ParseWithPrefix

func ParseWithPrefix(s string, expected Prefix) (ID, error)

ParseWithPrefix parses a TypeID string and validates that its prefix matches the expected value.

func (ID) IsNil

func (i ID) IsNil() bool

IsNil reports whether this ID is the zero value.

func (ID) MarshalBSONValue

func (i ID) MarshalBSONValue() (bsonType byte, data []byte, err error)

MarshalBSONValue satisfies bson.ValueMarshaler (mongo-driver v2) so the ID is stored as a BSON string instead of an opaque struct. No bson import needed because Go uses structural typing for interface satisfaction.

func (ID) MarshalText

func (i ID) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (ID) Prefix

func (i ID) Prefix() Prefix

Prefix returns the prefix component of this ID.

func (*ID) Scan

func (i *ID) Scan(src any) error

Scan implements sql.Scanner for database retrieval.

func (ID) String

func (i ID) String() string

String returns the full TypeID string representation (prefix_suffix). Returns an empty string for the Nil ID.

func (*ID) UnmarshalBSONValue

func (i *ID) UnmarshalBSONValue(t byte, data []byte) error

UnmarshalBSONValue satisfies bson.ValueUnmarshaler (mongo-driver v2).

func (*ID) UnmarshalText

func (i *ID) UnmarshalText(data []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

func (ID) Value

func (i ID) Value() (driver.Value, error)

Value implements driver.Valuer for database storage. Returns nil for the Nil ID so that optional foreign key columns store NULL.

type MemoryID

type MemoryID = ID

MemoryID is a type-safe identifier for memories (prefix: "mem").

type MessageID

type MessageID = ID

MessageID is a type-safe identifier for a2a envelopes (prefix: "msg").

type OrchestrationConfigID

type OrchestrationConfigID = ID

OrchestrationConfigID is a type-safe identifier for orchestration configs (prefix: "orchcfg").

type OrchestrationID

type OrchestrationID = ID

OrchestrationID is a type-safe identifier for orchestrations (prefix: "orch").

type OverlayID

type OverlayID = ID

OverlayID is a type-safe identifier for prompt overlays (prefix: "ovl").

type PersonaID

type PersonaID = ID

PersonaID is a type-safe identifier for personas (prefix: "prs").

type Prefix

type Prefix string

Prefix identifies the entity type encoded in a TypeID.

const (
	PrefixAgent               Prefix = "agt"
	PrefixAgentRun            Prefix = "arun"
	PrefixTool                Prefix = "tool"
	PrefixToolCall            Prefix = "tcall"
	PrefixStep                Prefix = "astp"
	PrefixMemory              Prefix = "mem"
	PrefixCheckpoint          Prefix = "acp"
	PrefixOrchestration       Prefix = "orch"
	PrefixOrchestrationConfig Prefix = "orchcfg"
	PrefixSkill               Prefix = "skl"
	PrefixTrait               Prefix = "trt"
	PrefixBehavior            Prefix = "bhv"
	PrefixPersona             Prefix = "prs"
	PrefixSession             Prefix = "ses"
	PrefixSuspension          Prefix = "sus"
	PrefixOverlay             Prefix = "ovl"
	PrefixMessage             Prefix = "msg"
	PrefixConversation        Prefix = "conv"
	PrefixDelivery            Prefix = "dlv"
	PrefixDeliveryClaim       Prefix = "dclaim"
)

Prefix constants for all Cortex entity types.

type SessionID

type SessionID = ID

SessionID is a type-safe identifier for sessions (prefix: "ses").

type SkillID

type SkillID = ID

SkillID is a type-safe identifier for skills (prefix: "skl").

type StepID

type StepID = ID

StepID is a type-safe identifier for steps (prefix: "astp").

type SuspensionID

type SuspensionID = ID

SuspensionID is a type-safe identifier for suspensions (prefix: "sus").

type ToolCallID

type ToolCallID = ID

ToolCallID is a type-safe identifier for tool calls (prefix: "tcall").

type ToolID

type ToolID = ID

ToolID is a type-safe identifier for tools (prefix: "tool").

type TraitID

type TraitID = ID

TraitID is a type-safe identifier for traits (prefix: "trt").

Jump to

Keyboard shortcuts

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