failproofai 1.0.13-beta.2 → 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.
Files changed (127) hide show
  1. package/.next/standalone/.next/BUILD_ID +1 -1
  2. package/.next/standalone/.next/build-manifest.json +3 -3
  3. package/.next/standalone/.next/prerender-manifest.json +4 -4
  4. package/.next/standalone/.next/required-server-files.json +1 -1
  5. package/.next/standalone/.next/server/app/_global-error/page/server-reference-manifest.json +1 -1
  6. package/.next/standalone/.next/server/app/_global-error/page.js.nft.json +1 -1
  7. package/.next/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  8. package/.next/standalone/.next/server/app/_global-error.html +1 -1
  9. package/.next/standalone/.next/server/app/_global-error.rsc +2 -2
  10. package/.next/standalone/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +2 -2
  11. package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +2 -2
  12. package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  13. package/.next/standalone/.next/server/app/_not-found/page/server-reference-manifest.json +1 -1
  14. package/.next/standalone/.next/server/app/_not-found/page.js.nft.json +1 -1
  15. package/.next/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  16. package/.next/standalone/.next/server/app/_not-found.html +1 -1
  17. package/.next/standalone/.next/server/app/_not-found.rsc +3 -3
  18. package/.next/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +3 -3
  19. package/.next/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +2 -2
  20. package/.next/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  21. package/.next/standalone/.next/server/app/api/audit/invite/route.js.nft.json +1 -1
  22. package/.next/standalone/.next/server/app/api/audit/run/route.js.nft.json +1 -1
  23. package/.next/standalone/.next/server/app/api/audit/status/route.js.nft.json +1 -1
  24. package/.next/standalone/.next/server/app/api/auth/login-request/route.js.nft.json +1 -1
  25. package/.next/standalone/.next/server/app/api/auth/login-verify/route.js.nft.json +1 -1
  26. package/.next/standalone/.next/server/app/api/auth/logout/route.js.nft.json +1 -1
  27. package/.next/standalone/.next/server/app/api/auth/status/route.js.nft.json +1 -1
  28. package/.next/standalone/.next/server/app/api/download/[project]/[session]/route.js.nft.json +1 -1
  29. package/.next/standalone/.next/server/app/audit/page/server-reference-manifest.json +2 -2
  30. package/.next/standalone/.next/server/app/audit/page.js.nft.json +1 -1
  31. package/.next/standalone/.next/server/app/audit/page_client-reference-manifest.js +1 -1
  32. package/.next/standalone/.next/server/app/index.html +1 -1
  33. package/.next/standalone/.next/server/app/index.rsc +3 -3
  34. package/.next/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
  35. package/.next/standalone/.next/server/app/index.segments/_full.segment.rsc +3 -3
  36. package/.next/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  37. package/.next/standalone/.next/server/app/page/server-reference-manifest.json +1 -1
  38. package/.next/standalone/.next/server/app/page.js.nft.json +1 -1
  39. package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
  40. package/.next/standalone/.next/server/app/policies/page/server-reference-manifest.json +14 -14
  41. package/.next/standalone/.next/server/app/policies/page.js.nft.json +1 -1
  42. package/.next/standalone/.next/server/app/policies/page_client-reference-manifest.js +1 -1
  43. package/.next/standalone/.next/server/app/project/[name]/page/server-reference-manifest.json +1 -1
  44. package/.next/standalone/.next/server/app/project/[name]/page.js.nft.json +1 -1
  45. package/.next/standalone/.next/server/app/project/[name]/page_client-reference-manifest.js +1 -1
  46. package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page/react-loadable-manifest.json +2 -2
  47. package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page/server-reference-manifest.json +2 -2
  48. package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page.js.nft.json +1 -1
  49. package/.next/standalone/.next/server/app/project/[name]/session/[sessionId]/page_client-reference-manifest.js +1 -1
  50. package/.next/standalone/.next/server/app/projects/page/server-reference-manifest.json +1 -1
  51. package/.next/standalone/.next/server/app/projects/page.js.nft.json +1 -1
  52. package/.next/standalone/.next/server/app/projects/page_client-reference-manifest.js +1 -1
  53. package/.next/standalone/.next/server/app/settings/page/server-reference-manifest.json +8 -8
  54. package/.next/standalone/.next/server/app/settings/page.js.nft.json +1 -1
  55. package/.next/standalone/.next/server/app/settings/page_client-reference-manifest.js +1 -1
  56. package/.next/standalone/.next/server/chunks/_0tovk6q0miud6._.js +1 -1
  57. package/.next/standalone/.next/server/chunks/_0trp3ycqv17cl._.js +1 -1
  58. package/.next/standalone/.next/server/chunks/package_json_[json]_cjs_1nxcc4vkpxxu7._.js +1 -1
  59. package/.next/standalone/.next/server/chunks/src_hooks_0_em82s16zfym._.js +1 -1
  60. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__08ch3staq3ejw._.js +1 -1
  61. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0bigvy9xmv2ka._.js +1 -1
  62. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0h86bl2qf0k_o._.js +1 -1
  63. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0pia5h3p8re4c._.js +1 -1
  64. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1-ey9fgesfbc0._.js +1 -1
  65. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__15usvs-ms-0hf._.js +1 -1
  66. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__16gb3_92zvk5x._.js +1 -1
  67. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1avi2kypusyb_._.js +1 -1
  68. package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__19nvo1qfswchs._.js → [root-of-the-server]__1jq2bh84rafc7._.js} +2 -2
  69. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__1r7drlqli-ado._.js +1 -1
  70. package/.next/standalone/.next/server/chunks/ssr/_0eoura3_9gjb-._.js +1 -1
  71. package/.next/standalone/.next/server/chunks/ssr/_0ouu886szh6yj._.js +1 -1
  72. package/.next/standalone/.next/server/chunks/ssr/_0pedwblqdoh58._.js +1 -1
  73. package/.next/standalone/.next/server/chunks/ssr/{_1nvqg4si0splb._.js → _100nvr7rei3us._.js} +2 -2
  74. package/.next/standalone/.next/server/chunks/ssr/_1djqs9i27e4kg._.js +1 -1
  75. package/.next/standalone/.next/server/chunks/ssr/_next-internal_server_app_policies_page_actions_1sp2-yo5_vm5f.js +2 -2
  76. package/.next/standalone/.next/server/chunks/ssr/app_actions_get-scheduled-audit_ts_0ei9snixb5fd-._.js +1 -1
  77. package/.next/standalone/.next/server/chunks/ssr/app_audit__components_audit-dashboard_tsx_0p9ud47q0xq5w._.js +1 -1
  78. package/.next/standalone/.next/server/chunks/ssr/app_global-error_tsx_1kp6l3x33jqb6._.js +1 -1
  79. package/.next/standalone/.next/server/chunks/ssr/app_policies_hooks-client_tsx_19dqvpcz0uxur._.js +1 -1
  80. package/.next/standalone/.next/server/chunks/ssr/app_settings_02tf1h47jmhhd._.js +1 -1
  81. package/.next/standalone/.next/server/chunks/ssr/{node_modules_html-to-image_es_index_1gk40bvx2bftt.js → node_modules_html-to-image_es_index_1cmkmhnty0-x7.js} +1 -1
  82. package/.next/standalone/.next/server/chunks/ssr/node_modules_posthog-node_dist_entrypoints_index_node_mjs_11bnuznb72p7z._.js +2 -2
  83. package/.next/standalone/.next/server/chunks/ssr/package_json_[json]_cjs_013tntikdft59._.js +1 -1
  84. package/.next/standalone/.next/server/chunks/ssr/src_hooks_0agdmptetetdt._.js +1 -1
  85. package/.next/standalone/.next/server/chunks/ssr/src_hooks_0mdwgjisv4fub._.js +1 -1
  86. package/.next/standalone/.next/server/middleware-build-manifest.js +3 -3
  87. package/.next/standalone/.next/server/pages/404.html +1 -1
  88. package/.next/standalone/.next/server/pages/500.html +1 -1
  89. package/.next/standalone/.next/server/preview-props.json +3 -3
  90. package/.next/standalone/.next/server/server-reference-manifest.js +1 -1
  91. package/.next/standalone/.next/server/server-reference-manifest.json +23 -23
  92. package/.next/standalone/.next/static/chunks/{1mkf3bas1g5ka.js → 0mm-e5t9denbu.js} +1 -1
  93. package/.next/standalone/.next/static/chunks/{3lgxb73wehfv2.js → 0rucj5pu307i4.js} +1 -1
  94. package/.next/standalone/.next/static/chunks/{2q-6h4rclnu98.js → 1-0se0uwja_ny.js} +1 -1
  95. package/.next/standalone/.next/static/chunks/{061bksch79zq2.js → 173vw1xs-5m5g.js} +1 -1
  96. package/.next/standalone/.next/static/chunks/{1l9lji2he-mbw.js → 20cme7d6wv6md.js} +1 -1
  97. package/.next/standalone/.next/static/chunks/2mz-k_jt_76xt.js +1 -0
  98. package/.next/standalone/.next/static/chunks/{2f9-xdgd1o3r5.js → 2u1m0f-wnhz44.js} +1 -1
  99. package/.next/standalone/.next/static/chunks/{2x-77r0k0xm3b.js → 2ytnb83xmjn3u.js} +1 -1
  100. package/.next/standalone/.next/static/chunks/{44rukkkzacqkl.js → 40g_e46c1-j4k.js} +2 -2
  101. package/.next/standalone/.next/static/chunks/44yz8zx53euy1.js +1 -0
  102. package/.next/standalone/hermes-plugin/plugin.yaml +1 -1
  103. package/.next/standalone/package.json +11 -10
  104. package/.next/standalone/sdk/python/uv.lock +6 -6
  105. package/.next/standalone/sdk/typescript/package-lock.json +31 -61
  106. package/.next/standalone/sdk/typescript/package.json +3 -0
  107. package/.next/standalone/server.js +1 -1
  108. package/dist/cli.mjs +84 -43
  109. package/dist/worker.mjs +34 -5
  110. package/hermes-plugin/plugin.yaml +1 -1
  111. package/openclaw-plugin/daemon-client.js +254 -0
  112. package/openclaw-plugin/hooks.js +187 -0
  113. package/openclaw-plugin/index.js +17 -211
  114. package/package.json +11 -10
  115. package/src/hooks/antigravity-path-guard.ts +73 -0
  116. package/src/hooks/daemon-service.ts +26 -21
  117. package/src/hooks/enforcement-capability.ts +1 -1
  118. package/src/hooks/handler.ts +24 -0
  119. package/src/hooks/integrations.ts +5 -2
  120. package/src/hooks/shell-quote.ts +9 -0
  121. package/src/hooks/types.ts +20 -17
  122. package/src/hooks/uninstall-cli.ts +28 -9
  123. package/.next/standalone/.next/static/chunks/22gs9785ug-vp.js +0 -1
  124. package/.next/standalone/.next/static/chunks/2xox4fr0q-ftn.js +0 -1
  125. /package/.next/standalone/.next/static/{TdOlUedz_AHC-0Ops67a_ → 4MgI0mZP1iVhhocpUivMm}/_buildManifest.js +0 -0
  126. /package/.next/standalone/.next/static/{TdOlUedz_AHC-0Ops67a_ → 4MgI0mZP1iVhhocpUivMm}/_clientMiddlewareManifest.js +0 -0
  127. /package/.next/standalone/.next/static/{TdOlUedz_AHC-0Ops67a_ → 4MgI0mZP1iVhhocpUivMm}/_ssgManifest.js +0 -0
@@ -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 forwards each to the
8
- * failproofai binary as `failproofai --hook <event> --cli openclaw`. failproofai
9
- * prints a flat `{permission, reason}` verdict on stdout; this shim maps it to
10
- * each hook's native return shape. On before_tool_call, an `instruct` verdict
11
- * uses a one-shot blockReason as OpenClaw's model-visible instruction channel;
12
- * retries from the same session/policy are allowed for a short window.
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 (verified live against openclaw v2026.7.1):
18
- * • ASYNC spawn, never spawnSync — the gateway is a long-running multi-channel
19
- * process; a synchronous spawn on every hook would stall every channel.
20
- * 30s guard timer; fail-open on any error (never block on infra failure).
21
- * • Raw forwarding — we send the raw tool name / params and a Claude-shaped
22
- * stdin (params→tool_input, toolName→tool_name, transcriptPath→
23
- * transcript_path, stopHookActive→stop_hook_active, sessionKey→session_id).
24
- * The binary canonicalizes via OPENCLAW_* maps (single source of truth); the
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 { spawn } from "node:child_process";
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
- // before_tool_call → PreToolUse. Deny always blocks. Instruct blocks the
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-beta.2",
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-beta.2",
130
- "@failproofai/failproofaid-linux-arm64": "1.0.13-beta.2",
131
- "@failproofai/failproofaid-darwin-x64": "1.0.13-beta.2",
132
- "@failproofai/failproofaid-darwin-arm64": "1.0.13-beta.2"
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": "8301567948ddf752b6db30ed5998e62139df4c7e1669b280159a83a9b951b94c",
136
- "linux-arm64": "ad53ec24d7c09b2dbc07b792c0739dc1e5f443fdb9a795174d3a40453f90bbcf",
137
- "darwin-x64": "e4e65a1071a5793bafb73625dc49d211ff19d7e0d8c03c804959d1357aebea1e",
138
- "darwin-arm64": "78aa90272e2ace07ac3648a419b961f8d8bfe56c7fd3a0193d3579085d77e9cb"
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
+ }
@@ -25,6 +25,7 @@ import { execFileSync } from "node:child_process";
25
25
  import { hookLogWarn } from "./hook-logger";
26
26
  import { downloadFailproofaidBinary, installFromNpmPackage, installedBinaryPath } from "./daemon-download";
27
27
  import { logsDir } from "./fp-home";
28
+ import { shellQuote } from "./shell-quote";
28
29
  import { version } from "../../package.json";
29
30
  import { readVersionFile, updateConfig, writeVersionFile } from "./fp-config";
30
31
 
@@ -290,11 +291,6 @@ export function resolveCliCommand(): string | null {
290
291
  return `${shellQuote(process.execPath)} ${shellQuote(cliScript)}`;
291
292
  }
292
293
 
293
- /** POSIX single-quoting: everything is literal inside '…', and a literal
294
- * quote is closed, escaped and reopened. */
295
- function shellQuote(value: string): string {
296
- return `'${value.replace(/'/g, `'\\''`)}'`;
297
- }
298
294
 
299
295
  /**
300
296
  * The raw, unquoted path to the worker script the service will run — the same
@@ -934,9 +930,12 @@ function daemonInstallCommands(
934
930
  const dir = systemBinaryDir();
935
931
  const stage = target
936
932
  ? [
937
- `sudo install -d -m 0755 ${dir}`,
938
- `sudo install -m 0755 ${binaryPath} ${target}`,
939
- `{ sudo restorecon -R ${systemBinaryRoot()} 2>/dev/null || true; }`,
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; }`,
940
939
  ]
941
940
  : [];
942
941
  return [
@@ -1824,21 +1823,27 @@ export async function uninstallDaemonService(): Promise<void> {
1824
1823
  try {
1825
1824
  if (process.platform === "linux") {
1826
1825
  const unitPath = systemdUnitPath();
1827
- if (!existsSync(unitPath)) return;
1828
- try {
1829
- runPrivileged("systemctl", ["disable", "--now", systemdUnitName()]);
1830
- } catch {
1831
- // Already stopped/not enabled — removing the unit is still the point.
1832
- }
1833
- runPrivileged("rm", ["-f", unitPath]);
1834
- try {
1835
- runPrivileged("systemctl", ["daemon-reload"]);
1836
- } catch {
1837
- // Best-effort.
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
+ }
1838
1840
  }
1839
1841
  // The copy systemd ran. After the unit is gone, so nothing enabled is
1840
- // left pointing at a deleted file. The shared parent goes only if no
1841
- // other user's directory is in it.
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.
1842
1847
  const binRoot = systemBinaryRoot();
1843
1848
  if (existsSync(binRoot)) {
1844
1849
  runPrivileged("rm", ["-rf", binRoot]);
@@ -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/index.js, which returns undefined for 5 of the 8 hooks.
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}
@@ -30,6 +30,14 @@ import { normalizeCliPayload } from "./normalize-cli-payload";
30
30
  import type { PolicyFunction, PolicyResult, HooksConfig } from "./policy-types";
31
31
  import { readMergedHooksConfig } from "./hooks-config";
32
32
  import { registerBuiltinPolicies } from "./builtin-policies";
33
+ import {
34
+ ANTIGRAVITY_PATH_GUARD_DESCRIPTION,
35
+ ANTIGRAVITY_PATH_GUARD_MATCH,
36
+ ANTIGRAVITY_PATH_GUARD_NAME,
37
+ antigravityCallLacksPath,
38
+ antigravityPathGuard,
39
+ antigravityPathGuardActive,
40
+ } from "./antigravity-path-guard";
33
41
  import { evaluatePolicies } from "./policy-evaluator";
34
42
  // Types only: the semantic (Jev) modules are loaded with a dynamic import, and
35
43
  // only once a Jev config exists, so an unconfigured machine never loads them.
@@ -839,6 +847,22 @@ export async function evaluateHookEvent(
839
847
  cli,
840
848
  });
841
849
  }
850
+ // Outside the enabled set, because the policies it protects may be the
851
+ // ones that cannot see the path. After the Cloud read, because a pause
852
+ // lifts this only while no enforcing Cloud policy is deployed: see
853
+ // `antigravityPathGuardActive`.
854
+ if (
855
+ cli === "antigravity" &&
856
+ antigravityPathGuardActive(Boolean(activePause), cloudManagedPolicies) &&
857
+ antigravityCallLacksPath(canonicalEventType, parsed.tool_name as string | undefined, parsed.tool_input)
858
+ ) {
859
+ registerPolicy(
860
+ ANTIGRAVITY_PATH_GUARD_NAME,
861
+ ANTIGRAVITY_PATH_GUARD_DESCRIPTION,
862
+ antigravityPathGuard,
863
+ ANTIGRAVITY_PATH_GUARD_MATCH,
864
+ );
865
+ }
842
866
  // Recorded on every row once a machine is managed, whether or not a cloud
843
867
  // policy decided this event: "what was deployed here at the time" is a
844
868
  // separate question from "what decided", and only the former can tell a
@@ -2277,8 +2277,10 @@ export function unhookedHermesProfiles(): string[] {
2277
2277
  // OpenClaw is a self-hosted assistant gateway. Enforcement is via its in-process
2278
2278
  // PLUGIN hooks (file-based "internal hooks" are observation-only), so failproofai
2279
2279
  // ships a static plugin package (`openclaw-plugin/`, like Pi's pi-extension) that
2280
- // async-spawns the binary and maps verdicts back. Install registers the plugin in
2281
- // every profile's `openclaw.json` (JSON):
2280
+ // asks failproofaid for each verdict over its Unix socket — like the Hermes plugin,
2281
+ // and so likewise daemon-only — and maps verdicts back. It cannot spawn the CLI:
2282
+ // OpenClaw ≥ 2026.9.6 loads plugins from a copy that holds only the plugin dir.
2283
+ // Install registers the plugin in every profile's `openclaw.json` (JSON):
2282
2284
  // • plugins.load.paths[] → the shipped openclaw-plugin dir (absolute path)
2283
2285
  // • plugins.entries.failproofai = { enabled: true, hooks: { allowConversationAccess: true } }
2284
2286
  // (allowConversationAccess is required for the raw-conversation hooks
@@ -2318,6 +2320,7 @@ function isFailproofaiOpenClawPath(p: unknown): boolean {
2318
2320
  export const openclaw: Integration = {
2319
2321
  id: "openclaw",
2320
2322
  displayName: "OpenClaw",
2323
+ requiresHealthyDaemon: true,
2321
2324
  scopes: OPENCLAW_HOOK_SCOPES,
2322
2325
  eventTypes: OPENCLAW_HOOK_EVENT_TYPES,
2323
2326
 
@@ -0,0 +1,9 @@
1
+ /**
2
+ * POSIX single-quoting: everything is literal inside '…', and a literal quote
3
+ * is closed, escaped and reopened. For every path this package puts into a
4
+ * shell command — the service's worker command, and the recipes printed for
5
+ * someone to run as root when the install or uninstall could not elevate.
6
+ */
7
+ export function shellQuote(value: string): string {
8
+ return `'${value.replace(/'/g, `'\\''`)}'`;
9
+ }
@@ -863,16 +863,19 @@ export const ANTIGRAVITY_EVENT_MAP: Record<AntigravityHookEventType, HookEventTy
863
863
  /**
864
864
  * Antigravity's tool names → Claude PascalCase canonical names so existing
865
865
  * builtin policies (which match `toolName === "Bash"`, etc.) fire unchanged.
866
- * Tool names VERIFIED against the agy binary's tool registry + live transcripts:
867
- * the file tool is `write_to_file` (NOT `write_file`), listing is `list_dir`
868
- * (NOT `list_directory`), and glob is `find_by_name` (NOT `find_filepath`) — the
869
- * earlier best-effort names were wrong, so `block-env-files`/`block-secrets-write`
870
- * silently no-op'd on Antigravity file writes. Unknown tools pass through via the
871
- * `?? raw` fallback.
866
+ * Tool names VERIFIED against live recorder-hook captures, and they have moved
867
+ * once: agy 1.4.9 and 1.4.12 deliver `read_file`/`write_file`/`edit_file`, with
868
+ * listing and search reached through `read_file` on a directory and `run_command`.
869
+ * Earlier builds delivered `view_file`/`write_to_file`/`replace_file_content`/
870
+ * `list_dir`/`find_by_name`/`grep_search`; those stay mapped for installs that
871
+ * have not updated. A file tool missing here is not an error anywhere: every
872
+ * policy matching on the canonical name silently allows it. Unknown tools pass
873
+ * through via the `?? raw` fallback.
872
874
  */
873
875
  export const ANTIGRAVITY_TOOL_MAP: Record<string, string> = {
874
876
  run_command: "Bash",
875
877
  write_to_file: "Write",
878
+ write_file: "Write",
876
879
  read_file: "Read",
877
880
  view_file: "Read",
878
881
  edit_file: "Edit",
@@ -886,20 +889,20 @@ export const ANTIGRAVITY_TOOL_MAP: Record<string, string> = {
886
889
 
887
890
  /**
888
891
  * Antigravity tool args are PascalCase. Keyed by the CANONICAL tool name
889
- * (canonicalizeToolInput runs after canonicalizeToolName). VERIFIED live:
890
- * `run_command` delivers `CommandLine`/`Cwd`; `write_to_file` delivers the path
891
- * as `TargetFile` and body as `CodeContent`. Without the Write/Edit/Read entries
892
- * the path/content builtins (`block-env-files`, `block-secrets-write`,
893
- * `block-read-outside-cwd`) never saw a `file_path` and silently no-op'd on
894
- * Antigravity file operations. Read/Edit path keys are best-effort within the
895
- * same tool family (all file tools operate on `TargetFile`); extra keys are
896
- * harmless (only remapped when present).
892
+ * (canonicalizeToolInput runs after canonicalizeToolName). VERIFIED live against
893
+ * agy 1.4.12: `run_command` delivers `CommandLine`; `read_file` delivers `Path`;
894
+ * `write_file` delivers `Path`/`Content`; `edit_file` delivers
895
+ * `Path`/`Target`/`Replacement`. Earlier builds delivered `AbsolutePath` on
896
+ * `view_file` and `TargetFile`/`CodeContent` on `write_to_file`, kept because
897
+ * extra keys are harmless (only remapped when present). Without these entries
898
+ * the path/content builtins, and the always-on guard over failproofai's own
899
+ * state, never see a `file_path` and silently allow the call.
897
900
  */
898
901
  export const ANTIGRAVITY_TOOL_INPUT_MAP: Record<string, Record<string, string>> = {
899
902
  Bash: { CommandLine: "command", Cwd: "cwd" },
900
- Write: { TargetFile: "file_path", CodeContent: "content" },
901
- Edit: { TargetFile: "file_path" },
902
- Read: { TargetFile: "file_path", AbsolutePath: "file_path", File: "file_path" },
903
+ Write: { Path: "file_path", Content: "content", TargetFile: "file_path", CodeContent: "content" },
904
+ Edit: { Path: "file_path", Target: "old_string", Replacement: "new_string", TargetFile: "file_path" },
905
+ Read: { Path: "file_path", TargetFile: "file_path", AbsolutePath: "file_path", File: "file_path" },
903
906
  };
904
907
 
905
908
  // ── Goose (codename goose, Block) ────────────────────────────────────────────