io library

The dart:io half of tom_llm: finding the Node runtime on this machine.

Classes

CapturedWirePrompt
The prompt a backend actually received, captured for an audit trail.
LlmCallReport
What one call cost and where it went.
LlmCapabilities
What a provider can do. A surface reads this before offering a feature, and hides what the provider cannot serve rather than failing when pressed.
LlmContextSummary
What a request's context was assembled from — never the context text.
LlmEvent
One thing an AI run, or the session it runs in, did.
LlmFailure
Why a call failed, classified by the provider.
LlmLiveTrailSession
One session's trail file: its text, and the records of the run in progress mapped onto it.
LlmLiveTrailText
One live-trail file's text, changed by the extension's writer operations.
LlmModelUsage
One model's share of a run's LlmUsage.
LlmNodeCandidate
One place the search looked at, and what was there.
LlmNodeHost
What a Node search needs from the machine it runs on.
LlmNodeResolution
The outcome of a Node search: the executable to run, or the account of where the search looked and what it found.
LlmNotice
Something that is neither model output nor a failure.
LlmOptions
How a request is run.
LlmProcessNodeHost
The running process's own view of the machine: its PATH, its home directory, its filesystem, and a --version run with no shell.
LlmProvider
One model backend.
LlmQuestTarget
Where a quest session writes: its quest folder, as an absolute path, and a medium rooted at it.
LlmRequest
One self-contained request.
LlmRetry
The far end announced it will retry a failed API call.
LlmRunAccount
What one run has reported about itself so far, and the terminal event it ends with.
LlmRunCompleted
The run completed, and report accounts for it.
LlmRunEnded
The run is over: LlmRunCompleted or LlmRunFailed. rounds is the far end's turn count when it reported one.
LlmRunError
The run failed: its failure kind and its sentence.
LlmRunFailed
The run failed, was cancelled or went silent, for the reason failure gives.
LlmRunStarted
A run began: what raised it, which provider serves it, and — when the provider knows them at the start — the model and its own call id.
LlmSessionClosed
A session's isolate ended; message says why when it reason is LlmSessionCloseReason.failed.
LlmSessionInfo
One session as the app knows it: its id, its name in the trail view, its kind and, for a quest session, the quest folder it is bound to.
LlmSessionOpened
A session's isolate started.
LlmSessionRegistry
The sessions of the app: the two built-ins and those the user created, and which session a gesture runs in.
LlmStall
The run was abandoned because nothing arrived for silence.
LlmSystemInit
The far end started: its model and the tools it offers. No credential and no working directory — what crossed the provider and nothing more.
LlmTextDelta
A piece of the answer, in order. The answer is the concatenation of a run's text deltas (llmAnswerText).
LlmThinkingDelta
A piece of the model's thinking.
LlmToolBinding
Tools a provider runs while the request is in flight: each call the model makes is dispatched here and its answer sent back.
LlmToolCall
The model called a tool. arguments is the call's JSON input.
LlmToolResult
What the tool call callId answered. fullLength is the length of the whole result; a writer that clips text reports it.
LlmTrailEntry
One entry of a folded trail.
LlmTrailFileWriter
Writes the sessions' trail files.
LlmTrailMedium
A folder the writer keeps files in: read and write a named text file.
LlmTrailNoticeEntry
A line between the blocks: a retry, a stall, a notice, an error, or a session opening or closing.
LlmTrailRecord
One trail entry: an event in the session sessionId, the run runId (absent for a session event), the sequence number within the session and the UTC time at it was recorded.
LlmTrailRunEntry
A run's header: when, over which transport, for which task, and what the user asked.
LlmTrails
The trails of every session, consolidated in the main isolate.
LlmTrailSummaryEntry
A run's last line: its outcome, how long it took, and what it cost.
LlmTrailTextEntry
The model's answer text, deltas joined.
LlmTrailThinkingEntry
The model's thinking, deltas joined.
LlmTrailToolEntry
A tool call and, once it arrived, its result.
LlmUnavailableProvider
A provider that is never available.
LlmUsage
What a run cost. Every field is optional: a far end reports what it has.
LlmUserPrompt
The instruction a run was given, and a summary of its context — the sections it drew on, its length, what it left out. Never the context text : a trail is a plaintext file a user may keep for days.
ToolCatalogue
Tools a model may propose calls to; the caller decides whether to run them. Contrast LlmToolBinding, whose calls the provider makes itself.
ToolDescriptor
A tool a model may be told about.
WirePrompt
The prompt a provider sends, in two channels.

Enums

LlmErrorKind
Why a transport call failed. Callers switch on this rather than on message text; the message is for the user and the diagnostics log, the kind is for control flow.
LlmNodeLookOutcome
What was found at one place.
LlmNodeSource
Where a candidate came from — the vocabulary of the report.
LlmRunOutcome
How a run ended.
LlmSessionCloseReason
Why a session's isolate ended.
LlmSessionKind
What kind of session a trail belongs to.
LlmSummaryTrailKind
Which file of the pair.
LlmToolStatus
Where a tool call is.
LlmTrailEntryKind
What an entry shows — the trail view's filter.
LlmTrailNoticeKind
What a notice entry reports.

Constants

llmAgentPurpose → const String
The purpose of an agent run — a request that drives tools — which runs in llmChatSession; every other purpose runs in llmDefaultSession.
llmChatSession → const String
The built-in session an agent run runs in.
llmDefaultSession → const String
The built-in session ordinary requests run in.
llmLiveTrailCancelledMessage → const String
The words of a cancelled run, as the trail file writes them.
llmNotConfiguredReason → const String
What a build that wired no model at all says for itself — "not configured", never "could not be reached", which would accuse a backend nobody asked for.
llmRequiredNodeMajorVersion → const int
The lowest Node major version an agent server built on the Anthropic Agent SDK accepts. Declared once, so the discovery, a transport's probe and an installer compare against one number; a server's engines.node is kept in step with it.
llmReservedSessionIds → const Set<String>
Ids no user-created session may take: the two built-ins, and the name the Tom VS Code extension writes its own trail under.
llmSummaryTrailMaxEntries → const int
The extension's bound on a summary file's entries.

Functions

llmAnswerText(Stream<LlmEvent> run) → Stream<String>
The answer a run gives: the concatenation of its LlmTextDeltas, in order (complete is derived from run).
llmDiscoverNode({required LlmNodeHost host, String? nodePath, int floor = llmRequiredNodeMajorVersion}) → Future<LlmNodeResolution>
Finds a Node at or above floor through host, or accounts for why not.
llmErrorKindOf(LlmFailure failure) → LlmErrorKind?
The LlmErrorKind a failed run's LlmFailure.classCode names, when it names one.
llmIsSessionId(String id) → bool
Whether id is a well-formed session id.
llmLiveTrailFileName(String sessionId) → String
The file a session's trail is written to: live-trail.<session>.md.
llmLiveTrailRetryMessage(LlmRetry retry) → String
The words of a retry, as the trail file writes them.
llmLiveTrailStallMessage(LlmStall stall) → String
The words of a stall, as the trail file writes them.
llmLiveTrailTimestamp(DateTime at) → String
YYYYMMDD_HHMMSS in local time — the prompt header's stamp.
llmLiveTrailUsage(LlmUsage usage, DateTime at) → String
The extension's ### 📊 usage block for usage, recorded at at; empty when there is nothing to say.
llmNodeAt(String path) → LlmNodeResolver
A resolver for a path the caller vouches for — see LlmNodeResolution.explicit.
llmNodeExecutableName({required bool isWindows}) → String
The Node a search is for: node.exe on Windows, node elsewhere.
llmNodeResolverFor({String? nodePath, LlmNodeHost host = const LlmProcessNodeHost(), int floor = llmRequiredNodeMajorVersion}) → LlmNodeResolver
The resolver a desktop root hands its standalone transport: a search of this machine, or the one executable ai.nodePath names.
llmNodeSearchPlaces(LlmNodeHost host) → List<(String, LlmNodeSource)>
The places a discovery looks at, in order, before deduplication: every PATH entry, nvm's versions newest first, then the fixed locations.
llmParseNodeVersion(String answer) → ({int major, String version})?
v22.22.3, 22.22.3 or a line starting with either → the normalised version and its major; null for anything else.
llmReportOf(Stream<LlmEvent> run, {required String providerId}) → Future<LlmCallReport>
The report a run ends with.
llmRunPrelude(LlmRequest request, {required String providerId, String? modelId, String? callId}) → List<LlmEvent>
The two events every run opens with: what it is, and what it was asked.
llmSessionFor(String purpose) → String
The built-in session a request of purpose runs in: an agent run in chat, everything else in default.
llmSessionIdFor(String name, {Set<String> taken = const {}}) → String
A session id made from name: lower case, letters, digits and -, starting with a letter, at most 32 characters, and none of taken or the reserved ids — a number is appended where it would be.
llmSummaryTrailFileName(String quest, String sessionId, LlmSummaryTrailKind kind) → String
The file name of kind for session sessionId of the quest named quest: <q>.<session>.prompts.md or .answers.md.
llmSummaryTrailPrepend(String existing, {required LlmSummaryTrailKind kind, required String requestId, required DateTime at, required String body, int maxEntries = llmSummaryTrailMaxEntries}) → String
existing with a new kind entry for requestId at at prepended, the sequence one past the newest entry's, and the oldest entry dropped when the sequence passes maxEntries.
llmSummaryTrailTimestamp(DateTime at) → String
The ISO-8601 instant the extension writes: UTC, milliseconds, Z.
llmTrailEntries(Iterable<LlmTrailRecord> records) → List<LlmTrailEntry>
Folds records into entries, in the order their first record arrived.

Typedefs

LlmNodeResolver = Future<LlmNodeResolution> Function()
Produces the Node resolution a transport runs on, when it is asked for — so a selector can be built before the settings are read and a search can run on the probe rather than at construction.
LlmToolAnswer = ({bool isError, String text})
What a tool call answers the model: a result or a refusal, as text.
LlmTrailLog = void Function(String operation, Map<String, Object?> fields)
Records a write that failed: the operation, a path and the error's type. Never content.

Exceptions / Errors

LlmSessionBusyException
A request refused because its session already has a run. An app whose user starts runs refuses rather than queues: a queued run would start at a moment nobody chose, against a document that may have changed. A backend serving its own lanes may queue instead, and then never raises this.
LlmSessionException
A session operation that cannot be done, with the sentence the user is shown.
LlmTransportException
The single error type crossing the seam.