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

@maicolextic/bg-subagents-core

v0.1.1

Published

Pure domain core for bg-subagents: policy loader + resolver, picker, task registry, history store. Zero host deps.

Readme

@maicolextic/bg-subagents-core

Pure domain runtime for the bg-subagents plugin ecosystem.

Contains the policy loader + resolver, TaskRegistry, HistoryStore, Picker, and BackgroundInvoker. No host dependencies — only @maicolextic/bg-subagents-protocol, zod, @clack/prompts, and jsonc-parser.

Audience: adapter authors building a new host integration (OpenCode, Claude Code, MCP, or custom). End-user OpenCode consumers should install @maicolextic/bg-subagents-opencode instead.

Install

pnpm add @maicolextic/bg-subagents-core

Public API surface

Policy

import { PolicyResolver, loadPolicy } from "@maicolextic/bg-subagents-core";

const resolver = new PolicyResolver(async () => loadPolicy());
await resolver.reload();

const resolved = resolver.resolve({ agent_name: "researcher" });
// { mode: "background", timeout_ms: 2000, source: "name" }

PolicyResolver — resolves per-invocation mode + timeout using the precedence chain:

  1. default_mode_by_agent_name (highest)
  2. default_mode_by_agent_type
  3. Global default ("ask")

TaskRegistry

import { TaskRegistry } from "@maicolextic/bg-subagents-core";

const registry = new TaskRegistry({ history });
const handle = registry.spawn({ meta: { subagent_type: "researcher" }, run: async (signal) => { ... } });
// handle.id  → "tsk_a1b2c3d4"
// handle.done → Promise<unknown>

registry.list();           // TaskState[]
registry.get("tsk_...");   // TaskState | undefined
registry.abort("tsk_..."); // sends AbortSignal
registry.onComplete((event) => { /* CompletionEvent */ });

HistoryStore

import { HistoryStore, resolveHistoryPath } from "@maicolextic/bg-subagents-core";

const history = new HistoryStore({ path: resolveHistoryPath() });
await history.append(envelope);       // writes JSONL line
const lines = await history.read(id); // all log lines for task

JSONL files rotate at rotation_size_mb (default 10 MB) with gzip compression. Old files beyond retention_days (default 30) are pruned on rotation.

Picker

import { createDefaultPicker } from "@maicolextic/bg-subagents-core";

const picker = createDefaultPicker({}, {});
const result = await picker.prompt({
  agentName: "researcher",
  defaultMode: "ask",
  timeoutMs: 2000,
});
// result.kind === "picked" | "cancelled"

createDefaultPicker returns a ClackPicker when a TTY is available, a BarePicker otherwise. BarePicker applies the defaultMode immediately (used in headless/CI environments).

BackgroundInvoker

import {
  StrategyChain,
  NativeBackgroundStrategy,
  SubagentSwapStrategy,
  PromptInjectionStrategy,
} from "@maicolextic/bg-subagents-core";

const invoker = new StrategyChain([
  new NativeBackgroundStrategy(),
  new SubagentSwapStrategy(),
  new PromptInjectionStrategy(),
]);

const rewrite = await invoker.invokeRewrite(spec, "background");

The strategy chain tries each strategy in order, stopping at the first that can handle the host context.

CLI commands (/task)

import { listCommand, showCommand, killCommand, logsCommand } from "@maicolextic/bg-subagents-core";

Pure command impls consumed by the OpenCode adapter's /task slash-command dispatcher. Accept registry, history, and a stdout writer; return { exit_code: number }.

Full documentation

See the root README for the end-user quickstart, policy reference, and troubleshooting guide.

License

MIT.