observability library

Module — observability v0. Structured action log + natural-language renderer.

Classes

ActionLog
Bounded ring of LogEntrys. Oldest entries drop off when the capacity is reached. Thread of execution is single per session, so no locking.
AppAlert
One thing an app reported: name is the event's alert field, group the AlertKind a watch selects it by.
AppLogBuffer
Bounded ring of app-side log events. Subscribes to the VM service's Stderr + Logging streams on subscribe and cancels them on unsubscribe. Survives glint session re-attach: the buffer itself outlives any one subscription.
AppLogEntry
AppLogScan
What AppLogBuffer.scan found: the entries to show and the counts behind them.
AuditEntry
AuditLog
Tamper-evident telemetry log at <dataDir>/telemetry-audit.log: one <ts>|<prev_hash>|<payload_b64>|<this_hash> line per payload, each hash covering the line before it, like git log.
AuditVerifyResult
BreakpointHit
One matched line: what matched, whether the app was paused for it, and the screen at that moment.
CallMark
Where a call's counters stood at one moment; the difference between two marks is what happened in between.
CallProgress
What one tool call is doing right now: feeds the heartbeat, names the stuck phase on a timeout, and owns the subprocesses to kill when the call is abandoned. Found from any code on the call via current.
FailureEntry
FlutterErrorEntry
One distinct error the app reported, with how often and where.
FlutterErrorFeed
The distinct errors an app reports, read without any app code: Flutter's structured error events when flutter run enabled them, else the error dumps in the app's console output.
GlintConfig
Runtime-tunable defaults. Tools that have a baked-in constant (poll cadences, ceilings, ring capacities) consult this instead, so the agent can adjust them via the config MCP tool without restarting glint.
HttpFailureMonitor
Reads one app's dart:io HTTP profile on a timer and raises an AppAlert for each request that failed (4xx, 5xx or a transport error); runs only while something holds it.
LogBreakpoint
A regex armed on the app's log lines.
LogBreakpoints
Log breakpoints for one app: matches each new log line, pauses the app on a hit, and queues hits for the agent.
LogEntry
Closed set of log entry kinds. Sealed so the logs tool can branch exhaustively when rendering.
LogRenderer
Natural-language view of an ActionLog's entries. Renders each event on one line: [t+Δ] tool(args) → summary. Δ is relative to the first entry in the slice.
OverflowInfo
How far a render object overflowed, read from the framework's A RenderFlex overflowed by 42 pixels on the bottom. message.
Session
One named slice of activity — opens at a point in the ActionLog's sequence, closes at a later point. Sessions don't own their entries; they hold a sequence range that ActionLog.query can slice on.
SessionManager
Tracks one active session at a time plus the history of closed ones. Opening a new session auto-closes the previous one.
SessionNote
StateObserver
SuccessEntry
ToolEvent
UsageEventStore
Append-only JSONL store at <dataDir>/usage-events.jsonl; ids stay monotonic across processes, and a full file is gzipped into usage-archive/ (newest 20 MB kept) instead of being cut. Writes are best-effort and never throw.
UsageRecorder
Bounded ring of ToolEvents with FNM-style correlation IDs, backed by UsageEventStore when a data dir is configured. One process-wide instance; tool handlers call record post-call.
UsageReporter
glint's usage rollups: the shared UsageShipper over the recorder's events; sends nothing unless GLINT_TELEMETRY=on.
UsageShipResult
The outcome of UsageShipper.ship.

Enums

AlertKind
The kinds of alert a watch can ask for; disconnected (opt-in) covers the disconnected and reconnected events around a terminated.
AppLogStream
Where a log entry came from. stderr captures direct stderr writes, stdout captures FlutterError dumps + print() (Flutter routes FlutterError through debugPrint → stdout, not stderr), logging captures developer.log calls.
FlutterErrorChannel
Where an occurrence was read from: Flutter's Flutter.Error events, glint's in-app error hooks or the app's console output.
SceneState
Coarse top-level state per §8.6: derived cheaply from the already- read scene. No extra polling — just inspects what's there.
ToolOutcome
ok / error / empty. Same vocabulary as flutter_network_mcp.

Constants

glintSwitches → const TelemetrySwitches
glint's telemetry switches: GLINT_TELEMETRY, GLINT_NO_TELEMETRY, GLINT_NO_USAGE.
kCharsPerToken → const double
Rough characters per token, the usual heuristic for JSON-ish text.
kCollectorEndpoint → const String
Collector endpoint baked into the binary so users can audit where payloads go.
kErrorMessageMaxChars → const int
Max chars in the errorMessage field for crash payloads.
kGlintVersion → const String
The version glint's rollups carry, so the shared collector tells the products apart.
kStackHeadFrames → const int
Max stack frames in crash payloads.
kTelemetryTimeout → const Duration
Budget for one POST, short enough that shutdown never waits on an unreachable collector.
kTelemetryUserAgent → const String
User-Agent for the HTTPS request. Lets the collector rate-limit by product if a future glint fork misuses the endpoint.

Functions

dartVersion() → String
The Dart SDK version: the leading semver triple of Platform.version.
estimateTokens(int bytes) → int
Estimated agent-side tokens for a reply of bytes characters.
installId(String dataDir) → String
A random id created once per install in dataDir; unlike a hash of the path, it reveals nothing about the user or the machine.
looseBool(Object? value) → bool?
A bool from a bool or the strings "true" / "false"; null otherwise.
looseInt(Object? value) → int?
An int from an int, a whole double (15000.0) or a numeric string ("15000"); null otherwise.
looseNum(Object? value) → double?
A number from a num or a numeric string; null otherwise.
osDescriptor() → String
"macos 14.6", with long version strings capped at 60 characters.
postTelemetry(String jsonStr) → Future<int>
POSTs jsonStr to the collector as glint; throws on connection failure, callers swallow.
redactForSharing(String input, {Iterable<String> appNames = const [], Iterable<String> deviceNames = const [], Iterable<String> hosts = const []}) → String
redactPath, redactSecrets and the given app, device and host names together, for anything posted publicly; reports build one IdentityRedactor and reuse it.
redactPath(String input, {String? home}) → String
Strips filesystem identity (username, project name, directory layout) from text that leaves the machine; <home>/…/lib/x.dart becomes <project>/lib/x.dart, package: URIs are untouched, and it is idempotent.
redactSecrets(String input) → String
Masks bearer tokens, JWTs, long hex keys and password=-style values in free text.
redactStackHead(StackTrace stack, {int maxFrames = 8}) → List<String>
Redacts every line of a Dart stack trace, keeping the first maxFrames frames.
resolveDataDir() → String
Glint's per-install data dir. Holds the audit log + ship watermark.
sharingEnabled([Map<String, String>? env]) → bool
True only when the user opted in to sharing usage stats.
sharingOffReason([Map<String, String>? env]) → String?
Why usage stats are not shared, or null when the user opted in with GLINT_TELEMETRY=on and nothing overrides it.
summarizeUsage(List<Map<String, Object?>> rows, {int topTransitions = 15}) → Map<String, Object?>
Aggregates tool-call rows, ordered by correlation_id then id, into per-tool stats, the outcome-tagged tool-to-next-tool transitions, and self-correction rates; tokens come from estimated_tokens or else result_bytes.
telemetryDisabled([Map<String, String>? env]) → bool
True when GLINT_NO_TELEMETRY turns off local usage recording and sharing alike.
truthyEnv(String? v) → bool
Treats true, 1, yes and on (any case, trimmed) as true.
usageDisabled([Map<String, String>? env]) → bool
True when local usage recording is off (GLINT_NO_TELEMETRY or GLINT_NO_USAGE).

Exceptions / Errors

CallAbandoned
The call is being abandoned (its ceiling passed), so new subprocesses must not start.
CallTimeboxExceeded
Thrown by CallProgress.timeboxed when its body outlived its limit; says where the body had got to.