Skip to content

Commit d41454c

Browse files
committed
fix: add README.md to package root so npm page displays documentation (v0.1.5)
1 parent 6325647 commit d41454c

File tree

2 files changed

+156
-1
lines changed

2 files changed

+156
-1
lines changed

packages/core/README.md

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
# AuthorityLayer
2+
3+
[![CI](https://github.com/032383justin/authority-layer/actions/workflows/ci.yml/badge.svg)](https://github.com/032383justin/authority-layer/actions/workflows/ci.yml)
4+
[![npm version](https://img.shields.io/npm/v/authority-layer?color=blue)](https://www.npmjs.com/package/authority-layer)
5+
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
6+
[![Node.js >= 18](https://img.shields.io/badge/node-%3E%3D18-brightgreen)](https://nodejs.org)
7+
8+
Hard execution and budget limits for autonomous agents — enforced locally.
9+
10+
✔ No telemetry
11+
✔ Works fully offline
12+
✔ Fail-closed by default
13+
✔ Zero runtime dependencies
14+
15+
---
16+
17+
## Why AuthorityLayer Exists
18+
19+
Autonomous AI agents can fail in expensive, hard-to-detect ways:
20+
21+
- **Runaway token spend** — a looping agent burns thousands of dollars before anyone notices
22+
- **Infinite tool loops** — agents retry the same failing call indefinitely
23+
- **Retry storms** — cascading failures hammer external APIs with no ceiling
24+
- **Cascading tool call explosions** — one agent spawns sub-calls that spawn more
25+
26+
Most tooling detects these problems after they happen — in dashboards, alerts, or post-run analytics.
27+
28+
AuthorityLayer prevents them inside the runtime, before cost or damage accumulates.
29+
30+
It helps developers:
31+
32+
- prevent runaway LLM costs
33+
- stop infinite agent loops
34+
- limit AI agent tool calls per run and per minute
35+
- enforce runtime safety for autonomous agents
36+
37+
---
38+
39+
## Live Enforcement Demo (10-second example)
40+
41+
![AuthorityLayer enforcement demo](https://raw.githubusercontent.com/032383justin/authority-layer/main/docs/assets/enforcement-demo.svg)
42+
43+
---
44+
45+
## Quick Start
46+
47+
```bash
48+
npm install authority-layer
49+
```
50+
51+
Verify the install:
52+
53+
```bash
54+
npx authority-layer doctor
55+
```
56+
57+
```
58+
AuthorityLayer Doctor authority-layer@0.1.2
59+
60+
✔ Node.js version >= 18 pass
61+
✔ crypto module (sha256) pass
62+
✔ AUTHORITY_LAYER_DISABLE not set pass
63+
✔ core module loads offline pass
64+
✔ AuthorityLayer instantiates pass
65+
66+
All checks passed. AuthorityLayer is ready.
67+
```
68+
69+
## CLI Tools
70+
71+
| Command | What it does |
72+
|---------|-------------|
73+
| `npx authority-layer doctor` | Verify your installation passes all environment checks |
74+
| `npx authority-layer simulate` | Run a live enforcement simulation — see a halt in action without writing any code |
75+
76+
---
77+
78+
## Minimal Integration
79+
80+
```typescript
81+
import { AuthorityLayer, EnforcementHalt } from "authority-layer";
82+
83+
const authority = new AuthorityLayer({
84+
budget: { dailyUSD: 50 }, // Hard USD spend cap
85+
loopGuard: { maxToolCallsPerRun: 25 }, // Max tool calls per run
86+
toolThrottle: { maxCallsPerMinute: 60 }, // Sliding-window rate cap
87+
});
88+
89+
try {
90+
await authority.wrap(async () => {
91+
const result = await authority.tool("llm.chat", () =>
92+
callYourModel(prompt)
93+
);
94+
authority.recordSpend(calculateCostUSD(result));
95+
});
96+
} catch (err) {
97+
if (err instanceof EnforcementHalt) {
98+
console.error(err.enforcement);
99+
// { status: "halted", reason: "budget_exceeded", limit: 50, spent: 52.14, event_id: "evt_..." }
100+
}
101+
}
102+
```
103+
104+
---
105+
106+
## Enforcement Primitives
107+
108+
AuthorityLayer V1 provides three composable enforcement primitives. Each is opt-in — omit a config key to disable it.
109+
110+
These primitives enforce boundaries directly inside the execution loop — not in dashboards or external monitoring.
111+
112+
| Primitive | Config key | What it enforces |
113+
|-----------|------------|------------------|
114+
| **Budget cap** | `budget.dailyUSD` | Cumulative USD spend across the process lifetime. Halts when spend exceeds the cap. → [docs](./docs/enforcement.md#1-budget-cap) |
115+
| **Loop guard** | `loopGuard.maxToolCallsPerRun` | Total tool calls per `wrap()` invocation. Counter resets each run. → [docs](./docs/enforcement.md#2-loop-guard) |
116+
| **Tool throttle** | `toolThrottle.maxCallsPerMinute` | Rate of tool calls using a sliding 60-second window — no fixed buckets. → [docs](./docs/enforcement.md#3-tool-throttle) |
117+
118+
When a primitive breaches, AuthorityLayer throws a typed `EnforcementHalt` error with a structured `.enforcement` object. Execution never crashes silently.
119+
120+
---
121+
122+
## How AuthorityLayer Is Different
123+
124+
Most AI guardrail tools focus on moderation or observability. AuthorityLayer focuses on **runtime enforcement**.
125+
126+
| Tool type | What it does |
127+
|-----------|-------------|
128+
| Prompt guardrails | Filter or rewrite prompts and outputs |
129+
| Observability platforms | Analyze agent behavior after execution |
130+
| Cost analytics | Track and report token usage |
131+
| **AuthorityLayer** | Enforces hard limits **during** execution — halts immediately when a boundary is crossed |
132+
133+
---
134+
135+
## Documentation
136+
137+
| Topic | File |
138+
|------|------|
139+
| Concepts & philosophy | [docs/concepts.md](./docs/concepts.md) |
140+
| Enforcement primitives | [docs/enforcement.md](./docs/enforcement.md) |
141+
| API reference | [docs/api.md](./docs/api.md) |
142+
| Integrity chain | [docs/integrity.md](./docs/integrity.md) |
143+
| Example run | `npm run example` |
144+
145+
---
146+
147+
AuthorityLayer is designed as a minimal enforcement primitive — not a platform, dashboard, or governance system.
148+
149+
---
150+
151+
## License
152+
153+
MIT © 2025 AuthorityLayer Contributors
154+
155+
[GitHub](https://github.com/032383justin/authority-layer) · [npm](https://www.npmjs.com/package/authority-layer) · [Issues](https://github.com/032383justin/authority-layer/issues)

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "authority-layer",
3-
"version": "0.1.4",
3+
"version": "0.1.5",
44
"description": "Runtime guardrails for AI agents that enforce token budgets, loop limits, and tool rate limits locally.",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

0 commit comments

Comments
 (0)