Skip to content

Commit 107c2d1

Browse files
1bcMaxclaude
andcommitted
v0.12.278 — remove TWZRD AutoGate and its optional dependency
The pre-sign path carries no third-party vendor. `clawrouter policy` (SpendControl) is the pre-spend control ClawRouter ships. Deletes `src/twzrd-autogate.ts` and its tests, the `twzrd-x402-gate` optionalDependency and its lockfile entry, the tsup `external` carve-out, the proxy hook composition, and the TWZRD_* flags and docs in README, docs/configuration.md and `clawrouter --help`. The vendor's own follow-up (#360, closed) verified `0.9.4` against the installed package and showed four things we cannot carry inside `onBeforePaymentCreation`: - The engine changed under a patch bump. `0.9.3` ran the full `/v1/intel/preflight`; the same `createTwzrdBeforePaymentHook` call in `0.9.4` became a wash-only `GET merchant_card/{payTo}` against a different endpoint with a different refusal set, no code change here. - The package ignores the `failOpen` we pass and converts a fast 503 / 404 / `fetch failed` / non-JSON into allow internally, so `TWZRD_FAIL_OPEN=false` never meant refuse-on-outage as documented. - `wash_flagged: false` with missing, partial or stale coverage aborts — an unscored recipient stops a payment. - Every lookup stamped `X-Twzrd-Caller` / `X-TWZRD-Integration` / `X-TWZRD-Client` attribution from the code path that signs with the user's wallet. The surface was opt-in and default-off, so nothing that worked before stops working; `TWZRD_AUTO_GATE=1` installs now fall back to SpendControl, which was always the guarantee. npm test 1088 passed / 1 skipped · typecheck · lint · prettier · build + dist smoke · sync-brand-numbers --check — all green. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CMn84JAawTdBgpQCkU7aYn
1 parent 2bff0e5 commit 107c2d1

15 files changed

Lines changed: 54 additions & 1073 deletions

‎CHANGELOG.md‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,49 @@ All notable changes to ClawRouter.
44

55
---
66

7+
## v0.12.278 — September 7, 2026
8+
9+
### Removed — TWZRD AutoGate, and the optional dependency behind it
10+
11+
`src/twzrd-autogate.ts`, the `twzrd-x402-gate` optionalDependency, the
12+
`TWZRD_AUTO_GATE` / `TWZRD_GATE_ENABLED` / `TWZRD_GATE_TIMEOUT_MS` /
13+
`TWZRD_FAIL_OPEN` flags and their docs are gone. `clawrouter policy`
14+
(SpendControl) is the pre-spend control ClawRouter ships, and the x402
15+
pre-sign path carries no third-party vendor.
16+
17+
The evidence for removing it came from the vendor's own follow-up
18+
([#360](https://github.com/BlockRunAI/ClawRouter/pull/360), closed), which
19+
verified `0.9.4` against the installed package rather than the docs:
20+
21+
**The engine changed under a patch bump.** `0.9.3` ran the full
22+
`/v1/intel/preflight` the v0.12.277 notes described. In `0.9.4` the same
23+
`createTwzrdBeforePaymentHook` call became a wash-only `GET merchant_card/{payTo}`
24+
against a different endpoint, on Solana and Base alike, with a different refusal
25+
set — no code change on our side. A dependency that redefines what it does
26+
inside `onBeforePaymentCreation` on a patch release cannot sit there.
27+
28+
**Our failure config was never honoured.** The package converts a fast lookup
29+
failure — `503`, `404`, `fetch failed`, invalid JSON, its own 3s timeout — into
30+
allow internally, and ignores the `failOpen` we pass. `TWZRD_FAIL_OPEN=false`
31+
therefore meant "refuse on hang", not "refuse on outage", for the whole life of
32+
the feature. The flag documented a guarantee the package would not give.
33+
34+
**Unknown became a refusal.** `wash_flagged: false` with missing, partial or
35+
stale coverage aborts as `twzrd_wash_unknown`. A recipient nobody has scored
36+
yet stops a payment.
37+
38+
**Every lookup was attributed.** `X-Twzrd-Caller`, `X-TWZRD-Integration`,
39+
`X-TWZRD-Client` and a per-process run id went out with each call, from inside
40+
the code path that signs with the user's wallet.
41+
42+
`0.9.3` remains uninstalled either way: `0.10.0` / `0.10.1` are deprecated
43+
upstream as unreproducible, and the gate's whole surface was opt-in and
44+
default-off, so nothing that worked before this release stops working. Anyone
45+
who had `TWZRD_AUTO_GATE=1` set now falls back to SpendControl alone, which was
46+
always the guarantee.
47+
48+
---
49+
750
## v0.12.277 — September 6, 2026
851

952
### Added — opt-in TWZRD AutoGate on the x402 pre-sign hook

‎README.md‎

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -767,24 +767,9 @@ For basic usage, no configuration needed. For advanced options:
767767
| `CLAWROUTER_DISABLED` | `false` | Disable smart routing |
768768
| `CLAWROUTER_DEBUG_HEADERS` | `on` | Set to `off` to suppress `x-clawrouter-*` debug response headers |
769769
| `CLAWROUTER_SOLANA_RPC_URL` | `https://api.mainnet-beta.solana.com` | Solana RPC endpoint — balance checks and payment signing |
770-
| `TWZRD_AUTO_GATE` | unset (off) | Set to `1` to compose TWZRD AutoGate after SpendControl on the x402 pre-sign hook |
771770

772771
**Full reference:** [docs/configuration.md](docs/configuration.md)
773772

774-
### Pre-spend trust (TWZRD AutoGate, opt-in)
775-
776-
Default **off**. Spend limits and counterparty lists (`clawrouter policy`) stay the vendor-neutral path. This is not a default-on vendor lock.
777-
778-
To also run TWZRD wash/preflight on the same `onBeforePaymentCreation` chain — after SpendControl, before the wallet signs:
779-
780-
```bash
781-
export TWZRD_AUTO_GATE=1
782-
```
783-
784-
Equivalent flag: `TWZRD_GATE_ENABLED=true`. Requires optional dependency `twzrd-x402-gate@0.9.3` (forks that omit it still install). A refuse stamps `X-Twzrd-Caller: clawrouter/<version>` so it is attributable. Unset the flag to go back to SpendControl only.
785-
786-
**It gates Solana, not Base.** The gate scores Solana recipients; Base/EVM classifies as `network_not_scored` and is waved through without a lookup. On Solana it POSTs the resource URL, `payTo`, price and chain to `intel.twzrd.xyz` before each signature — payment metadata leaves your machine when this is on. We bound that call at `TWZRD_GATE_TIMEOUT_MS` (default 2000) and proceed if it does not answer, because SpendControl is the guarantee and a third party must not be able to stop your payments; set `TWZRD_FAIL_OPEN=false` to refuse instead.
787-
788773
### Model Exclusion
789774

790775
Block specific models from being routed to. Useful if a model doesn't follow your agent instructions or you want to control costs.

‎apps/desktop/electron/core/runtime.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type { AdapterContext } from "./types.js";
66
import { ensureServiceToken, verifyClawRouter } from "./service-auth.js";
77

88
/** Keep in sync with the root package; runtime-version.test.ts enforces it. */
9-
export const CLAWROUTER_PACKAGE_VERSION = "0.12.277";
9+
export const CLAWROUTER_PACKAGE_VERSION = "0.12.278";
1010

1111
export function managedBin(context: AdapterContext, name: string): string {
1212
const suffix = process.platform === "win32" ? ".cmd" : "";

‎dist/cli.js‎

Lines changed: 2 additions & 148 deletions
Original file line numberDiff line numberDiff line change
@@ -60460,149 +60460,6 @@ var init_api_key = __esm({
6046060460
}
6046160461
});
6046260462

60463-
// src/twzrd-autogate.ts
60464-
import { randomUUID } from "crypto";
60465-
function normalizeFlag(value) {
60466-
const trimmed = value?.trim().toLowerCase();
60467-
return trimmed === "" ? void 0 : trimmed;
60468-
}
60469-
function isTwzrdAutoGateEnabled(env = process.env) {
60470-
const auto = normalizeFlag(env.TWZRD_AUTO_GATE);
60471-
const gate = normalizeFlag(env.TWZRD_GATE_ENABLED);
60472-
if (auto !== void 0 && FALSY.has(auto) || gate !== void 0 && FALSY.has(gate)) {
60473-
return false;
60474-
}
60475-
return auto !== void 0 && TRUTHY.has(auto) || gate !== void 0 && TRUTHY.has(gate);
60476-
}
60477-
function isMissingTwzrdGateModule(err) {
60478-
const code = err?.code;
60479-
const msg = err instanceof Error ? err.message : String(err);
60480-
const missingModule = code === "ERR_MODULE_NOT_FOUND" || code === "MODULE_NOT_FOUND" || /Cannot find module/i.test(msg) || /Cannot find package/i.test(msg);
60481-
return missingModule && new RegExp(String.raw`['"]${TWZRD_GATE_PACKAGE}['"]`).test(msg);
60482-
}
60483-
function twzrdGateTimeoutMs(env = process.env) {
60484-
const raw = normalizeFlag(env.TWZRD_GATE_TIMEOUT_MS);
60485-
if (raw === void 0) return TWZRD_GATE_TIMEOUT_MS;
60486-
const parsed = Number(raw);
60487-
return Number.isFinite(parsed) && parsed > 0 ? parsed : TWZRD_GATE_TIMEOUT_MS;
60488-
}
60489-
function twzrdGateFailOpen(env = process.env) {
60490-
const raw = normalizeFlag(env.TWZRD_FAIL_OPEN);
60491-
return !(raw !== void 0 && FALSY.has(raw));
60492-
}
60493-
function twzrdAutoGateInstallOptions(env = process.env, runId = randomUUID) {
60494-
return {
60495-
refuseWashFlagged: true,
60496-
gateOnCanSpend: false,
60497-
unsupportedNetworkMode: "observe",
60498-
failOpen: twzrdGateFailOpen(env),
60499-
attribution: {
60500-
integration: `clawrouter/${VERSION}`,
60501-
runId: runId()
60502-
}
60503-
};
60504-
}
60505-
async function runTwzrdGateWithTimeout(run, opts) {
60506-
const log = opts.log ?? console;
60507-
let timer2;
60508-
try {
60509-
const raced = await Promise.race([
60510-
// Swallow here, not at the race, so a late rejection never goes unhandled.
60511-
Promise.resolve().then(run).catch((err) => ({ __twzrdError: err })),
60512-
new Promise((resolve) => {
60513-
timer2 = setTimeout(() => resolve(TIMED_OUT), opts.timeoutMs);
60514-
})
60515-
]);
60516-
if (raced === TIMED_OUT) {
60517-
return decideOnGateFailure(`did not answer within ${opts.timeoutMs}ms`, opts.failOpen, log);
60518-
}
60519-
if (raced && typeof raced === "object" && "__twzrdError" in raced) {
60520-
const err = raced.__twzrdError;
60521-
const msg = err instanceof Error ? err.message : String(err);
60522-
return decideOnGateFailure(`threw: ${msg.slice(0, 120)}`, opts.failOpen, log);
60523-
}
60524-
return raced;
60525-
} finally {
60526-
if (timer2) clearTimeout(timer2);
60527-
}
60528-
}
60529-
function decideOnGateFailure(what, failOpen, log) {
60530-
const reason = `twzrd gate ${what}`;
60531-
if (failOpen) {
60532-
log.warn(
60533-
`[ClawRouter] ${reason} \u2014 proceeding. SpendControl still applied. Set TWZRD_FAIL_OPEN=false to refuse instead.`
60534-
);
60535-
return void 0;
60536-
}
60537-
log.warn(`[ClawRouter] ${reason} \u2014 refusing the payment (TWZRD_FAIL_OPEN=false).`);
60538-
return { abort: true, reason };
60539-
}
60540-
async function defaultLoadTwzrdGate() {
60541-
const specifier = TWZRD_GATE_PACKAGE;
60542-
return import(specifier);
60543-
}
60544-
async function maybeComposeTwzrdAutoGate(x402, options) {
60545-
const env = options?.env ?? process.env;
60546-
const log = options?.log ?? console;
60547-
if (!isTwzrdAutoGateEnabled(env)) {
60548-
return { status: "skipped" };
60549-
}
60550-
const load = options?.loadGate ?? defaultLoadTwzrdGate;
60551-
let gate;
60552-
try {
60553-
gate = await load();
60554-
} catch (err) {
60555-
if (isMissingTwzrdGateModule(err)) {
60556-
const reason = `${TWZRD_GATE_PACKAGE} is not installed`;
60557-
log.warn(
60558-
`[ClawRouter] TWZRD AutoGate opted in but ${reason} \u2014 skipping. npm i ${TWZRD_GATE_PACKAGE}@0.9.3`
60559-
);
60560-
return { status: "unavailable", reason };
60561-
}
60562-
throw err;
60563-
}
60564-
const installOpts = twzrdAutoGateInstallOptions(env);
60565-
const timeoutMs = twzrdGateTimeoutMs(env);
60566-
const ready = (via) => log.log(
60567-
`[ClawRouter] TWZRD AutoGate ON (opt-in, after SpendControl, ${via}; ${timeoutMs}ms budget, failOpen=${installOpts.failOpen}). Unset TWZRD_AUTO_GATE to disable.`
60568-
);
60569-
if (typeof gate.createTwzrdBeforePaymentHook === "function") {
60570-
const hook = gate.createTwzrdBeforePaymentHook(installOpts);
60571-
x402.onBeforePaymentCreation(
60572-
async (ctx) => runTwzrdGateWithTimeout(() => hook(ctx.selectedRequirements, ctx), {
60573-
timeoutMs,
60574-
failOpen: installOpts.failOpen,
60575-
log
60576-
})
60577-
);
60578-
ready("createTwzrdBeforePaymentHook");
60579-
return { status: "composed", via: "createTwzrdBeforePaymentHook" };
60580-
}
60581-
if (typeof gate.installTwzrdAutoGate === "function") {
60582-
gate.installTwzrdAutoGate(x402, installOpts);
60583-
log.warn(
60584-
"[ClawRouter] TWZRD AutoGate installed via installTwzrdAutoGate \u2014 that entry point registers its own hook, so the timeout budget does not apply and it replaces onBeforePaymentCreation on this client. Prefer a gate build exporting createTwzrdBeforePaymentHook."
60585-
);
60586-
ready("installTwzrdAutoGate");
60587-
return { status: "composed", via: "installTwzrdAutoGate" };
60588-
}
60589-
throw new Error(
60590-
`[ClawRouter] ${TWZRD_GATE_PACKAGE} is installed but exports neither installTwzrdAutoGate nor createTwzrdBeforePaymentHook`
60591-
);
60592-
}
60593-
var TWZRD_GATE_PACKAGE, TRUTHY, FALSY, TWZRD_GATE_TIMEOUT_MS, TIMED_OUT;
60594-
var init_twzrd_autogate = __esm({
60595-
"src/twzrd-autogate.ts"() {
60596-
"use strict";
60597-
init_version4();
60598-
TWZRD_GATE_PACKAGE = "twzrd-x402-gate";
60599-
TRUTHY = /* @__PURE__ */ new Set(["1", "true", "yes", "on"]);
60600-
FALSY = /* @__PURE__ */ new Set(["0", "false", "no", "off"]);
60601-
TWZRD_GATE_TIMEOUT_MS = 2e3;
60602-
TIMED_OUT = { __twzrdTimedOut: true };
60603-
}
60604-
});
60605-
6060660463
// src/compression/types.ts
6060760464
var DEFAULT_COMPRESSION_CONFIG;
6060860465
var init_types2 = __esm({
@@ -92187,7 +92044,6 @@ async function startProxy(options) {
9218792044
const evmSigner = toClientEvmSigner(account, evmPublicClient);
9218892045
const spendControl = options.spendControl ?? getSharedSpendControl();
9218992046
registerSpendPolicyHook(x402, spendControl);
92190-
await maybeComposeTwzrdAutoGate(x402);
9219192047
registerExactEvmScheme(x402, { signer: evmSigner });
9219292048
}
9219392049
let solanaAddress;
@@ -95773,7 +95629,6 @@ var init_proxy = __esm({
9577395629
init_auth();
9577495630
init_api_key();
9577595631
init_spend_control();
95776-
init_twzrd_autogate();
9577795632
init_compression();
9577895633
init_errors5();
9577995634
init_version4();
@@ -228831,7 +228686,7 @@ import {
228831228686
} from "fs";
228832228687
import { readFile as readFileAsync } from "fs/promises";
228833228688
import { homedir as homedir15 } from "os";
228834-
import { randomUUID as randomUUID2 } from "crypto";
228689+
import { randomUUID } from "crypto";
228835228690
import { join as join18 } from "path";
228836228691
async function waitForProxyHealth(port, timeoutMs = 3e3) {
228837228692
const start = Date.now();
@@ -228846,7 +228701,7 @@ async function waitForProxyHealth(port, timeoutMs = 3e3) {
228846228701
return false;
228847228702
}
228848228703
function writePrivateJsonSync(path5, value) {
228849-
const temporary = `${path5}.tmp.${randomUUID2()}`;
228704+
const temporary = `${path5}.tmp.${randomUUID()}`;
228850228705
try {
228851228706
writeFileSync3(temporary, JSON.stringify(value, null, 2), { mode: 384 });
228852228707
renameSync2(temporary, path5);
@@ -231337,7 +231192,6 @@ Environment Variables:
231337231192
BLOCKRUN_API_KEY BlockRun API key (brk_...) \u2014 wins over the wallet when set
231338231193
BLOCKRUN_WALLET_KEY Private key for x402 payments (auto-generated if not set)
231339231194
BLOCKRUN_PROXY_PORT Default proxy port (default: 8402)
231340-
TWZRD_AUTO_GATE Set to 1 to compose TWZRD AutoGate after SpendControl (default off)
231341231195

231342231196
For more info: https://blockrun.ai/clawrouter.md
231343231197
`);

‎dist/cli.js.map‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)