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

@agent-action-runner/fastify

v0.8.2

Published

Fastify adapter for agent-safe action and workflow runner for TypeScript backends.

Readme

@agent-action-runner/fastify

Fastify adapter for Agent Action Runner.

Use this package to expose a core AgentActionRunner through Fastify routes while resolving user identity, allowed modes, approval tokens, approval context, and metadata on the server.

The plugin exposes registered actions. It does not execute agent-generated code or discover arbitrary Fastify routes.

Experimental / pre-1.0.

Install

npm install @agent-action-runner/core @agent-action-runner/http @agent-action-runner/fastify fastify zod

fastify and @agent-action-runner/core are peer dependencies. @agent-action-runner/http contains the shared HTTP contract used by the official HTTP adapters.

Quickstart

import Fastify from 'fastify';
import { createRunner } from '@agent-action-runner/core';
import { agentRunnerFastifyPlugin } from '@agent-action-runner/fastify';
import { z } from 'zod';

const app = Fastify();
const runner = createRunner();

runner.registerAction({
  name: 'delivery.searchJobs',
  mode: 'read',
  description: 'Search delivery jobs by status.',
  inputSchema: z.object({
    status: z.array(z.string()),
  }),
  handler: async (input) => ({
    jobIds: input.status.includes('FAILED') ? ['job_1'] : [],
  }),
});

await app.register(agentRunnerFastifyPlugin, {
  prefix: '/agent-runner',
  runner,
  getUserId: async (request) => request.headers['x-user-id']?.toString() ?? 'anonymous',
});

await app.listen({ port: 3000 });

Endpoints

With the plugin registered using prefix: '/agent-runner', the routes are:

| Method | Path | Description | |---|---|---| | GET | /agent-runner/actions | Lists registered action metadata. | | POST | /agent-runner/actions/:name/execute | Executes one action. | | POST | /agent-runner/workflows/execute | Executes a JSON workflow. |

GET /actions returns action metadata only. Schemas are not serialized. Metadata can include tags, resource type, risk level, deprecation, and examples.

Execute An Action

curl -s http://localhost:3000/agent-runner/actions/delivery.searchJobs/execute \
  -H "content-type: application/json" \
  -H "x-user-id: operator_1" \
  -d '{"input":{"status":["FAILED"]}}'

Successful responses use this shape:

{
  "ok": true,
  "result": {
    "executionId": "exec_1",
    "actionName": "delivery.searchJobs",
    "mode": "read",
    "output": {
      "jobIds": ["job_1"]
    }
  }
}

Execute A Workflow

curl -s http://localhost:3000/agent-runner/workflows/execute \
  -H "content-type: application/json" \
  -H "x-user-id: operator_1" \
  -d '{
    "workflow": {
      "workflowName": "search-failed-jobs",
      "steps": [
        {
          "id": "jobs",
          "action": "delivery.searchJobs",
          "input": {
            "status": ["FAILED"]
          }
        }
      ]
    }
  }'

Plugin Options

await app.register(agentRunnerFastifyPlugin, {
  prefix: '/agent-runner',
  runner,
  getUserId: (request) => request.user.id,
  getAllowedModes: (request) => request.user.canMutate
    ? ['read', 'draft', 'dryRun', 'mutate']
    : ['read', 'draft', 'dryRun'],
  getApprovalToken: (request) => request.headers['x-approval-token']?.toString(),
  getApprovalContext: (request) => ({
    dryRunHash: request.headers['x-dry-run-hash']?.toString(),
  }),
  getMetadata: (request) => ({
    requestId: request.id,
    ip: request.ip,
  }),
});

getUserId is required. Identity should come from your server-side auth/session layer, not the request body.

By default, request body execution options are ignored:

  • allowedModes
  • approvalToken
  • approvalContext
  • metadata

Set allowClientExecutionOptions: true only for trusted internal tooling.

Mutate Actions

mutate actions still go through the core runner. They require:

  • mutate in allowed modes
  • approval hook approval
  • any policy hook checks your application configures

The Fastify adapter does not implement authentication, sessions, approval signing, or persistent audit storage.

Error Responses

Errors use a stable JSON shape:

{
  "ok": false,
  "error": {
    "code": "MODE_NOT_ALLOWED",
    "message": "Action \"admin.disableUser\" uses mode \"mutate\", which is not allowed for this execution."
  }
}

Common status mappings:

| Error | Status | |---|---| | action not found | 404 | | schema validation failed | 400 | | action timeout | 408 | | invalid step reference | 400 | | mode not allowed | 403 | | approval required | 403 | | policy rejected | 403 |

Example

See examples/fastify-admin-ops for a runnable Fastify app with the full read -> dryRun -> approve -> mutate -> audit flow.

License

Apache-2.0