blazeITHugo

payload ai admin

by blazeITHugo
Admin customization
v3
^3.37.0
MIT

Overview

Summary generated from the README

Adds an AI chat view and nav link to the Payload admin. You declare per-collection read, create, update and delete permissions plus optional field scoping, and tools are generated only for allowed operations. Every action runs through the Local API as the logged-in user with access control enforced. Built on AI SDK v6 with Anthropic Claude as the default model; requires Payload 3.37+, Next.js 15 or 16, React 19 and an Anthropic API key for the default model.

Features

  • Config-driven capability map per collection for read, create, update and delete
  • Runs tools as the logged-in user with overrideAccess disabled, so existing access rules apply
  • Field include and exclude lists to hide sensitive fields such as salt and hash
  • Human approval gating for chosen writes, shown as approval cards
  • Audit ledger collection recording each action from preview to executed, failed or reverted
  • Custom domain tools and any AI SDK model supported, with Claude by default

Use cases

  • Let admin staff query and update orders or products through natural-language chat
  • Require human approval before the AI updates or deletes sensitive records
  • Expose custom business actions like refunds to an access-scoped AI assistant

From the author

Config-driven AI control panel for Payload CMS. Declare what the AI may read/create/update/delete; get a chat panel in the admin that controls your app — every action runs through Payload access control as the logged-in user.

Installation

npm i payload-ai-admin

3

Stars

0

Forks

0

Open Issues

6 months ago

Last Updated

9

Weekly Downloads

v0.1.0

npm Version

118.0 KB

Unpacked Size

5

Dependencies

GitHub stars

30 since Sep 6

Show data
GitHub stars by day (UTC)
DateStars
Dec 5, 20263
Dec 4, 20263
Dec 3, 20263
Dec 2, 20263
Dec 1, 20263
Nov 30, 20263
Nov 29, 20263
Nov 28, 20263
Nov 27, 20263
Nov 26, 20263
Nov 25, 20263
Nov 24, 20263
Nov 23, 20263
Nov 22, 20263
Nov 21, 20263
Nov 20, 20263
Nov 19, 20263
Nov 18, 20263
Nov 17, 20263
Nov 16, 20263
Nov 15, 20263
Nov 14, 20263
Nov 13, 20263
Nov 12, 20263
Nov 11, 20263
Nov 10, 20263
Nov 9, 20263
Nov 8, 20263
Nov 7, 20263
Nov 6, 20263
Nov 5, 20263
Nov 4, 20263
Nov 3, 20263
Nov 2, 20263
Nov 1, 20263
Oct 31, 20263
Oct 30, 20263
Oct 29, 20263
Oct 28, 20263
Oct 27, 20263
Oct 26, 20263
Oct 25, 20263
Oct 24, 20263
Oct 23, 20263
Oct 22, 20263
Oct 21, 20263
Oct 20, 20263
Oct 19, 20263
Oct 18, 20263
Oct 17, 20263
Oct 16, 20263
Oct 15, 20263
Oct 14, 20263
Oct 13, 20263
Oct 12, 20263
Oct 11, 20263
Oct 10, 20263
Oct 9, 20263
Oct 8, 20263
Oct 7, 20263
Oct 6, 20263
Oct 5, 20263
Oct 4, 20263
Oct 3, 20263
Oct 2, 20263
Oct 1, 20263
Sep 30, 20263
Sep 29, 20263
Sep 28, 20263
Sep 27, 20263
Sep 26, 20263
Sep 25, 20263
Sep 24, 20263
Sep 23, 20263
Sep 22, 20263
Sep 21, 20263
Sep 20, 20263
Sep 19, 20263
Sep 18, 20263
Sep 17, 20263
Sep 16, 20263
Sep 15, 20263
Sep 14, 20263
Sep 13, 20263
Sep 12, 20263
Sep 11, 20263
Sep 10, 20263
Sep 9, 20263
Sep 8, 20263
Sep 7, 20263
Sep 6, 20263
npm weekly downloads

7+2 since Sep 6

Show data
npm weekly downloads by day (UTC)
DateWeekly downloads
Dec 5, 20267
Dec 4, 20267
Dec 3, 20266
Dec 2, 20265
Dec 1, 20266
Nov 30, 20269
Nov 29, 20269
Nov 28, 20268
Nov 27, 202614
Nov 26, 202614
Nov 25, 202614
Nov 24, 202611
Nov 23, 20268
Nov 22, 20268
Nov 21, 20268
Nov 20, 20261
Nov 19, 20263
Nov 18, 20265
Nov 17, 20265
Nov 16, 20267
Nov 15, 20267
Nov 14, 20268
Nov 13, 202611
Nov 12, 202611
Nov 11, 20269
Nov 10, 20269
Nov 9, 20267
Nov 8, 20267
Nov 7, 20267
Nov 6, 20264
Nov 5, 20263
Nov 4, 20264
Nov 3, 20264
Nov 2, 20268
Nov 1, 20268
Oct 31, 20267
Oct 30, 20267
Oct 29, 20266
Oct 28, 20265
Oct 27, 20266
Oct 26, 20263
Oct 25, 20262
Oct 24, 20264
Oct 23, 20264
Oct 22, 20266
Oct 21, 20266
Oct 20, 20265
Oct 19, 20266
Oct 18, 20266
Oct 17, 20265
Oct 16, 20265
Oct 15, 20264
Oct 14, 20264
Oct 13, 20264
Oct 12, 20263
Oct 11, 20264
Oct 10, 20263
Oct 9, 20264
Oct 8, 20263
Oct 7, 20264
Oct 6, 20264
Oct 5, 20263
Oct 4, 20262
Oct 3, 20263
Oct 2, 20264
Oct 1, 20264
Sep 30, 20263
Sep 29, 20263
Sep 28, 20263
Sep 27, 20264
Sep 26, 20267
Sep 25, 20266
Sep 24, 20266
Sep 23, 20266
Sep 22, 20267
Sep 21, 20267
Sep 20, 20267
Sep 19, 20264
Sep 18, 20263
Sep 17, 20264
Sep 16, 20265
Sep 15, 20264
Sep 14, 20266
Sep 13, 20266
Sep 12, 20265
Sep 11, 20265
Sep 10, 20264
Sep 9, 20264
Sep 8, 20264
Sep 7, 20266
Sep 6, 20265

Each point is npm's rolling 7-day download count.

Health Score

41/100Fair

Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.

Badge for your README

Payload Directory health badge
Markdown
[![Payload Directory](https://payloaddirectory.dev/badge/1245559680-root.svg)](https://payloaddirectory.dev/plugins/1245559680-root)
HTML
<a href="https://payloaddirectory.dev/plugins/1245559680-root"><img src="https://payloaddirectory.dev/badge/1245559680-root.svg" alt="Payload Directory"></a>
Updated May 22, 2026Created May 21, 2026Published May 22, 2026

README

payload-ai-admin

npm version License: MIT

A config-driven AI control panel for PayloadCMS. Install the plugin, declare which collections/fields/operations the AI may touch, and get a chat panel inside the Payload admin that reads and edits your app on command.

Built on the AI SDK v6. The default model is Anthropic Claude; any AI SDK model works.

Status: v0.x, experimental. The plugin API (a function config => config) is stable; option shapes may still change before 1.0.

Why it's safe

Capability is enforced in two layers:

  1. Payload access control, as the user. Every tool runs the Local API with the request's authenticated user and overrideAccess: false. The AI can never do anything the logged-in user couldn't do by hand — your existing collection/field access functions apply unchanged.
  2. A plugin allowlist (narrower). collections declares per-slug read/create/update/delete, optional field include/exclude lists, and which writes require human approval. A tool for a slug/op you didn't allow is never even generated, so the model can't call it.

Auth is free: the chat is a Payload custom endpoint and the admin view reuses the Payload admin session cookie — no separate app, JWT proxy, or second deployment.

Features

  • Config-driven capability map — declare per-collection read/create/update/delete
  • Two-layer security: Payload access control (overrideAccess: false) + a narrower plugin allowlist
  • Field-level scoping with include/exclude lists (e.g. hide salt/hash)
  • Human-in-the-loop approval gating for destructive or sensitive writes
  • Audit ledger of every action (preview → executed/failed/reverted)
  • Embedded admin chat view + nav link — reuses the Payload admin session, no second app
  • Custom domain tools, access-scoped to the logged-in user
  • Built on AI SDK v6 — Anthropic Claude by default, any AI SDK model supported
  • Full TypeScript support
  • Next.js 15 / 16 + React 19 compatible

Installation

npm install payload-ai-admin
# or
pnpm add payload-ai-admin
# or
yarn add payload-ai-admin

Requirements

  • PayloadCMS 3.x (payload@^3.37)
  • Next.js 15+ or Next.js 16
  • React 19 (react@^19, react-dom@^19)
  • ANTHROPIC_API_KEY in your environment (for the default model)

Quick Start

1. Server Configuration

Add the plugin to your Payload config and declare what the AI may touch:

// payload.config.ts
import { buildConfig } from 'payload'
import { payloadAiAdmin } from 'payload-ai-admin'

export default buildConfig({
  // ...your config
  plugins: [
    payloadAiAdmin({
      // who may use the chat (defaults to any authenticated user)
      access: (user) => user?.roles?.includes('admin') ?? false,
      collections: {
        orders:   { read: true, update: true, approval: ['update'] },
        products: { read: true, create: true, update: true },
        users:    { read: true, fields: { exclude: ['salt', 'hash'] } },
      },
    }),
  ],
})

2. Generate the import map

payload generate:importmap

This resolves the embedded admin view + nav link.

3. Environment Variables

ANTHROPIC_API_KEY=sk-ant-...

Start your app and open /admin/claudia.

Configuration Options

OptionTypeDefaultDescription
collectionsRecord<string, ClaudiaCollectionRule>requiredThe capability map.
access(user) => booleanany authed userWho may use the chat + see the audit ledger.
modelAI SDK LanguageModelanthropic('claude-sonnet-4-6')Any AI SDK v6 model.
tools(ctx) => Record<string, Tool>—Register custom domain tools (access-scoped ctx).
instructionsstring | (ctx) => stringauto from configOverride/extend the system prompt.
maxStepsnumber6Agent loop cap.
labelstring'Claudia'Nav-item / view label.
siteNamestring—Name injected into the system prompt.
conversationsSlugstringclaudia-conversationsSlug for the chat-history collection.
actionsSlugstringclaudia-actionsSlug for the audit-ledger collection.
enabledbooleantrueDisable without uninstalling.

Collection rule (ClaudiaCollectionRule)

{
  read?: boolean
  create?: boolean
  update?: boolean
  delete?: boolean
  fields?: { include?: string[]; exclude?: string[] }   // field-level scoping
  approval?: ('create' | 'update' | 'delete')[]          // writes that need human OK
}

How It Works

  • Adds two collections: claudia-conversations (chat history) and claudia-actions (an audit ledger — preview → executed/failed/reverted).
  • Adds endpoints POST /api/claudia/chat (streams the agent via AI SDK) and POST /api/claudia/actions/:id/:decision (approve/reject a queued write).
  • Generic tools (queryCollection, getDocument, countDocuments, createDocument, updateDocument, deleteDocument) are generated from your collections config.
  • Approval-gated writes don't mutate — they record a preview row and surface an approval card; the change executes only when a human approves it.
  • Registers an embedded admin view at /admin/claudia + a nav link.

Custom Tools

Register domain-specific tools alongside the generated CRUD tools. The context (payload/req) is access-scoped to the logged-in user:

import { tool } from 'ai'
import { z } from 'zod'
import { payloadAiAdmin } from 'payload-ai-admin'

payloadAiAdmin({
  collections: { orders: { read: true } },
  tools: ({ payload, req }) => ({
    refundOrder: tool({
      description: 'Refund an order via the payment provider.',
      inputSchema: z.object({ orderId: z.number() }),
      execute: async ({ orderId }) => {
        // your domain logic; payload/req are access-scoped
        return { ok: true }
      },
    }),
  }),
})

TypeScript

Full TypeScript support. The package ships type declarations and three entry points:

import { payloadAiAdmin } from 'payload-ai-admin'        // server / payload.config.ts
import { /* client components */ } from 'payload-ai-admin/client'
import { /* RSC exports */ } from 'payload-ai-admin/rsc'

Development

pnpm install
pnpm build       # tsc → dist (preserves 'use client')
pnpm test        # vitest

Currently dogfooded inside a full Payload ecommerce app. A standalone dev/ harness (via create-payload-app --template plugin) is on the roadmap.

Changelog

0.1.0

  • Initial release

Contributing

Contributions are welcome! Please open an issue or pull request.

License

MIT © blaze IT s.r.o.

Similar plugins