claude

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2026 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GetDailyUsagePayloadType = "claude.getDailyUsage.result"
)
View Source
const MessagePayloadType = "claude.message"

Variables

This section is empty.

Functions

This section is empty.

Types

type ActorSummary added in v0.28.0

type ActorSummary struct {
	Actor        string `json:"actor"`
	Type         string `json:"type"`
	Sessions     int64  `json:"sessions"`
	LinesAdded   int64  `json:"linesAdded"`
	LinesRemoved int64  `json:"linesRemoved"`
	Commits      int64  `json:"commits"`
	PullRequests int64  `json:"pullRequests"`
}

ActorSummary is a per-user/per-API-key productivity rollup from the Claude Code usage report.

type Claude

type Claude struct{}

func (*Claude) Actions

func (i *Claude) Actions() []core.Action

func (*Claude) Cleanup

func (i *Claude) Cleanup(ctx core.IntegrationCleanupContext) error

func (*Claude) Configuration

func (i *Claude) Configuration() []configuration.Field

func (*Claude) Description

func (i *Claude) Description() string

func (*Claude) HandleHook added in v0.18.0

func (i *Claude) HandleHook(ctx core.IntegrationHookContext) error

func (*Claude) HandleRequest

func (i *Claude) HandleRequest(ctx core.HTTPRequestContext)

func (*Claude) Hooks added in v0.18.0

func (i *Claude) Hooks() []core.Hook

func (*Claude) Icon

func (i *Claude) Icon() string

func (*Claude) Instructions

func (i *Claude) Instructions() string

func (*Claude) Label

func (i *Claude) Label() string

func (*Claude) ListResources

func (i *Claude) ListResources(resourceType string, ctx core.ListResourcesContext) ([]core.IntegrationResource, error)

func (*Claude) Name

func (i *Claude) Name() string

func (*Claude) Sync

func (i *Claude) Sync(ctx core.SyncContext) error

func (*Claude) Triggers

func (i *Claude) Triggers() []core.Trigger

type ClaudeCodeActor added in v0.28.0

type ClaudeCodeActor struct {
	Type         string `json:"type"`
	EmailAddress string `json:"email_address"`
	APIKeyName   string `json:"api_key_name"`
}

func (ClaudeCodeActor) Name added in v0.28.0

func (a ClaudeCodeActor) Name() string

type ClaudeCodeCoreMetrics added in v0.28.0

type ClaudeCodeCoreMetrics struct {
	CommitsByClaudeCode      int64                 `json:"commits_by_claude_code"`
	LinesOfCode              ClaudeCodeLinesOfCode `json:"lines_of_code"`
	NumSessions              int64                 `json:"num_sessions"`
	PullRequestsByClaudeCode int64                 `json:"pull_requests_by_claude_code"`
}

type ClaudeCodeEstimatedCost added in v0.28.0

type ClaudeCodeEstimatedCost struct {
	Amount   float64 `json:"amount"`
	Currency string  `json:"currency"`
}

type ClaudeCodeLinesOfCode added in v0.28.0

type ClaudeCodeLinesOfCode struct {
	Added   int64 `json:"added"`
	Removed int64 `json:"removed"`
}

type ClaudeCodeModelBreakdown added in v0.28.0

type ClaudeCodeModelBreakdown struct {
	Model         string                  `json:"model"`
	EstimatedCost ClaudeCodeEstimatedCost `json:"estimated_cost"`
	Tokens        ClaudeCodeModelTokens   `json:"tokens"`
}

type ClaudeCodeModelTokens added in v0.28.0

type ClaudeCodeModelTokens struct {
	CacheCreation int64 `json:"cache_creation"`
	CacheRead     int64 `json:"cache_read"`
	Input         int64 `json:"input"`
	Output        int64 `json:"output"`
}

type ClaudeCodeSummary added in v0.28.0

type ClaudeCodeSummary struct {
	Sessions            int64          `json:"sessions"`
	LinesAdded          int64          `json:"linesAdded"`
	LinesRemoved        int64          `json:"linesRemoved"`
	Commits             int64          `json:"commits"`
	PullRequests        int64          `json:"pullRequests"`
	ToolActionsAccepted int64          `json:"toolActionsAccepted"`
	ToolActionsRejected int64          `json:"toolActionsRejected"`
	EstimatedCostUsd    float64        `json:"estimatedCostUsd"`
	ByModel             []ModelCost    `json:"byModel"`
	ByActor             []ActorSummary `json:"byActor"`
}

ClaudeCodeSummary rolls up Claude Code productivity metrics and cost.

type ClaudeCodeToolAction added in v0.28.0

type ClaudeCodeToolAction struct {
	Accepted int64 `json:"accepted"`
	Rejected int64 `json:"rejected"`
}

type ClaudeCodeUsageRecord added in v0.28.0

type ClaudeCodeUsageRecord struct {
	Actor          ClaudeCodeActor                 `json:"actor"`
	Date           string                          `json:"date"`
	CoreMetrics    ClaudeCodeCoreMetrics           `json:"core_metrics"`
	ModelBreakdown []ClaudeCodeModelBreakdown      `json:"model_breakdown"`
	ToolActions    map[string]ClaudeCodeToolAction `json:"tool_actions"`
}

type ClaudeCodeUsageReportResponse added in v0.28.0

type ClaudeCodeUsageReportResponse struct {
	Data     []ClaudeCodeUsageRecord `json:"data"`
	HasMore  bool                    `json:"has_more"`
	NextPage string                  `json:"next_page"`
}

ClaudeCodeUsageReportResponse is the response of GET /v1/organizations/usage_report/claude_code.

type Client

type Client struct {
	APIKey   string
	AdminKey string
	BaseURL  string
	// contains filtered or unexported fields
}

func NewClient

func NewClient(httpClient core.HTTPContext, ctx core.IntegrationContext) (*Client, error)

func (*Client) CreateMessage

func (c *Client) CreateMessage(req CreateMessageRequest) (*CreateMessageResponse, error)

func (*Client) DeleteFile added in v0.28.0

func (c *Client) DeleteFile(fileID string) error

DeleteFile removes an uploaded file. Best-effort cleanup; no-op for empty IDs.

func (*Client) GetClaudeCodeUsageReport added in v0.28.0

func (c *Client) GetClaudeCodeUsageReport(startDate, endDate time.Time) ([]ClaudeCodeUsageRecord, error)

GetClaudeCodeUsageReport fetches per-day, per-actor Claude Code productivity metrics for every day between startDate and endDate (inclusive). The upstream endpoint only accepts a single day per call, so this issues one request (plus pagination) per day in range.

func (*Client) GetMessagesUsageReport added in v0.28.0

func (c *Client) GetMessagesUsageReport(startingAt, endingAt string, days int) ([]MessagesUsageBucket, error)

GetMessagesUsageReport fetches per-day, per-model token usage between startingAt (inclusive) and endingAt (exclusive), both RFC 3339 timestamps.

func (*Client) ListModels

func (c *Client) ListModels() ([]Model, error)

func (*Client) UploadFile added in v0.28.0

func (c *Client) UploadFile(content io.Reader, filename, contentType string) (string, error)

UploadFile uploads a file to the Anthropic Files API and returns its file_id.

func (*Client) Verify

func (c *Client) Verify() error

type Configuration

type Configuration struct {
	APIKey   string `json:"apiKey"`
	AdminKey string `json:"adminKey"`
}

type ContentBlock added in v0.26.0

type ContentBlock struct {
	Type   string              `json:"type"`
	Text   string              `json:"text,omitempty"`
	Source *ContentBlockSource `json:"source,omitempty"`
}

ContentBlock represents a content block in a Claude message. Used for text, images, and documents.

type ContentBlockSource added in v0.26.0

type ContentBlockSource struct {
	Type      string `json:"type"`
	MediaType string `json:"media_type,omitempty"`
	Data      string `json:"data,omitempty"`
	FileID    string `json:"file_id,omitempty"`
}

ContentBlockSource describes the source of an image/document content block. Type "text"/"base64" carry MediaType+Data inline; type "file" references a Files API file_id.

type CreateMessageRequest

type CreateMessageRequest struct {
	Model        string        `json:"model"`
	Messages     []Message     `json:"messages"`
	System       string        `json:"system,omitempty"`
	MaxTokens    int           `json:"max_tokens,omitempty"`
	Temperature  *float64      `json:"temperature,omitempty"`
	OutputConfig *OutputConfig `json:"output_config,omitempty"`
}

type CreateMessageResponse

type CreateMessageResponse struct {
	ID           string           `json:"id"`
	Type         string           `json:"type"`
	Role         string           `json:"role"`
	Content      []MessageContent `json:"content"`
	Model        string           `json:"model"`
	StopReason   string           `json:"stop_reason"`
	StopSequence string           `json:"stop_sequence,omitempty"`
	Usage        MessageUsage     `json:"usage"`
}

type DailyUsage added in v0.28.0

type DailyUsage struct {
	Date                 string  `json:"date"`
	MessagesInputTokens  int64   `json:"messagesInputTokens"`
	MessagesOutputTokens int64   `json:"messagesOutputTokens"`
	CodeSessions         int64   `json:"codeSessions"`
	CodeLinesAdded       int64   `json:"codeLinesAdded"`
	CodeLinesRemoved     int64   `json:"codeLinesRemoved"`
	CodeCommits          int64   `json:"codeCommits"`
	CodePullRequests     int64   `json:"codePullRequests"`
	CodeEstimatedCostUsd float64 `json:"codeEstimatedCostUsd"`
}

DailyUsage is an org-wide, per-calendar-day rollup combining both reports, for trend charts.

type GetDailyUsage added in v0.28.0

type GetDailyUsage struct{}

func (*GetDailyUsage) Cancel added in v0.28.0

func (c *GetDailyUsage) Cancel(ctx core.ExecutionContext) error

func (*GetDailyUsage) Cleanup added in v0.28.0

func (c *GetDailyUsage) Cleanup(ctx core.SetupContext) error

func (*GetDailyUsage) Color added in v0.28.0

func (c *GetDailyUsage) Color() string

func (*GetDailyUsage) Configuration added in v0.28.0

func (c *GetDailyUsage) Configuration() []configuration.Field

func (*GetDailyUsage) Description added in v0.28.0

func (c *GetDailyUsage) Description() string

func (*GetDailyUsage) Documentation added in v0.28.0

func (c *GetDailyUsage) Documentation() string

func (*GetDailyUsage) ExampleOutput added in v0.28.0

func (c *GetDailyUsage) ExampleOutput() map[string]any

func (*GetDailyUsage) Execute added in v0.28.0

func (c *GetDailyUsage) Execute(ctx core.ExecutionContext) error

func (*GetDailyUsage) HandleHook added in v0.28.0

func (c *GetDailyUsage) HandleHook(ctx core.ActionHookContext) error

func (*GetDailyUsage) HandleWebhook added in v0.28.0

func (*GetDailyUsage) Hooks added in v0.28.0

func (c *GetDailyUsage) Hooks() []core.Hook

func (*GetDailyUsage) Icon added in v0.28.0

func (c *GetDailyUsage) Icon() string

func (*GetDailyUsage) Label added in v0.28.0

func (c *GetDailyUsage) Label() string

func (*GetDailyUsage) Name added in v0.28.0

func (c *GetDailyUsage) Name() string

func (*GetDailyUsage) OutputChannels added in v0.28.0

func (c *GetDailyUsage) OutputChannels(config any) []core.OutputChannel

func (*GetDailyUsage) ProcessQueueItem added in v0.28.0

func (c *GetDailyUsage) ProcessQueueItem(ctx core.ProcessQueueContext) (*uuid.UUID, error)

func (*GetDailyUsage) Setup added in v0.28.0

func (c *GetDailyUsage) Setup(ctx core.SetupContext) error

type GetDailyUsageOutput added in v0.28.0

type GetDailyUsageOutput struct {
	Period     Period            `json:"period"`
	Messages   MessagesSummary   `json:"messages"`
	ClaudeCode ClaudeCodeSummary `json:"claudeCode"`
	Daily      []DailyUsage      `json:"daily"`
}

type GetDailyUsageSpec added in v0.28.0

type GetDailyUsageSpec struct {
	StartDate string `json:"startDate" mapstructure:"startDate"`
	EndDate   string `json:"endDate" mapstructure:"endDate"`
}

type Message

type Message struct {
	Role    string `json:"role"`
	Content any    `json:"content"`
}

Message represents a Claude API message. Content can be a plain string (for simple text) or []ContentBlock (for multi-part content with documents, images and text).

type MessageContent

type MessageContent struct {
	Type string `json:"type"`
	Text string `json:"text,omitempty"`
}

type MessagePayload

type MessagePayload struct {
	ID         string                 `json:"id"`
	Model      string                 `json:"model"`
	Text       string                 `json:"text"`
	Parsed     any                    `json:"parsed,omitempty"`
	Usage      *MessageUsage          `json:"usage,omitempty"`
	StopReason string                 `json:"stopReason,omitempty"`
	Response   *CreateMessageResponse `json:"response"`
}

type MessageUsage

type MessageUsage struct {
	InputTokens  int `json:"input_tokens"`
	OutputTokens int `json:"output_tokens"`
}

type MessagesSummary added in v0.28.0

type MessagesSummary struct {
	InputTokens         int64        `json:"inputTokens"`
	OutputTokens        int64        `json:"outputTokens"`
	CacheReadTokens     int64        `json:"cacheReadTokens"`
	CacheCreationTokens int64        `json:"cacheCreationTokens"`
	WebSearchRequests   int64        `json:"webSearchRequests"`
	ByModel             []ModelUsage `json:"byModel"`
}

MessagesSummary rolls up raw API/SDK usage. The Messages usage report has no cost or request-count field, only token counts.

type MessagesUsageBucket added in v0.28.0

type MessagesUsageBucket struct {
	StartingAt string                `json:"starting_at"`
	EndingAt   string                `json:"ending_at"`
	Results    []MessagesUsageResult `json:"results"`
}

type MessagesUsageCacheCreation added in v0.28.0

type MessagesUsageCacheCreation struct {
	Ephemeral1hInputTokens int64 `json:"ephemeral_1h_input_tokens"`
	Ephemeral5mInputTokens int64 `json:"ephemeral_5m_input_tokens"`
}

type MessagesUsageReportResponse added in v0.28.0

type MessagesUsageReportResponse struct {
	Data     []MessagesUsageBucket `json:"data"`
	HasMore  bool                  `json:"has_more"`
	NextPage string                `json:"next_page"`
}

MessagesUsageReportResponse is the response of GET /v1/organizations/usage_report/messages.

type MessagesUsageResult added in v0.28.0

type MessagesUsageResult struct {
	Model                string                     `json:"model"`
	UncachedInputTokens  int64                      `json:"uncached_input_tokens"`
	OutputTokens         int64                      `json:"output_tokens"`
	CacheReadInputTokens int64                      `json:"cache_read_input_tokens"`
	CacheCreation        MessagesUsageCacheCreation `json:"cache_creation"`
	ServerToolUse        MessagesUsageServerTool    `json:"server_tool_use"`
}

type MessagesUsageServerTool added in v0.28.0

type MessagesUsageServerTool struct {
	WebSearchRequests int64 `json:"web_search_requests"`
}

type Model

type Model struct {
	ID string `json:"id"`
}

type ModelCost added in v0.28.0

type ModelCost struct {
	Model            string  `json:"model"`
	InputTokens      int64   `json:"inputTokens"`
	OutputTokens     int64   `json:"outputTokens"`
	EstimatedCostUsd float64 `json:"estimatedCostUsd"`
}

ModelCost is a per-model token and cost rollup from the Claude Code usage report.

type ModelUsage added in v0.28.0

type ModelUsage struct {
	Model               string `json:"model"`
	InputTokens         int64  `json:"inputTokens"`
	OutputTokens        int64  `json:"outputTokens"`
	CacheReadTokens     int64  `json:"cacheReadTokens"`
	CacheCreationTokens int64  `json:"cacheCreationTokens"`
}

ModelUsage is a per-model token rollup from the Messages usage report.

type ModelsResponse

type ModelsResponse struct {
	Data []Model `json:"data"`
}

type OutputConfig added in v0.28.0

type OutputConfig struct {
	Format *OutputFormat `json:"format,omitempty"`
}

OutputConfig configures Claude's response format (structured outputs). See https://platform.claude.com/docs/en/build-with-claude/structured-outputs

type OutputFormat added in v0.28.0

type OutputFormat struct {
	Type   string `json:"type"`   // always "json_schema"
	Schema any    `json:"schema"` // the JSON Schema object
}

OutputFormat constrains the final text response to a JSON schema.

type Period added in v0.28.0

type Period struct {
	StartDate string `json:"startDate"`
	EndDate   string `json:"endDate"`
}

type TextPrompt

type TextPrompt struct{}

func (*TextPrompt) Cancel

func (c *TextPrompt) Cancel(ctx core.ExecutionContext) error

func (*TextPrompt) Cleanup

func (c *TextPrompt) Cleanup(ctx core.SetupContext) error

func (*TextPrompt) Color

func (c *TextPrompt) Color() string

func (*TextPrompt) Configuration

func (c *TextPrompt) Configuration() []configuration.Field

func (*TextPrompt) Description

func (c *TextPrompt) Description() string

func (*TextPrompt) Documentation

func (c *TextPrompt) Documentation() string

func (*TextPrompt) ExampleOutput

func (c *TextPrompt) ExampleOutput() map[string]any

func (*TextPrompt) Execute

func (c *TextPrompt) Execute(ctx core.ExecutionContext) error

func (*TextPrompt) HandleHook added in v0.18.0

func (c *TextPrompt) HandleHook(ctx core.ActionHookContext) error

func (*TextPrompt) HandleWebhook

func (*TextPrompt) Hooks added in v0.18.0

func (c *TextPrompt) Hooks() []core.Hook

func (*TextPrompt) Icon

func (c *TextPrompt) Icon() string

func (*TextPrompt) Label

func (c *TextPrompt) Label() string

func (*TextPrompt) Name

func (c *TextPrompt) Name() string

func (*TextPrompt) OutputChannels

func (c *TextPrompt) OutputChannels(configuration any) []core.OutputChannel

func (*TextPrompt) ProcessQueueItem

func (c *TextPrompt) ProcessQueueItem(ctx core.ProcessQueueContext) (*uuid.UUID, error)

func (*TextPrompt) Setup

func (c *TextPrompt) Setup(ctx core.SetupContext) error

type TextPromptNodeMetadata added in v0.28.0

type TextPromptNodeMetadata struct {
	Model            string `json:"model" mapstructure:"model"`
	MaxTokens        int    `json:"maxTokens" mapstructure:"maxTokens"`
	StructuredOutput bool   `json:"structuredOutput" mapstructure:"structuredOutput"`
}

TextPromptNodeMetadata is node-level metadata surfaced in the UI so the configured model and options are visible on the node without opening it.

type TextPromptSpec

type TextPromptSpec struct {
	Model         string   `json:"model"`
	Prompt        string   `json:"prompt"`
	SystemMessage string   `json:"systemMessage"`
	MaxTokens     int      `json:"maxTokens"`
	Temperature   *float64 `json:"temperature"`
	Files         []string `json:"files"`
	OutputSchema  string   `json:"outputSchema"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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