Expand description
Modules§
- atomic_
fs - Atomic file-write helpers shared across workspace crates.
- prelude
- Convenience re-exports for common Swink-Agent types.
- stream_
assembly - Narrow public module for shared stream-assembly helpers.
Structs§
- Agent
- Stateful wrapper over the agent loop.
- Agent
Config - A fully serializable snapshot of agent configuration.
- Agent
Context - The immutable snapshot passed into each loop turn.
- Agent
Handle - A handle to a spawned agent task.
- AgentId
- Unique identifier assigned to every
crate::Agenton construction. - Agent
Loop Config - Configuration for the agent loop.
- Agent
Mailbox - A per-agent inbox for receiving messages.
- Agent
Options - Configuration options for constructing an
Agent. - Agent
Orchestrator - Manages a set of named agents with parent/child hierarchies and supervision.
- Agent
Registry - Thread-safe registry that maps string names to
AgentRefhandles. - Agent
Request - A message sent to a running agent via its request channel.
- Agent
Result - The value returned by non-streaming invocations.
- Agent
State - Observable state of the agent.
- Agent
Tool Result - The result of a tool execution.
- Assistant
Message - A message from the assistant (LLM response).
- Auth
Config - Per-tool declaration of authentication requirements.
- Bash
Tool - Built-in tool that executes a shell command.
- Cache
Config - Configuration for provider-side context caching.
- Cache
Config Data - Serializable representation of
CacheConfig. - Cache
State - Tracks the cache lifecycle across turns.
- Catalog
Preset - Channel
Message Provider - A
MessageProviderbacked by tokio unbounded mpsc channels. - Checkpoint
- A serializable snapshot of agent conversation state.
- Compaction
Report - Result of a context transformation pass.
- Composed
Message Provider - A
MessageProviderthat combines two providers, draining both on each poll. - Context
Version - A snapshot of messages captured at a point in time.
- Context
Version Meta - Metadata for a stored context version (returned by
list_versions). - Core
Display Message - A message converted to a frontend-friendly format.
- Cost
- Per-category and total cost breakdown (floating-point currency values).
- Custom
Message Registry - Registry for deserializing
CustomMessagetypes from JSON. - Default
Retry Strategy - Exponential back-off retry strategy with optional jitter.
- Default
Supervisor - A supervisor that restarts on retryable errors and stops otherwise.
- Default
Token Counter - Default token counter using the
chars / 4heuristic. - Downcast
Error - Error returned when downcasting an
AgentMessageto a concrete custom message type fails. - Edit
File Tool - Built-in tool for making precise, surgical edits to a file.
- Emission
- A structured event emitted by an agent, tool, or callback.
- FnTool
- A tool built entirely from closures and configuration, implementing
AgentToolwithout requiring a custom struct. - InMemory
Version Store - In-memory implementation of
ContextVersionStore. - Loop
Checkpoint - A serializable snapshot of the agent loop’s in-flight state.
- Message
Sender - A clonable handle for pushing messages into a
ChannelMessageProvider. - Model
Capabilities - Per-model capability flags and limits.
- Model
Catalog - Model
Connection - Model
Connections - Model
Connections Builder - Incrementally builds a
ModelConnectionsvalue. - Model
Fallback - An ordered sequence of fallback models to attempt when the primary model (and its retries) are exhausted.
- Model
Spec - Identifies the target model for a request.
- Noop
Tool - A placeholder tool that returns an error message when invoked.
- Orchestrated
Handle - Handle to a spawned orchestrated agent.
- Policy
Context - Shared read-only context available to every policy evaluation.
- Preset
Catalog - Provider
Catalog - Read
File Tool - Built-in tool that reads a file and returns its contents.
- Retry
Config - Serializable representation of
DefaultRetryStrategyparameters. - Serialized
Custom Message - A lightweight
CustomMessagestand-in that holds pre-serialized data. - Serialized
Messages - The result of splitting an
AgentMessageslice into LLM and custom vectors, plus ordering metadata. - Session
State - Key-value store with change tracking for session-attached structured data.
- Sliding
Window Transformer - Built-in sliding window context transformer with compaction reporting.
- State
Delta - Record of mutations since the last flush.
- Stream
Middleware - Intercepts the output stream from a wrapped
StreamFn. - Stream
Options - Per-call configuration passed through to the LLM provider.
- Stream
Options Config - Serializable representation of
StreamOptions. - SubAgent
- A tool that wraps an agent, enabling multi-agent composition.
- Subscription
Id - Unique identifier for an event subscription.
- Thinking
Budgets - Optional per-level token budget overrides for providers that support token-based reasoning control.
- Tool
Approval Request - Information about a tool call pending approval.
- Tool
Call Summary - Lightweight view of a pending tool call, exposed to policy callbacks.
- Tool
Dispatch Context - Combined context for
PreDispatchpolicies. - Tool
Exec Metrics - Timing and outcome data for a single tool execution within a turn.
- Tool
Filter - Filters tools at registration time using pattern-based allow/reject lists.
- Tool
Metadata - Optional organizational metadata for an
AgentTool. - Tool
Middleware - Intercepts
execute()on a wrappedAgentTool. - Tool
Result Message - The result of a tool execution, sent back to the LLM.
- Tool
Schema - Common tool metadata extracted from
AgentToolinstances. - Transfer
Chain - Safety mechanism tracking the ordered sequence of agents in a transfer chain.
- Transfer
Signal - Data structure carrying all information needed for a target agent to continue a conversation after a handoff.
- Transfer
ToAgent Tool - Tool that signals the agent loop to transfer conversation to another agent.
- Turn
Metrics - Metrics snapshot emitted at the end of each agent loop turn.
- Turn
Policy Context - Per-turn context for
PostTurnpolicies. - Turn
Snapshot - A point-in-time snapshot of agent state at a turn boundary.
- Usage
- Token usage counters for an LLM response.
- User
Message - A message from the user.
- Versioning
Transformer - A context transformer that captures dropped messages as versioned snapshots.
- Write
File Tool - Built-in tool that writes content to a file, creating parent directories as needed.
Enums§
- Agent
Error - The top-level error type for the swink agent.
- Agent
Event - Fine-grained lifecycle event emitted by the agent loop.
- Agent
Message - The top-level message type that wraps either an LLM message or a custom application-defined message.
- Agent
Status - The lifecycle status of a spawned agent task.
- ApiVersion
- Approval
Mode - Controls whether the approval gate is active.
- Approval
Mode Config - Serializable mirror of
ApprovalMode. - Assistant
Message Delta - A typed incremental update during streaming, used in
MessageUpdateevents. - Assistant
Message Event - An incremental event emitted by a
StreamFnimplementation. - Auth
Mode - Auth
Scheme - How a resolved credential is attached to the outbound request.
- Cache
Hint - Hint attached to messages indicating the desired cache action.
- Cache
Strategy - Provider-agnostic caching configuration.
- Content
Block - The atomic unit of all message content.
- Credential
- A secret value with type information for tool authentication.
- Credential
Error - Errors from credential resolution.
- Credential
Type - Credential type discriminant for mismatch checking (FR-018).
- Display
Role - Role of a message for display styling.
- Follow
UpMode - Controls how follow-up messages are drained from the queue.
- Follow
UpMode Config - Serializable mirror of
FollowUpMode. - Image
Source - Source for image data.
- LlmMessage
- A discriminated union of the three LLM message roles.
- Message
Slot - Tracks the original position of each message in the sequence.
- Policy
Verdict - Outcome of a policy evaluation for
PreTurn,PostTurn, andPostLoopslots. - PreDispatch
Verdict - Outcome of a
PreDispatchpolicy evaluation. - Preset
Capability - Preset
Status - Provider
Kind - Resolved
Credential - Minimal secret value delivered to a tool after credential resolution.
- Steering
Mode - Controls how steering messages are drained from the queue.
- Steering
Mode Config - Serializable mirror of
SteeringMode. - Stop
Reason - Indicates why assistant generation ended.
- Stream
Error Kind - Structured classification of stream errors.
- Stream
Transport - Transport protocol for streaming responses.
- Supervisor
Action - What the supervisor decides after an agent error.
- Thinking
Level - Reasoning depth for models that support configurable thinking.
- Tool
Approval - Result of the approval gate for a tool call.
- Tool
Execution Policy - Controls how tool calls within a single turn are dispatched.
- Tool
Pattern - A pattern for matching tool names.
- Transfer
Error - Error type for transfer chain safety violations.
- Turn
EndReason - Why a turn ended.
Constants§
- DEFAULT_
PLAN_ MODE_ ADDENDUM - Fallback addendum appended in plan mode when no custom addendum is set.
Traits§
- Agent
Tool - A tool that can be invoked by the agent loop.
- Async
Context Transformer - Async context transformer for operations that require I/O (summary fetching, RAG retrieval, database lookups) before transforming the message context.
- Checkpoint
Store - Async trait for persisting and loading agent checkpoints.
- Context
Summarizer - Pre-computed summarization of dropped context messages.
- Context
Transformer - Context
Version Store - Pluggable storage for context version snapshots.
- Credential
Resolver - Orchestrator for credential resolution — checks validity, triggers refresh, deduplicates concurrent requests.
- Credential
Store - Pluggable credential storage abstraction.
- Custom
Message - Trait for application-defined custom message types.
- Into
Display Messages - Convert message types into display-ready representations.
- Into
Tool - Convenience trait to convert a tool implementation into
Arc<dyn AgentTool>. - Json
Schema - A type which can be described as a JSON Schema document.
- Message
Converter - Callbacks for provider-specific message conversion.
- Message
Provider - Provides steering and follow-up messages to the agent loop.
- Metrics
Collector - Async observer that receives structured metrics at the end of each turn.
- Post
Loop Policy - Slot 4: Evaluated after the inner loop exits, before follow-up polling.
- Post
Turn Policy - Slot 3: Evaluated after each completed turn.
- PreDispatch
Policy - Slot 2: Evaluated per tool call, before approval and execution.
- PreTurn
Policy - Slot 1: Evaluated before each LLM call.
- Retry
Strategy - Determines whether a failed model call should be retried and, if so, how long to wait before the next attempt.
- Stream
Fn - The pluggable boundary between the harness and LLM providers.
- Supervisor
Policy - Policy that determines how to handle agent failures.
- Token
Counter - Pluggable token counting strategy.
- Tool
Execution Strategy - Fully custom tool execution strategy.
- Tool
Parameters - Trait for types that can produce a JSON Schema describing their fields.
Functions§
- accumulate_
message - Reconstruct a finalized
AssistantMessagefrom a collected list of stream events. - agent_
loop - Start a new agent loop with prompt messages.
- agent_
loop_ continue - Resume an agent loop from existing messages.
- builtin_
tools - Returns all built-in tools (
BashTool,ReadFileTool,WriteFileTool) wrapped inArc, ready to pass to anAgent. - calculate_
cost - Compute monetary cost from token usage using catalog pricing data.
- clone_
messages_ for_ send - Snapshot a slice of
AgentMessageinto fullySend + Clone-safe values. - convert_
messages - Generic message conversion that iterates
AgentMessagevalues, skips non-LLM variants, and delegates to theMessageConverterimplementation for format-specific construction. - default_
convert - Default message converter: pass LLM messages through, drop custom messages.
- deserialize_
custom_ message - Deserialize a
CustomMessagefrom a JSON envelope produced byserialize_custom_message. - estimate_
tokens - Estimate token count using
chars / 4for LLM messages, 100 flat for custom. - extract_
tool_ schemas - Extract tool metadata from a slice of
AgentTooltrait objects. - from_
fns - Create a
MessageProviderfrom two closures. - is_
context_ overflow - Estimate whether the context exceeds the model’s maximum context window.
- message_
channel - Create a channel-backed
MessageProviderand its pairedMessageSender. - model_
catalog - now_
timestamp - Get the current Unix timestamp in seconds.
- prefix_
chars - Return the longest prefix containing at most
max_charsUnicode scalar values. - redact_
sensitive_ values - Scan a
serde_json::Valuefor common secret patterns and replace matching string values with"[REDACTED]". - restore_
messages - Reconstruct an interleaved
Vec<AgentMessage>from separate LLM and custom vectors, usingMessageSlotordering metadata. - restore_
single_ custom - Restore a single custom-message envelope via a registry.
- run_
policies - Evaluate
PreTurn,PostTurn, orPostLooppolicies in order. - run_
post_ loop_ policies - Evaluate
PostLooppolicies in order. - run_
post_ turn_ policies - Evaluate
PostTurnpolicies in order. - run_
pre_ dispatch_ policies - Evaluate
PreDispatchpolicies for a single tool call. - sanitize_
incomplete_ tool_ calls - Scrub incomplete
ToolCallblocks in an assistant message so it can safely be replayed to a provider. - schema_
for - Generate a JSON Schema as a
serde_json::Valuefrom a type implementingJsonSchema. - selective_
approve - Wraps an approval callback so that only tools with
requires_approval == truego through the inner callback. All other tools are auto-approved. - send_to
- Send a message to a named agent via its steering queue.
- serialize_
custom_ message - Serialize a
CustomMessageinto a portable JSON envelope. - serialize_
messages - Split a slice of
AgentMessageinto separate LLM and custom vectors with ordering metadata. - sliding_
window Deprecated - Create a sliding-window context compaction function.
- suffix_
chars - Return the longest suffix containing at most
max_charsUnicode scalar values. - unknown_
tool_ result - Build an error result for an unknown tool name.
- validate_
schema - Validate that a JSON value is a valid JSON Schema document.
- validate_
tool_ arguments - Validate tool call arguments against a JSON Schema.
- validation_
error_ result - Build an error result listing all validation errors.
Type Aliases§
- Agent
Ref - A shareable, async-safe handle to an
Agent. - Async
Transform Future - A boxed future returned by an
AsyncContextTransformer. - Checkpoint
Future - A boxed future returned by
CheckpointStoremethods. - Credential
Future - Boxed async result used by credential traits.
- Event
Forwarder Fn - A function that receives forwarded agent events.
- Metrics
Future - OnRaw
Payload - Callback for observing raw SSE data lines before event parsing.
- Priority
Fn - Callback that assigns an integer priority to a tool call.
- Tool
Execution Strategy Future - A boxed future returned by a
ToolExecutionStrategy. - Tool
Future - A boxed future returned by
AgentToolexecution.
Derive Macros§
- Json
Schema - Derive macro for
JsonSchematrait.