Documentation
¶
Overview ¶
Package agentidentity resolves daemon-validated caller identity for agent-facing CLI and UDS operations.
Index ¶
Constants ¶
const ( // ExitOK reports successful agent command execution. ExitOK = 0 // ExitIdentityRequired reports missing caller identity input. ExitIdentityRequired = 64 // ExitIdentityInvalid reports stale or mismatched caller identity. ExitIdentityInvalid = 65 ExitUnauthorized = 77 ExitUnavailable = 69 // ExitDoctorWarn reports doctor diagnostics with warnings. ExitDoctorWarn = 70 // ExitDoctorError reports doctor diagnostics with errors. ExitDoctorError = 71 // ExitConfigInvalid reports invalid runtime configuration. ExitConfigInvalid = 78 )
const ( // EnvSessionID is the daemon-issued session identifier visible inside agent sessions. EnvSessionID = "AGH_SESSION_ID" // EnvAgent is the daemon-issued agent name visible inside agent sessions. EnvAgent = "AGH_AGENT" // HeaderSessionID carries EnvSessionID over the local UDS HTTP transport. HeaderSessionID = "X-AGH-Session-ID" // HeaderAgent carries EnvAgent over the local UDS HTTP transport. HeaderAgent = "X-AGH-Agent" // HeaderWorkspaceID optionally narrows an agent request to the caller workspace. HeaderWorkspaceID = "X-AGH-Workspace-ID" )
Variables ¶
var ( // ErrIdentityRequired reports missing required agent caller sandbox. ErrIdentityRequired = errors.New("agent identity required") // ErrIdentityStale reports a missing, unknown, stopped, or otherwise inactive session identity. ErrIdentityStale = errors.New("agent identity stale") // ErrIdentityMismatch reports env/header identity that does not match the daemon session record. ErrIdentityMismatch = errors.New("agent identity mismatch") ErrIdentityUnauthorized = errors.New("agent identity unauthorized") ErrIdentityLookupUnavailable = errors.New("agent identity lookup unavailable") )
Functions ¶
func ExitCodeForError ¶
ExitCodeForError maps agent identity and command errors to deterministic CLI exit codes.
func MarshalErrorJSON ¶
MarshalErrorJSON renders a stable JSON error object for agent CLI commands.
func MarshalErrorJSONL ¶
MarshalErrorJSONL renders one stable JSONL error frame for agent CLI streaming commands.
Types ¶
type Caller ¶
type Caller struct {
Credentials Credentials
Session SessionSnapshot
Actor taskpkg.ActorContext
}
Caller is a validated agent-session caller and its task-domain actor context.
type Credentials ¶
Credentials carries untrusted caller identity hints from env or transport headers.
type Error ¶
Error carries a stable machine-readable identity failure code with an actionable message.
func (*Error) DiagnosticItem ¶
func (e *Error) DiagnosticItem() contract.DiagnosticItem
DiagnosticItem exposes the shared diagnostic shape for errors.As callers.
func (*Error) ToDiagnosticItem ¶
func (e *Error) ToDiagnosticItem() contract.DiagnosticItem
ToDiagnosticItem converts the identity error into the shared diagnostic shape.
type ErrorPayload ¶
type ErrorPayload struct {
Code string `json:"code"`
Message string `json:"message"`
Action string `json:"action"`
ExitCode int `json:"exit_code"`
}
ErrorPayload is the stable machine-readable CLI error shape for agent namespaces.
func ErrorPayloadFor ¶
func ErrorPayloadFor(err error) ErrorPayload
ErrorPayloadFor returns the stable machine-readable error payload for agent CLI output.
type ResolveOptions ¶
type ResolveOptions struct {
Credentials Credentials
Lookup SessionLookup
ExpectedWorkspaceID string
OriginKind taskpkg.OriginKind
OriginRef string
}
ResolveOptions configures agent caller resolution.
type SessionLookup ¶
type SessionLookup func(context.Context, string) (SessionSnapshot, error)
SessionLookup loads a daemon-authoritative session snapshot by session ID.
type SessionSnapshot ¶
type SessionSnapshot struct {
ID string
Name string
AgentName string
Provider string
Model string
WorkspaceID string
WorkspacePath string
Channel string
Type session.Type
Lineage *store.SessionLineage
State session.State
SoulSnapshotID string
SoulDigest string
ParentSoulDigest string
CreatedAt time.Time
UpdatedAt time.Time
}
SessionSnapshot is the daemon-authoritative session subset needed for identity validation.
func SessionSnapshotFromInfo ¶
func SessionSnapshotFromInfo(info *session.Info) SessionSnapshot
SessionSnapshotFromInfo converts the runtime session read model into a validation snapshot.