@happyvertical/smrt-playbooks

中文文档
0.62.1发布于 2026/11/17MITTypeScriptES Module近 30 天下载 2.1万

Layered playbook registry, app/tenant overrides, and plan resolution for SMRT agents

原始使用文档
文档目录5 节
  1. Installation
  2. Quick start
  3. What this package provides
  4. Guarantees
  5. Documentation

@happyvertical/smrt-playbooks

Layered playbook definitions, tenant-aware overrides, and plan resolution for s-m-r-t agents.

A playbook is a named, described sequence of steps an agent follows. It gives a multi-step intent — "check out this cart" — a home that is neither a custom model action nor a view intent, and browser agents, in-app agents, the Node MCP server, and the CLI all follow the same resolved plan.

Installation

pnpm add @happyvertical/smrt-playbooks

Quick start

import { definePlaybook, resolvePlaybook } from '@happyvertical/smrt-playbooks';

// 1. Register a playbook's defaults at startup
definePlaybook({
  key: 'commerce.cart.checkout',
  title: 'Check out this cart',
  description: 'Submits the order and captures payment.',
  steps: [
    {
      kind: 'operation',
      model: '@happyvertical/smrt-commerce:Order',
      action: 'submit',
    },
    {
      kind: 'operation',
      model: '@happyvertical/smrt-commerce:Payment',
      action: 'capture',
    },
  ],
  onStepFailure: 'abort',
});

// 2. Resolve a plan for a caller on a plane
const resolution = await resolvePlaybook('commerce.cart.checkout', {
  db,
  plane: 'server',
});

if (!resolution.ok) {
  // Fails closed with a specific reason: unknown-playbook, disabled,
  // plane-not-declared, intent-registry-unavailable, unknown-intent.
  throw new Error(resolution.message);
}

for (const step of resolution.plan.steps) {
  // The agent executes each step itself; this package never does.
  // step.classification is inherited from the referenced operation.
}

What this package provides

  • definePlaybook() — code-first playbook registration in a global process registry, so a package ships its own playbooks
  • resolvePlaybook() — layered resolution: code default → config override → stored app override → stored tenant override → runtime override
  • PlaybookOverride — CRUD model for app-level and tenant-level playbook settings, stored in _smrt_playbook_overrides
  • Plane validity — a playbook declares browser, server, or both, and resolution on an undeclared plane fails closed
  • TTL cache keyed by (key, tenantId), invalidated on override save/delete

Guarantees

  • A playbook is a script, never a call. Resolution returns a plan; nothing here executes a step. A playbook is therefore never an authority boundary — each step is authorized independently where it runs.
  • Step lists are never editable. No override layer, including a direct model write, can change a playbook's steps. An agent's description of what it is about to do always matches the steps it will follow.
  • Enablement narrows only. A tenant may disable a playbook; it can never enable one a lower layer disabled.
  • Undeclared classification fails closed to { effect: 'destructive', idempotent: false, openWorld: true }. Steps never classify themselves; classification is inherited from the referenced operation.

Documentation

版本与发布记录

@happyvertical/smrt-playbooks 共发布 186 个版本,首次发布于 2026/09/02;过去 12 个月发布了 186 个版本。

版本发布日期距今
0.62.1latest2026/11/17今天
0.62.02026/11/17今天
0.61.62026/11/161 天前
0.61.52026/11/161 天前
0.61.42026/11/161 天前
0.61.32026/11/152 天前

关于 @happyvertical/smrt-playbooks 的常见问题

@happyvertical/smrt-playbooks 是什么?

Layered playbook registry, app/tenant overrides, and plan resolution for SMRT agents

如何安装 @happyvertical/smrt-playbooks?

在项目目录运行 npm install @happyvertical/smrt-playbooks,或使用 pnpm add / yarn add / bun add。

@happyvertical/smrt-playbooks 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@happyvertical/smrt-playbooks 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@happyvertical/smrt-playbooks 可以商用吗?

@happyvertical/smrt-playbooks 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@happyvertical/smrt-playbooks 的下载量有多少?

根据 npm 官方下载统计,@happyvertical/smrt-playbooks 在 2026/10/17 – 2026/11/15 这 30 天内被下载 21,161 次,日均约 705 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@happyvertical/smrt-playbooks 还在维护吗?

最新版本 0.62.1 发布于 2026/11/17(今天);至今共发布 186 个版本,其中过去 12 个月发布了 186 个;首次发布于 2026/09/02。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。