@agentguard-run/burn 0.3.17 → 0.3.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OVERRIDE_COMMAND = void 0;
4
+ exports.stopSummary = stopSummary;
5
+ exports.primarySummary = primarySummary;
6
+ exports.sessionSoFar = sessionSoFar;
7
+ exports.continueLines = continueLines;
8
+ exports.askReason = askReason;
9
+ exports.overriddenLine = overriddenLine;
10
+ /**
11
+ * The override the person runs. The unscoped `agentguard-burn` launcher runs
12
+ * the latest Burn through npx, so it works for everyone, including plugin-only
13
+ * installs that never put a Burn binary on PATH, and it has no "@" for X to
14
+ * turn into a mention link when it is quoted in a post.
15
+ */
16
+ exports.OVERRIDE_COMMAND = 'npx agentguard-burn resume --once --reason "..."';
17
+ function fmt(n) {
18
+ if (n >= 1e9)
19
+ return `${(n / 1e9).toFixed(2)}B`;
20
+ if (n >= 1e6)
21
+ return `${(n / 1e6).toFixed(1)}M`;
22
+ if (n >= 1e3)
23
+ return `${(n / 1e3).toFixed(0)}K`;
24
+ return String(Math.round(n));
25
+ }
26
+ /** The one limit that stopped this launch, in its own words and numbers. */
27
+ function stopSummary(report) {
28
+ return report.findings.find((f) => f.verdict === 'STOP')?.summary
29
+ ?? 'Sub-agents starting right now would pass the fan-out limit.';
30
+ }
31
+ /** The finding a one-line message should lead with: the STOP, else the first WARN, else the first finding. */
32
+ function primarySummary(report) {
33
+ return (report.findings.find((f) => f.verdict === 'STOP') ?? report.findings.find((f) => f.verdict === 'WARN') ?? report.findings[0])?.summary ?? '';
34
+ }
35
+ function sessionSoFar(report, subject = 'spawn') {
36
+ return subject === 'call'
37
+ ? `Session so far: ${fmt(report.totals.tokens)} tokens.`
38
+ : `Session so far: ${report.totals.spawns} sub-agents, ${fmt(report.totals.tokens)} tokens.`;
39
+ }
40
+ /**
41
+ * How the person continues once. In Claude Code a command typed with `!` runs
42
+ * in the person's own shell and never passes through a hook, so it is the
43
+ * person's key; the same command attempted by the agent is refused.
44
+ */
45
+ function continueLines(host, subject = 'spawn') {
46
+ const what = subject === 'call' ? 'send it' : 'launch it';
47
+ return host === 'claude-code'
48
+ ? [`To ${what} anyway, once, type this yourself:`, `! ${exports.OVERRIDE_COMMAND}`]
49
+ : [`To ${what} anyway, once, run this in a terminal:`, exports.OVERRIDE_COMMAND];
50
+ }
51
+ /**
52
+ * The text of Claude Code's permission prompt when a STOP holds a launch.
53
+ * Claude Code shows this to the person and not to Claude.
54
+ */
55
+ function askReason(report) {
56
+ return `AgentGuard: ${stopSummary(report)}\n${sessionSoFar(report)}\nAllow this one launch? If you say no, nothing starts.`;
57
+ }
58
+ /** The line after a person-approved override, naming the limit it passed. */
59
+ function overriddenLine(report, override) {
60
+ return `AgentGuard STOP overridden${override.once ? ' once' : ''} ("${override.reason}"): ${stopSummary(report)}`;
61
+ }
@@ -147,6 +147,15 @@ export interface Policy {
147
147
  teamPolicyFile?: string;
148
148
  mode: Mode;
149
149
  thresholds: Thresholds;
150
+ /**
151
+ * How an enforced STOP reaches the person in an interactive Claude Code
152
+ * session. "ask" (the default) holds the launch behind Claude Code's own
153
+ * permission prompt: the person answers with one keypress, Claude never sees
154
+ * the reason, and auto mode cannot approve it silently. "deny" refuses
155
+ * outright everywhere. Hosts and modes that cannot show a prompt (print
156
+ * mode, bypassPermissions, dontAsk, Codex, Cursor) always refuse.
157
+ */
158
+ stopStyle?: 'ask' | 'deny';
150
159
  /** Additive local usage advisories. Older policy files use these defaults. */
151
160
  insights?: {
152
161
  rewriteWarnDollarsPerHour?: number;
@@ -22,7 +22,7 @@ REPLAY SHARE % │ spawn_rate:WARN
22
22
  │
23
23
  session cache-read / tokens │
24
24
  │
25
- │ STOP · blocked
25
+ │ STOP · refused
26
26
  │ spawn_rate:STOP
27
27
  │ Reason held for 2 seconds.
28
28
  │
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentguard-run/burn",
3
- "version": "0.3.17",
3
+ "version": "0.3.19",
4
4
  "description": "Local session usage and runaway-agent circuit breaker. Explain tokens, cache rewrites and API list cost, track pace, warn on heavy turns, and gate agent fan-out with signed receipts. Developer command ranking requires explicit --rank.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "type": "commonjs",