npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@x12i/agent-roles

v1.0.1

Published

Which model a role uses for an agent, org, process, and step — store, edit, and resolve to a concrete call

Readme

@x12i/agent-roles

Which model does role R use for agent A, org O, process P, and step S? This package stores that answer, edits it, and returns a concrete call target.

It does not call models, hold credentials, or choose a role from severity. Pricing is read from @x12i/ai-catalogs. Profile keys are resolved with @x12i/ai-profiles.

npm install @x12i/agent-roles

Node.js 20 or newer.

Resolve

import { createAgentRoles } from "@x12i/agent-roles";

const roles = createAgentRoles();
const resolved = await roles.resolve({
  dir: "/path/to/agent",
  role: "thinker",
  orgId: "tgi",
  processFile: "processes/alerts/process.json",
  stepId: "nx-p4",
});

resolved.layer;       // step | process | org | agent | default | pack | code
resolved.call?.model;    // OpenRouter slug when prefer-openrouter is on
resolved.call?.provider; // dispatcher target: "openrouter" for that slug
resolved.call?.digest;

First non-blank choice wins: step → process → org → agent → general default → pack models.json → openai/gpt-6-luna. A process file does not inherit another process file. Pack placeholders such as configured-analysis-model are skipped. A stale profile warns and the next layer is used. strict: true (or AGENT_ROLES_STRICT=true) throws instead.

AGENT_ROLES_PROFILES=off loads no @x12i/ai-profiles code and rejects profile choices with PROFILES_DISABLED.

Where files live

Agent document: <agentDir>/metadata/agent-roles.json

General default: <workspaceRoot>/metadata/agent-roles.json

metadata/ is managed. It is not part of a package digest, and materializePackage does not copy it. carry(from, to) copies it onto a pin that does not have one yet, and only for process files that still exist.

Legacy memorix.role-models/v1 files are still read, including both nested spellings (processes/<id>/process.role-models.json and processes/<id>/role-models.json). Writes use the new file only.

npx agent-roles migrate --from <workspace>          # dry run
npx agent-roles migrate --from <workspace> --apply --remove-legacy
npx agent-roles doctor
npx agent-roles resolve --agent neo --role thinker --explain

Browser

@x12i/agent-roles/browser is the pure entry: registry, document parse, and resolveFromDocument. It does not import fs, mongodb, or @x12i/env. createBrowserGateway() lazily loads @x12i/ai-profiles/browser.

import { ROLES, ROLE_DEFAULTS, resolveFromDocument } from "@x12i/agent-roles/browser";

Environment

Init options override env. Env is read through @x12i/env. No .env file is required. See .env.example and erc-manifest.json.

| Variable | Default | |---|---| | AGENT_ROLES_STORE | auto (mongo only when AGENT_ROLES_MONGO_URI is set) | | AGENT_ROLES_AGENTS_ROOT | AGENTS_DIR, then PACKS_ROOT, then <cwd>/.memorix-agents | | AGENT_ROLES_WORKSPACE_ROOT | <parent of agents root>/.tmp/memorix-runtime/workspaces | | AGENT_ROLES_METADATA_DIR | metadata | | AGENT_ROLES_FILE | agent-roles.json | | AGENT_ROLES_MONGO_URI | unset. After mongo is chosen: MONGO_METADATA_URI, then MONGO_URI | | AGENT_ROLES_MONGO_DB | MONGO_METADATA_DB, then agent-roles | | AGENT_ROLES_MONGO_COLLECTION | agent-roles | | AGENT_ROLES_PROFILES | auto (off = concrete models only) | | AGENT_ROLES_PROFILE_SOURCE | bundled | | AGENT_ROLES_PREFER_OPENROUTER | PREFER_OPENROUTER, then true | | AGENT_ROLES_CATALOG_LANE | text | | AGENT_ROLES_DEFAULT_MODEL | openai/gpt-6-luna | | AGENT_ROLES_STRICT | false | | AGENT_ROLES_READONLY | false | | AGENT_ROLES_CACHE_TTL_MS | 15000 | | AGENT_ROLES_LOG_LEVEL | warn |

Mongo URIs are masked in doctor output and are rejected if a caller tries to store one in a role document. mongodb is an optional peer dependency.

Host intents ship the studio defaults (overview → sum/default, analysis → cyber/default, and the rest). Pass hostIntents to override keys, or replaceHostIntents: true to replace the map. They are registered with @x12i/ai-profiles unless profiles are off.

Errors

AgentRolesError codes: UNKNOWN_ROLE, INVALID_CHOICE, UNKNOWN_PROFILE, UNKNOWN_MODEL, PROFILES_DISABLED, NOT_CALLABLE, STORE_UNAVAILABLE, STORE_READONLY, CONFLICT, AGENT_NOT_FOUND, PROCESS_NOT_FOUND, CONFIG_INVALID.