Skip to main content

vv_agent/
lib.rs

1//! VectorVein agent runtime, SDK, CLI, tools, memory, prompt, and workspace APIs.
2//!
3//! This crate exposes a stable Rust library surface for building and running
4//! agent workflows with built-in tool dispatch and vv-llm backed chat clients.
5
6pub mod agent;
7pub mod app_server;
8pub mod approval;
9pub mod budget;
10pub mod checkpoint;
11pub mod cli;
12pub mod config;
13pub mod constants;
14pub mod context;
15pub mod context_providers;
16pub mod event_store;
17pub mod events;
18pub mod execution_mode;
19pub mod guardrails;
20pub mod handoffs;
21pub mod integrations;
22pub mod interactive;
23pub mod llm;
24pub mod memory;
25pub mod model;
26pub mod model_settings;
27pub mod prompt;
28pub mod result;
29pub mod run_config;
30pub mod run_handle;
31pub mod runner;
32pub mod runtime;
33pub mod sessions;
34pub mod skills;
35pub mod tools;
36pub mod tracing;
37pub mod types;
38pub mod workspace;
39
40pub use agent::{Agent, InstructionProvider, ToolUseBehavior};
41pub use app_server::{
42    AgentResolutionRequest, AppServerHost, AppServerHostError, DefaultAppServerHost,
43    RunConfigResolutionRequest,
44};
45pub use approval::{
46    ApprovalBroker, ApprovalError, ApprovalFuture, ApprovalProvider, ApprovalRequest,
47};
48pub use budget::{
49    BudgetDimension, BudgetEnforcementBoundary, BudgetExhaustion, BudgetExhaustionReason,
50    BudgetUnavailableDimension, BudgetUnavailableReason, BudgetUsageSnapshot, HostCost,
51    HostCostMeter, RunBudgetLimits, RunBudgetLimitsBuilder, UnavailableMetricPolicy,
52    MAX_WIRE_INTEGER,
53};
54pub use checkpoint::{
55    canonical_json_bytes, event_payload_digest, model_request_digest, normalize_run_definition,
56    operation_request_digest, redact_run_definition, run_definition_digest, tool_request_digest,
57    validate_extension_namespace, validate_run_definition, AmbiguousModelPolicy,
58    AmbiguousToolPolicy, AppendOnceResult, CheckpointConfig, CheckpointError, CheckpointExtension,
59    CheckpointStatus, ClaimMode, EventCursor, IdempotentRunEventStore, InMemoryRunEventStore,
60    OperationKind, OperationState, ReconciliationDecision, ReconciliationDecisionKind,
61    ReconciliationError, ReconciliationProvider, ResumeObservation, ResumePolicy, ToolIdempotency,
62};
63pub use config::{
64    apply_resolved_model_limits, build_vv_llm_from_local_settings, build_vv_llm_settings,
65    decode_api_key, load_llm_settings_from_file, load_memory_summary_defaults_from_file,
66    resolve_model_endpoint, ConfigError, EndpointConfig, EndpointOption, MemorySummaryDefaults,
67    ResolvedModelConfig,
68};
69pub use context::{RunContext, ToolCallContext};
70pub use context_providers::{
71    assemble_context_fragments, collect_context_fragments, ContextBundle, ContextError,
72    ContextFragment, ContextProvider, ContextRequest, ContextSection,
73};
74pub use event_store::{
75    EventStoreError, JsonlRunEventStore, RunEventIter, RunEventReplayQuery, RunEventStore,
76};
77pub use events::{
78    AgentErrorPayload, EventId, RunEvent, RunEventPayload, RunEventVersion, ToolStatus,
79};
80pub use execution_mode::ExecutionMode;
81pub use guardrails::{GuardrailOutcome, InputGuardrail, OutputGuardrail};
82pub use handoffs::{handoff, Handoff};
83pub use interactive::{
84    create_interactive_session, InteractiveAgentClient, InteractiveSession,
85    InteractiveSessionError, InteractiveSessionEvent, InteractiveSessionOptions,
86    InteractiveSessionState,
87};
88pub use llm::{
89    EndpointTarget, LlmClient, LlmError, LlmRequest, LlmStreamCallback, ScriptStep,
90    ScriptStepCallback, ScriptedLlmClient, VvLlmClient,
91};
92pub use memory::{
93    sanitize_for_resume, CompactionExhaustedError, LocalSummary, MemoryError, MemoryFuture,
94    MemoryManager, MemoryManagerConfig, MemoryProvider, MemoryProviderResult, MemorySaveRequest,
95    MemorySaveResult, MemorySearchRequest, MemorySearchResult, SessionMemory, SessionMemoryConfig,
96    SessionMemoryEntry, SessionMemoryState, SummaryCallback,
97};
98pub use model::{ModelError, ModelProvider, ModelRef, ScriptedModelProvider, VvLlmModelProvider};
99pub use model_settings::{ModelSettings, ResponseFormat, RetryPolicy, RetrySettings, ToolChoice};
100pub use result::{ApprovalSnapshot, FinalOutputError, RunResult, RunState};
101pub use run_config::{RunConfig, ToolRegistryFactory};
102pub use run_handle::{RunHandle, RunHandleState, RunHandleStatus};
103pub use runner::{NormalizedInput, RunEventStream, Runner};
104pub use runtime::backends::{
105    run_checkpointed_cycle, CapabilityRef, CycleDispatchResult, CycleDispatcher,
106    DistributedBackend, DistributedCapabilities, DistributedCapabilityError,
107    DistributedCapabilityRegistry, DistributedCycleWorker, DistributedRunEnvelope,
108    DistributedToolPolicy, InlineBackend, ResolvedDistributedCapabilities, RuntimeExecutionBackend,
109    RuntimeRecipe, ThreadBackend, ToolsetRef,
110};
111pub use runtime::background_sessions::{
112    background_session_manager, BackgroundSessionAdoptOptions, BackgroundSessionListener,
113    BackgroundSessionManager, BackgroundSessionStartOptions, BackgroundSessionSubscription,
114};
115pub use runtime::checkpoint_codec_v2::{
116    checkpoint_v2_from_json, checkpoint_v2_to_json, decode_checkpoint, decode_checkpoint_bytes,
117    encode_checkpoint_v1, migrate_terminal_v1, DecodedCheckpoint,
118};
119pub use runtime::shell::{
120    build_shell_invocation, prepare_shell_execution, resolve_shell_invocation,
121    PreparedShellCommand, ShellInvocation,
122};
123pub use runtime::state::{Checkpoint, InMemoryStateStore, StateStore};
124pub use runtime::state_v2::{
125    CheckpointStoreV2, CheckpointV2, EventOutboxEntry, ExtensionStateEntry, OperationError,
126    OperationJournalEntry,
127};
128pub use runtime::stores::memory_v2::InMemoryCheckpointStoreV2;
129pub use runtime::stores::redis::RedisStateStore;
130pub use runtime::stores::redis_v2::RedisCheckpointStoreV2;
131pub use runtime::stores::sqlite::SqliteStateStore;
132pub use runtime::stores::sqlite_v2::SqliteCheckpointStoreV2;
133pub use runtime::sub_task_manager::{
134    ManagedSubTask, ManagedSubTaskSnapshot, SubTaskManager, SubTaskSessionAttachment,
135    SubTaskTurnSnapshot,
136};
137pub use runtime::{
138    _register_sub_agent_session, _unregister_sub_agent_session, continue_sub_agent_session,
139    get_sub_agent_session, register_sub_agent_session, steer_sub_agent_session,
140    sub_agent_session_registry, subscribe_sub_agent_session, unregister_sub_agent_session,
141    AfterLlmEvent, AfterToolCallEvent, AgentRuntime, BeforeCycleMessageProvider, BeforeLlmEvent,
142    BeforeLlmPatch, BeforeMemoryCompactEvent, BeforeToolCallEvent, BeforeToolCallPatch,
143    CancellationToken, CancelledError, CycleRunRequest, CycleRunner, ExecutionContext,
144    InterruptionMessageProvider, RuntimeEventHandler, RuntimeHook, RuntimeHookManager,
145    RuntimeRunControls, StreamCallback, SubAgentSession, SubAgentSessionListener,
146    SubAgentSessionRegistry, SubAgentSessionUnsubscribe, ToolCallRunner, ToolRunOutcome,
147    ToolRunRequest, MAX_PROMPT_TOO_LONG_RETRIES, MAX_PTL_RETRIES,
148};
149pub use sessions::{
150    session_store_conformance, MemorySession, MemorySessionStore, RedisSessionStore, Session,
151    SessionItem, SessionStore, SqliteSessionStore,
152};
153pub use tools::{
154    build_default_registry, dispatch_tool_call, AgentTool, AgentToolBuilder, ApprovalDecision,
155    ApprovalPolicy, ApprovalPredicate, ApprovalRequirement, BackgroundAgentTask,
156    BackgroundAgentTaskBuilder, BackgroundAgentTaskHandle, BackgroundAgentTaskSnapshot,
157    FunctionTool, StaticTool, Tool, ToolApprovalRule, ToolContext, ToolError, ToolExecutor,
158    ToolExposure, ToolFuture, ToolHandler, ToolNotFoundError, ToolOrchestrator, ToolOutput,
159    ToolPolicy, ToolRegistry, ToolRunContext, ToolRunOptions, ToolSpec, ToolSpecContext,
160    ToolSpecExecutor, ToolSpecKind,
161};
162pub use tracing::{JsonlTraceExporter, Span, TraceSink};
163pub use types::{
164    AgentResult, AgentStatus, AgentTask, CacheUsage, CacheUsageStatus, CompletionReason,
165    CycleRecord, CycleStatus, LLMResponse, Message, MessageRole, NoToolPolicy, SubAgentConfig,
166    SubAgentConfigValidationError, SubTaskOutcome, SubTaskRequest, TaskTokenUsage, TokenUsage,
167    ToolCall, ToolDirective, ToolExecutionResult, ToolResultStatus, UsageSource,
168    INVALID_SUB_AGENT_MODEL_CODE, INVALID_SUB_AGENT_MODEL_MESSAGE,
169    INVALID_SUB_AGENT_SYSTEM_PROMPT_CODE, INVALID_SUB_AGENT_SYSTEM_PROMPT_MESSAGE,
170};
171pub use workspace::{
172    validate_portable_exclude_pattern, DiscoveryFilteredWorkspaceBackend, FileInfo,
173    LocalWorkspaceBackend, MemoryWorkspaceBackend, PortableRegexError, S3WorkspaceBackend,
174    S3WorkspaceConfig, WorkspaceBackend, INVALID_EXCLUDE_FILES_PATTERN_CODE,
175    INVALID_EXCLUDE_FILES_PATTERN_MESSAGE,
176};