Skip to main content
Glama
nymrel-agent

nymrel-agent

Official
by nymrel
README.md
# Nymrel Agent

Nymrel Agent is an explainable multi-model router with one deterministic contract across a public API, local CLI, MCP server, and low-custody execution harness.

You supply a model catalog and explicit requirements. Nymrel Agent rejects candidates that violate health, risk, capability, data-boundary, context, modality, cost, or latency constraints; ranks the eligible set under a balanced, quality, cost, or latency objective; and returns the full explanation.

The hosted router accepts model metadata only. It does not accept prompts, provider credentials, files, or customer identifiers, and it does not execute model calls.

## Quickstart

The public routing endpoint requires no account or key:

```bash
curl -sS https://nymrel-agent.vercel.app/v1/route \
  -H "content-type: application/json" \
  --data-binary @examples/route-request.json
```

Route the same payload locally:

```bash
corepack enable npm
npm ci
npm run compile
node dist/src/bin/nymrel-agent.js route --file examples/route-request.json
```

`nymrel.agent.route/v2` is an explicit opt-in. It requires request-budget anchors, computes a Pareto frontier after eligibility, and only then selects from that frontier:

```bash
node dist/src/bin/nymrel-agent.js route --contract-version v2 --file examples/route-request-v2.json
```

Plan a multi-step workflow locally without sending task bodies or executing any provider:

```bash
node dist/src/bin/nymrel-agent.js job plan --file examples/job-48h-game-builder.json
```

Job Mode accepts only a bounded, body-free manifest with a shared model catalog and ordered v2 route requests. It makes deterministic selections for each step, emits a body-free correlation receipt, and marks any non-read step as an external handoff; it does not run the workflow. See [Job Mode](docs/JOB_MODE.md).

Job Lifecycle is a separate local envelope contract for callers that want to retain a bounded checkpoint chain around an already-routable Job Mode plan. It records only digests, counts, ordinals, enums, metrics, and timestamps; it does not parse transcripts, retain tasks, invoke a provider, schedule work, or persist anything. Callers write the returned JSON themselves.

Full documentation: <https://nymrel-agent.vercel.app/docs>

OpenAPI 3.1: <https://nymrel-agent.vercel.app/openapi.json>

Machine-readable product context: <https://nymrel-agent.vercel.app/llms.txt>

## What the result means

Routing has two stages:

1. Fail-closed eligibility filters reject incompatible profiles with stable reason codes.
2. Eligible profiles receive visible, integer score components and a deterministic tie-break.

The selected objective changes explicit weights. Explicit cost and latency ceilings also anchor their matching score components, so changing unrelated catalog membership cannot change an anchored component merely by moving the normalization range. When a ceiling is omitted, that component falls back to eligible-set normalization. Without changing the closed v1 response shape, each route receipt reports the chosen modes in `decisionCodes` and the numeric bounds in `explanation`. Model quality, reliability, cost, latency, boundary, and capability facts are caller-supplied evidence; Nymrel Agent explains how it used them but does not certify them.

The opt-in v2 contract leaves v1 unchanged. Its required `normalization` object uses `basis: "request_budget"` plus positive cost and latency anchors. v2 normalizes cost and latency against those request anchors, returns a sorted `paretoFrontierModelIds` list, and selects only from that frontier. An incumbent can resolve an exact weighted-score tie inside the frontier; it never receives a score bonus.

## Embed routing in your application

The `@nymrel/agent/router` subpath exposes the existing v1/v2 routing functions
and their TypeScript contracts without importing the CLI, MCP server, provider
adapters, or local execution runtime. It can sit between an application's
orchestration code and its chosen provider SDK:

```typescript
import { routeV2, type ModelProfile, type RouteRequestV2 } from '@nymrel/agent/router';

const plan = routeV2(requestMetadata as RouteRequestV2, modelCatalog as ModelProfile[]);
if (plan.selectedModelId === null) {
  // Stop or ask for changed constraints; no model satisfied the supplied policy.
} else {
  // Hand the selected identifiers to your application's existing provider code.
}
```

This entry point makes a routing decision only. Model facts remain caller-supplied;
the result does not authenticate those facts or authorize execution. It uses no
Node-only APIs and makes no provider/network call. The package still contains
the other entry points and their declared dependencies; the subpath isolates the
module graph rather than creating a separate dependency-free distribution.

The library entry point first appears in version 0.5.0; immutable 0.4.x downloads
do not include it. See the [library consumer guide](docs/ROUTER_LIBRARY.md) for
verified versioned-artifact installation and exact-source builds. npm publication
remains separate from a GitHub release.
The existing routing contracts and public endpoints are unchanged.

## CLI

```text
nymrel-agent route --file PAYLOAD.json [--contract-version v2] [--endpoint https://host]
nymrel-agent route --file PAYLOAD.json --contract-version v2 --format summary
nymrel-agent job plan --file MANIFEST.json
nymrel-agent job plan --file MANIFEST.json --format summary
nymrel-agent job lifecycle init --file MANIFEST.json [--at RFC3339_UTC]
nymrel-agent job lifecycle checkpoint --state-file STATE.json --file CHECKPOINT.json
nymrel-agent job lifecycle complete --state-file STATE.json --file TERMINAL.json
nymrel-agent models doctor [--config CONFIG.json]
nymrel-agent run --config CONFIG.json (--task TEXT | --task-file FILE|-)
nymrel-agent contract
nymrel-agent demo
```

Local routing is the default. `--endpoint` sends the metadata-only payload to a hosted router.

The local `route --format summary` view is an **unreleased source addition** after
the committed 0.5.0 candidate archives. Build the current reviewed source to try
it; the existing versioned tarball does not contain this option. It shows the
selected model, caller catalog cost/latency estimates, requested ceilings,
eligibility counts, canonical scores and rejection codes, with
at most eight eligible and eight rejected candidates. A blocked summary exits
`2`; a selected summary exits `0`. JSON remains the default (also available as
`--format json`) and preserves its existing output and exit behavior, including
exit `0` for a valid blocked plan. Summary mode is local-only and refuses
`--endpoint` before reading input or making a network call. See the
[consumer guide](docs/ROUTER_LIBRARY.md#inspect-a-local-plan) for an example.

`job lifecycle` is local-only and reads JSON files only; it prints the next state envelope to stdout rather than writing state. The state has a canonical SHA-256 integrity hash and checkpoint chain. Those hashes support correlation and tamper detection, not confidentiality or freshness; retain the newest state envelope and keep it private.

## Local graphical workbench — unreleased source example

Inspect the same canonical router in a local browser without editing JSON for
each policy change. From a current reviewed source checkout with the supported
Node toolchain:

```text
corepack npm@11.19.1 ci
corepack npm@11.19.1 run workbench -- --port 0
```

Open the printed `http://127.0.0.1:PORT/` URL. Edit objective and USD/ms ceilings,
inspect selected, blocked or invalid states and rejection/Pareto explanations,
reset the synthetic example, or explicitly export validated metadata and its
canonical plan. Imports are closed-schema v2 metadata, limited to 1 MiB of UTF-8
JSON; edits stay in browser memory. No provider call, account, storage or hosted
service is involved. Exports may contain your imported catalog: review it before
sharing. See the [workbench guide](docs/ROUTER_LIBRARY.md#local-graphical-workbench).

This is a source/dev-tool example after the committed 0.5.0 candidate archives.
It requires the source's development tooling and compiled router; a production-
only package installation is not its runner. No historical download is changed.

## MCP

The stdio MCP server exposes five read-only tools:

- `route_models` — validate and route a `nymrel.agent.route/v1` JSON payload.
- `route_models_v2` — validate and route an explicit `nymrel.agent.route/v2` JSON payload.
- `explain_contract` — return the stable routing and custody boundary.
- `explain_contract_v2` — return the explicit v2 routing and custody boundary.
- `plan_job` — validate and plan a body-free local Job Mode manifest without a provider call or a receipt timestamp. MCP remains stdio-only; the host application may retain arguments even though Nymrel sends nothing over its network.

Example client configuration after building from source:

```json
{
  "mcpServers": {
    "nymrel-agent": {
      "command": "node",
      "args": ["/absolute/path/to/nymrel-agent/dist/src/bin/nymrel-agent-mcp.js"]
    }
  }
}
```

## Customer-local execution

v0.1 includes an OpenAI Responses adapter for read-only local runs. The local config stores an environment-variable name, never the key value:

```powershell
$env:OPENAI_API_KEY = "set-this-in-your-secret-aware-shell"
node dist/src/bin/nymrel-agent.js run --config examples/openai-local-config.example.json --task-file -
```

The adapter calls `POST /v1/responses` from the customer's machine, requires a completed response, sets `store: false`, bounds time and response size, sanitizes provider errors, and keeps task/output bodies out of receipts. A profile that claims `local_only` custody is accepted only with a loopback base URL. The public Worker is never in this path.

The example contains `YOUR_MODEL_ID`; replace it and its caller-supplied profile facts with a model your account can use. Nymrel does not ship benchmark claims in the example.

## Security boundary

- Public API: routing metadata only, no prompt or provider execution, streamed 256 KiB and 100-model caps, strict unknown-field rejection, Vercel deployment-wide WAF rate limiting (or a Cloudflare edge-location binding), exact-source readiness, and deterministic JSON errors.
- Local runtime: read-only execution only, explicit adapters, bounded provider events/output, body-free receipts.
- Not included: hosted keys, accounts, billing, customer-data persistence, shell or filesystem-write tools, outreach, purchases, deployment tools, or autonomous side effects.
- Receipt SHA-256 values are correlation digests, not encryption or confidentiality controls.

See [SECURITY.md](SECURITY.md) for reporting and supported-version policy.

## Nymrel implementation service

Nymrel can configure evidence-backed catalogs, routing policy, evals, customer-local adapters, and operational receipts around a real workflow. Hosted execution, data retention, credentials, and write-capable tools require a separate scope and security review. Pricing is provided on request at <https://nymrel.com/brief>.

## Development and release proof

Requires Node.js `>=22 <25`. `.node-version` pins the preferred Node 24 patch, while CI verifies Node 22 and 24 on both Ubuntu and Windows. The `packageManager` and `devEngines` contracts require npm 11.19.1 for development.

```powershell
corepack enable npm
npm --version
npm ci
npm run verify
npm run audit
npm pack --dry-run
git show --check --oneline HEAD
```

The version check must print `11.19.1`. Installs fail closed on unreviewed dependency lifecycle scripts; `allowScripts` approves only the exact locked `esbuild` and `workerd` versions required by the toolchain. `npm run verify` runs type checking, the offline/integration and workflow-policy suite, the release manifest and secret scan, packed-consumer CLI/MCP verification, and a Cloudflare deployment dry-run. `npm run audit` covers the complete locked dependency graph. The production Vercel adapter is exercised by the same compiled integration suite and by preview verification before promotion. Phase 0 evidence remains under `docs/PHASE0_CONTRACT.md` and `evidence/phase0-receipt.json` as historical provenance, not current product status.

## License

MIT. See [LICENSE](LICENSE).