Documentation
¶
Overview ¶
Package interfaces defines all core abstractions for the Currier application. All components communicate through these interfaces for loose coupling.
Index ¶
- Constants
- type AgentError
- type AgentMessage
- type AgentMessageHandler
- type AgentServer
- type AgentTool
- type AgentTransport
- type AuthConfig
- type AuthField
- type AuthProvider
- type Body
- type BodyConfig
- type BodyFormatter
- type Collection
- type CollectionMeta
- type CollectionStore
- type CommandExecutor
- type CommandHandler
- type Component
- type Connection
- type ConnectionInfo
- type ConnectionManager
- type ConnectionOptions
- type ConnectionState
- type Environment
- type EnvironmentMeta
- type EnvironmentStore
- type ExportOptions
- type Exporter
- type ExporterRegistry
- type Folder
- type Headers
- type HistoryEntry
- type HistoryQueryOpts
- type HistoryStore
- type HookHandler
- type ImportError
- type ImportOptions
- type ImportResult
- type Importer
- type ImporterRegistry
- type KeyHandler
- type Layout
- type LayoutRegion
- type ParameterInfo
- type Plugin
- type PluginCommand
- type PluginCommandContext
- type PluginContext
- type PluginManager
- type PluginMetadata
- type PluginSetting
- type Request
- type RequestDefinition
- type RequestMeta
- type RequestOptions
- type RequestStore
- type Requester
- type Response
- type ResponseStream
- type ScriptContext
- type ScriptEngine
- type ScriptEnvironmentContext
- type ScriptRequestContext
- type ScriptResponseContext
- type ScriptScope
- type Status
- type StreamRequester
- type TestDefinition
- type TestResult
- type Theme
- type TimingInfo
- type ToolInfo
- type ToolParameters
- type VariableInfo
- type VariableScope
- type VariableStore
- type View
- type VimMode
Constants ¶
const ( ToolSendRequest = "send_request" ToolListCollections = "list_collections" ToolGetRequest = "get_request" ToolRunRequest = "run_request" ToolRunCollection = "run_collection" ToolImportCollection = "import_collection" ToolExportCollection = "export_collection" ToolSetEnvironment = "set_environment" ToolGetEnvironment = "get_environment" ToolGetHistory = "get_history" ToolSetVariable = "set_variable" ToolGetVariable = "get_variable" )
Standard tool names
const ( HookPreRequest = "pre_request" HookPostResponse = "post_response" HookFormatBody = "format_body" HookAuthProvider = "auth_provider" HookImporter = "importer" HookExporter = "exporter" HookCommand = "command" HookKeybinding = "keybinding" )
Hook names
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AgentError ¶
AgentError represents an error in agent communication.
type AgentMessage ¶
type AgentMessage struct {
ID string
Type string // "request", "response", "notification"
Method string // For requests
Params map[string]any
Result any
Error *AgentError
}
AgentMessage represents a message to/from an agent.
type AgentMessageHandler ¶
type AgentMessageHandler interface {
// HandleMessage processes an incoming message.
HandleMessage(ctx context.Context, msg AgentMessage) (AgentMessage, error)
}
AgentMessageHandler processes messages from agents.
type AgentServer ¶
type AgentServer interface {
// Start starts the agent server.
Start(ctx context.Context) error
// Stop gracefully stops the server.
Stop() error
// RegisterTool registers a tool for agents to use.
RegisterTool(tool AgentTool) error
// ListTools returns all available tools.
ListTools() []ToolInfo
// ExecuteTool executes a tool by name.
ExecuteTool(ctx context.Context, name string, params map[string]any) (any, error)
}
AgentServer exposes functionality to AI agents via MCP or similar protocols.
type AgentTool ¶
type AgentTool interface {
// Name returns the tool name.
Name() string
// Description returns a description for the AI agent.
Description() string
// Parameters returns the parameter schema.
Parameters() ToolParameters
// Execute runs the tool with the given parameters.
Execute(ctx context.Context, params map[string]any) (any, error)
}
AgentTool represents a capability exposed to AI agents.
type AgentTransport ¶
type AgentTransport interface {
// Start begins listening for agent connections.
Start(ctx context.Context) error
// Stop stops the transport.
Stop() error
// SetHandler sets the message handler.
SetHandler(handler AgentMessageHandler)
}
AgentTransport handles communication with agents.
type AuthConfig ¶
type AuthConfig struct {
Type string // "none", "basic", "bearer", "oauth2", "apikey", "aws"
Params map[string]string
}
AuthConfig represents authentication configuration.
type AuthField ¶
type AuthField struct {
Name string
Type string // "string", "password", "select"
Label string
Required bool
Default string
Placeholder string
}
AuthField describes an authentication field.
type AuthProvider ¶
type AuthProvider struct {
Name string
DisplayName string
Fields []AuthField
Apply func(req Request, params map[string]string) error
}
AuthProvider defines a custom authentication type.
type Body ¶
type Body interface {
// Type returns the body type (e.g., "json", "form", "raw", "graphql", "protobuf").
Type() string
// ContentType returns the MIME content type.
ContentType() string
// Bytes returns the raw body bytes.
Bytes() []byte
// String returns the body as a string.
String() string
// Reader returns an io.Reader for the body.
Reader() io.Reader
// Size returns the body size in bytes.
Size() int64
// IsEmpty returns true if the body is empty.
IsEmpty() bool
// JSON attempts to parse the body as JSON and returns the result.
JSON() (any, error)
}
Body represents request or response body content.
type BodyConfig ¶
type BodyConfig struct {
Type string // "json", "form", "multipart", "raw", "graphql", "protobuf"
Content any
ContentType string
}
BodyConfig represents body configuration.
type BodyFormatter ¶
type BodyFormatter struct {
Name string
DisplayName string
ContentTypes []string
Format func(body []byte) (string, error)
Parse func(formatted string) ([]byte, error)
}
BodyFormatter provides custom body formatting.
type Collection ¶
type Collection interface {
// ID returns the collection identifier.
ID() string
// Name returns the collection name.
Name() string
// Description returns the collection description.
Description() string
// Version returns the collection version.
Version() string
// Variables returns collection-level variables.
Variables() map[string]string
// Auth returns the default authentication for the collection.
Auth() AuthConfig
// PreScript returns the pre-request script.
PreScript() string
// Folders returns the collection folders.
Folders() []Folder
// Requests returns top-level requests (not in folders).
Requests() []RequestDefinition
// Path returns the file system path.
Path() string
// CreatedAt returns the creation timestamp.
CreatedAt() time.Time
// UpdatedAt returns the last update timestamp.
UpdatedAt() time.Time
}
Collection represents a collection of requests.
type CollectionMeta ¶
type CollectionMeta struct {
ID string
Name string
Description string
Path string
RequestCount int
CreatedAt time.Time
UpdatedAt time.Time
}
CollectionMeta contains collection metadata without full content.
type CollectionStore ¶
type CollectionStore interface {
// List returns all collections.
List(ctx context.Context) ([]CollectionMeta, error)
// Get retrieves a collection by ID.
Get(ctx context.Context, id string) (Collection, error)
// GetByPath retrieves a collection by file path.
GetByPath(ctx context.Context, path string) (Collection, error)
// Save persists a collection.
Save(ctx context.Context, c Collection) error
// Delete removes a collection.
Delete(ctx context.Context, id string) error
// Search finds collections matching the query.
Search(ctx context.Context, query string) ([]CollectionMeta, error)
}
CollectionStore manages collection persistence.
type CommandExecutor ¶
type CommandExecutor interface {
// Execute runs a command.
Execute(command string) tea.Cmd
// Complete returns completions for a partial command.
Complete(partial string) []string
// Register registers a custom command.
Register(name string, handler CommandHandler)
}
CommandExecutor executes : commands.
type CommandHandler ¶
CommandHandler handles a custom command.
type Component ¶
type Component interface {
// Init initializes the component.
Init() tea.Cmd
// Update handles messages and returns the updated component.
Update(msg tea.Msg) (Component, tea.Cmd)
// View renders the component to a string.
View() string
// Focus gives focus to the component.
Focus() Component
// Blur removes focus from the component.
Blur() Component
// Focused returns true if the component is focused.
Focused() bool
// SetSize sets the component dimensions.
SetSize(width, height int) Component
// Width returns the component width.
Width() int
// Height returns the component height.
Height() int
}
Component represents a reusable TUI component.
type Connection ¶
type Connection interface {
// ID returns the unique connection identifier.
ID() string
// Endpoint returns the connection endpoint.
Endpoint() string
// State returns the current connection state.
State() ConnectionState
// Send sends a message on this connection.
Send(ctx context.Context, data []byte) error
// Receive receives a message from this connection.
Receive(ctx context.Context) ([]byte, error)
// Close closes the connection.
Close() error
}
Connection represents an active connection for stateful protocols.
type ConnectionInfo ¶
type ConnectionInfo struct {
ID string
Endpoint string
State ConnectionState
CreatedAt time.Time
Protocol string
}
ConnectionInfo provides metadata about a connection.
type ConnectionManager ¶
type ConnectionManager interface {
// Connect establishes a connection to the given endpoint.
Connect(ctx context.Context, endpoint string, opts ConnectionOptions) (Connection, error)
// Disconnect closes the connection with the given ID.
Disconnect(id string) error
// ListConnections returns all active connections.
ListConnections() []ConnectionInfo
// GetConnection returns a specific connection by ID.
GetConnection(id string) (Connection, error)
}
ConnectionManager manages persistent connections for stateful protocols.
type ConnectionOptions ¶
ConnectionOptions contains options for establishing a connection.
type ConnectionState ¶
type ConnectionState int
ConnectionState represents the state of a connection.
const ( ConnectionStateConnecting ConnectionState = iota ConnectionStateConnected ConnectionStateDisconnecting ConnectionStateDisconnected ConnectionStateError )
func (ConnectionState) String ¶
func (s ConnectionState) String() string
type Environment ¶
type Environment interface {
// ID returns the environment identifier.
ID() string
// Name returns the environment name.
Name() string
// Variables returns the environment variables.
Variables() map[string]string
// Secrets returns the encrypted secrets.
Secrets() map[string]string
// IsActive returns true if this is the active environment.
IsActive() bool
// CreatedAt returns the creation timestamp.
CreatedAt() time.Time
// UpdatedAt returns the last update timestamp.
UpdatedAt() time.Time
// SetVariable sets a variable value.
SetVariable(key, value string)
// GetVariable gets a variable value.
GetVariable(key string) (string, bool)
// DeleteVariable removes a variable.
DeleteVariable(key string)
}
Environment represents an environment with variables.
type EnvironmentMeta ¶
type EnvironmentMeta struct {
ID string
Name string
IsActive bool
VarCount int
UpdatedAt time.Time
}
EnvironmentMeta contains environment metadata.
type EnvironmentStore ¶
type EnvironmentStore interface {
// List returns all environments.
List(ctx context.Context) ([]EnvironmentMeta, error)
// Get retrieves an environment by ID.
Get(ctx context.Context, id string) (Environment, error)
// GetByName retrieves an environment by name.
GetByName(ctx context.Context, name string) (Environment, error)
// Save persists an environment.
Save(ctx context.Context, e Environment) error
// Delete removes an environment.
Delete(ctx context.Context, id string) error
// GetActive returns the currently active environment.
GetActive(ctx context.Context) (Environment, error)
// SetActive sets the active environment.
SetActive(ctx context.Context, id string) error
}
EnvironmentStore manages environment persistence.
type ExportOptions ¶
type ExportOptions struct {
// IncludeEnvironment includes environment variables.
IncludeEnvironment bool
// Environment is the environment to include.
Environment Environment
// IncludeScripts includes pre/post scripts.
IncludeScripts bool
// IncludeTests includes test definitions.
IncludeTests bool
// PrettyPrint formats output for readability.
PrettyPrint bool
// IndentSize is the indentation size for pretty printing.
IndentSize int
}
ExportOptions configures export behavior.
type Exporter ¶
type Exporter interface {
// Name returns the exporter name.
Name() string
// DisplayName returns a human-readable name.
DisplayName() string
// FileExtension returns the file extension for exported files.
FileExtension() string
// Export converts a collection to the external format.
Export(ctx context.Context, c Collection, opts ExportOptions) ([]byte, error)
}
Exporter writes Currier format to external formats.
type ExporterRegistry ¶
type ExporterRegistry interface {
// Register adds an exporter.
Register(exporter Exporter)
// Get retrieves an exporter by name.
Get(name string) (Exporter, bool)
// List returns all registered exporters.
List() []Exporter
}
ExporterRegistry manages available exporters.
type Folder ¶
type Folder interface {
// Name returns the folder name.
Name() string
// Description returns the folder description.
Description() string
// Requests returns the requests in this folder.
Requests() []RequestDefinition
// Folders returns nested folders.
Folders() []Folder
// Auth returns folder-level authentication override.
Auth() AuthConfig
// PreScript returns folder-level pre-request script.
PreScript() string
}
Folder represents a folder within a collection.
type Headers ¶
type Headers interface {
// Get returns the first value for the given key.
Get(key string) string
// GetAll returns all values for the given key.
GetAll(key string) []string
// Set sets the value for the given key, replacing any existing values.
Set(key, value string)
// Add adds a value for the given key.
Add(key, value string)
// Del removes all values for the given key.
Del(key string)
// Keys returns all header keys.
Keys() []string
// Clone creates a deep copy of the headers.
Clone() Headers
// ToMap returns the headers as a map.
ToMap() map[string][]string
}
Headers provides access to header values.
type HistoryEntry ¶
type HistoryEntry struct {
ID string
RequestID string
RequestName string
Method string
URL string
Status int
StatusText string
Duration time.Duration
Size int64
Timestamp time.Time
// Full request/response data (may be loaded on demand)
Request Request
Response Response
}
HistoryEntry represents a request/response in history.
type HistoryQueryOpts ¶
type HistoryQueryOpts struct {
Limit int
Offset int
Method string
URL string
Status int
MinStatus int
MaxStatus int
Before time.Time
After time.Time
Search string
SortBy string
Descending bool
}
HistoryQueryOpts specifies options for querying history.
type HistoryStore ¶
type HistoryStore interface {
// Add adds a history entry.
Add(ctx context.Context, entry HistoryEntry) error
// List returns history entries matching the options.
List(ctx context.Context, opts HistoryQueryOpts) ([]HistoryEntry, error)
// Get retrieves a history entry by ID.
Get(ctx context.Context, id string) (HistoryEntry, error)
// Clear removes history entries older than the given time.
Clear(ctx context.Context, before time.Time) error
// Search finds history entries matching the query.
Search(ctx context.Context, query string) ([]HistoryEntry, error)
// Count returns the total number of history entries.
Count(ctx context.Context) (int64, error)
}
HistoryStore manages request history.
type HookHandler ¶
HookHandler is a function that handles a hook event.
type ImportError ¶
ImportError describes an import error for a specific item.
type ImportOptions ¶
type ImportOptions struct {
// Name overrides the imported collection name.
Name string
// BasePath is the directory to save imported files.
BasePath string
// IncludeEnvironments imports environments if available.
IncludeEnvironments bool
// MergeWithExisting merges with an existing collection.
MergeWithExisting bool
// ExistingCollectionID is the ID of the collection to merge with.
ExistingCollectionID string
}
ImportOptions configures import behavior.
type ImportResult ¶
type ImportResult struct {
// Collection is the imported collection.
Collection Collection
// Environments are the imported environments.
Environments []Environment
// RequestCount is the number of requests imported.
RequestCount int
// Warnings contains non-fatal issues encountered during import.
Warnings []string
// Errors contains errors that prevented some items from being imported.
Errors []ImportError
}
ImportResult contains the results of an import operation.
type Importer ¶
type Importer interface {
// Name returns the importer name (e.g., "postman", "openapi").
Name() string
// DisplayName returns a human-readable name.
DisplayName() string
// FileExtensions returns supported file extensions.
FileExtensions() []string
// DetectFormat checks if the content matches this format.
DetectFormat(content []byte) bool
// Import converts the content to a Currier collection.
Import(ctx context.Context, content []byte, opts ImportOptions) (ImportResult, error)
}
Importer reads external formats and converts them to Currier format.
type ImporterRegistry ¶
type ImporterRegistry interface {
// Register adds an importer.
Register(importer Importer)
// Get retrieves an importer by name.
Get(name string) (Importer, bool)
// List returns all registered importers.
List() []Importer
// DetectFormat finds the best importer for the given content.
DetectFormat(content []byte) (Importer, bool)
// GetByExtension finds importers supporting the given extension.
GetByExtension(ext string) []Importer
}
ImporterRegistry manages available importers.
type KeyHandler ¶
type KeyHandler interface {
// HandleKey processes a key press.
HandleKey(key tea.KeyMsg) (tea.Cmd, bool)
// SetMode sets the current vim mode.
SetMode(mode VimMode)
// GetMode returns the current vim mode.
GetMode() VimMode
}
KeyHandler processes keyboard input.
type Layout ¶
type Layout interface {
// AddComponent adds a component to the layout.
AddComponent(name string, c Component, region LayoutRegion)
// RemoveComponent removes a component.
RemoveComponent(name string)
// GetComponent retrieves a component by name.
GetComponent(name string) (Component, bool)
// FocusNext moves focus to the next component.
FocusNext() Component
// FocusPrev moves focus to the previous component.
FocusPrev() Component
// SetSize sets the layout dimensions.
SetSize(width, height int)
// View renders the layout.
View() string
}
Layout manages component arrangement.
type LayoutRegion ¶
type LayoutRegion int
LayoutRegion identifies a layout region.
const ( LayoutRegionLeft LayoutRegion = iota LayoutRegionCenter LayoutRegionRight LayoutRegionTop LayoutRegionBottom LayoutRegionOverlay )
type ParameterInfo ¶
type ParameterInfo struct {
Type string // "string", "number", "boolean", "object", "array"
Description string
Enum []string // Allowed values for string type
Default any
Items *ParameterInfo // For array types
Properties map[string]ParameterInfo // For object types
}
ParameterInfo describes a single parameter.
type Plugin ¶
type Plugin interface {
// Metadata returns plugin metadata.
Metadata() PluginMetadata
// Activate initializes the plugin.
Activate(ctx PluginContext) error
// Deactivate cleans up the plugin.
Deactivate() error
}
Plugin represents a loadable extension.
type PluginCommand ¶
type PluginCommand struct {
Name string
Description string
Execute func(args []string, ctx PluginCommandContext) error
}
PluginCommand represents a custom command.
type PluginCommandContext ¶
type PluginCommandContext interface {
// Output writes output to the user.
Output(msg string)
// Error writes an error message.
Error(msg string)
// Prompt asks for user input.
Prompt(msg string) (string, error)
// Confirm asks for confirmation.
Confirm(msg string) (bool, error)
}
PluginCommandContext provides context for command execution.
type PluginContext ¶
type PluginContext interface {
// Log logs a message.
Log(msg string)
// LogError logs an error.
LogError(msg string, err error)
// Settings returns plugin settings.
Settings() map[string]any
// GetSetting retrieves a specific setting.
GetSetting(key string) (any, bool)
// RegisterHook registers a hook handler.
RegisterHook(hook string, handler HookHandler) error
// RegisterCommand registers a custom command.
RegisterCommand(name string, cmd PluginCommand) error
// RegisterAuthProvider registers a custom auth type.
RegisterAuthProvider(provider AuthProvider) error
// RegisterFormatter registers a custom body formatter.
RegisterFormatter(formatter BodyFormatter) error
// RegisterImporter registers a custom importer.
RegisterImporter(importer Importer) error
// RegisterExporter registers a custom exporter.
RegisterExporter(exporter Exporter) error
}
PluginContext provides services to plugins.
type PluginManager ¶
type PluginManager interface {
// Install installs a plugin from a source.
Install(ctx context.Context, source string) error
// Uninstall removes a plugin.
Uninstall(ctx context.Context, name string) error
// Enable enables a plugin.
Enable(ctx context.Context, name string) error
// Disable disables a plugin.
Disable(ctx context.Context, name string) error
// List returns all installed plugins.
List() []PluginMetadata
// Get retrieves a plugin by name.
Get(name string) (Plugin, error)
// Reload reloads a plugin.
Reload(ctx context.Context, name string) error
// ExecuteHook executes all handlers for a hook.
ExecuteHook(ctx context.Context, hook string, data any) (any, error)
// GetAuthProviders returns all registered auth providers.
GetAuthProviders() []AuthProvider
// GetFormatters returns all registered formatters.
GetFormatters() []BodyFormatter
// GetCommands returns all registered commands.
GetCommands() []PluginCommand
}
PluginManager manages plugin lifecycle.
type PluginMetadata ¶
type PluginMetadata struct {
Name string
Version string
Description string
Author string
License string
Homepage string
Requires string // Minimum Currier version
Hooks []string
Settings []PluginSetting
Enabled bool
Path string
}
PluginMetadata contains plugin information.
type PluginSetting ¶
type PluginSetting struct {
Name string
Type string // "string", "number", "boolean", "select"
Description string
Default any
Required bool
Enum []string // For "select" type
}
PluginSetting describes a plugin configuration option.
type Request ¶
type Request interface {
// ID returns the unique request identifier.
ID() string
// Protocol returns the protocol type (e.g., "http", "websocket", "grpc").
Protocol() string
// Method returns the request method (e.g., "GET", "POST", "SUBSCRIBE").
Method() string
// Endpoint returns the target endpoint (URL, topic, service/method).
Endpoint() string
// Headers returns the request headers.
Headers() Headers
// Body returns the request body.
Body() Body
// Metadata returns protocol-specific metadata.
Metadata() map[string]any
// Clone creates a deep copy of the request.
Clone() Request
// Validate checks if the request is valid.
Validate() error
// SetHeader sets a header value.
SetHeader(key, value string)
// SetBody sets the request body.
SetBody(body Body)
// SetMetadata sets a metadata value.
SetMetadata(key string, value any)
}
Request represents a protocol-agnostic request.
type RequestDefinition ¶
type RequestDefinition interface {
// ID returns the request identifier.
ID() string
// Name returns the request name.
Name() string
// Description returns the request description.
Description() string
// Protocol returns the protocol type.
Protocol() string
// Method returns the HTTP method or equivalent.
Method() string
// URL returns the request URL (may contain variables).
URL() string
// Headers returns the request headers.
Headers() map[string]string
// QueryParams returns query parameters.
QueryParams() map[string]string
// Body returns the request body configuration.
Body() BodyConfig
// Auth returns the authentication configuration.
Auth() AuthConfig
// PreScript returns the pre-request script.
PreScript() string
// PostScript returns the post-response script.
PostScript() string
// Tests returns the test definitions.
Tests() []TestDefinition
// Options returns request options.
Options() RequestOptions
// CollectionID returns the parent collection ID.
CollectionID() string
// FolderPath returns the folder path within the collection.
FolderPath() string
// CreatedAt returns the creation timestamp.
CreatedAt() time.Time
// UpdatedAt returns the last update timestamp.
UpdatedAt() time.Time
}
RequestDefinition represents a saved request definition.
type RequestMeta ¶
type RequestMeta struct {
ID string
Name string
Method string
URL string
CollectionID string
FolderPath string
UpdatedAt time.Time
}
RequestMeta contains request metadata without full content.
type RequestOptions ¶
type RequestOptions struct {
Timeout time.Duration
FollowRedirects bool
VerifySSL bool
MaxRedirects int
}
RequestOptions contains request options.
type RequestStore ¶
type RequestStore interface {
// Get retrieves a request by ID.
Get(ctx context.Context, id string) (RequestDefinition, error)
// Save persists a request.
Save(ctx context.Context, r RequestDefinition) error
// Delete removes a request.
Delete(ctx context.Context, id string) error
// ListByCollection returns all requests in a collection.
ListByCollection(ctx context.Context, collectionID string) ([]RequestMeta, error)
}
RequestStore manages individual request persistence.
type Requester ¶
type Requester interface {
// Send executes a request and returns the response.
Send(ctx context.Context, req Request) (Response, error)
// Protocol returns the protocol identifier (e.g., "http", "websocket", "grpc").
Protocol() string
}
Requester is the core interface for sending requests. Implemented by: HTTPClient, WebSocketClient, GRPCClient, GraphQLClient, etc.
type Response ¶
type Response interface {
// ID returns the unique response identifier.
ID() string
// RequestID returns the ID of the originating request.
RequestID() string
// Protocol returns the protocol type.
Protocol() string
// Status returns the response status.
Status() Status
// Headers returns the response headers.
Headers() Headers
// Body returns the response body.
Body() Body
// Timing returns timing information.
Timing() TimingInfo
// Metadata returns protocol-specific metadata.
Metadata() map[string]any
}
Response represents a protocol-agnostic response.
type ResponseStream ¶
type ResponseStream interface {
// Next returns the next response in the stream.
// Returns io.EOF when the stream is exhausted.
Next() (Response, error)
// Close closes the stream.
Close() error
}
ResponseStream provides streaming access to responses.
type ScriptContext ¶
type ScriptContext struct {
// Request provides access to request data and modification.
Request ScriptRequestContext
// Response provides access to response data.
Response ScriptResponseContext
// Environment provides access to environment variables.
Environment ScriptEnvironmentContext
// Variables provides access to all variables.
Variables map[string]any
}
ScriptContext provides the currier.* API to scripts.
type ScriptEngine ¶
type ScriptEngine interface {
// Execute runs a script with the given scope.
Execute(ctx context.Context, script string, scope ScriptScope) (any, error)
// RegisterFunction registers a Go function for use in scripts.
RegisterFunction(name string, fn any) error
// RegisterObject registers a Go object for use in scripts.
RegisterObject(name string, obj any) error
// Validate checks if a script is syntactically valid.
Validate(script string) error
}
ScriptEngine executes JavaScript scripts.
type ScriptEnvironmentContext ¶
type ScriptEnvironmentContext struct {
Name string
Get func(key string) string
Set func(key, value string)
}
ScriptEnvironmentContext provides the currier.environment.* API.
type ScriptRequestContext ¶
type ScriptRequestContext struct {
Method string
URL string
Headers map[string]string
Body any
SetHeader func(key, value string)
SetBody func(body any)
SetURL func(url string)
}
ScriptRequestContext provides the currier.request.* API.
type ScriptResponseContext ¶
type ScriptResponseContext struct {
Status int
StatusText string
Headers map[string]string
Body string
Time int64 // milliseconds
Size int64 // bytes
JSON func() (any, error)
}
ScriptResponseContext provides the currier.response.* API.
type ScriptScope ¶
type ScriptScope interface {
// Request returns the current request (may be nil in some contexts).
Request() Request
// Response returns the current response (may be nil in pre-request scripts).
Response() Response
// Variables returns the variable store.
Variables() VariableStore
// Environment returns the current environment.
Environment() Environment
// Log writes a message to the script log.
Log(msg string)
// SetRequest allows modifying the request (for pre-request scripts).
SetRequest(req Request)
// AddTestResult adds a test result.
AddTestResult(name string, passed bool, message string)
// GetTestResults returns all test results.
GetTestResults() []TestResult
}
ScriptScope provides context to scripts during execution.
type Status ¶
type Status interface {
// Code returns the numeric status code.
Code() int
// Text returns the status text.
Text() string
// IsSuccess returns true if the status indicates success.
IsSuccess() bool
// IsError returns true if the status indicates an error.
IsError() bool
}
Status represents a response status.
type StreamRequester ¶
type StreamRequester interface {
Requester
// SendStream executes a request and returns a stream of responses.
SendStream(ctx context.Context, req Request) (ResponseStream, error)
}
StreamRequester extends Requester for protocols that support streaming responses.
type TestDefinition ¶
TestDefinition represents a test assertion.
type TestResult ¶
TestResult represents the result of a test assertion.
type Theme ¶
type Theme interface {
// Name returns the theme name.
Name() string
// Background returns the background color.
Background() string
// Foreground returns the foreground color.
Foreground() string
// Primary returns the primary accent color.
Primary() string
// Secondary returns the secondary accent color.
Secondary() string
// Success returns the success color.
Success() string
// Warning returns the warning color.
Warning() string
// Error returns the error color.
Error() string
// Border returns the border color.
Border() string
// Muted returns the muted text color.
Muted() string
// Highlight returns the highlight color.
Highlight() string
}
Theme defines UI colors and styles.
type TimingInfo ¶
type TimingInfo struct {
// StartTime is when the request started.
StartTime time.Time
// EndTime is when the response was fully received.
EndTime time.Time
// DNSLookup is the time spent on DNS lookup.
DNSLookup time.Duration
// TCPConnection is the time spent establishing TCP connection.
TCPConnection time.Duration
// TLSHandshake is the time spent on TLS handshake.
TLSHandshake time.Duration
// TimeToFirstByte is the time until the first byte was received.
TimeToFirstByte time.Duration
// ContentTransfer is the time spent receiving the response body.
ContentTransfer time.Duration
// Total is the total request duration.
Total time.Duration
}
TimingInfo contains request/response timing information.
type ToolInfo ¶
type ToolInfo struct {
Name string
Description string
Parameters ToolParameters
}
ToolInfo provides metadata about a tool.
type ToolParameters ¶
type ToolParameters struct {
Type string // "object"
Properties map[string]ParameterInfo
Required []string
}
ToolParameters describes tool input parameters.
type VariableInfo ¶
type VariableInfo struct {
Value string
Scope VariableScope
}
VariableInfo contains variable metadata.
type VariableScope ¶
type VariableScope int
VariableScope indicates where a variable is defined.
const ( VariableScopeLocal VariableScope = iota VariableScopeRequest VariableScopeCollection VariableScopeEnvironment VariableScopeGlobal VariableScopeBuiltin )
func (VariableScope) String ¶
func (s VariableScope) String() string
type VariableStore ¶
type VariableStore interface {
// Get retrieves a variable value, checking all scopes.
Get(key string) (string, bool)
// Set sets a variable in the current scope.
Set(key, value string)
// SetLocal sets a request-scoped variable.
SetLocal(key, value string)
// SetEnvironment sets an environment-scoped variable.
SetEnvironment(key, value string)
// SetCollection sets a collection-scoped variable.
SetCollection(key, value string)
// Delete removes a variable.
Delete(key string)
// All returns all variables with their scopes.
All() map[string]VariableInfo
// Interpolate replaces variables in a string.
Interpolate(s string) (string, error)
}
VariableStore manages variables across scopes.
type View ¶
type View interface {
// Init initializes the view.
Init() tea.Cmd
// Update handles messages and returns the updated view.
Update(msg tea.Msg) (View, tea.Cmd)
// View renders the view to a string.
View() string
// Name returns the view name.
Name() string
// Focused returns true if the view is focused.
Focused() bool
// Focus gives focus to the view.
Focus() View
// Blur removes focus from the view.
Blur() View
}
View represents a TUI view/screen.