failproofai 1.0.13-beta.3 → 1.0.13
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/.next/standalone/.next/BUILD_ID +1 -1
- package/.next/standalone/.next/build-manifest.json +3 -3
- package/.next/standalone/.next/prerender-manifest.json +4 -4
- package/.next/standalone/.next/required-server-files.json +1 -1
- package/.next/standalone/.next/server/app/_global-error/page/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/server/app/_global-error/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/_global-error.html +1 -1
- package/.next/standalone/.next/server/app/_global-error.rsc +2 -2
- package/.next/standalone/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found/page/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/_not-found.html +1 -1
- package/.next/standalone/.next/server/app/_not-found.rsc +3 -3
- package/.next/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/api/audit/invite/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/audit/run/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/audit/status/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/auth/login-request/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/auth/login-verify/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/auth/logout/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/auth/status/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/download/[project]/[session]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/audit/page/server-reference-manifest.json +2 -2
- package/.next/standalone/.next/server/app/audit/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/audit/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/index.html +1 -1
- package/.next/standalone/.next/server/app/index.rsc +3 -3
- package/.next/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/index.segments/_full.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/page/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/server/app/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/policies/page/server-reference-manifest.json +14 -14
- package/.next/standalone/.next/server/app/policies/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/policies/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/project/[name]/page/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/server/app/project/[name]/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/project/[name]/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page/react-loadable-manifest.json +2 -2
- package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page/server-reference-manifest.json +2 -2
- package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/projects/page/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/server/app/projects/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/projects/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/settings/page/server-reference-manifest.json +8 -8
- package/.next/standalone/.next/server/app/settings/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/settings/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/chunks/_0tovk6q0miud6._.js +1 -1
- package/.next/standalone/.next/server/chunks/_0trp3ycqv17cl._.js +1 -1
- package/.next/standalone/.next/server/chunks/package_json_[json]_cjs_1nxcc4vkpxxu7._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__08ch3staq3ejw._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0bigvy9xmv2ka._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0h86bl2qf0k_o._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0pia5h3p8re4c._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1-ey9fgesfbc0._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__15usvs-ms-0hf._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__16gb3_92zvk5x._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1avi2kypusyb_._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__070rqh7scntiu._.js → [root-of-the-server]__1jq2bh84rafc7._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1r7drlqli-ado._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/_0eoura3_9gjb-._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/_0ouu886szh6yj._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/_0pedwblqdoh58._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{_1tcvpgd7hugnx._.js → _100nvr7rei3us._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/_1djqs9i27e4kg._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/_next-internal_server_app_policies_page_actions_1sp2-yo5_vm5f.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/app_actions_get-scheduled-audit_ts_0ei9snixb5fd-._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/app_audit__components_audit-dashboard_tsx_0p9ud47q0xq5w._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/app_global-error_tsx_1kp6l3x33jqb6._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/app_policies_hooks-client_tsx_19dqvpcz0uxur._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/app_settings_02tf1h47jmhhd._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/{node_modules_html-to-image_es_index_1p-is71j0j7fb.js → node_modules_html-to-image_es_index_1cmkmhnty0-x7.js} +1 -1
- package/.next/standalone/.next/server/chunks/ssr/node_modules_posthog-node_dist_entrypoints_index_node_mjs_11bnuznb72p7z._.js +2 -2
- package/.next/standalone/.next/server/chunks/ssr/package_json_[json]_cjs_013tntikdft59._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/src_hooks_0agdmptetetdt._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/src_hooks_0mdwgjisv4fub._.js +1 -1
- package/.next/standalone/.next/server/middleware-build-manifest.js +3 -3
- package/.next/standalone/.next/server/pages/404.html +1 -1
- package/.next/standalone/.next/server/pages/500.html +1 -1
- package/.next/standalone/.next/server/preview-props.json +3 -3
- package/.next/standalone/.next/server/server-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/server-reference-manifest.json +23 -23
- package/.next/standalone/.next/static/chunks/{2sthn8c56n9m_.js → 0mm-e5t9denbu.js} +1 -1
- package/.next/standalone/.next/static/chunks/{095l2av-xsus2.js → 0rucj5pu307i4.js} +1 -1
- package/.next/standalone/.next/static/chunks/{19l5hbzn475am.js → 1-0se0uwja_ny.js} +1 -1
- package/.next/standalone/.next/static/chunks/{3m9g1l6-yh0s3.js → 173vw1xs-5m5g.js} +1 -1
- package/.next/standalone/.next/static/chunks/{1s__s2o5zcfcy.js → 20cme7d6wv6md.js} +1 -1
- package/.next/standalone/.next/static/chunks/2mz-k_jt_76xt.js +1 -0
- package/.next/standalone/.next/static/chunks/{1uxq_gbvdti30.js → 2u1m0f-wnhz44.js} +1 -1
- package/.next/standalone/.next/static/chunks/{3uaguc-tbu_ik.js → 2ytnb83xmjn3u.js} +1 -1
- package/.next/standalone/.next/static/chunks/{0h7mkux811w5b.js → 40g_e46c1-j4k.js} +1 -1
- package/.next/standalone/.next/static/chunks/44yz8zx53euy1.js +1 -0
- package/.next/standalone/hermes-plugin/plugin.yaml +1 -1
- package/.next/standalone/package.json +11 -10
- package/.next/standalone/sdk/python/uv.lock +6 -6
- package/.next/standalone/sdk/typescript/package-lock.json +31 -61
- package/.next/standalone/sdk/typescript/package.json +3 -0
- package/.next/standalone/server.js +1 -1
- package/dist/cli.mjs +431 -243
- package/dist/worker.mjs +30 -2
- package/hermes-plugin/plugin.yaml +1 -1
- package/openclaw-plugin/daemon-client.js +254 -0
- package/openclaw-plugin/hooks.js +187 -0
- package/openclaw-plugin/index.js +17 -211
- package/package.json +11 -10
- package/src/hooks/antigravity-path-guard.ts +73 -0
- package/src/hooks/daemon-service.ts +188 -18
- package/src/hooks/enforcement-capability.ts +1 -1
- package/src/hooks/handler.ts +24 -0
- package/src/hooks/integrations.ts +5 -2
- package/src/hooks/shell-quote.ts +9 -0
- package/src/hooks/uninstall-cli.ts +30 -8
- package/.next/standalone/.next/static/chunks/3eonfpk9jyceg.js +0 -1
- package/.next/standalone/.next/static/chunks/3zwff_ax3hust.js +0 -1
- /package/.next/standalone/.next/static/{fHR90vZ5ls7d-K8cH9hxe → 4MgI0mZP1iVhhocpUivMm}/_buildManifest.js +0 -0
- /package/.next/standalone/.next/static/{fHR90vZ5ls7d-K8cH9hxe → 4MgI0mZP1iVhhocpUivMm}/_clientMiddlewareManifest.js +0 -0
- /package/.next/standalone/.next/static/{fHR90vZ5ls7d-K8cH9hxe → 4MgI0mZP1iVhhocpUivMm}/_ssgManifest.js +0 -0
package/openclaw-plugin/index.js
CHANGED
|
@@ -4,230 +4,36 @@
|
|
|
4
4
|
* Loaded in-process by the gateway (registered via `plugins.load.paths` +
|
|
5
5
|
* `plugins.entries.failproofai` in ~/.openclaw/openclaw.json). It subscribes to
|
|
6
6
|
* OpenClaw's typed PLUGIN hooks — the only surface that can block; OpenClaw's
|
|
7
|
-
* file-based "internal hooks" are observation-only — and
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
7
|
+
* file-based "internal hooks" are observation-only — and asks failproofaid for
|
|
8
|
+
* each verdict over its Unix socket (daemon-client.js), the way the Hermes
|
|
9
|
+
* plugin does. The daemon answers with the flat `{permission, reason}` verdict
|
|
10
|
+
* `failproofai --hook <event> --cli openclaw` prints; hooks.js maps it to each
|
|
11
|
+
* hook's native return shape. On before_tool_call, an `instruct` verdict uses a
|
|
12
|
+
* one-shot blockReason as OpenClaw's model-visible instruction channel; retries
|
|
13
|
+
* from the same session/policy are allowed for a short window.
|
|
13
14
|
*
|
|
14
15
|
* Marker comment for failproofai's installer detection (do not remove):
|
|
15
16
|
* __failproofai_hook__: true
|
|
16
17
|
*
|
|
17
|
-
* Design notes
|
|
18
|
-
* •
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* shim ships NO inline maps (unlike the OpenCode/Pi shims).
|
|
18
|
+
* Design notes:
|
|
19
|
+
* • No process per hook, and no path outside this directory. OpenClaw ≥
|
|
20
|
+
* 2026.9.6 imports plugins from a copy under ~/.openclaw/tmp/plugin-captures,
|
|
21
|
+
* so a CLI located relative to this file is not there; the shim that spawned
|
|
22
|
+
* one allowed every call once that started. Every module here imports only
|
|
23
|
+
* node built-ins and its siblings.
|
|
24
|
+
* • Non-blocking — the gateway is a long-running multi-channel process, so all
|
|
25
|
+
* I/O is async; a synchronous call on every hook would stall every channel.
|
|
26
26
|
* • No top-level `await` — OpenClaw's plugin loader rejects it; all async work
|
|
27
27
|
* happens inside register()'s handlers.
|
|
28
|
-
*
|
|
29
|
-
* Binary resolution mirrors pi-extension/index.ts: prefer the bundled
|
|
30
|
-
* dist/cli.mjs (node-compatible), fall back to bin/failproofai.mjs with bun for
|
|
31
|
-
* dev; honor FAILPROOFAI_BINARY_OVERRIDE. Paths resolve relative to this file
|
|
32
|
-
* via import.meta.url (the gateway spawns plugins with an undefined cwd).
|
|
33
28
|
*/
|
|
34
29
|
import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
|
|
35
|
-
import {
|
|
36
|
-
import { existsSync } from "node:fs";
|
|
37
|
-
import { resolve, dirname } from "node:path";
|
|
38
|
-
import { fileURLToPath } from "node:url";
|
|
39
|
-
import { createInstructRetryGate, mapBeforeToolVerdict } from "./instruct-retry-gate.js";
|
|
40
|
-
import { createWorkspaceContext } from "./workspace-context.js";
|
|
41
|
-
|
|
42
|
-
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
43
|
-
const DIST_BIN = resolve(HERE, "..", "dist", "cli.mjs");
|
|
44
|
-
const SRC_BIN = resolve(HERE, "..", "bin", "failproofai.mjs");
|
|
45
|
-
const instructRetryGate = createInstructRetryGate();
|
|
46
|
-
const workspaceContext = createWorkspaceContext();
|
|
47
|
-
|
|
48
|
-
function resolveSpawn() {
|
|
49
|
-
if (process.env.FAILPROOFAI_BINARY_OVERRIDE) {
|
|
50
|
-
return { cmd: "node", args: [process.env.FAILPROOFAI_BINARY_OVERRIDE] };
|
|
51
|
-
}
|
|
52
|
-
if (existsSync(DIST_BIN)) {
|
|
53
|
-
return { cmd: "node", args: [DIST_BIN] };
|
|
54
|
-
}
|
|
55
|
-
return { cmd: "bun", args: [SRC_BIN] };
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function debug(msg) {
|
|
59
|
-
if (process.env.FAILPROOFAI_OPENCLAW_DEBUG === "1") {
|
|
60
|
-
process.stderr.write(`[failproofai-openclaw-shim] ${msg}\n`);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Spawn `failproofai --hook <rawEvent> --cli openclaw`, write the JSON payload
|
|
66
|
-
* to stdin, and resolve the parsed flat `{permission, reason}` verdict. Async +
|
|
67
|
-
* fail-open: any spawn/parse error or timeout resolves to `{permission:"allow"}`
|
|
68
|
-
* so a failproofai fault never blocks the gateway.
|
|
69
|
-
*/
|
|
70
|
-
function callPolicy(rawEvent, payload) {
|
|
71
|
-
return new Promise((done) => {
|
|
72
|
-
const { cmd, args } = resolveSpawn();
|
|
73
|
-
let child;
|
|
74
|
-
try {
|
|
75
|
-
child = spawn(cmd, [...args, "--hook", rawEvent, "--cli", "openclaw"], {
|
|
76
|
-
stdio: ["pipe", "pipe", "pipe"],
|
|
77
|
-
});
|
|
78
|
-
} catch (err) {
|
|
79
|
-
debug(`spawn threw: ${err && err.message ? err.message : String(err)}`);
|
|
80
|
-
done({ permission: "allow" });
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
let out = "";
|
|
84
|
-
let settled = false;
|
|
85
|
-
const finish = (verdict) => {
|
|
86
|
-
if (settled) return;
|
|
87
|
-
settled = true;
|
|
88
|
-
clearTimeout(timer);
|
|
89
|
-
done(verdict);
|
|
90
|
-
};
|
|
91
|
-
const timer = setTimeout(() => {
|
|
92
|
-
debug(`timeout on ${rawEvent}; killing child`);
|
|
93
|
-
try { child.kill(); } catch { /* ignore */ }
|
|
94
|
-
finish({ permission: "allow" });
|
|
95
|
-
}, 30_000);
|
|
96
|
-
child.stdout.on("data", (d) => { out += d; });
|
|
97
|
-
child.on("error", (err) => {
|
|
98
|
-
debug(`child error: ${err && err.message ? err.message : String(err)}`);
|
|
99
|
-
finish({ permission: "allow" });
|
|
100
|
-
});
|
|
101
|
-
child.on("close", () => {
|
|
102
|
-
const stdout = out.trim();
|
|
103
|
-
if (!stdout) { finish({ permission: "allow" }); return; }
|
|
104
|
-
try {
|
|
105
|
-
finish(JSON.parse(stdout));
|
|
106
|
-
} catch (err) {
|
|
107
|
-
debug(`parse error: ${err && err.message ? err.message : String(err)}`);
|
|
108
|
-
finish({ permission: "allow" });
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
try {
|
|
112
|
-
child.stdin.end(JSON.stringify(payload));
|
|
113
|
-
} catch (err) {
|
|
114
|
-
debug(`stdin write failed: ${err && err.message ? err.message : String(err)}`);
|
|
115
|
-
finish({ permission: "allow" });
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/** Claude-shaped stdin base. Extra keys are ignored by the binary's payload
|
|
121
|
-
* parser; they're forwarded for future use / activity attribution. */
|
|
122
|
-
function baseMeta(payload, ctx, config) {
|
|
123
|
-
const p = payload || {};
|
|
124
|
-
const c = ctx || {};
|
|
125
|
-
return {
|
|
126
|
-
session_id: c.sessionId ?? p.sessionId ?? c.sessionKey ?? p.sessionKey,
|
|
127
|
-
cwd: workspaceContext.resolveWorkspace(p, c, config) ?? process.cwd(),
|
|
128
|
-
transcript_path: p.transcriptPath,
|
|
129
|
-
stop_hook_active: p.stopHookActive === true,
|
|
130
|
-
openclaw: {
|
|
131
|
-
agentId: c.agentId,
|
|
132
|
-
sessionKey: c.sessionKey ?? p.sessionKey,
|
|
133
|
-
runId: c.runId ?? p.runId,
|
|
134
|
-
provider: p.provider,
|
|
135
|
-
model: p.model,
|
|
136
|
-
},
|
|
137
|
-
};
|
|
138
|
-
}
|
|
30
|
+
import { registerFailproofaiHooks } from "./hooks.js";
|
|
139
31
|
|
|
140
32
|
export default definePluginEntry({
|
|
141
33
|
id: "failproofai",
|
|
142
34
|
name: "failproofai",
|
|
143
35
|
description: "Real-time policy enforcement for OpenClaw by failproofai",
|
|
144
36
|
register(api) {
|
|
145
|
-
|
|
146
|
-
// first matching attempt only, using blockReason to give the model the
|
|
147
|
-
// instruction, then permits retries from that session/policy for 5 minutes.
|
|
148
|
-
api.on(
|
|
149
|
-
"before_tool_call",
|
|
150
|
-
async (payload, ctx) => {
|
|
151
|
-
const p = payload || {};
|
|
152
|
-
const verdict = await callPolicy("before_tool_call", {
|
|
153
|
-
...baseMeta(payload, ctx, api.config),
|
|
154
|
-
tool_name: p.toolName,
|
|
155
|
-
tool_input: p.params,
|
|
156
|
-
hook_event_name: "before_tool_call",
|
|
157
|
-
});
|
|
158
|
-
return mapBeforeToolVerdict(verdict, payload, ctx, instructRetryGate);
|
|
159
|
-
},
|
|
160
|
-
{ priority: 100, timeoutMs: 60_000 },
|
|
161
|
-
);
|
|
162
|
-
|
|
163
|
-
// before_agent_run → UserPromptSubmit. Deny: return {outcome:"block", reason}.
|
|
164
|
-
api.on(
|
|
165
|
-
"before_agent_run",
|
|
166
|
-
async (payload, ctx) => {
|
|
167
|
-
const p = payload || {};
|
|
168
|
-
workspaceContext.remember(payload, ctx);
|
|
169
|
-
const verdict = await callPolicy("before_agent_run", {
|
|
170
|
-
...baseMeta(payload, ctx, api.config),
|
|
171
|
-
prompt: p.prompt,
|
|
172
|
-
hook_event_name: "before_agent_run",
|
|
173
|
-
});
|
|
174
|
-
if (verdict.permission === "deny") {
|
|
175
|
-
return { outcome: "block", reason: verdict.reason || "Blocked by failproofai" };
|
|
176
|
-
}
|
|
177
|
-
return undefined;
|
|
178
|
-
},
|
|
179
|
-
{ priority: 100, timeoutMs: 60_000 },
|
|
180
|
-
);
|
|
181
|
-
|
|
182
|
-
// before_agent_finalize → Stop. The real turn-end gate: a deny becomes a
|
|
183
|
-
// revise so the agent runs another pass. The evaluator supplies the
|
|
184
|
-
// MANDATORY ACTION wording; the payload's stop_hook_active guards the
|
|
185
|
-
// require-*-before-stop builtins against infinite loops.
|
|
186
|
-
api.on(
|
|
187
|
-
"before_agent_finalize",
|
|
188
|
-
async (payload, ctx) => {
|
|
189
|
-
const verdict = await callPolicy("before_agent_finalize", {
|
|
190
|
-
...baseMeta(payload, ctx, api.config),
|
|
191
|
-
hook_event_name: "before_agent_finalize",
|
|
192
|
-
});
|
|
193
|
-
if (verdict.permission === "deny") {
|
|
194
|
-
return { action: "revise", reason: verdict.reason || "Action required by failproofai" };
|
|
195
|
-
}
|
|
196
|
-
return undefined;
|
|
197
|
-
},
|
|
198
|
-
{ priority: 100, timeoutMs: 60_000 },
|
|
199
|
-
);
|
|
200
|
-
|
|
201
|
-
// Observation hooks — await so activity ordering is stable, ignore verdict.
|
|
202
|
-
// after_tool_call → PostToolUse; session_start/end → SessionStart/End;
|
|
203
|
-
// subagent_ended → SubagentStop (obs only); before_compaction → PreCompact.
|
|
204
|
-
for (const ev of [
|
|
205
|
-
"after_tool_call",
|
|
206
|
-
"session_start",
|
|
207
|
-
"session_end",
|
|
208
|
-
"subagent_ended",
|
|
209
|
-
"before_compaction",
|
|
210
|
-
]) {
|
|
211
|
-
api.on(
|
|
212
|
-
ev,
|
|
213
|
-
async (payload, ctx) => {
|
|
214
|
-
const p = payload || {};
|
|
215
|
-
await callPolicy(ev, {
|
|
216
|
-
...baseMeta(payload, ctx, api.config),
|
|
217
|
-
tool_name: p.toolName,
|
|
218
|
-
tool_input: p.params,
|
|
219
|
-
tool_response: p.result,
|
|
220
|
-
reason: p.reason,
|
|
221
|
-
hook_event_name: ev,
|
|
222
|
-
});
|
|
223
|
-
if (ev === "session_end") {
|
|
224
|
-
instructRetryGate.clear(payload, ctx);
|
|
225
|
-
workspaceContext.clear(payload, ctx);
|
|
226
|
-
}
|
|
227
|
-
return undefined;
|
|
228
|
-
},
|
|
229
|
-
{ priority: 100, timeoutMs: 60_000 },
|
|
230
|
-
);
|
|
231
|
-
}
|
|
37
|
+
registerFailproofaiHooks(api);
|
|
232
38
|
},
|
|
233
39
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "failproofai",
|
|
3
|
-
"version": "1.0.13
|
|
3
|
+
"version": "1.0.13",
|
|
4
4
|
"description": "Observability and enforcement for AI agent harnesses. 40 built-in policies hooked into 12 of them — Claude Code, Codex, Cursor, Hermes, OpenClaw and more — blocking the tool call before it runs. Local dashboard included, no account needed.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"failproofai": "./dist/cli.mjs",
|
|
@@ -123,18 +123,19 @@
|
|
|
123
123
|
"brace-expansion": "5.0.12",
|
|
124
124
|
"sharp": "0.35.5",
|
|
125
125
|
"source-map-js": "1.2.2",
|
|
126
|
-
"browserslist": "4.28.8"
|
|
126
|
+
"browserslist": "4.28.8",
|
|
127
|
+
"minimatch": "11.0.3"
|
|
127
128
|
},
|
|
128
129
|
"optionalDependencies": {
|
|
129
|
-
"@failproofai/failproofaid-linux-x64": "1.0.13
|
|
130
|
-
"@failproofai/failproofaid-linux-arm64": "1.0.13
|
|
131
|
-
"@failproofai/failproofaid-darwin-x64": "1.0.13
|
|
132
|
-
"@failproofai/failproofaid-darwin-arm64": "1.0.13
|
|
130
|
+
"@failproofai/failproofaid-linux-x64": "1.0.13",
|
|
131
|
+
"@failproofai/failproofaid-linux-arm64": "1.0.13",
|
|
132
|
+
"@failproofai/failproofaid-darwin-x64": "1.0.13",
|
|
133
|
+
"@failproofai/failproofaid-darwin-arm64": "1.0.13"
|
|
133
134
|
},
|
|
134
135
|
"failproofaidBinaries": {
|
|
135
|
-
"linux-x64": "
|
|
136
|
-
"linux-arm64": "
|
|
137
|
-
"darwin-x64": "
|
|
138
|
-
"darwin-arm64": "
|
|
136
|
+
"linux-x64": "f4e4047ea3b1fc005f2b2d825ab76b02f83a322d946f3f25d09f33e9e913f79d",
|
|
137
|
+
"linux-arm64": "5bd5468230f345cedef952293dbd085d68fead2029c88c51d04aefaff629f99b",
|
|
138
|
+
"darwin-x64": "897c2e00e392ee7bd429cd4c65132fd2b1a5cd7c8c66aa8a87d4a9cfdd6117c9",
|
|
139
|
+
"darwin-arm64": "a63bf038330f2a804d659a16d81d0bca265c08a9b37677d0e252106659848366"
|
|
139
140
|
}
|
|
140
141
|
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Refuses an Antigravity file tool call whose path failproofai cannot read.
|
|
3
|
+
*
|
|
4
|
+
* Antigravity has renamed its file tools' path arguments between releases, and a
|
|
5
|
+
* key `ANTIGRAVITY_TOOL_INPUT_MAP` does not know leaves `file_path` empty. Every
|
|
6
|
+
* path policy then has nothing to check and allows the call, which is how #961
|
|
7
|
+
* stayed silent: `.env` was readable and writable with those policies enabled.
|
|
8
|
+
* Refusing is loud on the next rename, and allowing is a silent bypass.
|
|
9
|
+
*
|
|
10
|
+
* Registered by `handler.ts`, not declared as a builtin, for three reasons:
|
|
11
|
+
* - Policies come from packs, and a pack's copy of `block-env-files` is not
|
|
12
|
+
* this build's, so a check there would not reach most machines.
|
|
13
|
+
* - `block-failproofai-commands` runs everywhere but is pinned never to route
|
|
14
|
+
* on Read, because a guard that blocks diagnosis gets worked around. This
|
|
15
|
+
* refuses only a call nothing could check, not reading.
|
|
16
|
+
* - It is one CLI's contract, not a policy anyone would enable or configure.
|
|
17
|
+
*
|
|
18
|
+
* A tool NAME the map does not know still passes through, as on every CLI: an
|
|
19
|
+
* unknown name could be anything, and most of Antigravity's are not file tools.
|
|
20
|
+
*
|
|
21
|
+
* Registered only for a call that lacks a path, so every normal call's activity
|
|
22
|
+
* row and evaluation stay exactly as they were, with no entry for a check that
|
|
23
|
+
* had nothing to say.
|
|
24
|
+
*/
|
|
25
|
+
import { deny, allow } from "./policy-helpers";
|
|
26
|
+
import type { PolicyContext, PolicyMatcher, PolicyResult } from "./policy-types";
|
|
27
|
+
import type { HookEventType } from "./types";
|
|
28
|
+
|
|
29
|
+
export const ANTIGRAVITY_PATH_GUARD_NAME = "failproofai/antigravity-file-path-required";
|
|
30
|
+
|
|
31
|
+
export const ANTIGRAVITY_PATH_GUARD_DESCRIPTION =
|
|
32
|
+
"Refuse an Antigravity file tool call with no file path failproofai can check.";
|
|
33
|
+
|
|
34
|
+
export const ANTIGRAVITY_PATH_GUARD_MATCH: PolicyMatcher = {
|
|
35
|
+
events: ["PreToolUse"],
|
|
36
|
+
toolNames: ["Read", "Write", "Edit"],
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* A pause is the way through: if Antigravity renames an argument, this refuses
|
|
41
|
+
* every file call until failproofai is updated, and the operator needs one. But a
|
|
42
|
+
* pause suspends local policy only, and Cloud policies keep running. A pathless
|
|
43
|
+
* call would slip past a Cloud path policy, so a local pause cannot lift this
|
|
44
|
+
* while one enforces. An `observe` Cloud policy decides nothing, so it does not
|
|
45
|
+
* count. Any enforcing policy counts, since a policy's source does not say
|
|
46
|
+
* whether it reads paths.
|
|
47
|
+
*/
|
|
48
|
+
export function antigravityPathGuardActive(
|
|
49
|
+
paused: boolean,
|
|
50
|
+
cloudPolicies: ReadonlyArray<{ effect?: string }>,
|
|
51
|
+
): boolean {
|
|
52
|
+
return !paused || cloudPolicies.some((p) => p.effect !== "observe");
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Whether this canonicalized call is a file tool with no path anything could check. */
|
|
56
|
+
export function antigravityCallLacksPath(
|
|
57
|
+
eventType: HookEventType | string,
|
|
58
|
+
toolName: string | undefined,
|
|
59
|
+
toolInput: unknown,
|
|
60
|
+
): boolean {
|
|
61
|
+
if (eventType !== "PreToolUse") return false;
|
|
62
|
+
if (!toolName || !ANTIGRAVITY_PATH_GUARD_MATCH.toolNames?.includes(toolName)) return false;
|
|
63
|
+
const path = (toolInput as Record<string, unknown> | null | undefined)?.file_path;
|
|
64
|
+
return typeof path !== "string" || path.trim() === "";
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function antigravityPathGuard(ctx: PolicyContext): PolicyResult {
|
|
68
|
+
if (!antigravityCallLacksPath(ctx.eventType, ctx.toolName, ctx.toolInput)) return allow();
|
|
69
|
+
return deny(
|
|
70
|
+
`failproofai could not find a file path in this ${ctx.toolName ?? "file"} call, so it cannot check it against your policies. ` +
|
|
71
|
+
"Your Antigravity version may have changed its tool arguments: update failproofai.",
|
|
72
|
+
);
|
|
73
|
+
}
|
|
@@ -13,16 +13,19 @@ import {
|
|
|
13
13
|
mkdirSync,
|
|
14
14
|
mkdtempSync,
|
|
15
15
|
readFileSync,
|
|
16
|
+
readdirSync,
|
|
17
|
+
statSync,
|
|
16
18
|
writeFileSync,
|
|
17
19
|
unlinkSync,
|
|
18
20
|
rmSync,
|
|
19
21
|
} from "node:fs";
|
|
20
22
|
import { homedir, tmpdir, userInfo } from "node:os";
|
|
21
|
-
import { resolve } from "node:path";
|
|
23
|
+
import { dirname, resolve } from "node:path";
|
|
22
24
|
import { execFileSync } from "node:child_process";
|
|
23
25
|
import { hookLogWarn } from "./hook-logger";
|
|
24
26
|
import { downloadFailproofaidBinary, installFromNpmPackage, installedBinaryPath } from "./daemon-download";
|
|
25
27
|
import { logsDir } from "./fp-home";
|
|
28
|
+
import { shellQuote } from "./shell-quote";
|
|
26
29
|
import { version } from "../../package.json";
|
|
27
30
|
import { readVersionFile, updateConfig, writeVersionFile } from "./fp-config";
|
|
28
31
|
|
|
@@ -288,11 +291,6 @@ export function resolveCliCommand(): string | null {
|
|
|
288
291
|
return `${shellQuote(process.execPath)} ${shellQuote(cliScript)}`;
|
|
289
292
|
}
|
|
290
293
|
|
|
291
|
-
/** POSIX single-quoting: everything is literal inside '…', and a literal
|
|
292
|
-
* quote is closed, escaped and reopened. */
|
|
293
|
-
function shellQuote(value: string): string {
|
|
294
|
-
return `'${value.replace(/'/g, `'\\''`)}'`;
|
|
295
|
-
}
|
|
296
294
|
|
|
297
295
|
/**
|
|
298
296
|
* The raw, unquoted path to the worker script the service will run — the same
|
|
@@ -413,6 +411,142 @@ function systemdUnitPath(user: string = serviceUser()): string {
|
|
|
413
411
|
return resolve(systemdUnitDir(), systemdUnitName(user));
|
|
414
412
|
}
|
|
415
413
|
|
|
414
|
+
/**
|
|
415
|
+
* Where a Linux install puts the copy of the daemon that systemd actually runs:
|
|
416
|
+
* `/opt/failproofai/<user>/bin/failproofaid-<version>`, root-owned.
|
|
417
|
+
*
|
|
418
|
+
* The binary is downloaded into `~/.failproofai/bin`, and a unit whose
|
|
419
|
+
* `ExecStart` points there works on Debian, Ubuntu and Mint — and on Fedora,
|
|
420
|
+
* RHEL, Rocky and Alma it never starts. Those ship SELinux enforcing, a file
|
|
421
|
+
* under a home directory is labelled `user_home_t`, and the targeted policy
|
|
422
|
+
* gives systemd (`init_t`) no execute permission on that type at all. The unit
|
|
423
|
+
* fails `203/EXEC Permission denied`, `waitForDaemonRunning()` times out, and
|
|
424
|
+
* `failproofai config` aborts at its very last step.
|
|
425
|
+
*
|
|
426
|
+
* The policy's generic `/opt/(.*\/)?bin(/.*)?` rule labels this path `bin_t`,
|
|
427
|
+
* which systemd may execute, and executing it moves the daemon into
|
|
428
|
+
* `unconfined_service_t` — the domain that may in turn run the worker's node
|
|
429
|
+
* from `~/.nvm` (also `user_home_t`) and accept hooks on the socket. So only
|
|
430
|
+
* the daemon binary moves; the worker command, the socket and the state under
|
|
431
|
+
* `~/.failproofai` stay where they are. Not `/usr/local/libexec`: both
|
|
432
|
+
* policies label that `usr_t`, which starts the daemon only through a
|
|
433
|
+
* secondary `init_t usr_t → unconfined_service_t` rule, where `bin_t` is the
|
|
434
|
+
* type the policy means for programs. Not `/usr/libexec` either: `/usr` is the
|
|
435
|
+
* package manager's, and read-only on Silverblue and CoreOS. All checked
|
|
436
|
+
* against the shipped policy on Fedora 41 and Rocky 9 with `matchpathcon` and
|
|
437
|
+
* `sesearch`.
|
|
438
|
+
*
|
|
439
|
+
* Per user for the same reason the unit name is: two people on one box may run
|
|
440
|
+
* different versions, and one's uninstall must not delete the other's binary.
|
|
441
|
+
* The `~/.failproofai/bin` copy is kept — `daemonVersionSkew()` and
|
|
442
|
+
* `refreshDaemonToCliVersion()` read the installed version from it.
|
|
443
|
+
*
|
|
444
|
+
* Redirectable for tests ONLY, like the unit directory.
|
|
445
|
+
*/
|
|
446
|
+
function systemBinaryRoot(user: string = serviceUser()): string {
|
|
447
|
+
return resolve(process.env.FAILPROOFAI_SYSTEM_BIN_DIR || "/opt/failproofai", user);
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
function systemBinaryDir(): string {
|
|
451
|
+
return resolve(systemBinaryRoot(), "bin");
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
/** The system binary directory on Linux, for the manual-removal instructions. */
|
|
455
|
+
export function daemonSystemBinaryDir(): string | null {
|
|
456
|
+
return process.platform === "linux" ? systemBinaryRoot() : null;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* The path systemd should start for `binaryPath`, or null when it should start
|
|
461
|
+
* `binaryPath` itself.
|
|
462
|
+
*
|
|
463
|
+
* Only a real file is copied. `FAILPROOFAI_DAEMON_BINARY` is "someone named a
|
|
464
|
+
* binary explicitly" and may be a command with arguments (this repo's own
|
|
465
|
+
* systemd tests use `/usr/bin/sleep infinity`), so it is started as given.
|
|
466
|
+
*/
|
|
467
|
+
export function systemBinaryTarget(binaryPath: string): string | null {
|
|
468
|
+
if (process.platform !== "linux" || process.env.FAILPROOFAI_DAEMON_BINARY) return null;
|
|
469
|
+
try {
|
|
470
|
+
if (!statSync(binaryPath).isFile()) return null;
|
|
471
|
+
} catch {
|
|
472
|
+
return null;
|
|
473
|
+
}
|
|
474
|
+
return resolve(systemBinaryDir(), `failproofaid-${version}`);
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
/**
|
|
478
|
+
* Whether this kernel has SELinux enabled. `/sys/fs/selinux` is mounted only
|
|
479
|
+
* when it is, enforcing or permissive.
|
|
480
|
+
*/
|
|
481
|
+
function selinuxEnabled(): boolean {
|
|
482
|
+
return existsSync("/sys/fs/selinux/enforce");
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
/**
|
|
486
|
+
* Copies the daemon binary into the system directory and returns the path the
|
|
487
|
+
* unit should start. Privileged; throws when the copy fails, which the caller
|
|
488
|
+
* reports as a failed install before any unit is written.
|
|
489
|
+
*
|
|
490
|
+
* Staged under a temp name and renamed into place, so a reinstall of the same
|
|
491
|
+
* version never writes into the file a running daemon was started from.
|
|
492
|
+
*
|
|
493
|
+
* `restorecon` afterwards, because a new file inherits the label of the
|
|
494
|
+
* directory it is created in, not the one the policy assigns to its path: the
|
|
495
|
+
* directories `install -d` creates under `/opt` (`usr_t`) come out `usr_t`
|
|
496
|
+
* too, never the `bin_t` the policy names for them.
|
|
497
|
+
*/
|
|
498
|
+
function stageSystemBinary(binaryPath: string): string {
|
|
499
|
+
const target = systemBinaryTarget(binaryPath);
|
|
500
|
+
if (!target) return binaryPath;
|
|
501
|
+
const dir = systemBinaryDir();
|
|
502
|
+
const staging = `${target}.${process.pid}.tmp`;
|
|
503
|
+
runPrivileged("install", ["-d", "-m", "0755", dir]);
|
|
504
|
+
try {
|
|
505
|
+
runPrivileged("install", ["-m", "0755", binaryPath, staging]);
|
|
506
|
+
runPrivileged("mv", ["-f", staging, target]);
|
|
507
|
+
} catch (err) {
|
|
508
|
+
try {
|
|
509
|
+
runPrivileged("rm", ["-f", staging]);
|
|
510
|
+
} catch {
|
|
511
|
+
/* best-effort */
|
|
512
|
+
}
|
|
513
|
+
throw err;
|
|
514
|
+
}
|
|
515
|
+
if (selinuxEnabled()) {
|
|
516
|
+
const root = systemBinaryRoot();
|
|
517
|
+
try {
|
|
518
|
+
runPrivileged("restorecon", ["-R", root]);
|
|
519
|
+
} catch (err) {
|
|
520
|
+
// Not fatal here: a wrong label still surfaces as the daemon not
|
|
521
|
+
// reaching a running state, which fails the install with its status.
|
|
522
|
+
hookLogWarn(`restorecon on ${root} failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
return target;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
/**
|
|
529
|
+
* Removes system copies other than `current` and the most recent one before
|
|
530
|
+
* it — the same keep-one-for-rollback rule `pruneOldDaemonBinaries()` applies
|
|
531
|
+
* to `~/.failproofai/bin`. Best-effort; only called once the service runs
|
|
532
|
+
* `current`.
|
|
533
|
+
*/
|
|
534
|
+
function pruneSystemBinaries(current: string): void {
|
|
535
|
+
try {
|
|
536
|
+
const dir = systemBinaryDir();
|
|
537
|
+
const stale = readdirSync(dir)
|
|
538
|
+
.filter((f) => f.startsWith("failproofaid-"))
|
|
539
|
+
.map((f) => resolve(dir, f))
|
|
540
|
+
.filter((p) => p !== current)
|
|
541
|
+
.map((p) => ({ p, mtime: statSync(p).mtimeMs }))
|
|
542
|
+
.sort((a, b) => b.mtime - a.mtime)
|
|
543
|
+
.slice(1);
|
|
544
|
+
for (const { p } of stale) runPrivileged("rm", ["-f", p]);
|
|
545
|
+
} catch {
|
|
546
|
+
// Nothing to prune, or no elevation left — leaving a file costs disk only.
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
|
|
416
550
|
/**
|
|
417
551
|
* The pre-1.0.0-beta.1 user-scope unit. Still removed on install and
|
|
418
552
|
* uninstall: it holds the same flock the new service needs, so leaving one
|
|
@@ -792,8 +926,21 @@ function daemonInstallCommands(
|
|
|
792
926
|
cliCmd: string | null,
|
|
793
927
|
): string[] {
|
|
794
928
|
if (process.platform === "linux") {
|
|
929
|
+
const target = systemBinaryTarget(binaryPath);
|
|
930
|
+
const dir = systemBinaryDir();
|
|
931
|
+
const stage = target
|
|
932
|
+
? [
|
|
933
|
+
// Quoted: a home directory may hold a space, and an unquoted path
|
|
934
|
+
// splits into words that stop this `&&`-joined recipe before the
|
|
935
|
+
// unit is ever written.
|
|
936
|
+
`sudo install -d -m 0755 ${shellQuote(dir)}`,
|
|
937
|
+
`sudo install -m 0755 ${shellQuote(binaryPath)} ${shellQuote(target)}`,
|
|
938
|
+
`{ sudo restorecon -R ${shellQuote(systemBinaryRoot())} 2>/dev/null || true; }`,
|
|
939
|
+
]
|
|
940
|
+
: [];
|
|
795
941
|
return [
|
|
796
|
-
|
|
942
|
+
...stage,
|
|
943
|
+
`sudo tee ${systemdUnitPath()} <<'EOF'\n${systemdUnitContents(target ?? binaryPath, workerCmd, cliCmd)}EOF`,
|
|
797
944
|
"sudo systemctl daemon-reload",
|
|
798
945
|
`sudo systemctl enable ${systemdUnitName()}`,
|
|
799
946
|
// `restart`, not `enable --now`, for the reason the install path gives:
|
|
@@ -865,9 +1012,13 @@ export async function installDaemonService(): Promise<DaemonInstallResult> {
|
|
|
865
1012
|
// never came up. Clear it first, every time.
|
|
866
1013
|
removeLegacyUserService();
|
|
867
1014
|
|
|
1015
|
+
let execPath = binaryPath;
|
|
868
1016
|
try {
|
|
869
1017
|
if (process.platform === "linux") {
|
|
870
|
-
|
|
1018
|
+
// Before the unit is written, so a copy that fails leaves the previous
|
|
1019
|
+
// unit and the daemon it runs untouched. See `systemBinaryDir()`.
|
|
1020
|
+
execPath = stageSystemBinary(binaryPath);
|
|
1021
|
+
writePrivilegedFile(systemdUnitPath(), systemdUnitContents(execPath, workerCmd, cliCmd));
|
|
871
1022
|
runPrivileged("systemctl", ["daemon-reload"]);
|
|
872
1023
|
// `enable` for boot persistence, then `restart` — NOT `enable --now`.
|
|
873
1024
|
//
|
|
@@ -927,6 +1078,7 @@ export async function installDaemonService(): Promise<DaemonInstallResult> {
|
|
|
927
1078
|
hookLogWarn(`daemon service install failed: ${reason}`);
|
|
928
1079
|
return { installed: false, reason };
|
|
929
1080
|
}
|
|
1081
|
+
if (execPath !== binaryPath) pruneSystemBinaries(execPath);
|
|
930
1082
|
|
|
931
1083
|
// NOTE: this reports that the SERVICE is installed and running, which is all
|
|
932
1084
|
// it can honestly claim. Whether the daemon can actually evaluate a hook is a
|
|
@@ -1671,17 +1823,35 @@ export async function uninstallDaemonService(): Promise<void> {
|
|
|
1671
1823
|
try {
|
|
1672
1824
|
if (process.platform === "linux") {
|
|
1673
1825
|
const unitPath = systemdUnitPath();
|
|
1674
|
-
if (
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1826
|
+
if (existsSync(unitPath)) {
|
|
1827
|
+
try {
|
|
1828
|
+
runPrivileged("systemctl", ["disable", "--now", systemdUnitName()]);
|
|
1829
|
+
} catch {
|
|
1830
|
+
// Already stopped/not enabled — removing the unit is still the point.
|
|
1831
|
+
}
|
|
1832
|
+
// Throws when it cannot elevate, which also skips the removal below:
|
|
1833
|
+
// a unit still on disk may yet start the binary under it.
|
|
1834
|
+
runPrivileged("rm", ["-f", unitPath]);
|
|
1835
|
+
try {
|
|
1836
|
+
runPrivileged("systemctl", ["daemon-reload"]);
|
|
1837
|
+
} catch {
|
|
1838
|
+
// Best-effort.
|
|
1839
|
+
}
|
|
1679
1840
|
}
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1841
|
+
// The copy systemd ran. After the unit is gone, so nothing enabled is
|
|
1842
|
+
// left pointing at a deleted file, and whether or not there was a unit to
|
|
1843
|
+
// remove: an install that failed after staging, or a unit deleted by hand,
|
|
1844
|
+
// leaves this behind with nothing else to clean it up. The directory is
|
|
1845
|
+
// per user, so no other user's unit can reference it. The shared parent
|
|
1846
|
+
// goes only if no other user's directory is in it.
|
|
1847
|
+
const binRoot = systemBinaryRoot();
|
|
1848
|
+
if (existsSync(binRoot)) {
|
|
1849
|
+
runPrivileged("rm", ["-rf", binRoot]);
|
|
1850
|
+
try {
|
|
1851
|
+
runPrivileged("rmdir", [dirname(binRoot)]);
|
|
1852
|
+
} catch {
|
|
1853
|
+
// Not empty — another user's daemon lives there.
|
|
1854
|
+
}
|
|
1685
1855
|
}
|
|
1686
1856
|
} else {
|
|
1687
1857
|
const plistPath = launchdPlistPath();
|
|
@@ -182,7 +182,7 @@ export const ENFORCEMENT_CAPABILITY: Record<
|
|
|
182
182
|
|
|
183
183
|
// ── openclaw ──────────────────────────────────────────────────────────────
|
|
184
184
|
// openclaw/openclaw @f8ed8ecf (v2026.7.2) + our own shipped shim
|
|
185
|
-
// openclaw-plugin/
|
|
185
|
+
// openclaw-plugin/hooks.js, which returns undefined for 5 of the 8 hooks.
|
|
186
186
|
openclaw: {
|
|
187
187
|
PreToolUse: "block", // before_tool_call -> shim returns {block:true, blockReason}
|
|
188
188
|
UserPromptSubmit: "block", // before_agent_run -> shim returns {outcome:"block", reason}
|