docs/

directory
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 7, 2026 License: Apache-2.0

README

Documentation

mivia-ai-sdk is a Go module of composable building blocks for tool-calling agents. agentloop drives the tool-calling loop over a model provider and a tool registry. The remaining blocks compose around it: envelope, room, machine, flow, events, a2a, dispatch, tools, context/budget, schema, mcp, ledger, memory, provider, provider/anthropic, context/plan, context/ref, channel, trace, scheduler, workflow, workflow/run, subagent, and workspace. Each package covers one concern and composes through its exported API. This doc tree covers the module map, the wire-protocol rationale, every package's exported surface, and runnable-style walkthroughs.

Start here

  • architecture.md — the single design reference: the module map, the message flow, why the envelope is shaped this way, the gate system, and the invariants.

Agents and subagents

The composition stack, bottom to top:

  • packages/workflow.md — one identity, one card, one plan, driven through signed, acked, hash-chained messages.
  • packages/workflow/run.md — the config-struct layer over workflow.Run: tools, store, artifacts, ask, budget, and monitor wired by one Options value.
  • packages/subagent.md — the SDK's blocks as tools: a runner becomes a spawnable subagent, spawns run in parallel behind a depth guard, and a signed-message mailbox carries both directions.
  • packages/dispatch.md and packages/a2a.md — the receive and remote halves: an HTTP envelope endpoint, and a remote A2A task as one step's ack.

Internal tools an agent can be given, all optional, all registered into a tools.Registry through subagent:

  • FlowTool — run a flow plan, report the final status.
  • LedgerTool — record one completed task through the taskrun ceremony, report key state.
  • MemoryTool — store and fetch blobs under content-addressed refs.
  • RoomTool — admit, remove, promote, list, and query membership.
  • SchedulerTool — schedule and cancel one bound job.
  • HeartbeatTool — beat, alive, and dead against a monitor.
  • DiscoveryTool — match one capability card against a need.
  • ProviderTool — one model turn through a caller's Completer.
  • TriggerTool — fire a named trigger.
  • ChannelTool — ask a human through a Notifier.
  • SendTool and InboxTool — the mailbox plane's two ends.

Package reference

  • packages/envelope.md — the wire unit: the message, its metadata types, the semantic ack, signing, and the agent key (Identity, New, Load).
  • packages/events.md — the in-process reaction bus and the hook registry: typed events, one subscription set, and vetoable lifecycle hooks.
  • packages/machine.md — the state-machine building block: the status model and the move dispatch.
  • packages/room.md — standing groups for messages: the roster, the roles, and message admission.
  • packages/flow.md — the declarative workflow building block: the step graph, the cycle check, the runner, the capability card, and the liveness monitor.
  • packages/a2a.md — the A2A v1.0 protocol: a message part shape, the functions that map an envelope message onto it and back, the a2a-go client adapter, and the remote step ack.
  • packages/dispatch.md — the NDJSON envelope endpoint: an http.Handler that runs the receive ladder per line and answers with confirmed acks, plus Send, the client-side counterpart.
  • packages/tools.md — the tool registry: named actions a step can resolve and run by name, plus execution-risk markers, scoping, and approval gating.
  • packages/budget.md — a pure, storage-agnostic budget check for one model call's context: a byte cap, an event-count cap, and Fits.
  • packages/ref.md — the canonical content-reference minter and parser: HashPrefix, Digest, Mint, and IsRef.
  • packages/schema.md — the JSON Schema compile/validate/corrective-message primitive: Compile admits and compiles a schema, Validate checks a payload against it, and Corrective renders a bounded, model-facing correction message.
  • packages/mcp.md — the MCP tool-calling client: connect to a server, list its tools, and call them, over stdio or streamable HTTP.
  • packages/ledger.md — the durable-task-admission primitive plus the one-task ceremony: idempotency-keyed admission, a leased claim with a fence, dependency blocking, and admit-claim-run-complete in one call.
  • packages/memory.md — the content-addressed context store plus the principal-scoped spool: content refs, byte-budget eviction, grant-scoped oversized content, and tool wrappers.
  • packages/provider.md — the model provider interface plus usage accounting and the routing registry: the Completer contract, per-session usage totals, and ordered named-provider fallback.
  • packages/provider/anthropic.md — the Anthropic Messages API adapter: concrete Completer, ContextAccountant, and ReasoningPolicy implementation.
  • packages/plan.md — manages token budget windows and history compaction, plus the summarizer: a token Window, compaction thresholds, an EWMA-calibrated estimator, and one bounded summary call.
  • packages/channel.md — the ask-and-wait shape: a Question, a typed Answer, and the caller-implemented Notifier that connects them.
  • packages/trace.md — the structured-trace primitive: a Span records one named operation, a Tracer links spans through ctx, and SpanFrom reads the current span back.
  • packages/scheduler.md — the invoke-on-schedule primitive plus the trigger registry: due-job firing, and the Condition/Action vocabulary that maps one name to a guarded call.
  • packages/workflow.md — the composition layer: one identity, one capability card, and one step plan, driven through signed, acked, hash-chained messages.
  • packages/workflow/run.md — the config-struct composition layer: one Options value validated and wired into a Runner that drives workflow.Run.
  • packages/subagent.md — the SDK's blocks as tools: a runner becomes a spawnable subagent, RunAll runs several at once, internal tools expose the blocks, and a signed-message mailbox carries both directions.
  • packages/workspace.md — filesystem confinement plus secret path matching: Open binds a handle to a root, rejects traversal or symlink escapes, and a Matcher flags configured secret paths.
  • packages/agentloop.md — a tool-calling loop over a provider.Completer and a tools.Registry: offer tools, run model-requested calls, repeat until the model stops asking or a bound trips.

The core module also ships x/, a nested sub-module of orphaned packages — contextstate, contextsession, longtermmemory, skills, envfile, and runconfig — kept alive for the consumers that import them but not advertised as SDK surface.

Examples

Internal records

docs/history/ holds internal development records: the change contract behind each package. They are not part of this documentation.

Directories

Path Synopsis
examples
_agentloop command
Command agentloop wires a complete agentloop.Options and runs one scripted two-turn tool exchange offline.
Command agentloop wires a complete agentloop.Options and runs one scripted two-turn tool exchange offline.
_agentloop_adoption command
Command agentloop_adoption is the external-adopter positive control: it sets every agentloop Options row an external consumer is expected to adopt, one commented line per row of the adoption table (Usage, Budget, MaxTotalTokens, MaxConsecutiveToolFailures, Tracer, DedupWithinTurn, Audit, Conclude, HeartbeatInterval + Bus, and the Window/Summarizer/Calibrated compaction triple).
Command agentloop_adoption is the external-adopter positive control: it sets every agentloop Options row an external consumer is expected to adopt, one commented line per row of the adoption table (Usage, Budget, MaxTotalTokens, MaxConsecutiveToolFailures, Tracer, DedupWithinTurn, Audit, Conclude, HeartbeatInterval + Bus, and the Window/Summarizer/Calibrated compaction triple).
_agentloop_minimal command
Command agentloop_minimal shows the smallest useful agentloop entry: one completer, one tool, DefaultBounds, and EnableCompaction build the whole Options.
Command agentloop_minimal shows the smallest useful agentloop entry: one completer, one tool, DefaultBounds, and EnableCompaction build the whole Options.
_quickstart command
Command quickstart is the README Quick Start program: one schema tool, one agentloop.Run call.
Command quickstart is the README Quick Start program: one schema tool, one agentloop.Run call.
_sdksurface command
Command sdksurface exercises the exported SDK symbols that carry no in-repo caller: the surface a public SDK ships for external application code.
Command sdksurface exercises the exported SDK symbols that carry no in-repo caller: the surface a public SDK ships for external application code.
_workflowrun command
Command workflowrun walks a two-step pipeline through the workflow/run composition layer.
Command workflowrun walks a two-step pipeline through the workflow/run composition layer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL