Documentation
¶
Index ¶
- Constants
- func CreateCloudflareCommands() *cobra.Command
- func ResolveAPIToken() string
- func ResolveAccountID() string
- type AccountStatus
- type BackendCloudflareCredentials
- type Client
- func (c *Client) CreateD1Database(ctx context.Context, name string) (*CreateD1DatabaseResult, error)
- func (c *Client) CreateDNSRecord(ctx context.Context, opts CreateDNSRecordOptions) (*CreateDNSRecordResult, error)
- func (c *Client) CreateKVNamespace(ctx context.Context, title string) (*CreateKVNamespaceResult, error)
- func (c *Client) CreatePagesProject(ctx context.Context, opts CreatePagesProjectOptions) (*CreatePagesProjectResult, error)
- func (c *Client) CreateR2Bucket(ctx context.Context, name string, location string) (*CreateR2BucketResult, error)
- func (c *Client) CreateTunnel(ctx context.Context, name string) (*CreateTunnelResult, error)
- func (c *Client) DeleteD1Database(ctx context.Context, databaseID string) error
- func (c *Client) DeleteDNSRecord(ctx context.Context, zoneID, recordID string) error
- func (c *Client) DeleteKVNamespace(ctx context.Context, namespaceID string) error
- func (c *Client) DeletePagesProject(ctx context.Context, name string) error
- func (c *Client) DeleteR2Bucket(ctx context.Context, name string) error
- func (c *Client) DeleteTunnel(ctx context.Context, tunnelID string) error
- func (c *Client) DeleteWorker(ctx context.Context, name string) error
- func (c *Client) DeployPages(ctx context.Context, opts DeployPagesOptions) (*DeployPagesResult, error)
- func (c *Client) DeployWorker(ctx context.Context, opts DeployWorkerOptions) (*DeployWorkerResult, error)
- func (c *Client) GetAPIToken() string
- func (c *Client) GetAccountID() string
- func (c *Client) GetRelevantContext(ctx context.Context, question string) (string, error)
- func (c *Client) GetZoneIDByName(ctx context.Context, name string) (string, error)
- func (c *Client) ListZones(ctx context.Context) ([]Zone, error)
- func (c *Client) RunAPI(method, endpoint, body string) (string, error)
- func (c *Client) RunAPIWithContext(ctx context.Context, method, endpoint, body string) (string, error)
- func (c *Client) RunCloudflared(args ...string) (string, error)
- func (c *Client) RunCloudflaredWithContext(ctx context.Context, args ...string) (string, error)
- func (c *Client) RunWrangler(args ...string) (string, error)
- func (c *Client) RunWranglerWithContext(ctx context.Context, args ...string) (string, error)
- func (c *Client) UpdateDNSRecord(ctx context.Context, zoneID, recordID string, opts CreateDNSRecordOptions) (*CreateDNSRecordResult, error)
- type CloudflareClient
- type ConversationEntry
- type ConversationHistory
- func (h *ConversationHistory) AddEntry(question, answer, accountID string)
- func (h *ConversationHistory) Clear()
- func (h *ConversationHistory) GetAccountStatus() *AccountStatus
- func (h *ConversationHistory) GetAccountStatusContext() string
- func (h *ConversationHistory) GetRecentContext(maxEntries int) string
- func (h *ConversationHistory) Load() error
- func (h *ConversationHistory) Save() error
- func (h *ConversationHistory) UpdateAccountStatus(status *AccountStatus)
- type CreateD1DatabaseResult
- type CreateDNSRecordOptions
- type CreateDNSRecordResult
- type CreateKVNamespaceResult
- type CreatePagesProjectOptions
- type CreatePagesProjectResult
- type CreateR2BucketResult
- type CreateTunnelResult
- type D1Binding
- type DeployPagesOptions
- type DeployPagesResult
- type DeployWorkerOptions
- type DeployWorkerResult
- type KVBinding
- type QueryOptions
- type R2Binding
- type Response
- type ResponseType
- type Zone
Constants ¶
const MaxAnswerLengthInContext = 500
MaxAnswerLengthInContext limits how much of previous answers to include in context
const MaxHistoryEntries = 20
MaxHistoryEntries limits the conversation history size
Variables ¶
This section is empty.
Functions ¶
func CreateCloudflareCommands ¶
CreateCloudflareCommands creates the Cloudflare command tree for static commands
func ResolveAPIToken ¶
func ResolveAPIToken() string
ResolveAPIToken returns the Cloudflare API token from config or environment
func ResolveAccountID ¶
func ResolveAccountID() string
ResolveAccountID returns the Cloudflare account ID from config or environment
Types ¶
type AccountStatus ¶
type AccountStatus struct {
Timestamp time.Time `json:"timestamp"`
ZoneCount int `json:"zone_count"`
WorkerCount int `json:"worker_count"`
TunnelCount int `json:"tunnel_count"`
PlanType string `json:"plan_type"`
}
AccountStatus represents cached Cloudflare account status information
func GatherAccountStatus ¶
func GatherAccountStatus(ctx context.Context, client *Client) (*AccountStatus, error)
GatherAccountStatus collects basic Cloudflare account information for context
type BackendCloudflareCredentials ¶
BackendCloudflareCredentials represents Cloudflare credentials from the backend
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps Cloudflare API and CLI tools
func NewClientWithCredentials ¶
func NewClientWithCredentials(creds *BackendCloudflareCredentials, debug bool) (*Client, error)
NewClientWithCredentials creates a new Cloudflare client using credentials from the backend
func (*Client) CreateD1Database ¶
func (c *Client) CreateD1Database(ctx context.Context, name string) (*CreateD1DatabaseResult, error)
CreateD1Database creates a new D1 database
func (*Client) CreateDNSRecord ¶
func (c *Client) CreateDNSRecord(ctx context.Context, opts CreateDNSRecordOptions) (*CreateDNSRecordResult, error)
CreateDNSRecord creates a new DNS record
func (*Client) CreateKVNamespace ¶
func (c *Client) CreateKVNamespace(ctx context.Context, title string) (*CreateKVNamespaceResult, error)
CreateKVNamespace creates a new Workers KV namespace
func (*Client) CreatePagesProject ¶
func (c *Client) CreatePagesProject(ctx context.Context, opts CreatePagesProjectOptions) (*CreatePagesProjectResult, error)
CreatePagesProject creates a new Cloudflare Pages project
func (*Client) CreateR2Bucket ¶
func (c *Client) CreateR2Bucket(ctx context.Context, name string, location string) (*CreateR2BucketResult, error)
CreateR2Bucket creates a new R2 bucket
func (*Client) CreateTunnel ¶
CreateTunnel creates a new Cloudflare Tunnel
func (*Client) DeleteD1Database ¶
DeleteD1Database deletes a D1 database
func (*Client) DeleteDNSRecord ¶
DeleteDNSRecord deletes a DNS record
func (*Client) DeleteKVNamespace ¶
DeleteKVNamespace deletes a Workers KV namespace
func (*Client) DeletePagesProject ¶
DeletePagesProject deletes a Cloudflare Pages project
func (*Client) DeleteR2Bucket ¶
DeleteR2Bucket deletes an R2 bucket
func (*Client) DeleteTunnel ¶
DeleteTunnel deletes a Cloudflare Tunnel
func (*Client) DeleteWorker ¶
DeleteWorker deletes a Cloudflare Worker
func (*Client) DeployPages ¶
func (c *Client) DeployPages(ctx context.Context, opts DeployPagesOptions) (*DeployPagesResult, error)
DeployPages deploys assets to a Cloudflare Pages project
func (*Client) DeployWorker ¶
func (c *Client) DeployWorker(ctx context.Context, opts DeployWorkerOptions) (*DeployWorkerResult, error)
DeployWorker deploys a Cloudflare Worker
func (*Client) GetAPIToken ¶
GetAPIToken returns the API token
func (*Client) GetAccountID ¶
GetAccountID returns the account ID
func (*Client) GetRelevantContext ¶
GetRelevantContext gathers Cloudflare context for LLM queries
func (*Client) GetZoneIDByName ¶
GetZoneIDByName finds a zone ID by domain name
func (*Client) RunAPIWithContext ¶
func (c *Client) RunAPIWithContext(ctx context.Context, method, endpoint, body string) (string, error)
RunAPIWithContext executes a Cloudflare API call with context
func (*Client) RunCloudflared ¶
RunCloudflared executes a cloudflared CLI command
func (*Client) RunCloudflaredWithContext ¶
RunCloudflaredWithContext executes a cloudflared CLI command with context
func (*Client) RunWrangler ¶
RunWrangler executes a wrangler CLI command
func (*Client) RunWranglerWithContext ¶
RunWranglerWithContext executes a wrangler CLI command with context
func (*Client) UpdateDNSRecord ¶
func (c *Client) UpdateDNSRecord(ctx context.Context, zoneID, recordID string, opts CreateDNSRecordOptions) (*CreateDNSRecordResult, error)
UpdateDNSRecord updates an existing DNS record
type CloudflareClient ¶
type CloudflareClient interface {
RunAPI(method, endpoint, body string) (string, error)
RunWrangler(args ...string) (string, error)
RunCloudflared(args ...string) (string, error)
GetAccountID() string
GetAPIToken() string
}
CloudflareClient defines the interface for Cloudflare operations
type ConversationEntry ¶
type ConversationEntry struct {
Timestamp time.Time `json:"timestamp"`
Question string `json:"question"`
Answer string `json:"answer"`
AccountID string `json:"account_id"`
}
ConversationEntry represents a single Q&A exchange
type ConversationHistory ¶
type ConversationHistory struct {
Entries []ConversationEntry `json:"entries"`
AccountID string `json:"account_id"`
LastStatus *AccountStatus `json:"last_status,omitempty"`
// contains filtered or unexported fields
}
ConversationHistory maintains conversation state for Cloudflare ask mode
func NewConversationHistory ¶
func NewConversationHistory(accountID string) *ConversationHistory
NewConversationHistory creates a new conversation history for an account
func (*ConversationHistory) AddEntry ¶
func (h *ConversationHistory) AddEntry(question, answer, accountID string)
AddEntry adds a new conversation entry
func (*ConversationHistory) Clear ¶
func (h *ConversationHistory) Clear()
Clear clears all conversation history
func (*ConversationHistory) GetAccountStatus ¶
func (h *ConversationHistory) GetAccountStatus() *AccountStatus
GetAccountStatus returns the cached account status
func (*ConversationHistory) GetAccountStatusContext ¶
func (h *ConversationHistory) GetAccountStatusContext() string
GetAccountStatusContext returns a string representation of account status suitable for inclusion in LLM prompts
func (*ConversationHistory) GetRecentContext ¶
func (h *ConversationHistory) GetRecentContext(maxEntries int) string
GetRecentContext returns recent conversation context as a formatted string for inclusion in LLM prompts
func (*ConversationHistory) Load ¶
func (h *ConversationHistory) Load() error
Load loads conversation history from disk
func (*ConversationHistory) Save ¶
func (h *ConversationHistory) Save() error
Save persists the conversation history to disk
func (*ConversationHistory) UpdateAccountStatus ¶
func (h *ConversationHistory) UpdateAccountStatus(status *AccountStatus)
UpdateAccountStatus updates the cached account status
type CreateD1DatabaseResult ¶
CreateD1DatabaseResult contains the result of creating a D1 database
type CreateDNSRecordOptions ¶
type CreateDNSRecordOptions struct {
ZoneID string // Zone ID
Type string // Record type (A, AAAA, CNAME, MX, TXT, etc.)
Name string // Record name
Content string // Record content
TTL int // TTL in seconds (1 = auto)
Proxied bool // Whether to proxy through Cloudflare
Priority int // Priority (for MX records)
}
CreateDNSRecordOptions contains options for creating a DNS record
type CreateDNSRecordResult ¶
type CreateDNSRecordResult struct {
ID string `json:"id"`
Type string `json:"type"`
Name string `json:"name"`
Content string `json:"content"`
Proxied bool `json:"proxied"`
}
CreateDNSRecordResult contains the result of creating a DNS record
type CreateKVNamespaceResult ¶
CreateKVNamespaceResult contains the result of creating a KV namespace
type CreatePagesProjectOptions ¶
type CreatePagesProjectOptions struct {
Name string // Project name
ProductionBranch string // Production branch name (default: main)
BuildCommand string // Build command
BuildDirectory string // Build output directory
RootDirectory string // Root directory containing source
EnvironmentVars map[string]string // Environment variables
}
CreatePagesProjectOptions contains options for creating a Pages project
type CreatePagesProjectResult ¶
type CreatePagesProjectResult struct {
ID string `json:"id"`
Name string `json:"name"`
Subdomain string `json:"subdomain"`
}
CreatePagesProjectResult contains the result of creating a Pages project
type CreateR2BucketResult ¶
type CreateR2BucketResult struct {
Name string `json:"name"`
Location string `json:"location,omitempty"`
}
CreateR2BucketResult contains the result of creating an R2 bucket
type CreateTunnelResult ¶
type CreateTunnelResult struct {
ID string `json:"id"`
Name string `json:"name"`
Secret string `json:"secret"`
}
CreateTunnelResult contains the result of creating a Tunnel
type D1Binding ¶
type D1Binding struct {
Name string // Binding name in the worker
DatabaseID string // D1 database ID
}
D1Binding represents a D1 database binding for a Worker
type DeployPagesOptions ¶
type DeployPagesOptions struct {
ProjectName string // Pages project name
Directory string // Directory containing built assets
Branch string // Branch name (optional)
CommitHash string // Commit hash (optional)
CommitMsg string // Commit message (optional)
}
DeployPagesOptions contains options for deploying to Pages
type DeployPagesResult ¶
type DeployPagesResult struct {
ID string `json:"id"`
URL string `json:"url"`
Environment string `json:"environment"`
}
DeployPagesResult contains the result of a Pages deployment
type DeployWorkerOptions ¶
type DeployWorkerOptions struct {
Name string // Worker name
ScriptPath string // Path to the worker script file
ScriptContent string // Direct script content (alternative to ScriptPath)
Compatibility string // Compatibility date (e.g., "2024-01-01")
Bindings map[string]string // Environment variable bindings
KVNamespaces []KVBinding // KV namespace bindings
R2Buckets []R2Binding // R2 bucket bindings
D1Databases []D1Binding // D1 database bindings
Routes []string // Worker routes
CustomDomains []string // Custom domains
}
DeployWorkerOptions contains options for deploying a Worker
type DeployWorkerResult ¶
type DeployWorkerResult struct {
ID string `json:"id"`
Name string `json:"name"`
Etag string `json:"etag"`
Size int `json:"size"`
Routes []string `json:"routes,omitempty"`
ScriptURL string `json:"script_url,omitempty"`
}
DeployWorkerResult contains the result of a Worker deployment
type KVBinding ¶
type KVBinding struct {
Name string // Binding name in the worker
NamespaceID string // KV namespace ID
}
KVBinding represents a KV namespace binding for a Worker
type QueryOptions ¶
type QueryOptions struct {
ZoneID string `json:"zone_id,omitempty"`
ZoneName string `json:"zone_name,omitempty"`
AccountID string `json:"account_id,omitempty"`
}
QueryOptions contains options for Cloudflare queries
type R2Binding ¶
type R2Binding struct {
Name string // Binding name in the worker
BucketName string // R2 bucket name
}
R2Binding represents an R2 bucket binding for a Worker
type Response ¶
type Response struct {
Type ResponseType `json:"type"`
Result string `json:"result,omitempty"`
Plan interface{} `json:"plan,omitempty"`
Error error `json:"error,omitempty"`
Message string `json:"message,omitempty"`
}
Response represents the result of a Cloudflare query or operation
type ResponseType ¶
type ResponseType string
ResponseType indicates the type of response from a Cloudflare operation
const ( ResponseTypeResult ResponseType = "result" ResponseTypePlan ResponseType = "plan" ResponseTypeError ResponseType = "error" )