527 lines
16 KiB
Go
527 lines
16 KiB
Go
package elydora
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Enums
|
|
// ---------------------------------------------------------------------------
|
|
|
|
type AgentStatus string
|
|
|
|
const (
|
|
AgentStatusActive AgentStatus = "active"
|
|
AgentStatusFrozen AgentStatus = "frozen"
|
|
AgentStatusRevoked AgentStatus = "revoked"
|
|
)
|
|
|
|
type KeyStatus string
|
|
|
|
const (
|
|
KeyStatusActive KeyStatus = "active"
|
|
KeyStatusRetired KeyStatus = "retired"
|
|
KeyStatusRevoked KeyStatus = "revoked"
|
|
)
|
|
|
|
type IntegrationType string
|
|
|
|
const (
|
|
IntegrationTypeAugment IntegrationType = "augment"
|
|
IntegrationTypeClaudecode IntegrationType = "claudecode"
|
|
IntegrationTypeCline IntegrationType = "cline"
|
|
IntegrationTypeCodex IntegrationType = "codex"
|
|
IntegrationTypeCopilot IntegrationType = "copilot"
|
|
IntegrationTypeCursor IntegrationType = "cursor"
|
|
IntegrationTypeDroid IntegrationType = "droid"
|
|
IntegrationTypeGemini IntegrationType = "gemini"
|
|
IntegrationTypeGrok IntegrationType = "grok"
|
|
IntegrationTypeKimi IntegrationType = "kimi"
|
|
IntegrationTypeKiroCLI IntegrationType = "kirocli"
|
|
IntegrationTypeKiroIDE IntegrationType = "kiroide"
|
|
IntegrationTypeLetta IntegrationType = "letta"
|
|
IntegrationTypeOpenCode IntegrationType = "opencode"
|
|
IntegrationTypeQwen IntegrationType = "qwen"
|
|
IntegrationTypeEnterprise IntegrationType = "enterprise"
|
|
IntegrationTypeGUI IntegrationType = "gui"
|
|
IntegrationTypeSDK IntegrationType = "sdk"
|
|
IntegrationTypeOther IntegrationType = "other"
|
|
)
|
|
|
|
type ExportStatus string
|
|
|
|
const (
|
|
ExportStatusQueued ExportStatus = "queued"
|
|
ExportStatusRunning ExportStatus = "running"
|
|
ExportStatusDone ExportStatus = "done"
|
|
ExportStatusFailed ExportStatus = "failed"
|
|
)
|
|
|
|
type RbacRole string
|
|
|
|
const (
|
|
RbacRoleOrgOwner RbacRole = "org_owner"
|
|
RbacRoleSecurityAdmin RbacRole = "security_admin"
|
|
RbacRoleComplianceAuditor RbacRole = "compliance_auditor"
|
|
RbacRoleReadonlyInvestigator RbacRole = "readonly_investigator"
|
|
RbacRoleIntegrationEngineer RbacRole = "integration_engineer"
|
|
)
|
|
|
|
type ErrorCode string
|
|
|
|
const (
|
|
ErrorCodeInvalidSignature ErrorCode = "INVALID_SIGNATURE"
|
|
ErrorCodeUnknownAgent ErrorCode = "UNKNOWN_AGENT"
|
|
ErrorCodeKeyRevoked ErrorCode = "KEY_REVOKED"
|
|
ErrorCodeAgentFrozen ErrorCode = "AGENT_FROZEN"
|
|
ErrorCodeTTLExpired ErrorCode = "TTL_EXPIRED"
|
|
ErrorCodeReplayDetected ErrorCode = "REPLAY_DETECTED"
|
|
ErrorCodePrevHashMismatch ErrorCode = "PREV_HASH_MISMATCH"
|
|
ErrorCodePayloadTooLarge ErrorCode = "PAYLOAD_TOO_LARGE"
|
|
ErrorCodeRateLimited ErrorCode = "RATE_LIMITED"
|
|
ErrorCodeInternalError ErrorCode = "INTERNAL_ERROR"
|
|
ErrorCodeUnauthorized ErrorCode = "UNAUTHORIZED"
|
|
ErrorCodeForbidden ErrorCode = "FORBIDDEN"
|
|
ErrorCodeNotFound ErrorCode = "NOT_FOUND"
|
|
ErrorCodeValidationError ErrorCode = "VALIDATION_ERROR"
|
|
)
|
|
|
|
type ExportFormat string
|
|
|
|
const (
|
|
ExportFormatJSON ExportFormat = "json"
|
|
ExportFormatPDF ExportFormat = "pdf"
|
|
)
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Entity types
|
|
// ---------------------------------------------------------------------------
|
|
|
|
type Agent struct {
|
|
AgentID string `json:"agent_id"`
|
|
OrgID string `json:"org_id"`
|
|
DisplayName string `json:"display_name"`
|
|
ResponsibleEntity string `json:"responsible_entity"`
|
|
IntegrationType IntegrationType `json:"integration_type"`
|
|
Status AgentStatus `json:"status"`
|
|
CreatedAt int64 `json:"created_at"`
|
|
UpdatedAt int64 `json:"updated_at"`
|
|
}
|
|
|
|
type AgentKey struct {
|
|
KID string `json:"kid"`
|
|
AgentID string `json:"agent_id"`
|
|
PublicKey string `json:"public_key"`
|
|
Algorithm string `json:"algorithm"`
|
|
Status KeyStatus `json:"status"`
|
|
CreatedAt int64 `json:"created_at"`
|
|
RetiredAt *int64 `json:"retired_at"`
|
|
}
|
|
|
|
type Operation struct {
|
|
OperationID string `json:"operation_id"`
|
|
OrgID string `json:"org_id"`
|
|
AgentID string `json:"agent_id"`
|
|
SeqNo int64 `json:"seq_no"`
|
|
OperationType string `json:"operation_type"`
|
|
IssuedAt int64 `json:"issued_at"`
|
|
TTLMs int64 `json:"ttl_ms"`
|
|
Nonce string `json:"nonce"`
|
|
Subject string `json:"subject"`
|
|
Action string `json:"action"`
|
|
PayloadHash string `json:"payload_hash"`
|
|
PrevChainHash string `json:"prev_chain_hash"`
|
|
ChainHash string `json:"chain_hash"`
|
|
AgentPubkeyKID string `json:"agent_pubkey_kid"`
|
|
Signature string `json:"signature"`
|
|
R2PayloadKey *string `json:"r2_payload_key"`
|
|
CreatedAt int64 `json:"created_at"`
|
|
}
|
|
|
|
type Receipt struct {
|
|
ReceiptID string `json:"receipt_id"`
|
|
OperationID string `json:"operation_id"`
|
|
R2ReceiptKey string `json:"r2_receipt_key"`
|
|
CreatedAt int64 `json:"created_at"`
|
|
}
|
|
|
|
type Epoch struct {
|
|
EpochID string `json:"epoch_id"`
|
|
OrgID string `json:"org_id"`
|
|
StartTime int64 `json:"start_time"`
|
|
EndTime int64 `json:"end_time"`
|
|
RootHash string `json:"root_hash"`
|
|
LeafCount int64 `json:"leaf_count"`
|
|
R2EpochKey string `json:"r2_epoch_key"`
|
|
CreatedAt int64 `json:"created_at"`
|
|
}
|
|
|
|
type Organization struct {
|
|
OrgID string `json:"org_id"`
|
|
Name string `json:"name"`
|
|
Description string `json:"description"`
|
|
BAOrgID *string `json:"ba_org_id"`
|
|
CreatedAt int64 `json:"created_at"`
|
|
UpdatedAt int64 `json:"updated_at"`
|
|
}
|
|
|
|
type User struct {
|
|
UserID string `json:"user_id"`
|
|
OrgID string `json:"org_id"`
|
|
Email string `json:"email"`
|
|
DisplayName string `json:"display_name"`
|
|
Role RbacRole `json:"role"`
|
|
Status string `json:"status"`
|
|
CreatedAt int64 `json:"created_at"`
|
|
UpdatedAt int64 `json:"updated_at"`
|
|
}
|
|
|
|
type Export struct {
|
|
ExportID string `json:"export_id"`
|
|
OrgID string `json:"org_id"`
|
|
Status ExportStatus `json:"status"`
|
|
QueryParams string `json:"query_params"`
|
|
R2ExportKey *string `json:"r2_export_key"`
|
|
CreatedAt int64 `json:"created_at"`
|
|
CompletedAt *int64 `json:"completed_at"`
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Protocol types
|
|
// ---------------------------------------------------------------------------
|
|
|
|
// EOR is the Elydora Operation Record — the fundamental unit of auditable activity.
|
|
type EOR struct {
|
|
OpVersion string `json:"op_version"`
|
|
OperationID string `json:"operation_id"`
|
|
OrgID string `json:"org_id"`
|
|
AgentID string `json:"agent_id"`
|
|
IssuedAt int64 `json:"issued_at"`
|
|
TTLMs int64 `json:"ttl_ms"`
|
|
Nonce string `json:"nonce"`
|
|
OperationType string `json:"operation_type"`
|
|
Subject interface{} `json:"subject"`
|
|
Action interface{} `json:"action"`
|
|
Payload interface{} `json:"payload"`
|
|
PayloadHash string `json:"payload_hash"`
|
|
PrevChainHash string `json:"prev_chain_hash"`
|
|
AgentPubkeyKID string `json:"agent_pubkey_kid"`
|
|
Signature string `json:"signature"`
|
|
}
|
|
|
|
// EAR is the Elydora Acknowledgment Receipt — server-issued receipt confirming acceptance.
|
|
type EAR struct {
|
|
ReceiptVersion string `json:"receipt_version"`
|
|
ReceiptID string `json:"receipt_id"`
|
|
OperationID string `json:"operation_id"`
|
|
OrgID string `json:"org_id"`
|
|
AgentID string `json:"agent_id"`
|
|
ServerReceivedAt int64 `json:"server_received_at"`
|
|
SeqNo int64 `json:"seq_no"`
|
|
ChainHash string `json:"chain_hash"`
|
|
QueueMessageID string `json:"queue_message_id"`
|
|
ReceiptHash string `json:"receipt_hash"`
|
|
ElydoraKID string `json:"elydora_kid"`
|
|
ElydoraSignature string `json:"elydora_signature"`
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// API request/response types
|
|
// ---------------------------------------------------------------------------
|
|
|
|
type RegisterAgentKeyInput struct {
|
|
KID string `json:"kid"`
|
|
PublicKey string `json:"public_key"`
|
|
Algorithm string `json:"algorithm"`
|
|
}
|
|
|
|
type RegisterAgentRequest struct {
|
|
AgentID string `json:"agent_id"`
|
|
DisplayName string `json:"display_name,omitempty"`
|
|
ResponsibleEntity string `json:"responsible_entity,omitempty"`
|
|
IntegrationType IntegrationType `json:"integration_type"`
|
|
Keys []RegisterAgentKeyInput `json:"keys"`
|
|
}
|
|
|
|
type RegisterAgentResponse struct {
|
|
Agent Agent `json:"agent"`
|
|
Keys []AgentKey `json:"keys"`
|
|
}
|
|
|
|
type GetAgentResponse struct {
|
|
Agent Agent `json:"agent"`
|
|
Keys []AgentKey `json:"keys"`
|
|
}
|
|
|
|
type FreezeAgentRequest struct {
|
|
Reason string `json:"reason"`
|
|
}
|
|
|
|
type FreezeAgentResponse struct {
|
|
Agent Agent `json:"agent"`
|
|
PreviousStatus AgentStatus `json:"previous_status"`
|
|
}
|
|
|
|
type RevokeAgentRequest struct {
|
|
KID string `json:"kid"`
|
|
Reason string `json:"reason"`
|
|
}
|
|
|
|
type UnfreezeAgentRequest struct {
|
|
Reason string `json:"reason"`
|
|
}
|
|
|
|
type UnfreezeAgentResponse struct {
|
|
Agent Agent `json:"agent"`
|
|
PreviousStatus AgentStatus `json:"previous_status"`
|
|
}
|
|
|
|
type UpdateAgentRequest struct {
|
|
IntegrationType IntegrationType `json:"integration_type"`
|
|
}
|
|
|
|
type UpdateAgentResponse struct {
|
|
Agent Agent `json:"agent"`
|
|
}
|
|
|
|
type ListAgentsResponse struct {
|
|
Agents []Agent `json:"agents"`
|
|
}
|
|
|
|
type DeleteAgentResponse struct {
|
|
Deleted bool `json:"deleted"`
|
|
}
|
|
|
|
type GetMeResponse struct {
|
|
User User `json:"user"`
|
|
}
|
|
|
|
type IssueApiTokenRequest struct {
|
|
TTLSeconds *int `json:"ttl_seconds"`
|
|
}
|
|
|
|
type IssueApiTokenResponse struct {
|
|
Token string `json:"token"`
|
|
ExpiresAt *int64 `json:"expires_at"`
|
|
TokenID string `json:"token_id"`
|
|
}
|
|
|
|
type RotateApiTokenResponse struct {
|
|
Token string `json:"token"`
|
|
ExpiresAt *int64 `json:"expires_at"`
|
|
TokenID string `json:"token_id"`
|
|
}
|
|
|
|
type HealthResponse struct {
|
|
Status string `json:"status"`
|
|
Version string `json:"version"`
|
|
ProtocolVersion string `json:"protocol_version"`
|
|
Timestamp int64 `json:"timestamp"`
|
|
}
|
|
|
|
type SubmitOperationResponse struct {
|
|
Receipt EAR `json:"receipt"`
|
|
}
|
|
|
|
type GetOperationResponse struct {
|
|
Operation Operation `json:"operation"`
|
|
Receipt *Receipt `json:"receipt,omitempty"`
|
|
}
|
|
|
|
type VerifyOperationChecks struct {
|
|
Signature bool `json:"signature"`
|
|
Chain bool `json:"chain"`
|
|
Receipt bool `json:"receipt"`
|
|
Merkle *bool `json:"merkle,omitempty"`
|
|
}
|
|
|
|
type VerifyOperationResponse struct {
|
|
Valid bool `json:"valid"`
|
|
Checks VerifyOperationChecks `json:"checks"`
|
|
Errors []string `json:"errors,omitempty"`
|
|
}
|
|
|
|
type AuditQueryRequest struct {
|
|
OrgID string `json:"org_id,omitempty"`
|
|
AgentID string `json:"agent_id,omitempty"`
|
|
OperationType string `json:"operation_type,omitempty"`
|
|
StartTime *int64 `json:"start_time,omitempty"`
|
|
EndTime *int64 `json:"end_time,omitempty"`
|
|
Cursor string `json:"cursor,omitempty"`
|
|
Limit *int `json:"limit,omitempty"`
|
|
}
|
|
|
|
type AuditQueryResponse struct {
|
|
Operations []Operation `json:"operations"`
|
|
Cursor string `json:"cursor,omitempty"`
|
|
TotalCount int64 `json:"total_count"`
|
|
}
|
|
|
|
type GetEpochResponse struct {
|
|
Epoch Epoch `json:"epoch"`
|
|
Anchor *EpochAnchor `json:"anchor,omitempty"`
|
|
}
|
|
|
|
type EpochAnchor struct {
|
|
TSAToken string `json:"tsa_token,omitempty"`
|
|
TSAUrl string `json:"tsa_url,omitempty"`
|
|
AnchoredAt *int64 `json:"anchored_at,omitempty"`
|
|
}
|
|
|
|
type ListEpochsResponse struct {
|
|
Epochs []Epoch `json:"epochs"`
|
|
}
|
|
|
|
type CreateExportRequest struct {
|
|
StartTime int64 `json:"start_time"`
|
|
EndTime int64 `json:"end_time"`
|
|
AgentID string `json:"agent_id,omitempty"`
|
|
OperationType string `json:"operation_type,omitempty"`
|
|
Format ExportFormat `json:"format"`
|
|
}
|
|
|
|
type CreateExportResponse struct {
|
|
Export Export `json:"export"`
|
|
}
|
|
|
|
type GetExportResponse struct {
|
|
Export Export `json:"export"`
|
|
DownloadURL string `json:"download_url,omitempty"`
|
|
}
|
|
|
|
type ListExportsResponse struct {
|
|
Exports []Export `json:"exports"`
|
|
}
|
|
|
|
type JWK struct {
|
|
KTY string `json:"kty"`
|
|
CRV string `json:"crv,omitempty"`
|
|
X string `json:"x,omitempty"`
|
|
KID string `json:"kid"`
|
|
Use string `json:"use"`
|
|
Alg string `json:"alg"`
|
|
}
|
|
|
|
type JWKSResponse struct {
|
|
Keys []JWK `json:"keys"`
|
|
}
|
|
|
|
type AuthRegisterRequest struct {
|
|
Email string `json:"email"`
|
|
Password string `json:"password"`
|
|
DisplayName string `json:"display_name,omitempty"`
|
|
OrgName string `json:"org_name,omitempty"`
|
|
}
|
|
|
|
type AuthRegisterResponse struct {
|
|
User User `json:"user"`
|
|
Organization Organization `json:"organization"`
|
|
Token string `json:"token"`
|
|
}
|
|
|
|
type AuthLoginRequest struct {
|
|
Email string `json:"email"`
|
|
Password string `json:"password"`
|
|
}
|
|
|
|
type AuthLoginResponse struct {
|
|
User User `json:"user"`
|
|
Token string `json:"token"`
|
|
}
|
|
|
|
// AdminEvent represents an administrative event log entry.
|
|
type AdminEvent struct {
|
|
EventID string `json:"event_id"`
|
|
OrgID string `json:"org_id"`
|
|
Actor string `json:"actor"`
|
|
Action string `json:"action"`
|
|
TargetType string `json:"target_type"`
|
|
TargetID string `json:"target_id"`
|
|
Details *string `json:"details"`
|
|
CreatedAt int64 `json:"created_at"`
|
|
}
|
|
|
|
// AgentAssignment represents a many-to-many agent-to-user assignment.
|
|
type AgentAssignment struct {
|
|
ID string `json:"id"`
|
|
AgentID string `json:"agent_id"`
|
|
UserID string `json:"user_id"`
|
|
OrgID string `json:"org_id"`
|
|
AssignedBy string `json:"assigned_by"`
|
|
CreatedAt int64 `json:"created_at"`
|
|
}
|
|
|
|
// Webhook represents a registered webhook endpoint.
|
|
type Webhook struct {
|
|
WebhookID string `json:"webhook_id"`
|
|
OrgID string `json:"org_id"`
|
|
EndpointURL string `json:"endpoint_url"`
|
|
Events []string `json:"events"`
|
|
Status string `json:"status"`
|
|
CreatedAt int64 `json:"created_at"`
|
|
UpdatedAt int64 `json:"updated_at"`
|
|
}
|
|
|
|
type ListWebhooksResponse struct {
|
|
Webhooks []Webhook `json:"webhooks"`
|
|
}
|
|
|
|
type RegisterWebhookRequest struct {
|
|
EndpointURL string `json:"endpoint_url"`
|
|
Events []string `json:"events"`
|
|
Secret string `json:"secret"`
|
|
}
|
|
|
|
type RegisterWebhookResponse struct {
|
|
Webhook Webhook `json:"webhook"`
|
|
}
|
|
|
|
// Member represents a console user returned from the members list endpoint.
|
|
type Member struct {
|
|
MemberID string `json:"member_id"`
|
|
UserID string `json:"user_id"`
|
|
Role string `json:"role"`
|
|
JoinedAt string `json:"joined_at"`
|
|
Email string `json:"email"`
|
|
DisplayName string `json:"display_name"`
|
|
}
|
|
|
|
type ListMembersResponse struct {
|
|
Members []Member `json:"members"`
|
|
}
|
|
|
|
type ListAdminEventsResponse struct {
|
|
Events []AdminEvent `json:"events"`
|
|
}
|
|
|
|
// DependencyHealth holds the health status of a single backend dependency.
|
|
type DependencyHealth struct {
|
|
Status string `json:"status"`
|
|
LatencyMs int64 `json:"latency_ms"`
|
|
Error *string `json:"error,omitempty"`
|
|
}
|
|
|
|
// DeepHealthDependencies lists the health of all backend dependencies.
|
|
type DeepHealthDependencies struct {
|
|
D1 DependencyHealth `json:"d1"`
|
|
R2 DependencyHealth `json:"r2"`
|
|
KV DependencyHealth `json:"kv"`
|
|
}
|
|
|
|
// DeepHealthResponse is returned by GET /v1/health/deep.
|
|
type DeepHealthResponse struct {
|
|
Status string `json:"status"`
|
|
Version string `json:"version"`
|
|
Timestamp int64 `json:"timestamp"`
|
|
Dependencies DeepHealthDependencies `json:"dependencies"`
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// CreateOperation params (SDK-specific)
|
|
// ---------------------------------------------------------------------------
|
|
|
|
type CreateOperationParams struct {
|
|
OperationType string
|
|
Subject map[string]interface{}
|
|
Action map[string]interface{}
|
|
Payload interface{}
|
|
PrevChainHash string
|
|
KID string
|
|
}
|