@agentguard-run/burn 0.6.1 → 0.7.0
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.
- package/CHANGELOG.md +13 -1
- package/README.md +43 -0
- package/dist/src/cli.d.ts +1 -0
- package/dist/src/cli.js +27 -2
- package/dist/src/frames.js +8 -0
- package/dist/src/hook/pre-tool-use.d.ts +8 -1
- package/dist/src/hook/pre-tool-use.js +7 -3
- package/dist/src/hook-edit.d.ts +28 -0
- package/dist/src/hook-edit.js +232 -0
- package/dist/src/idle/collect.d.ts +8 -0
- package/dist/src/idle/collect.js +124 -4
- package/dist/src/idle/disk.d.ts +40 -0
- package/dist/src/idle/disk.js +152 -0
- package/dist/src/idle/platform.d.ts +5 -0
- package/dist/src/idle/platform.js +14 -0
- package/dist/src/idle/render.js +22 -1
- package/dist/src/idle/types.d.ts +30 -0
- package/dist/src/install-all.d.ts +209 -0
- package/dist/src/install-all.js +877 -0
- package/package.json +1 -1
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `agentguard-burn install`: AgentGuard on every agent host on this machine.
|
|
3
|
+
*
|
|
4
|
+
* It finds Claude Code, Codex, Cursor and Hermes by their command on PATH and
|
|
5
|
+
* their config folder, and decides what to do by reading files: nothing is
|
|
6
|
+
* started to look. Without --yes it prints the plan (each host, the exact
|
|
7
|
+
* commands, the files they change) and changes nothing, so an agent can show
|
|
8
|
+
* the plan to its person first. With --yes it runs each host's own plugin
|
|
9
|
+
* commands, reads the same files again, and reports one line per host.
|
|
10
|
+
*
|
|
11
|
+
* It never pipes a downloaded script to a shell, never uses sudo, never
|
|
12
|
+
* installs a host itself and never asks for or stores a key. It also never
|
|
13
|
+
* writes Burn's policy file: the plugin seeds enforce mode into a fresh one,
|
|
14
|
+
* and a file written first would keep a new install in shadow.
|
|
15
|
+
*/
|
|
16
|
+
export type AgentHost = 'claude' | 'codex' | 'cursor' | 'hermes';
|
|
17
|
+
export declare const AGENT_HOSTS: readonly AgentHost[];
|
|
18
|
+
export declare const HOST_NAMES: Record<AgentHost, string>;
|
|
19
|
+
export declare const PLUGIN_REPO = "agentguard-run/agentguard-codex-plugin";
|
|
20
|
+
export declare const PLUGIN_ID = "agentguard@agentguard";
|
|
21
|
+
export declare const HERMES_PACKAGE = "agentguard-spend-hermes";
|
|
22
|
+
export declare const HERMES_PLUGIN = "agentguard-spend";
|
|
23
|
+
/** Where the plugin lived before it moved; GitHub forwards it to PLUGIN_REPO. */
|
|
24
|
+
export declare const OLD_PLUGIN_REPO = "MerchantGuard/agentguard-codex-plugin";
|
|
25
|
+
/**
|
|
26
|
+
* The oldest plugin release this Burn treats as current. A host's local
|
|
27
|
+
* marketplace copy can be weeks stale (it refreshes only when asked), so an
|
|
28
|
+
* install older than this is updated even when that copy offers nothing newer.
|
|
29
|
+
*/
|
|
30
|
+
export declare const PLUGIN_FLOOR_VERSION = "0.5.0";
|
|
31
|
+
/** Negative when a is older than b. Versions that are not x.y.z compare equal. */
|
|
32
|
+
export declare function compareVersions(a: string, b: string): number;
|
|
33
|
+
export interface InstallContext {
|
|
34
|
+
home: string;
|
|
35
|
+
env: Record<string, string | undefined>;
|
|
36
|
+
platform: NodeJS.Platform;
|
|
37
|
+
/** This Burn's cli.js. The Cursor hook runs it. */
|
|
38
|
+
cliPath: string;
|
|
39
|
+
}
|
|
40
|
+
export interface InstallOptions {
|
|
41
|
+
yes: boolean;
|
|
42
|
+
json: boolean;
|
|
43
|
+
/** Hosts named with --only, or null for every host. */
|
|
44
|
+
only: AgentHost[] | null;
|
|
45
|
+
skip: AgentHost[];
|
|
46
|
+
}
|
|
47
|
+
export declare const INSTALL_USAGE = "Usage: agentguard-burn install [--yes] [--only claude,codex,cursor,hermes] [--skip <hosts>] [--json]";
|
|
48
|
+
export declare function parseInstallArgs(args: string[]): InstallOptions | {
|
|
49
|
+
error: string;
|
|
50
|
+
};
|
|
51
|
+
export declare function which(name: string, ctx: Pick<InstallContext, 'env' | 'platform'>): string | null;
|
|
52
|
+
/**
|
|
53
|
+
* The plugin's two locked runtime packages are on disk: in its folder, or in
|
|
54
|
+
* the durable copy its postinstall keeps in the plugin data folder, keyed by
|
|
55
|
+
* the lockfile digest (Codex can replace its install cache at session start).
|
|
56
|
+
*/
|
|
57
|
+
export declare function pluginDependenciesPresent(root: string, data?: string | null): boolean;
|
|
58
|
+
/** Where the host keeps the plugin's data: `<plugins>/data/agentguard-<marketplace>`, the same for Claude Code and Codex. */
|
|
59
|
+
export declare function pluginDataDir(configDir: string): string;
|
|
60
|
+
/** The mode AgentGuard runs in on a host, read from local files. */
|
|
61
|
+
export interface HostMode {
|
|
62
|
+
mode: 'enforce' | 'shadow';
|
|
63
|
+
/** Why it is not enforcing, or what can still change it; null when nothing does. */
|
|
64
|
+
reason: string | null;
|
|
65
|
+
/** Where the mode was read. */
|
|
66
|
+
source: string;
|
|
67
|
+
/** The status command that reports the effective mode on that host. */
|
|
68
|
+
check: string;
|
|
69
|
+
}
|
|
70
|
+
/** One host as found on this machine. */
|
|
71
|
+
export interface HostState {
|
|
72
|
+
host: AgentHost;
|
|
73
|
+
/** The host's command on PATH. */
|
|
74
|
+
binary: string | null;
|
|
75
|
+
/** Where the host keeps its config, whether or not it exists. */
|
|
76
|
+
configDir: string;
|
|
77
|
+
configDirExists: boolean;
|
|
78
|
+
present: boolean;
|
|
79
|
+
/** AgentGuard is in place and complete for this host. */
|
|
80
|
+
installed: boolean;
|
|
81
|
+
/** The host has AgentGuard registered (its record exists), complete or not. */
|
|
82
|
+
registered: boolean;
|
|
83
|
+
version: string | null;
|
|
84
|
+
/** The plugin folder, the hook file or the Python environment AgentGuard lives in. */
|
|
85
|
+
root: string | null;
|
|
86
|
+
/** The plugin's locked dependencies are on disk (Claude Code and Codex). */
|
|
87
|
+
dependencies: boolean | null;
|
|
88
|
+
/** The configured AgentGuard marketplace source, if any. */
|
|
89
|
+
marketplace: string | null;
|
|
90
|
+
/** False when the person turned AgentGuard off in the host's own config. */
|
|
91
|
+
enabled: boolean | null;
|
|
92
|
+
/** A file holding a standalone Burn hook for this host. */
|
|
93
|
+
standaloneHook: string | null;
|
|
94
|
+
/** Something found while reading that stops a safe install. */
|
|
95
|
+
problem: string | null;
|
|
96
|
+
/** Hermes: the Python environment Hermes runs from. */
|
|
97
|
+
python: string | null;
|
|
98
|
+
/** Cursor: a hook entry exists but its command is gone from disk. */
|
|
99
|
+
broken: boolean;
|
|
100
|
+
/** The mode AgentGuard runs in, once it is registered. */
|
|
101
|
+
mode: HostMode | null;
|
|
102
|
+
/** The plugin version the host's local marketplace copy offers. */
|
|
103
|
+
offered: string | null;
|
|
104
|
+
/** The version an update would bring, when the installed one is older. */
|
|
105
|
+
updateTo: string | null;
|
|
106
|
+
/** The marketplace still points at the plugin's old repository. */
|
|
107
|
+
oldMarketplace: boolean;
|
|
108
|
+
/** Nothing left to do: installed, current, and no standalone Burn hook beside an enabled plugin. */
|
|
109
|
+
complete: boolean;
|
|
110
|
+
}
|
|
111
|
+
/** The data folder the plugin derives from its install folder: `<plugins>/data/agentguard-<marketplace>`. */
|
|
112
|
+
export declare function dataDirForRoot(root: string): string;
|
|
113
|
+
export declare function probeHost(host: AgentHost, ctx: InstallContext): HostState;
|
|
114
|
+
export declare function detectHosts(ctx: InstallContext): HostState[];
|
|
115
|
+
export interface PlannedCommand {
|
|
116
|
+
/** The command as a person would type it, or what Burn does itself. */
|
|
117
|
+
command: string;
|
|
118
|
+
/** The program and arguments, run without a shell; null when Burn makes the change itself. */
|
|
119
|
+
argv: string[] | null;
|
|
120
|
+
/** Where it runs; null is the current folder. */
|
|
121
|
+
cwd: string | null;
|
|
122
|
+
/** Runs in the plugin folder the previous command installed, which is known only then. */
|
|
123
|
+
cwdFromPluginRoot?: boolean;
|
|
124
|
+
/** Runs only when the plugin's dependencies are missing after the step before. */
|
|
125
|
+
onlyIfDependenciesMissing?: boolean;
|
|
126
|
+
/** A change Burn makes itself (argv is null): Cursor's hook, or removing a standalone Burn hook from `file`. */
|
|
127
|
+
builtin?: 'cursor-hook' | 'remove-burn-hook';
|
|
128
|
+
file?: string;
|
|
129
|
+
}
|
|
130
|
+
export type HostPlanState = 'absent' | 'excluded' | 'installed' | 'install' | 'blocked';
|
|
131
|
+
export interface HostPlan {
|
|
132
|
+
host: AgentHost;
|
|
133
|
+
name: string;
|
|
134
|
+
found: {
|
|
135
|
+
binary: string | null;
|
|
136
|
+
configDir: string | null;
|
|
137
|
+
};
|
|
138
|
+
/** absent: not on this machine. excluded: left out by --only or --skip. installed: nothing to do. install: the commands below. blocked: present, but something it needs is missing. */
|
|
139
|
+
state: HostPlanState;
|
|
140
|
+
detail: string;
|
|
141
|
+
commands: PlannedCommand[];
|
|
142
|
+
/** Files and folders the commands change. */
|
|
143
|
+
files: string[];
|
|
144
|
+
notes: string[];
|
|
145
|
+
/** Named with --only. */
|
|
146
|
+
requested: boolean;
|
|
147
|
+
/** The mode AgentGuard runs in on this host, when it is already registered. */
|
|
148
|
+
mode: HostMode | null;
|
|
149
|
+
/** Set when an installed plugin is older than what is available. */
|
|
150
|
+
update?: {
|
|
151
|
+
from: string;
|
|
152
|
+
to: string;
|
|
153
|
+
} | null;
|
|
154
|
+
}
|
|
155
|
+
export interface InstallPlan {
|
|
156
|
+
hosts: HostPlan[];
|
|
157
|
+
options: InstallOptions;
|
|
158
|
+
/** The command that carries out this plan. */
|
|
159
|
+
next: string | null;
|
|
160
|
+
}
|
|
161
|
+
export declare function planInstall(ctx: InstallContext, options: InstallOptions): InstallPlan;
|
|
162
|
+
/** "enforce (local policy)" or "shadow: <why> (<where read>)". */
|
|
163
|
+
export declare function modeText(mode: HostMode): string;
|
|
164
|
+
export declare function renderPlan(plan: InstallPlan, ctx: InstallContext): string;
|
|
165
|
+
export interface RunResult {
|
|
166
|
+
status: number | null;
|
|
167
|
+
stdout: string;
|
|
168
|
+
stderr: string;
|
|
169
|
+
/** Set when the program could not be started (missing, timed out). */
|
|
170
|
+
error?: string;
|
|
171
|
+
}
|
|
172
|
+
export type Runner = (argv: string[], options: {
|
|
173
|
+
cwd: string | null;
|
|
174
|
+
}) => RunResult;
|
|
175
|
+
/** Runs a host command without a shell and without stdin, so nothing can wait on a prompt. */
|
|
176
|
+
export declare function defaultRunner(ctx: InstallContext): Runner;
|
|
177
|
+
export type HostOutcome = 'installed' | 'already-installed' | 'skipped' | 'failed';
|
|
178
|
+
export interface HostResult {
|
|
179
|
+
host: AgentHost;
|
|
180
|
+
name: string;
|
|
181
|
+
outcome: HostOutcome;
|
|
182
|
+
reason: string;
|
|
183
|
+
/** Every command started, in order, with its exit code. */
|
|
184
|
+
ran: Array<{
|
|
185
|
+
command: string;
|
|
186
|
+
cwd: string | null;
|
|
187
|
+
exitCode: number | null;
|
|
188
|
+
}>;
|
|
189
|
+
/** The host as read again after the run. */
|
|
190
|
+
after: {
|
|
191
|
+
installed: boolean;
|
|
192
|
+
version: string | null;
|
|
193
|
+
root: string | null;
|
|
194
|
+
mode: HostMode | null;
|
|
195
|
+
};
|
|
196
|
+
notes: string[];
|
|
197
|
+
}
|
|
198
|
+
export interface InstallReport {
|
|
199
|
+
ok: boolean;
|
|
200
|
+
hosts: HostResult[];
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Carries out a plan: each host in turn, continuing past a host that fails,
|
|
204
|
+
* then reads every host again (the same checks the plan used) for its line.
|
|
205
|
+
*/
|
|
206
|
+
export declare function runInstall(plan: InstallPlan, ctx: InstallContext, runner: Runner, log?: (line: string) => void): InstallReport;
|
|
207
|
+
export declare function renderReport(report: InstallReport): string;
|
|
208
|
+
/** What --json prints: the plan, and after --yes the result for each host. `mode` is plan or install; each host's `agentguardMode` is the enforce or shadow mode AgentGuard runs in there. */
|
|
209
|
+
export declare function installJson(version: string, plan: InstallPlan, report: InstallReport | null): Record<string, unknown>;
|