Documentation
¶
Overview ¶
Package computeid is the Go SDK for ComputeID — cryptographic identity for AI compute infrastructure and agentic AI systems.
Every GPU needs a passport. Every AI agent needs an identity.
Three core abstractions:
- AgentPassport — local cryptographic passport for an AI agent.
- DevicePassport — server-issued passport for a GPU/server.
- PassportOffice — organisation-wide registry and audit trail.
Two server-backed REST surfaces, both exposed through *Client:
- /v1/agents/* — issue, verify, log, revoke server-side agent passports.
- /api/devices/* — register and authenticate devices.
Quickstart — local agent passport (no network):
caps := computeid.StandardCapabilities()
passport, err := computeid.IssueAgentPassport(computeid.IssueOptions{
AgentName: "ResearchAgent",
AgentType: "researcher",
OwnerOrg: "Acme Corp",
OwnerEmail: "admin@acme.com",
Capabilities: caps,
Model: "claude-sonnet-4-6",
})
if passport.VerifyAction(computeid.ActionBrowseWeb) {
// run the agent
}
Quickstart — register a GPU:
dev, err := computeid.RegisterGPU(ctx, "NVIDIA A100", "192.168.1.10", apiKey)
Quickstart — server-backed agent passport:
client := computeid.NewClient(computeid.WithAPIKey(apiKey))
sp, err := client.RegisterAgent(ctx, computeid.AgentRegistration{
Name: "ResearchAgent",
Organization: "Acme Corp",
Capabilities: []string{"read", "web_browse", "api_call"},
})
Docs: https://compute-id.com GitHub: https://github.com/ComputeID/computeid-sdk
Index ¶
- Constants
- Variables
- func AuthenticateDevice(ctx context.Context, deviceCode string) (string, error)
- func RequirePassport[A any, R any](capability Action, fn func(p *AgentPassport, arg A) (R, error)) func(p *AgentPassport, arg A) (R, error)
- type APIError
- type Action
- type ActionOutcome
- type AgentAuditEntry
- type AgentCapabilities
- type AgentPassport
- func (p *AgentPassport) AuditLog() []AuditEntry
- func (p *AgentPassport) Export() ([]byte, error)
- func (p *AgentPassport) IsTrusted() bool
- func (p *AgentPassport) LogAction(action string, details map[string]any, outcome ActionOutcome) AuditEntry
- func (p *AgentPassport) Revoke(reason string)
- func (p *AgentPassport) String() string
- func (p *AgentPassport) Summary() Summary
- func (p *AgentPassport) VerifyAction(action Action) bool
- type AgentRegistration
- type AgentStatus
- type AuditEntry
- type AuditReport
- type CapabilityCheck
- type Client
- func (c *Client) AuthenticateDevice(ctx context.Context, deviceCode string) (string, error)
- func (c *Client) CheckCapability(ctx context.Context, passportID, capability string) (*CapabilityCheck, error)
- func (c *Client) ListAgentActions(ctx context.Context, passportID string, limit int) ([]ServerActionLog, error)
- func (c *Client) ListAgents(ctx context.Context, status string) ([]ServerAgentPassport, error)
- func (c *Client) LogAgentAction(ctx context.Context, passportID string, req LogActionRequest) error
- func (c *Client) RegisterAgent(ctx context.Context, reg AgentRegistration) (*ServerAgentPassport, error)
- func (c *Client) RegisterDevice(ctx context.Context, req RegisterDeviceRequest) (*DevicePassport, error)
- func (c *Client) RevokeAgent(ctx context.Context, passportID, reason string) error
- func (c *Client) VerifyAgent(ctx context.Context, passportID string) (*VerificationResult, error)
- type DevicePassport
- type DeviceStatus
- type IssueOptions
- type LogActionRequest
- type Option
- type PassportOffice
- func (o *PassportOffice) ActiveAgents() []*AgentPassport
- func (o *PassportOffice) ActiveDevices() []*DevicePassport
- func (o *PassportOffice) AuditReport() AuditReport
- func (o *PassportOffice) IsTrusted(agentID string) bool
- func (o *PassportOffice) RegisterAgent(p *AgentPassport)
- func (o *PassportOffice) RegisterDevice(p *DevicePassport)
- func (o *PassportOffice) RevokeAgent(agentID, reason string) bool
- func (o *PassportOffice) String() string
- type RegisterDeviceRequest
- type ServerActionLog
- type ServerAgentPassport
- type Summary
- type TrustLevel
- type TrustRegistry
- type VerificationResult
Constants ¶
const ( DefaultAPI = "https://api.aicomputeid.com" SDKVersion = "1.0.0" )
Default API endpoints. Both can be overridden per-Client via options.
Variables ¶
var ( ErrComputeID = errors.New("computeid") ErrAuthentication = errors.Join(ErrComputeID, errors.New("authentication")) ErrRegistration = errors.Join(ErrComputeID, errors.New("registration")) ErrRevocation = errors.Join(ErrComputeID, errors.New("revocation")) ErrTrust = errors.Join(ErrComputeID, errors.New("trust")) ErrCapability = errors.Join(ErrComputeID, errors.New("capability")) ErrAPI = errors.Join(ErrComputeID, errors.New("api")) )
Functions ¶
func AuthenticateDevice ¶
AuthenticateDevice exchanges a device_code for a short-lived access token against the default API.
func RequirePassport ¶
func RequirePassport[A any, R any](capability Action, fn func(p *AgentPassport, arg A) (R, error)) func(p *AgentPassport, arg A) (R, error)
RequirePassport wraps a function with passport + capability checks. The wrapper returns an error matching ErrAuthentication / ErrTrust if the passport is nil, not trusted, or lacks the required capability. On success it logs the call as an action on the passport and invokes fn.
Example:
search := computeid.RequirePassport(computeid.ActionBrowseWeb,
func(passport *computeid.AgentPassport, query string) (string, error) {
return doSearch(query), nil
})
res, err := search(passport, "GPU rental prices")
Types ¶
type Action ¶
type Action string
Action is the canonical name of an action that AgentPassport.VerifyAction gates on. Pass any of these to VerifyAction or check raw via the Can* fields directly.
type ActionOutcome ¶
type ActionOutcome string
ActionOutcome is the result label written into the audit trail.
const ( OutcomeSuccess ActionOutcome = "success" OutcomeBlocked ActionOutcome = "blocked" OutcomeFailure ActionOutcome = "failure" )
type AgentAuditEntry ¶
type AgentAuditEntry struct {
Summary
AuditLog []AuditEntry `json:"audit_log"`
}
AgentAuditEntry is a per-agent record in the audit report.
type AgentCapabilities ¶
type AgentCapabilities struct {
CanBrowseWeb bool `json:"can_browse_web"`
CanExecuteCode bool `json:"can_execute_code"`
CanAccessFiles bool `json:"can_access_files"`
CanCallAPIs bool `json:"can_call_apis"`
CanSpawnAgents bool `json:"can_spawn_agents"`
CanAccessDatabase bool `json:"can_access_database"`
CanSendEmail bool `json:"can_send_email"`
MaxActionsPerHour int `json:"max_actions_per_hour"`
TrustLevel TrustLevel `json:"trust_level"`
HumanInLoop bool `json:"human_in_loop"`
AllowedDomains []string `json:"allowed_domains,omitempty"`
AllowedTools []string `json:"allowed_tools,omitempty"`
MaxTokenBudget *int `json:"max_token_budget,omitempty"`
CustomPermissions map[string]any `json:"custom_permissions,omitempty"`
}
AgentCapabilities declares what an AI agent is permitted to do. Embed one in every AgentPassport. The zero value is safe but grants nothing useful; prefer one of the preset constructors.
func AutonomousCapabilities ¶
func AutonomousCapabilities() AgentCapabilities
AutonomousCapabilities — full autonomy; use with care.
func CapabilitiesFor ¶
func CapabilitiesFor(level TrustLevel) AgentCapabilities
CapabilitiesFor returns the preset matching a trust level, defaulting to StandardCapabilities for any unknown level.
func ElevatedCapabilities ¶
func ElevatedCapabilities() AgentCapabilities
ElevatedCapabilities — code execution, can spawn child agents.
func RestrictedCapabilities ¶
func RestrictedCapabilities() AgentCapabilities
RestrictedCapabilities — minimal permissions, human oversight required.
func StandardCapabilities ¶
func StandardCapabilities() AgentCapabilities
StandardCapabilities — web browsing, API calls, file read.
func (AgentCapabilities) Allows ¶
func (c AgentCapabilities) Allows(a Action) bool
Allows reports whether the capability set grants a given action.
type AgentPassport ¶
type AgentPassport struct {
AgentID string `json:"agent_id"`
AgentName string `json:"agent_name"`
AgentType string `json:"agent_type"`
OwnerOrg string `json:"owner_org"`
OwnerEmail string `json:"owner_email"`
Model string `json:"model"`
Version string `json:"version"`
Status AgentStatus `json:"status"`
TrustLevel TrustLevel `json:"trust_level"`
ParentAgentID string `json:"parent_agent_id,omitempty"`
IssuedAt time.Time `json:"issued_at"`
ExpiresAt time.Time `json:"expires_at"`
RevokedAt *time.Time `json:"revoked_at,omitempty"`
RevokeReason string `json:"revoke_reason,omitempty"`
Capabilities AgentCapabilities `json:"capabilities"`
Fingerprint string `json:"fingerprint"`
// contains filtered or unexported fields
}
AgentPassport is a local cryptographic passport for an AI agent. It carries who built it, what it may do, what it has done, and whether it is currently trusted. AgentPassports are mutated only through the methods on this type — the audit log in particular is append-only.
func IssueAgentPassport ¶
func IssueAgentPassport(opts IssueOptions) (*AgentPassport, error)
IssueAgentPassport mints a new AgentPassport. When a ParentPassport is provided it must be trusted and have CanSpawnAgents=true, mirroring the Python SDK's parent-child trust chain.
func IssueAgentPassportQuick ¶
func IssueAgentPassportQuick(agentName, ownerOrg, ownerEmail, model string, level TrustLevel) (*AgentPassport, error)
IssueAgentPassportQuick mints a passport in one call using a trust-level preset, mirroring the Python issue_agent_passport quickstart.
func LoadAgentPassport ¶
func LoadAgentPassport(data []byte) (*AgentPassport, error)
LoadAgentPassport rebuilds a passport previously serialised by Export.
func (*AgentPassport) AuditLog ¶
func (p *AgentPassport) AuditLog() []AuditEntry
AuditLog returns a defensive copy of the full immutable audit trail.
func (*AgentPassport) Export ¶
func (p *AgentPassport) Export() ([]byte, error)
Export serialises the passport to JSON. Round-trips through Load.
func (*AgentPassport) IsTrusted ¶
func (p *AgentPassport) IsTrusted() bool
IsTrusted reports whether the passport is active and not expired. Expiry flips the status to expired the first time it is observed.
func (*AgentPassport) LogAction ¶
func (p *AgentPassport) LogAction(action string, details map[string]any, outcome ActionOutcome) AuditEntry
LogAction appends an entry to the immutable audit trail. Returns the entry written so callers can record its log_id.
func (*AgentPassport) Revoke ¶
func (p *AgentPassport) Revoke(reason string)
Revoke immediately moves the passport to revoked status. Subsequent IsTrusted/VerifyAction calls will fail.
func (*AgentPassport) String ¶
func (p *AgentPassport) String() string
String returns a short debug representation, mirroring Python __repr__.
func (*AgentPassport) Summary ¶
func (p *AgentPassport) Summary() Summary
Summary returns a compact snapshot of the passport.
func (*AgentPassport) VerifyAction ¶
func (p *AgentPassport) VerifyAction(action Action) bool
VerifyAction returns true iff the passport is trusted and the capability for the action is granted. A negative result writes a blocked entry to the audit log with a reason, matching the Python SDK behaviour.
type AgentRegistration ¶
type AgentRegistration struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Organization string `json:"organization"`
Capabilities []string `json:"capabilities"`
}
AgentRegistration is the request body for RegisterAgent.
type AgentStatus ¶
type AgentStatus string
AgentStatus is the lifecycle state of an AgentPassport.
const ( StatusActive AgentStatus = "active" StatusRevoked AgentStatus = "revoked" StatusExpired AgentStatus = "expired" )
type AuditEntry ¶
type AuditEntry struct {
LogID string `json:"log_id"`
AgentID string `json:"agent_id"`
Action string `json:"action"`
Details map[string]any `json:"details,omitempty"`
Outcome ActionOutcome `json:"outcome"`
Timestamp time.Time `json:"timestamp"`
}
AuditEntry is one immutable record in an AgentPassport audit log.
type AuditReport ¶
type AuditReport struct {
OrgName string `json:"org_name"`
GeneratedAt time.Time `json:"generated_at"`
TotalAgents int `json:"total_agents"`
ActiveAgents int `json:"active_agents"`
TotalDevices int `json:"total_devices"`
ActiveDevices int `json:"active_devices"`
Agents []AgentAuditEntry `json:"agents"`
}
AuditReport summarises everything the office knows.
type CapabilityCheck ¶
type CapabilityCheck struct {
Granted bool `json:"granted"`
Capability string `json:"capability,omitempty"`
Scope map[string]any `json:"scope,omitempty"`
BoundAt *time.Time `json:"bound_at,omitempty"`
Reason string `json:"reason,omitempty"`
}
CapabilityCheck is the response from /v1/agents/{id}/capabilities/{cap}.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the HTTP client for the ComputeID REST API. It covers both /v1/agents/* (server-backed agent passports) and /api/devices/* (device passports). Construct one with NewClient.
func NewClient ¶
NewClient returns a Client wired to the default API. Pass options to override the base URL, API key, HTTP client, or User-Agent.
func (*Client) AuthenticateDevice ¶
AuthenticateDevice exchanges a device_code for a JWT access token.
func (*Client) CheckCapability ¶
func (c *Client) CheckCapability(ctx context.Context, passportID, capability string) (*CapabilityCheck, error)
CheckCapability tests a single capability grant on a passport.
func (*Client) ListAgentActions ¶
func (c *Client) ListAgentActions(ctx context.Context, passportID string, limit int) ([]ServerActionLog, error)
ListAgentActions reads the audit trail for a passport. limit <= 0 omits the parameter (server default applies).
func (*Client) ListAgents ¶
ListAgents enumerates passports. Pass an empty status to list all.
func (*Client) LogAgentAction ¶
LogAgentAction appends to the server-side audit log.
func (*Client) RegisterAgent ¶
func (c *Client) RegisterAgent(ctx context.Context, reg AgentRegistration) (*ServerAgentPassport, error)
RegisterAgent issues a server-backed agent passport.
func (*Client) RegisterDevice ¶
func (c *Client) RegisterDevice(ctx context.Context, req RegisterDeviceRequest) (*DevicePassport, error)
RegisterDevice registers a new device.
func (*Client) RevokeAgent ¶
RevokeAgent immediately revokes a server-backed passport.
func (*Client) VerifyAgent ¶
VerifyAgent returns status + signature validity for a passport.
type DevicePassport ¶
type DevicePassport struct {
DeviceID string `json:"device_id"`
DeviceCode string `json:"device_code"`
Name string `json:"name"`
DeviceType string `json:"type"`
IPAddress string `json:"ip_address"`
Status DeviceStatus `json:"status"`
IssuedAt time.Time `json:"issued_at"`
}
DevicePassport is a cryptographic passport for a GPU, server, or other compute device. Unlike AgentPassport it is server-backed: registration and authentication round-trip through the ComputeID API.
func RegisterDevice ¶
func RegisterDevice(ctx context.Context, req RegisterDeviceRequest, apiKey string) (*DevicePassport, error)
RegisterDevice registers a new device with the default API and returns the issued passport. For a customised client use Client.RegisterDevice.
func RegisterGPU ¶
func RegisterGPU(ctx context.Context, name, ipAddress, apiKey string) (*DevicePassport, error)
RegisterGPU is a one-liner over RegisterDevice with DeviceType="GPU".
func (*DevicePassport) IsPending ¶
func (d *DevicePassport) IsPending() bool
IsPending reports whether the passport is awaiting admin approval.
func (*DevicePassport) IsValid ¶
func (d *DevicePassport) IsValid() bool
IsValid reports whether the passport is active.
func (*DevicePassport) String ¶
func (d *DevicePassport) String() string
type DeviceStatus ¶
type DeviceStatus string
DeviceStatus is the lifecycle state of a DevicePassport.
const ( DeviceStatusPending DeviceStatus = "pending" DeviceStatusActive DeviceStatus = "active" DeviceStatusRevoked DeviceStatus = "revoked" )
type IssueOptions ¶
type IssueOptions struct {
AgentName string
AgentType string
OwnerOrg string
OwnerEmail string
Capabilities AgentCapabilities
Model string
Version string
ExpiresIn time.Duration // defaults to 24h
ParentPassport *AgentPassport
}
IssueOptions configures IssueAgentPassport. Required fields are AgentName, AgentType, OwnerOrg, OwnerEmail, and Capabilities.
type LogActionRequest ¶
type LogActionRequest struct {
Action string `json:"action"`
Details map[string]any `json:"details,omitempty"`
Outcome string `json:"outcome"`
}
LogActionRequest is the payload for LogAgentAction.
type Option ¶
type Option func(*Client)
Option customises NewClient.
func WithAPIKey ¶
WithAPIKey sets the X-API-Key header sent on every request.
func WithBaseURL ¶
WithBaseURL overrides the API base URL (e.g. for staging or tests).
func WithHTTPClient ¶
WithHTTPClient injects a custom *http.Client (useful for instrumentation, retries, or a shared transport).
func WithUserAgent ¶
WithUserAgent sets the User-Agent header sent on every request.
type PassportOffice ¶
type PassportOffice struct {
OrgName string
APIKey string
CreatedAt time.Time
// contains filtered or unexported fields
}
PassportOffice is an org-wide registry of agent and device passports. It is safe for concurrent use.
func NewPassportOffice ¶
func NewPassportOffice(orgName, apiKey string) *PassportOffice
NewPassportOffice constructs an empty office.
func (*PassportOffice) ActiveAgents ¶
func (o *PassportOffice) ActiveAgents() []*AgentPassport
ActiveAgents returns all currently trusted agents.
func (*PassportOffice) ActiveDevices ¶
func (o *PassportOffice) ActiveDevices() []*DevicePassport
ActiveDevices returns all currently active devices.
func (*PassportOffice) AuditReport ¶
func (o *PassportOffice) AuditReport() AuditReport
AuditReport builds a compliance snapshot across all registered passports.
func (*PassportOffice) IsTrusted ¶
func (o *PassportOffice) IsTrusted(agentID string) bool
IsTrusted reports whether a registered agent is currently trusted.
func (*PassportOffice) RegisterAgent ¶
func (o *PassportOffice) RegisterAgent(p *AgentPassport)
RegisterAgent adds an agent passport to the office.
func (*PassportOffice) RegisterDevice ¶
func (o *PassportOffice) RegisterDevice(p *DevicePassport)
RegisterDevice adds a device passport to the office.
func (*PassportOffice) RevokeAgent ¶
func (o *PassportOffice) RevokeAgent(agentID, reason string) bool
RevokeAgent revokes a registered agent and returns true if found.
func (*PassportOffice) String ¶
func (o *PassportOffice) String() string
type RegisterDeviceRequest ¶
type RegisterDeviceRequest struct {
Name string `json:"name"`
DeviceType string `json:"type"`
IPAddress string `json:"ip_address"`
}
RegisterDeviceRequest is the payload sent to /api/devices/register.
type ServerActionLog ¶
type ServerActionLog struct {
ActionID string `json:"action_id"`
Action string `json:"action"`
Details map[string]any `json:"details,omitempty"`
Outcome string `json:"outcome"`
Timestamp time.Time `json:"timestamp"`
}
ServerActionLog mirrors a row from /v1/agents/{id}/actions.
type ServerAgentPassport ¶
type ServerAgentPassport struct {
PassportID string `json:"passport_id"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
Organization string `json:"organization"`
Status string `json:"status"`
PublicKey string `json:"public_key,omitempty"`
Signature string `json:"signature,omitempty"`
SignatureAlgorithm string `json:"signature_algorithm,omitempty"`
Capabilities []string `json:"capabilities"`
IssuedAt time.Time `json:"issued_at"`
}
ServerAgentPassport is the response payload for /v1/agents/register and list endpoints. It is distinct from the local-model AgentPassport.
type Summary ¶
type Summary struct {
AgentID string `json:"agent_id"`
AgentName string `json:"agent_name"`
OwnerOrg string `json:"owner_org"`
Model string `json:"model"`
Status AgentStatus `json:"status"`
TrustLevel TrustLevel `json:"trust_level"`
IssuedAt time.Time `json:"issued_at"`
ExpiresAt time.Time `json:"expires_at"`
ActionsLogged int `json:"actions_logged"`
Fingerprint string `json:"fingerprint"`
}
Summary is a compact view suitable for dashboards and JSON exports.
type TrustLevel ¶
type TrustLevel string
TrustLevel describes the broad authority an agent operates under.
const ( TrustRestricted TrustLevel = "restricted" TrustStandard TrustLevel = "standard" TrustElevated TrustLevel = "elevated" TrustAutonomous TrustLevel = "autonomous" )
type TrustRegistry ¶
type TrustRegistry = PassportOffice
TrustRegistry is a backwards-compatible alias matching the Python SDK.
func NewTrustRegistry ¶
func NewTrustRegistry(orgName, apiKey string) *TrustRegistry
NewTrustRegistry mirrors the Python TrustRegistry constructor.
type VerificationResult ¶
type VerificationResult struct {
PassportID string `json:"passport_id"`
Status string `json:"status"`
SignatureValid bool `json:"signature_valid"`
Capabilities []string `json:"capabilities"`
IssuedAt time.Time `json:"issued_at,omitempty"`
RevokedAt *time.Time `json:"revoked_at,omitempty"`
}
VerificationResult is the response from /v1/agents/{id}/verify.
func (VerificationResult) IsTrusted ¶
func (v VerificationResult) IsTrusted() bool
IsTrusted is the authoritative authorisation check: active and signature valid, matching INTEGRATION.md guidance.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
computeid-server
command
Command computeid-server runs the Postgres-backed ComputeID API.
|
Command computeid-server runs the Postgres-backed ComputeID API. |
|
examples
|
|
|
basic
command
Local-only AgentPassport example — mirrors the Python "Full Example" in the SDK README.
|
Local-only AgentPassport example — mirrors the Python "Full Example" in the SDK README. |
|
devices
command
Device registration example.
|
Device registration example. |
|
serverbacked
command
Server-backed agent passport example — talks to the ComputeID API.
|
Server-backed agent passport example — talks to the ComputeID API. |
|
Package server is a Postgres-backed ComputeID API implementation.
|
Package server is a Postgres-backed ComputeID API implementation. |