StandaloneNodeAiTransport class final
Reaches Anthropic through a Node server the app starts and owns.
- Implemented types
Constructors
-
StandaloneNodeAiTransport({required LlmNodeResolver node, String? serverScript, AgentSdkServerInstaller? installer, String? apiKey, Set<
String> scrubbedVariables = const {}, String? credentialIsolationRoot, Duration startupTimeout = const Duration(seconds: 20), void onStderr(String line)?, CliServerAiChannel channelFactory(int port)?}) -
StandaloneNodeAiTransport.forApp({required String appDataDirectory, required LlmNodeResolver node, String? apiKey, Set<
String> scrubbedVariables = const {}, void onStderr(String line)?}) -
The transport a packaged app uses: the server installed under
appDataDirectory, from the source the app carries beside its executable (or, run from a checkout, this package'snode/), on the Nodenoderesolves — the root's search of the machine, honouringai.nodePath.factory
Properties
- apiKey → String?
-
The Anthropic credential, handed to the child in its environment.
final
- capabilities → LlmCapabilities
-
Identical to the hosted transport's, and deliberately so: the same models
through the same Agent SDK. A user switching paths must not find that the
feature set moved.
no setteroverride
- hashCode → int
-
The hash code for this object.
no setterinherited
- id → String
-
A stable, human-readable identifier used in diagnostics and in the
settings UI ("AI: connected via …"). Not a display string.
no setteroverride
- installer → AgentSdkServerInstaller?
-
Installs the server's dependencies on the user's request, or null for a
transport pointed at a server someone else installed (a developer's
checkout,
$standaloneScriptEnvVar).final - isConnected → bool
-
Whether a live connection is currently held.
no setteroverride
- node → LlmNodeResolution?
-
The resolution this transport is running on, once a probe has made it;
null before that.
no setter
- nodeExecutable → String?
-
The executable the resolution named, or null before a probe or when it
named none.
no setter
- onStderr → void Function(String line)?
-
The child's stderr lines, for the diagnostics log. Never contains the
credential: the child is written not to echo it.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
scrubbedVariables
→ Set<
String> -
Environment variables of the app's own that the child must not inherit
— credentials the app was handed for itself, such as a session token.
The child runs a tool-running SDK, and a credential in its environment is
one a tool can read (agentSdkChildEnvironment).
final
- selectionNotice → String?
-
Always null: this transport starts the server it talks to, so there is
never a choice between candidates for it to have resolved quietly.
no setteroverride
- serverScript → String
-
The server script to run. Defaults to the installer's installed
script, or to resolveDefaultServerScript when there is no installer.
final
- sessionCopy → AgentSdkServerTransport Function()?
-
a transport that starts its own server, on the Node this
one resolved and the script it runs. The server takes one client — the
security boundary its header states — so a session cannot share this
transport's child; it starts one, owned by the session's isolate and
gone with it. The installer and the stderr listener stay here: installing
is the main isolate's act, and the listener is the main isolate's object.
no setteroverride
- startupTimeout → Duration
-
How long to wait for the child's ready line before giving up.
final
-
The kind of the last false probe, or null when the last probe
succeeded or none has run.
no setteroverride
-
Why this transport is unavailable, as a sentence naming the remedy.
no setteroverride
Methods
-
close(
) → Future< void> -
Closes the channel and terminates the child. Idempotent.
override
-
complete(
AgentSdkCompletionRequest request) → Stream< AgentSdkCompletionEvent> -
Returns the channel's stream directly — see the hosted transport for
why a wrapping generator would break cancellation.
override
-
connect(
) → Future< void> -
Establishes the connection. Throws LlmTransportException with
LlmErrorKind.unreachable when no server can be reached.
override
-
install(
{void onProgress(String line)?}) → Future< AgentSdkInstallOutcome> -
Runs the installer, on the user's request, with the Node this
transport resolved — the same one the server will run on, so npm picks
the CLI the SDK will look for. A transport without an installer has
nothing to install and says so rather than pretending to.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
probe(
) → Future< bool> -
Checks the preconditions for starting, without starting.
override
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
credentialIsolationRootFor(
String appDataDirectory) → String - Where an app keeps the configuration directories of children started with an explicit key: beside the installed server, in its data directory.
Constants
- stderrDrainBound → const Duration
- How long an early-exit report waits for the child's stderr to close.