DECLARATIVE AGENT FRAMEWORK
Declare four kinds of capability with decorators + DI; a main agent orchestrates them. Every run yields structured output and an observable call tree(trace, cost, metrics) — a service you can put straight into production.
npm i -g @migor/cli && agentia create my-app
01 — CAPABILITIES
Capabilities are what a service is made of. All four kinds sit on the main agent's menu as callable entries — declare once, let the model do the dispatching.
A class method is a tool. Arguments are parsed against a JSON Schema and validated before execution; a failure comes back as is_error and the run keeps going.
Call the model on demand from deterministic code: how many times, when to stop, how to post-process — all decided by your code.
Its own loop with a trimmed context. Intermediate work stays inside; only the final report flows back to the main context.
Templates and playbooks. Pulled into context when the model decides it needs them; supports volatile and static constants.
02 — FEATURES
runId == traceId, built in from turn 0. Every model round-trip and capability call is accounted for — tokens, cost, latency, error class — and sub-agents recurse into a tree. One trace exit feeds OTLP or a sink of your own, per-capability and per-model metrics are derived from the trace (nothing to instrument), and agentia report prints a one-line tuning report of which capability is slow / expensive / error-prone.
create scaffolds, g generates capabilities. One capability per folder, long text in .md; assembly works from either a directory scan or an explicit registry.
Duplicate menu entries, missing references, DI cycles — all fail at startup, not in production.
Drop the oldest tool pairs first, then summarize and compress; the context-budget guardrail carries hysteresis so it does not flap; CJK-aware token estimation. maxTotalTokens / maxCostUsd stop the run hard once accounted, ending with budget_exceeded.
Synchronous RPC, asynchronous tasks, and scheduled dispatch share one input contract; idempotent de-duplication, resume from disk.
CapabilityMiddleware wraps every capability call in an onion model: auth / rate limiting / caching / auditing are all cross-cutting, accounted for at the trace level, with zero intrusion into business capabilities; the host side also gets graceful shutdown and /healthz.
Standard Stage 3 decorators + explicit DI, no bet on reflect-metadata; works with tsx / esbuild / tsgo.
An MCP server's tools map onto menu entries in one line — connectors (stdio / StreamableHTTP) are built in and use only the standard library, adding no third-party dependency (the framework still never imports the MCP SDK); defineEval turns "did my prompt change cause a regression?" into assertions over a trace.
03 — QUICKSTART
npm i -g @migor/cli
agentia create my-app
cd my-app && npm install
agentia g subagent doc-reviewer # isolated sub-agent
agentia g skill note-writer # code-driven flow
agentia g prompt style-guide # text asset
# put ANTHROPIC_API_KEY into the .env the scaffold generated
npm run dev
import { Tool } from '@migor/agentia';
export default class Weather {
@Tool({
description: 'Get the weather for a city',
schema: {
type: 'object',
properties: { city: { type: 'string' } },
required: ['city'],
additionalProperties: false,
},
strict: true,
})
get_weather(input: { city: string }) {
return `Shanghai 72°F sunny (${input.city})`;
}
}