antigravity library

The Native Dart SDK for Google Antigravity.

Classes

Agent
A high-level agent coordinator for the Google Antigravity SDK.
AgentConfig
Configuration schema for setting up an Agent in the Google Antigravity SDK.
ArgumentsHook
A mapping hook that decodes tool arguments from a JSON string and encodes them back to one.
AskQuestionEntry
A single question with predefined options.
AskQuestionHook
Hook that prompts the user to answer questions asked by the agent.
AskQuestionInteractionSpec
Interaction spec for an ask-question dialog.
AskQuestionOption
Option for an AskQuestionEntry.
Audio
Audio content attachment.
AutoPolicy
A policy rule enabling auto policy mode safety evaluation.
BaseLocalAgentConfig
Base configuration class for local harness agent configurations.
BinaryDiscovery
A utility to search for the pre-existing system binary dynamically within the Google Antigravity SDK.
BudgetConfig
Session-level budget limits and caps.
BuiltinToolListHook
Coerces deprecated tool spellings in a serialized builtin tool list.
CapabilitiesConfig
General agent capability configuration.
ChatResponse
The response to a single conversation turn.
CompactionConfig
Context compaction policy for an agent session.
Connection
A live session with an agent backend in the Google Antigravity SDK.
ConnectionStrategy
Abstract strategy for establishing a Connection in the Google Antigravity SDK.
Conversation
Manages a high-level stateful interaction between a user and an agent in the Google Antigravity SDK.
CustomSystemInstructions
Completely replaces system instructions.
DebugConfig
Configuration for client-side and server-side debugging and observability.
DecideHook<T>
Read-only, blocking hook for policy decisions.
Document
Document content attachment.
EditFileResult
Structured result from an edit_file tool execution.
ExtractedMedia
A tool result split into its non-media value and its media attachments.
FileChange
A single filesystem change detected by a file-watching trigger.
FindFileResult
Structured result from a find_file tool execution.
FunctionDecideHook<T>
Helper class to adapt functions into DecideHooks.
FunctionInspectHook<T>
Helper class to adapt functions into InspectHooks.
FunctionStopHook
Helper class to adapt functions into StopHooks.
FunctionTransformHook<T, R>
Helper class to adapt functions into TransformHooks.
GeminiAPIEndpoint
Endpoint for the Gemini Developer API.
GeminiModelOptions
Gemini-specific model options.
GenerateImageResult
Structured result from a generate_image tool execution.
HandshakeReader
Helper class to read handshake payload statefully.
HarnessDownloader
A utility to dynamically download the official precompiled localharness binary from PyPI wheels matching the host CPU architecture and OS.
Hook
Base interface for all Hooks in the Google Antigravity SDK.
HookContext
Base context for hooks to share state within the Google Antigravity SDK.
HookMapper
Mapper helper to map Hook objects for serialization.
HookResult
Result of a decision hook execution.
HookRunner
Coordinates registration and dispatch of lifecycle hooks.
Image
Image content attachment.
InlineSkill
An in-memory skill definition.
InspectHook<T>
Read-only, non-blocking hook for observability.
LevelMapper
Mapper helper to map Level objects for serialization.
ListDirectoryEntry
A single entry in a list_directory result.
ListDirectoryResult
Structured result from a list_directory tool execution.
LiteRTAgentConfig
Agent configuration for executing on-device local models via LiteRT.
LiteRTConnectionStrategy
Strategy for establishing connection to a local LiteRT loopback API server.
LocalAgentConfig
Configuration for the local harness backend.
LocalConnection
Live session connection to the local harness.
LocalConnectionStrategy
Strategy that launches the localharness binary and connects to it over a WebSocket.
LocalOpenAIAgentConfig
OpenAI-compatible local completions API configuration.
LocalOpenAIConnectionStrategy
Strategy for establishing connection to an external local OpenAI completions API (Ollama/LM Studio).
McpBridge
Discovers tools from configured MCP servers and exposes them as native Tool instances.
McpServerConfig
Abstract base for all MCP server configurations.
McpStdioServer
Configuration for an MCP server connected via stdio.
McpStreamableHttpServer
Configuration for an MCP server connected via Streamable HTTP.
McpTool
A tool discovered from an MCP server, wrapped in the SDK's Tool interface.
MediaContent
Base class for multimedia content attachments.
ModelAPIRetryConfig
Configuration for API retry behavior with exponential backoff.
ModelEndpoint
Base class for model endpoint authentication & routing.
ModelOutputRetryConfig
Configuration for model output retry behavior.
ModelTarget
Configuration for a single model.
OnCompactionHook
Invoked when a conversation context compaction event occurs.
OnInteractionHook
Invoked when the agent needs user interaction/questions answered.
OnSessionEndHook
Invoked when the agent session ends.
OnSessionStartHook
Invoked when the agent session starts.
OnToolErrorHook
Invoked when a tool fails, allowing recovery or transformation of the exception.
OperationContext
Context scoped to a single operation (e.g. a tool call) in the Google Antigravity SDK.
Policy
A single tool call policy rule in the Google Antigravity SDK.
PolicyDecideHook
A security policy decision hook in the Google Antigravity SDK.
PolicyMapper
Mapper helper to map Policy objects for serialization.
PostStepHook
Invoked when a step completes (internal).
PostToolCallHook
Invoked after a tool call completes successfully.
PostTurnHook
Invoked after a conversation turn successfully completes.
PreStepHook
Invoked when a step is first seen in the stream (internal).
PreToolCallDecideHook
Invoked before a tool call is executed to decide if it is allowed.
PreTurnHook
Invoked before a conversation turn starts.
QuestionHookResult
Result of an interaction, containing a list of responses.
QuestionResponse
Individual response for an AskQuestionEntry.
ReadUrlContentResult
Structured result from a read_url_content tool execution.
RetryConfig
Combined retry configuration for model API calls and output validation.
RunCommandConfig
Configuration for the builtin run_command tool.
RunCommandResult
Structured result from a run_command tool execution.
SandboxStatus
OS command sandbox (exebox) status reported by the harness.
SearchDirectoryResult
Structured result from a search_directory tool execution.
SearchWebResult
Structured result from a search_web tool execution.
SessionContext
Context scoped to an entire agent session in the Google Antigravity SDK.
SlashCommand
Slash command prompt input.
Spinner
A lightweight terminal spinner for async processing feedback.
Step
Represents a single execution step or lifecycle event emitted during an agent trajectory.
StopArgs
Arguments delivered to a Stop hook when the root turn reaches idle.
StopHook
Invoked when the root trajectory reaches fully idle to decide whether to stop or continue.
StopHookResult
Result returned by a Stop lifecycle hook.
StreamChunk
Base class for real-time semantic chunks yielded while a chat response streams.
SubagentCapabilities
Capabilities configuration for subagents.
SubagentConfig
Configuration for a static subagent.
SubagentInheritSkillsConfig
Inherits all parent skills unless filtered by skillNames.
SubagentNoneSkillsConfig
Disables skills and the lookup_skill tool for a subagent.
SubagentOverrideSkillsConfig
Replaces inherited skills with explicit paths or inline definitions.
SubagentSkillsConfig
How a subagent inherits, disables, or replaces its parent's skills.
SubagentSkillsOption
A subagent skills setting accepted by SubagentConfig.skillsConfig: a SubagentSkillsConfig, or one of its three mode types directly.
SystemInstructions
Sealed representation of system instructions.
SystemInstructionSection
A named section to append to the system instructions.
TemplatedSystemInstructions
Appends sections to default system instructions.
Text
A delta chunk holding a piece of the model's text output.
Thought
A delta chunk holding a piece of the model's internal reasoning.
Tool
Represents a custom tool that can be executed by an agent in the Google Antigravity SDK.
ToolCall
A request to execute a tool.
ToolConfirmationHook
Hook that prompts the user for confirmation before executing a tool.
ToolContext
Conversation-aware context for custom tools.
ToolMapper
Mapper helper to map Tool objects for serialization.
ToolOutputTruncationConfig
Configuration for truncating large tool outputs.
ToolResult
The result of a single tool execution.
ToolRunner
Registry and executor for custom tools in the Google Antigravity SDK.
TransformHook<T, R>
Modifying, blocking hook for data transformation.
TriggerContext
Execution handle and context provided to every background trigger at startup in the Google Antigravity SDK.
TriggerMapper
Mapper helper to map Trigger objects for serialization.
TriggerRunner
Manages registration, startup, and shutdown of background triggers in the Google Antigravity SDK.
TurnContext
Context scoped to a single interaction turn in the Google Antigravity SDK.
UnmappedHook
A mapping hook that excludes a field from serialization.
UsageMetadata
Token usage metadata from the model API.
VertexEndpoint
Endpoint for the Vertex AI backend.
Video
Video content attachment.
WorkflowProgress
Experimental metadata for a run_workflow tool step.
WorkflowResult
Experimental workflow result with all standard response accessors.

Enums

AgentBehavior
Operational execution behavior for an agent or subagent.
BudgetScope
Which tokens count toward a budget limit.
BuiltinSlashCommandName
Supported built-in slash commands.
BuiltinTools
Identifiers for common connection-provided builtin tools.
Decision
Outcomes that a policy can produce in the Google Antigravity SDK.
FileChangeKind
Kind of filesystem change detected by a file-watching trigger.
LiteRTBackend
Hardware backend options for local LiteRT model execution.
ModelType
Discriminator for model purpose.
ServiceTier
Service tier for Gemini model inference.
SessionContinuationMode
Mode for establishing a connection to an agent session.
StepSource
Source of a step.
StepStatus
Status of a step.
StepTarget
Target of a step interaction.
StepType
High-level type of a step.
StopDecision
Decision returned by a Stop lifecycle hook.
StopReason
Reason why the execution turn stopped.
ThinkingLevel
Thinking level for Gemini models that support extended thinking.

Extensions

StepSourceX on StepSource
Extension methods for StepSource providing idiomatic boolean checks.
StepStatusX on StepStatus
Extension methods for StepStatus providing idiomatic boolean checks.
StepX on Step
Extension methods for Step providing idiomatic turn and state checks.

Constants

defaultImageGenerationModel → const String
Default image generation model used by built-in image creation tools.
defaultModel → const String
Default generative text model used when no model target is explicitly specified.
deprecatedStartSubagentToolName → const String
Deprecated wire spelling of BuiltinTools.invokeSubagent.
maxGeminiOutputTokens → const int
Upper bound for GeminiModelOptions.maxOutputTokens (protobuf int32 max).
packageVersion → const String
The current version of the Google Antigravity Dart SDK.
supportedAudioMimes → const Set<String>
Audio MIME types accepted by Audio.
supportedDocumentMimes → const Set<String>
Document MIME types accepted by Document.
supportedImageMimes → const Set<String>
Image MIME types accepted by Image.
supportedVideoMimes → const Set<String>
Video MIME types accepted by Video.
workspaceOnlyPolicyName → const String
Wire name of the workspace-only rule, skipped by dynamic evaluation.

Properties

defaultAppDataDir → String
Default local app data directory location.
no setter

Functions

allow(dynamic tool, {List<String>? mcpTools, FutureOr<bool> when(ToolCall toolCall)?, String name = ''}) → dynamic
Creates an APPROVE policy.
allowAll() → Policy
Creates a policy that approves all tool calls without confirmation. For local agents, also disables workspace containment unless workspaceOnly rules are present.
askUser(dynamic tool, {List<String>? mcpTools, AskUserHandler? handler, FutureOr<bool> when(ToolCall toolCall)?, String name = '', String reason = ''}) → dynamic
Creates an ASK_USER policy.
askUserHandler(ToolCall tc, [String? reason]) → Future<bool>
A policy handler that prompts the user for confirmation before executing a tool.
asyncInput(String prompt) → Future<String>
Helper to read input asynchronously from standard input.
auto({String name = 'auto', AskUserHandler? handler, String? model}) → AutoPolicy
Creates a policy enabling auto policy mode safety evaluation.
confirmRunCommand({FutureOr<bool> handler(ToolCall toolCall)?}) → List<Policy>
Denies or asks confirmation for running commands, allowing everything else.
deny(dynamic tool, {List<String>? mcpTools, FutureOr<bool> when(ToolCall toolCall)?, String name = '', String reason = ''}) → dynamic
Creates a DENY policy.
denyAll() → Policy
Creates a policy that denies all tool calls.
enforce(List policies, {List<McpServerConfig>? mcpServers}) → PreToolCallDecideHook
Compiles list of Policies into a high-performance PreToolCallDecideHook.
every(Duration interval, FutureOr<void> callback(TriggerContext context)) → Trigger
Helper factory that creates a trigger running a callback on a fixed interval.
executeAskUser(Policy policy, ToolCall toolCall, {String reason = ''}) → Future<bool>
Invokes policy's ask-user handler, passing reason when the callback accepts it.
extractMediaFromResult(dynamic value) → ExtractedMedia
Splits MediaContent attachments out of a tool result value.
extractToolResult(Map<String, dynamic> stepUpdate) → dynamic
Returns the typed result of a built-in tool from a harness stepUpdate.
flattenPolicies(List policies) → List<Policy>
Flattens policies into a single list, expanding one level of nested iterables.
formatStepSpinnerMessage(Step step) → String?
Formats CLI interactive step spinner messages for single, concurrent, compaction, or reasoning steps.
isPathInWorkspace(String targetPath, String workspacePath) → bool
Returns true if targetPath canonicalizes strictly within workspacePath.
makeStepId(Object? trajectoryId, Object? stepIndex) → String?
Creates a unique step identifier from trajectory ID and step index.
normalizeBuiltinToolName(String name, {String? serverName}) → String
Normalizes deprecated builtin tool name aliases.
normalizeWorkspacePath(String path) → String
Normalizes wire URIs, expands user home ~, and resolves relative paths to clean absolute filesystem paths.
normalizeWorkspacePaths(dynamic workspaces, {bool defaultToCwd = false}) → List<String>
Coerces sequence workspace paths and normalizes each entry.
onFileChange(String path, FutureOr<void> callback(TriggerContext context, List<FileChange> changes)) → Trigger
Helper factory that creates a trigger watching for filesystem changes at the specified path.
resolveAgentBehaviorAndWarn({AgentBehavior? agentBehavior, AgentBehavior? agentMode, List<BuiltinTools>? enabledTools, required String targetName, required Logger logger}) → AgentBehavior
Helper to resolve AgentBehavior from new/legacy parameters and log a warning if interactive tools are enabled without interactive mode.
runInteractiveLoop(AgentConfig config, {Agent agentFactory(AgentConfig config)?}) → Future<void>
Runs an interactive CLI loop for debugging and development.
safeDefaults(AskUserHandler handler) → List<Policy>
Creates a list of safe default policies (allowing read-only, asking for everything else).
sanitizeTerminalText(Object? text) → String
Strips ANSI escape sequences and control characters to prevent UI spoofing.
toPolicyConfigProto(List policies) → ({Map<String, dynamic> config, Map<String, Policy> dynamicPolicies})
Serializes policies into the localharness policy_config map.
workspace(String workspacePath) → Policy
Creates a wildcard allow rule that matches non-file tools and file tools inside workspacePath.
workspaceOnly(List<String> workspaces) → List<Policy>
Restricts file manipulation tools to specific workspace directories.

Typedefs

AgentMode = AgentBehavior
Backward compatibility alias for AgentBehavior.
AskUserHandler = FutureOr<bool> Function(ToolCall toolCall)
An ask-user handler.
ContentPrimitive = dynamic
Union representation of dynamic prompt inputs.
ToolHandler = FutureOr Function(Map<String, dynamic> arguments, ToolContext? context)
Signature for a custom tool execution callback in the Google Antigravity SDK.
Trigger = FutureOr<void> Function(TriggerContext context)
A Trigger is any function that accepts a TriggerContext and runs asynchronously.

Exceptions / Errors

AntigravityBinaryNotFoundException
Exception thrown when the pre-existing system binary is not found at any search path in the Google Antigravity SDK.
AntigravityCancelledException
Exception thrown when an active turn is cancelled programmatically.
AntigravityConnectionException
Base connection exception for Google Antigravity SDK.
AntigravityExecutionException
Exception thrown when the agent execution encounters a terminal error.
AntigravityValidationException
Validation exception at the SDK boundary.
ToolExecutionException
Exception thrown when a tool execution fails, carrying tool metadata.