execute/2 is the primary live surface for callers that want incremental
output. It returns a lazy Stream.resource/3 enumerable. Enumeration starts a
supervised CliSubprocessCore.Session, subscribes with a tagged {pid, reference} mailbox channel, and projects normalized core events into SDK
structs.
Event Types
The SDK emits:
AntigravityCliSdk.Types.InitEventAntigravityCliSdk.Types.MessageEventAntigravityCliSdk.Types.ResultEventAntigravityCliSdk.Types.ErrorEvent
agy --print emits plain text, not NDJSON. The core Antigravity provider
profile treats each non-empty stdout line as an assistant delta. The SDK
accumulates those deltas and attaches the final text to the result event.
Basic Use
AntigravityCliSdk.execute("Reply with exactly: OK")
|> Enum.to_list()For user-facing output:
"Reply with exactly: OK"
|> AntigravityCliSdk.execute(%AntigravityCliSdk.Options{
dangerously_skip_permissions: true
})
|> Enum.each(fn
%AntigravityCliSdk.Types.MessageEvent{content: text} -> IO.write(text)
%AntigravityCliSdk.Types.ResultEvent{result: result} -> IO.puts("\n#{result}")
%AntigravityCliSdk.Types.ErrorEvent{} = error -> IO.inspect(error)
_event -> :ok
end)Lifecycle
execute/2validatesAntigravityCliSdk.Options.ArgBuilderrendersagy --print <prompt>and supported provider flags.Runtime.CLIstarts a core session through the Antigravity provider profile.Streamreceives tagged core events and projects them into SDK event structs.- The stream closes the session when enumeration ends or when a result/error event arrives.
The SDK does not expose untagged subscriber delivery. Internal stream
subscriptions always use {self(), ref} so mailbox extraction is bounded to
the current stream resource.
Errors
Launch failures return error events or {:error, reason} depending on which
API you call:
execute/2projects runtime failures intoErrorEventvalues when the session starts and then fails.run/2consumes the stream and returns{:ok, text}or{:error, reason}.- direct
Runtime.CLI.start_session/1returns{:error, reason}for invalid options, unavailable CLI binaries, or rejected governed launch state.