Documentation
¶
Index ¶
- Constants
- Variables
- func MakeBadRequest(err error) *goa.ServiceError
- func MakeConflict(err error) *goa.ServiceError
- func MakeForbidden(err error) *goa.ServiceError
- func MakeGatewayError(err error) *goa.ServiceError
- func MakeInvalid(err error) *goa.ServiceError
- func MakeInvariantViolation(err error) *goa.ServiceError
- func MakeNotFound(err error) *goa.ServiceError
- func MakeUnauthorized(err error) *goa.ServiceError
- func MakeUnexpected(err error) *goa.ServiceError
- func MakeUnsupportedMedia(err error) *goa.ServiceError
- func NewClaudeEndpoint(s Service) goa.Endpoint
- func NewCodexEndpoint(s Service, authAPIKeyFn security.AuthAPIKeyFunc) goa.Endpoint
- func NewCursorEndpoint(s Service, authAPIKeyFn security.AuthAPIKeyFunc) goa.Endpoint
- func NewLogsEndpoint(s Service, authAPIKeyFn security.AuthAPIKeyFunc) goa.Endpoint
- func NewMetricsEndpoint(s Service, authAPIKeyFn security.AuthAPIKeyFunc) goa.Endpoint
- type Auther
- type ClaudeHookResult
- type ClaudePayload
- type Client
- func (c *Client) Claude(ctx context.Context, p *ClaudePayload) (res *ClaudeHookResult, err error)
- func (c *Client) Codex(ctx context.Context, p *CodexPayload) (res *CodexHookResult, err error)
- func (c *Client) Cursor(ctx context.Context, p *CursorPayload) (res *CursorHookResult, err error)
- func (c *Client) Logs(ctx context.Context, p *LogsPayload) (err error)
- func (c *Client) Metrics(ctx context.Context, p *MetricsPayload) (err error)
- type CodexHookResult
- type CodexPayload
- type CursorHookResult
- type CursorPayload
- type Endpoints
- type LogsPayload
- type MetricsPayload
- type OTELAttribute
- type OTELAttributeValue
- type OTELLogBody
- type OTELLogRecord
- type OTELMetric
- type OTELNumberDataPoint
- type OTELResource
- type OTELResourceAttribute
- type OTELResourceLog
- type OTELResourceMetrics
- type OTELScope
- type OTELScopeLog
- type OTELScopeMetrics
- type OTELSum
- type Service
Constants ¶
const APIName = "gram"
APIName is the name of the API as defined in the design.
const APIVersion = "0.0.1"
APIVersion is the version of the API as defined in the design.
const ServiceName = "hooks"
ServiceName is the name of the service as defined in the design. This is the same value that is set in the endpoint request contexts under the ServiceKey key.
Variables ¶
var MethodNames = [5]string{"claude", "cursor", "codex", "logs", "metrics"}
MethodNames lists the service method names as defined in the design. These are the same values that are set in the endpoint request contexts under the MethodKey key.
Functions ¶
func MakeBadRequest ¶
func MakeBadRequest(err error) *goa.ServiceError
MakeBadRequest builds a goa.ServiceError from an error.
func MakeConflict ¶
func MakeConflict(err error) *goa.ServiceError
MakeConflict builds a goa.ServiceError from an error.
func MakeForbidden ¶
func MakeForbidden(err error) *goa.ServiceError
MakeForbidden builds a goa.ServiceError from an error.
func MakeGatewayError ¶
func MakeGatewayError(err error) *goa.ServiceError
MakeGatewayError builds a goa.ServiceError from an error.
func MakeInvalid ¶
func MakeInvalid(err error) *goa.ServiceError
MakeInvalid builds a goa.ServiceError from an error.
func MakeInvariantViolation ¶
func MakeInvariantViolation(err error) *goa.ServiceError
MakeInvariantViolation builds a goa.ServiceError from an error.
func MakeNotFound ¶
func MakeNotFound(err error) *goa.ServiceError
MakeNotFound builds a goa.ServiceError from an error.
func MakeUnauthorized ¶
func MakeUnauthorized(err error) *goa.ServiceError
MakeUnauthorized builds a goa.ServiceError from an error.
func MakeUnexpected ¶
func MakeUnexpected(err error) *goa.ServiceError
MakeUnexpected builds a goa.ServiceError from an error.
func MakeUnsupportedMedia ¶
func MakeUnsupportedMedia(err error) *goa.ServiceError
MakeUnsupportedMedia builds a goa.ServiceError from an error.
func NewClaudeEndpoint ¶
NewClaudeEndpoint returns an endpoint function that calls the method "claude" of service "hooks".
func NewCodexEndpoint ¶
func NewCodexEndpoint(s Service, authAPIKeyFn security.AuthAPIKeyFunc) goa.Endpoint
NewCodexEndpoint returns an endpoint function that calls the method "codex" of service "hooks".
func NewCursorEndpoint ¶
func NewCursorEndpoint(s Service, authAPIKeyFn security.AuthAPIKeyFunc) goa.Endpoint
NewCursorEndpoint returns an endpoint function that calls the method "cursor" of service "hooks".
func NewLogsEndpoint ¶
func NewLogsEndpoint(s Service, authAPIKeyFn security.AuthAPIKeyFunc) goa.Endpoint
NewLogsEndpoint returns an endpoint function that calls the method "logs" of service "hooks".
func NewMetricsEndpoint ¶
func NewMetricsEndpoint(s Service, authAPIKeyFn security.AuthAPIKeyFunc) goa.Endpoint
NewMetricsEndpoint returns an endpoint function that calls the method "metrics" of service "hooks".
Types ¶
type Auther ¶
type Auther interface {
// APIKeyAuth implements the authorization logic for the APIKey security scheme.
APIKeyAuth(ctx context.Context, key string, schema *security.APIKeyScheme) (context.Context, error)
}
Auther defines the authorization functions to be implemented by the service.
type ClaudeHookResult ¶
type ClaudeHookResult struct {
// Whether to continue (SessionStart only)
Continue *bool
// Reason if blocked (SessionStart only)
StopReason *string
// Whether to suppress the hook's output
SuppressOutput *bool
// Warning message shown to the user in the terminal
SystemMessage *string
// Hook-specific output as JSON object
HookSpecificOutput any
}
ClaudeHookResult is the result type of the hooks service claude method.
type ClaudePayload ¶
type ClaudePayload struct {
// Optional API key for plugin-driven attribution.
ApikeyToken *string
// Optional project slug for plugin-driven attribution.
ProjectSlugInput *string
// The type of hook event
HookEventName string
// The name of the tool (for tool-related events)
ToolName *string
// The unique ID for this tool use
ToolUseID *string
// The input to the tool
ToolInput any
// The response from the tool (PostToolUse only)
ToolResponse any
// The error from the tool (PostToolUseFailure only)
Error any
// Whether the failure was caused by user interruption (PostToolUseFailure only)
IsInterrupt *bool
// The Claude Code session ID
SessionID *string
// The working directory when the event fired
Cwd *string
// Path to the conversation transcript file
TranscriptPath *string
// Additional hook-specific data
AdditionalData map[string]any
// How the session started: startup, resume, clear, compact (SessionStart only)
Source *string
// The model identifier (SessionStart, Stop)
Model *string
// The user's prompt text (UserPromptSubmit only)
Prompt *string
// Claude's final response text (Stop only)
LastAssistantMessage *string
// Whether a stop hook continuation is active (Stop only)
StopHookActive *bool
// Why the session ended (SessionEnd only)
Reason *string
// Type of notification: permission_prompt, idle_prompt, auth_success,
// elicitation_dialog (Notification only)
NotificationType *string
// Notification message text (Notification only)
Message *string
// Notification title (Notification only)
Title *string
}
ClaudePayload is the payload type of the hooks service claude method.
type Client ¶
type Client struct {
ClaudeEndpoint goa.Endpoint
CursorEndpoint goa.Endpoint
CodexEndpoint goa.Endpoint
LogsEndpoint goa.Endpoint
MetricsEndpoint goa.Endpoint
}
Client is the "hooks" service client.
func (*Client) Claude ¶
func (c *Client) Claude(ctx context.Context, p *ClaudePayload) (res *ClaudeHookResult, err error)
Claude calls the "claude" endpoint of the "hooks" service. Claude may return the following errors:
- "unauthorized" (type *goa.ServiceError): unauthorized access
- "forbidden" (type *goa.ServiceError): permission denied
- "bad_request" (type *goa.ServiceError): request is invalid
- "not_found" (type *goa.ServiceError): resource not found
- "conflict" (type *goa.ServiceError): resource already exists
- "unsupported_media" (type *goa.ServiceError): unsupported media type
- "invalid" (type *goa.ServiceError): request contains one or more invalidation fields
- "invariant_violation" (type *goa.ServiceError): an unexpected error occurred
- "unexpected" (type *goa.ServiceError): an unexpected error occurred
- "gateway_error" (type *goa.ServiceError): an unexpected error occurred
- error: internal error
func (*Client) Codex ¶
func (c *Client) Codex(ctx context.Context, p *CodexPayload) (res *CodexHookResult, err error)
Codex calls the "codex" endpoint of the "hooks" service. Codex may return the following errors:
- "unauthorized" (type *goa.ServiceError): unauthorized access
- "forbidden" (type *goa.ServiceError): permission denied
- "bad_request" (type *goa.ServiceError): request is invalid
- "not_found" (type *goa.ServiceError): resource not found
- "conflict" (type *goa.ServiceError): resource already exists
- "unsupported_media" (type *goa.ServiceError): unsupported media type
- "invalid" (type *goa.ServiceError): request contains one or more invalidation fields
- "invariant_violation" (type *goa.ServiceError): an unexpected error occurred
- "unexpected" (type *goa.ServiceError): an unexpected error occurred
- "gateway_error" (type *goa.ServiceError): an unexpected error occurred
- error: internal error
func (*Client) Cursor ¶
func (c *Client) Cursor(ctx context.Context, p *CursorPayload) (res *CursorHookResult, err error)
Cursor calls the "cursor" endpoint of the "hooks" service. Cursor may return the following errors:
- "unauthorized" (type *goa.ServiceError): unauthorized access
- "forbidden" (type *goa.ServiceError): permission denied
- "bad_request" (type *goa.ServiceError): request is invalid
- "not_found" (type *goa.ServiceError): resource not found
- "conflict" (type *goa.ServiceError): resource already exists
- "unsupported_media" (type *goa.ServiceError): unsupported media type
- "invalid" (type *goa.ServiceError): request contains one or more invalidation fields
- "invariant_violation" (type *goa.ServiceError): an unexpected error occurred
- "unexpected" (type *goa.ServiceError): an unexpected error occurred
- "gateway_error" (type *goa.ServiceError): an unexpected error occurred
- error: internal error
func (*Client) Logs ¶
func (c *Client) Logs(ctx context.Context, p *LogsPayload) (err error)
Logs calls the "logs" endpoint of the "hooks" service. Logs may return the following errors:
- "unauthorized" (type *goa.ServiceError): unauthorized access
- "forbidden" (type *goa.ServiceError): permission denied
- "bad_request" (type *goa.ServiceError): request is invalid
- "not_found" (type *goa.ServiceError): resource not found
- "conflict" (type *goa.ServiceError): resource already exists
- "unsupported_media" (type *goa.ServiceError): unsupported media type
- "invalid" (type *goa.ServiceError): request contains one or more invalidation fields
- "invariant_violation" (type *goa.ServiceError): an unexpected error occurred
- "unexpected" (type *goa.ServiceError): an unexpected error occurred
- "gateway_error" (type *goa.ServiceError): an unexpected error occurred
- error: internal error
func (*Client) Metrics ¶
func (c *Client) Metrics(ctx context.Context, p *MetricsPayload) (err error)
Metrics calls the "metrics" endpoint of the "hooks" service. Metrics may return the following errors:
- "unauthorized" (type *goa.ServiceError): unauthorized access
- "forbidden" (type *goa.ServiceError): permission denied
- "bad_request" (type *goa.ServiceError): request is invalid
- "not_found" (type *goa.ServiceError): resource not found
- "conflict" (type *goa.ServiceError): resource already exists
- "unsupported_media" (type *goa.ServiceError): unsupported media type
- "invalid" (type *goa.ServiceError): request contains one or more invalidation fields
- "invariant_violation" (type *goa.ServiceError): an unexpected error occurred
- "unexpected" (type *goa.ServiceError): an unexpected error occurred
- "gateway_error" (type *goa.ServiceError): an unexpected error occurred
- error: internal error
type CodexHookResult ¶
type CodexHookResult struct {
// Permission decision for blocking events: allow or deny
Decision *string
// Reason for the decision, shown to the user
Reason *string
}
CodexHookResult is the result type of the hooks service codex method.
type CodexPayload ¶
type CodexPayload struct {
ApikeyToken *string
ProjectSlugInput *string
// The type of hook event
HookEventName string
// The Codex session ID
SessionID *string
// Path to the conversation transcript file
TranscriptPath *string
// The working directory when the event fired
Cwd *string
// The model identifier
Model *string
// The name of the tool
ToolName *string
// The input to the tool (PreToolUse only)
ToolInput any
// The output from the tool (PostToolUse only)
ToolOutput any
// The type of permission being requested (PermissionRequest only)
PermissionType *string
// The user's prompt text (UserPromptSubmit only)
Prompt *string
}
CodexPayload is the payload type of the hooks service codex method.
type CursorHookResult ¶
type CursorHookResult struct {
// Permission decision for preToolUse / beforeMCPExecution: allow, deny, or ask
Permission *string
// Message to display to the user
UserMessage *string
// Additional context to inject into the conversation
AdditionalContext *string
// Message sent back to the agent (beforeMCPExecution only)
AgentMessage *string
}
CursorHookResult is the result type of the hooks service cursor method.
type CursorPayload ¶
type CursorPayload struct {
ApikeyToken *string
ProjectSlugInput *string
// The type of hook event (e.g. beforeSubmitPrompt, stop, afterAgentResponse,
// afterAgentThought, preToolUse, postToolUse, postToolUseFailure,
// beforeMCPExecution, afterMCPExecution)
HookEventName string
// The Cursor conversation ID
ConversationID *string
// The Cursor generation ID
GenerationID *string
// The model being used
Model *string
// The Cursor IDE version
CursorVersion *string
// Email of the authenticated Cursor user, if available
UserEmail *string
// The session ID from Cursor
SessionID *string
// The name of the tool
ToolName *string
// The unique ID for this tool use
ToolUseID *string
// The input to the tool
ToolInput any
// The response from the tool (postToolUse only)
ToolResponse any
// The error from the tool (postToolUseFailure only)
Error any
// Whether the failure was caused by user interruption
IsInterrupt *bool
// Additional hook-specific data
AdditionalData map[string]any
// The user's prompt text (beforeSubmitPrompt only)
Prompt *string
// The composer mode, e.g. agent (beforeSubmitPrompt only)
ComposerMode *string
// Path to the conversation transcript JSONL file
TranscriptPath *string
// Completion status, e.g. completed (stop only)
Status *string
// Number of agentic loops executed (stop only)
LoopCount *int
// Total input tokens used (stop, afterAgentResponse)
InputTokens *int
// Total output tokens used (stop, afterAgentResponse)
OutputTokens *int
// Tokens read from cache (stop, afterAgentResponse)
CacheReadTokens *int
// Tokens written to cache (stop, afterAgentResponse)
CacheWriteTokens *int
// The assistant's response text (afterAgentResponse) or thinking text
// (afterAgentThought)
Text *string
// Duration in milliseconds for the thinking block (afterAgentThought only)
DurationMs *int
// URL of the MCP server (beforeMCPExecution / afterMCPExecution, URL-based
// servers only)
URL *string
// Command string for command-based MCP servers (beforeMCPExecution /
// afterMCPExecution only)
Command *string
// JSON-encoded string of the MCP tool response (afterMCPExecution only)
ResultJSON *string
// Execution duration in milliseconds, excluding approval wait time
// (afterMCPExecution only)
Duration *float64
}
CursorPayload is the payload type of the hooks service cursor method.
type Endpoints ¶
type Endpoints struct {
Claude goa.Endpoint
Cursor goa.Endpoint
Codex goa.Endpoint
Logs goa.Endpoint
Metrics goa.Endpoint
}
Endpoints wraps the "hooks" service endpoints.
func NewEndpoints ¶
NewEndpoints wraps the methods of the "hooks" service with endpoints.
type LogsPayload ¶
type LogsPayload struct {
ApikeyToken *string
ProjectSlugInput *string
// Array of resource logs
ResourceLogs []*OTELResourceLog
}
LogsPayload is the payload type of the hooks service logs method.
type MetricsPayload ¶
type MetricsPayload struct {
ApikeyToken *string
ProjectSlugInput *string
// Array of resource metrics
ResourceMetrics []*OTELResourceMetrics
}
MetricsPayload is the payload type of the hooks service metrics method.
type OTELAttribute ¶
type OTELAttribute struct {
// Attribute key
Key string
// Attribute value
Value *OTELAttributeValue
}
OTEL log attribute with key and typed value
type OTELAttributeValue ¶
type OTELAttributeValue struct {
// String value
StringValue *string
// Integer value (string-encoded per OTLP/JSON, or raw number)
IntValue any
// Boolean value
BoolValue *bool
// Double value
DoubleValue *float64
// Array value (passed through)
ArrayValue any
// Key-value list value (passed through)
KvlistValue any
// Bytes value (base64-encoded per OTLP/JSON)
BytesValue *string
}
OTEL attribute value - any of the OTLP/JSON value kinds
type OTELLogBody ¶
type OTELLogBody struct {
// String body value
StringValue *string
}
OTEL log body
type OTELLogRecord ¶
type OTELLogRecord struct {
// Timestamp in nanoseconds since Unix epoch
TimeUnixNano *string
// Observed timestamp in nanoseconds
ObservedTimeUnixNano *string
// Log body content
Body *OTELLogBody
// Log attributes
Attributes []*OTELAttribute
// Number of dropped attributes
DroppedAttributesCount *int
}
Individual OTEL log record
type OTELMetric ¶
type OTELMetric struct {
// Metric name
Name *string
// Metric description
Description *string
// Metric unit
Unit *string
// Sum metric data
Sum *OTELSum
// Gauge metric data (passed through)
Gauge any
// Histogram metric data (passed through)
Histogram any
// ExponentialHistogram metric data (passed through)
ExponentialHistogram any
// Summary metric data (passed through)
Summary any
}
OTEL metric
type OTELNumberDataPoint ¶
type OTELNumberDataPoint struct {
// Data point attributes
Attributes []*OTELAttribute
// Start timestamp in nanoseconds
StartTimeUnixNano *string
// Timestamp in nanoseconds
TimeUnixNano *string
// Value as double
AsDouble *float64
// Value as integer (string-encoded per OTLP/JSON, or raw number)
AsInt any
}
OTEL number data point
type OTELResource ¶
type OTELResource struct {
// Resource attributes
Attributes []*OTELResourceAttribute
// Number of dropped attributes
DroppedAttributesCount *int
}
OTEL resource information
type OTELResourceAttribute ¶
type OTELResourceAttribute struct {
// Resource attribute key
Key string
// Resource attribute value
Value *OTELAttributeValue
}
OTEL resource attribute
type OTELResourceLog ¶
type OTELResourceLog struct {
// Resource information
Resource *OTELResource
// Array of scope logs
ScopeLogs []*OTELScopeLog
}
OTEL resource logs container
type OTELResourceMetrics ¶
type OTELResourceMetrics struct {
// Resource information
Resource *OTELResource
// Array of scope metrics
ScopeMetrics []*OTELScopeMetrics
}
OTEL resource metrics container
type OTELScopeLog ¶
type OTELScopeLog struct {
// Instrumentation scope information
Scope *OTELScope
// Array of log records
LogRecords []*OTELLogRecord
}
OTEL scope logs container
type OTELScopeMetrics ¶
type OTELScopeMetrics struct {
// Instrumentation scope information
Scope *OTELScope
// Array of metrics
Metrics []*OTELMetric
}
OTEL scope metrics container
type OTELSum ¶
type OTELSum struct {
// Aggregation temporality (number or enum string)
AggregationTemporality any
// Whether the sum is monotonic
IsMonotonic *bool
// Data points
DataPoints []*OTELNumberDataPoint
}
OTEL sum metric
type Service ¶
type Service interface {
// Unified endpoint for all Claude Code hook events. Handles SessionStart,
// PreToolUse, PostToolUse, and PostToolUseFailure.
Claude(context.Context, *ClaudePayload) (res *ClaudeHookResult, err error)
// Endpoint for Cursor hook events. Handles beforeSubmitPrompt, stop,
// afterAgentResponse, afterAgentThought, preToolUse, postToolUse,
// postToolUseFailure, beforeMCPExecution, and afterMCPExecution.
Cursor(context.Context, *CursorPayload) (res *CursorHookResult, err error)
// Endpoint for Codex hook events. Handles SessionStart, PreToolUse,
// PermissionRequest, PostToolUse, UserPromptSubmit, and Stop.
Codex(context.Context, *CodexPayload) (res *CodexHookResult, err error)
// Endpoint to receive OTEL logs data from Claude Code. Requires API key
// authentication.
Logs(context.Context, *LogsPayload) (err error)
// Endpoint to receive OTEL metrics data from Claude Code. Requires API key
// authentication.
Metrics(context.Context, *MetricsPayload) (err error)
}
Receives hook events from coding assistants for tool usage observability.