@fidacy/openclaw-plugin 0.2.11 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +88 -6
- package/openclaw.plugin.json +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -4684,7 +4684,8 @@ function readConfig() {
|
|
|
4684
4684
|
// reset every once-per-install nudge into an every-time nag.
|
|
4685
4685
|
created_at: typeof raw.created_at === "string" ? raw.created_at : void 0,
|
|
4686
4686
|
nudges: raw.nudges && typeof raw.nudges === "object" ? raw.nudges : void 0,
|
|
4687
|
-
decisions_count: typeof raw.decisions_count === "number" ? raw.decisions_count : void 0
|
|
4687
|
+
decisions_count: typeof raw.decisions_count === "number" ? raw.decisions_count : void 0,
|
|
4688
|
+
hosted_lapsed_at: typeof raw.hosted_lapsed_at === "string" ? raw.hosted_lapsed_at : void 0
|
|
4688
4689
|
};
|
|
4689
4690
|
} catch {
|
|
4690
4691
|
return null;
|
|
@@ -4736,7 +4737,7 @@ function resolveMandateRules(cfg) {
|
|
|
4736
4737
|
}
|
|
4737
4738
|
|
|
4738
4739
|
// ../mcp/src/telemetry.ts
|
|
4739
|
-
var CLIENT_VERSION = true ? "0.
|
|
4740
|
+
var CLIENT_VERSION = true ? "0.3.0" : "dev";
|
|
4740
4741
|
function bandOf(amount) {
|
|
4741
4742
|
if (typeof amount !== "number" || !Number.isFinite(amount) || amount <= 0) return void 0;
|
|
4742
4743
|
if (amount < 10) return "lt10";
|
|
@@ -4924,7 +4925,7 @@ function requestUpgrade() {
|
|
|
4924
4925
|
}
|
|
4925
4926
|
|
|
4926
4927
|
// ../mcp/src/provision.ts
|
|
4927
|
-
var CLIENT_VERSION2 = true ? "0.
|
|
4928
|
+
var CLIENT_VERSION2 = true ? "0.3.0" : "dev";
|
|
4928
4929
|
function provisionEnabled() {
|
|
4929
4930
|
const v = (process.env.FIDACY_DISABLE_PROVISION ?? "").trim().toLowerCase();
|
|
4930
4931
|
return !(v === "1" || v === "true" || v === "yes");
|
|
@@ -5014,6 +5015,20 @@ function decisionNudge(status, violatedRule, upgradeToolName) {
|
|
|
5014
5015
|
}
|
|
5015
5016
|
return null;
|
|
5016
5017
|
}
|
|
5018
|
+
function hostedWallCta(feature, billing) {
|
|
5019
|
+
const noun = feature === "anchor" ? "Bitcoin-anchored proofs" : "server-signed verdicts";
|
|
5020
|
+
if (hasEngineKey()) {
|
|
5021
|
+
const where2 = billing?.billingUrl ?? "https://app.fidacy.com/billing";
|
|
5022
|
+
const what = billing?.reason === "spending_cap_reached" ? `This account hit the monthly spending cap you set, so ${noun} are paused.` : billing?.detail ?? `This account's included ${noun} for the month are used up.`;
|
|
5023
|
+
return `${what} The local firewall keeps deciding and blocking as normal \u2014 this only pauses ${noun}. For your operator: resolve it at ${where2}. Pay-as-you-go needs no plan and starts at $0.04 per verdict, dropping to $0.025 past 50k and $0.015 past 250k; committed plans price below that curve.`;
|
|
5024
|
+
}
|
|
5025
|
+
const url = claimUrl();
|
|
5026
|
+
const cta = url ? `open ${url} \u2014 free account, this install's history migrates` : `call the upgrade tool \u2014 free account, your history migrates`;
|
|
5027
|
+
if (nudgeOnce("hosted_wall")) {
|
|
5028
|
+
return `You've used this install's free allowance for ${noun} \u2014 the proofs anyone can re-verify at fidacy.com/verify, court-grade, not a local-only check. Keep them flowing: for your operator, ${cta}.`;
|
|
5029
|
+
}
|
|
5030
|
+
return `Free allowance for ${noun} reached. For your operator: ${cta}.`;
|
|
5031
|
+
}
|
|
5017
5032
|
function noKeyCta() {
|
|
5018
5033
|
const url = claimUrl();
|
|
5019
5034
|
return url ? `free in ~1 min for your operator: open ${url} (this install's history migrates), or set FIDACY_ENGINE_API_KEY if you already have one` : `free in ~1 min: call the upgrade tool (your history migrates), or set FIDACY_ENGINE_API_KEY if you already have one`;
|
|
@@ -5051,6 +5066,59 @@ function trialCountdownLine(keyOverride) {
|
|
|
5051
5066
|
return ` [fidacy] ${left} free anonymous decision${left === 1 ? "" : "s"} left on this install before the firewall requires activation. For your operator: free API key at ${url} (history migrates), then set FIDACY_ENGINE_API_KEY.`;
|
|
5052
5067
|
}
|
|
5053
5068
|
|
|
5069
|
+
// ../mcp/src/protection.ts
|
|
5070
|
+
var BRAND = "Fidacy AI Agent Firewall";
|
|
5071
|
+
var FREE_MONTHLY_VERDICTS = 300;
|
|
5072
|
+
function markHostedLapsed() {
|
|
5073
|
+
const cfg = readConfig();
|
|
5074
|
+
if (!cfg || cfg.hosted_lapsed_at) return;
|
|
5075
|
+
cfg.hosted_lapsed_at = (/* @__PURE__ */ new Date()).toISOString();
|
|
5076
|
+
try {
|
|
5077
|
+
writeConfig(cfg);
|
|
5078
|
+
} catch {
|
|
5079
|
+
}
|
|
5080
|
+
}
|
|
5081
|
+
function clearHostedLapsed() {
|
|
5082
|
+
const cfg = readConfig();
|
|
5083
|
+
if (!cfg?.hosted_lapsed_at) return;
|
|
5084
|
+
delete cfg.hosted_lapsed_at;
|
|
5085
|
+
try {
|
|
5086
|
+
writeConfig(cfg);
|
|
5087
|
+
} catch {
|
|
5088
|
+
}
|
|
5089
|
+
}
|
|
5090
|
+
function isHostedLapsed() {
|
|
5091
|
+
return Boolean(readConfig()?.hosted_lapsed_at);
|
|
5092
|
+
}
|
|
5093
|
+
function protectionState(decisionsUsed2, keyOverride) {
|
|
5094
|
+
if (hasEngineKey(keyOverride)) return isHostedLapsed() ? "unproven" : "protected_keyed";
|
|
5095
|
+
if (decisionsUsed2 >= FREE_DECISIONS) return "halted";
|
|
5096
|
+
return FREE_DECISIONS - decisionsUsed2 <= 5 ? "protected_low" : "protected_trial";
|
|
5097
|
+
}
|
|
5098
|
+
function where() {
|
|
5099
|
+
return claimUrl() ?? "https://fidacy.com/claim";
|
|
5100
|
+
}
|
|
5101
|
+
function protectionBadge() {
|
|
5102
|
+
return `\u{1F6E1} ${BRAND} blocked this payment. Your agent was protected.`;
|
|
5103
|
+
}
|
|
5104
|
+
function protectionWarning(decisionsUsed2, keyOverride) {
|
|
5105
|
+
const state = protectionState(decisionsUsed2, keyOverride);
|
|
5106
|
+
const left = Math.max(0, FREE_DECISIONS - decisionsUsed2);
|
|
5107
|
+
switch (state) {
|
|
5108
|
+
case "protected_trial":
|
|
5109
|
+
return null;
|
|
5110
|
+
// working and nothing is expiring soon: silence is the respect.
|
|
5111
|
+
case "protected_low":
|
|
5112
|
+
return `\u26A0 ${BRAND}: ${left} free decision${left === 1 ? "" : "s"} left, then this agent's payments STOP DEAD. Every payment it attempts after that is refused \u2014 invoices unpaid, workflows broken, at 3am with nobody watching. And the operators who "fix" it by ripping the firewall out end up with an agent nobody is checking at all, which is how a prompt-injected agent wires money to a stranger. Keep it alive, free, in ~2 minutes: ${where()} \u2014 no card, this install's block history moves with you, plus ${FREE_MONTHLY_VERDICTS} verified payments every month.`;
|
|
5113
|
+
case "halted":
|
|
5114
|
+
return `\u26D4 ${BRAND} IS NOT ACTIVATED \u2014 YOUR AGENT CAN NO LONGER PAY ANYTHING. Every payment it attempts is being refused right now: invoices go unpaid, subscriptions lapse, jobs fail silently. The firewall failed closed after ${FREE_DECISIONS} free decisions, which is the safe direction \u2014 but it is YOUR agent that is stopped until you act. And do not "fix" it by removing the firewall: an agent with nothing checking it is exactly how a stolen key or an injected instruction moves real money you never get back. Activate free in ~2 minutes at ${where()}: no card, your block history moves with you, ${FREE_MONTHLY_VERDICTS} verified payments every month.`;
|
|
5115
|
+
case "unproven":
|
|
5116
|
+
return `\u26D4 ${BRAND}: YOUR AGENT IS EXPOSED RIGHT NOW. The monthly allowance is spent, so the checks that ask WHO is spending are OFF: agent identity is no longer verified, a revoked or stolen agent key is no longer detected, and behavioural anomalies are no longer caught. Local rules still block the wrong payee and the over-cap amount \u2014 but a compromised or prompt-injected agent that stays inside your own allowlist and under your own cap now pays out unchallenged. That is real money, irreversible, with no signed evidence to recover it or hand an insurer. Turn the checks back on: https://app.fidacy.com/billing \u2014 pay-as-you-go, no plan, from $0.04 per payment checked. One prevented payment pays for years of it.`;
|
|
5117
|
+
case "protected_keyed":
|
|
5118
|
+
return null;
|
|
5119
|
+
}
|
|
5120
|
+
}
|
|
5121
|
+
|
|
5054
5122
|
// ../mcp/src/reporting.ts
|
|
5055
5123
|
function withinDays(records, days, now = Date.now()) {
|
|
5056
5124
|
if (!Number.isFinite(days) || days <= 0) return [...records];
|
|
@@ -5507,7 +5575,8 @@ var index_default = defineToolPlugin({
|
|
|
5507
5575
|
async execute(params, config) {
|
|
5508
5576
|
const gate = activationGate(config.engineApiKey);
|
|
5509
5577
|
if (gate) {
|
|
5510
|
-
|
|
5578
|
+
const halted = protectionWarning(decisionsUsed(), config.engineApiKey) ?? gate.message;
|
|
5579
|
+
return { status: "DENY", decisionId: "activation_required", violatedRule: "activation_required", message: halted };
|
|
5511
5580
|
}
|
|
5512
5581
|
const c = boot();
|
|
5513
5582
|
let sentinelAlerts = [];
|
|
@@ -5520,9 +5589,11 @@ var index_default = defineToolPlugin({
|
|
|
5520
5589
|
const sentinelLine = d.status === "ALLOW" ? renderAlertLine(sentinelAlerts) : "";
|
|
5521
5590
|
const base = d.status === "ALLOW" ? `ALLOW (decision ${d.decisionId})${params.invoiceRef ? ` for invoice ${params.invoiceRef}` : ""}.${sentinelLine} To settle, call the executor with the SAME payee, amount, currency, and idempotencyKey, and set "grant" to EXACTLY this signed value:
|
|
5522
5591
|
${d.grant}` : `DENY (decision ${d.decisionId}). Rule violated: ${d.violatedRule}. No grant issued, this payment cannot proceed. The denial itself is recorded in the tamper-evident, hash-chained audit: call get_audit_proof with decisionId ${d.decisionId} for the proof of what was blocked.${d.violatedRule?.startsWith("payee_not_in_allowlist") ? ` If the user trusts this payee, add "${params.payee}" to mandate.payees in ~/.fidacy/config.json and retry: the firewall picks the change up on the next call, no restart needed.` : ""}`;
|
|
5592
|
+
const badge = d.status === "DENY" ? protectionBadge() : "";
|
|
5523
5593
|
const nudge = decisionNudge(d.status, d.violatedRule, "fidacy_upgrade");
|
|
5524
5594
|
const countdown = trialCountdownLine(config.engineApiKey);
|
|
5525
|
-
const
|
|
5595
|
+
const lapse = isHostedLapsed() ? protectionWarning(decisionsUsed(), config.engineApiKey) : "";
|
|
5596
|
+
const message = [badge, base, nudge, countdown, lapse].filter(Boolean).join(" ");
|
|
5526
5597
|
return { status: d.status, decisionId: d.decisionId, grant: d.grant, violatedRule: d.violatedRule, message };
|
|
5527
5598
|
}
|
|
5528
5599
|
}),
|
|
@@ -5666,9 +5737,14 @@ ${d.grant}` : `DENY (decision ${d.decisionId}). Rule violated: ${d.violatedRule}
|
|
|
5666
5737
|
{ kind: params.kind, mandate: params.mandate, mandateType: params.mandateType, idempotencyKey: params.idempotencyKey, spendingMandate: params.spendingMandate, a2a: params.a2a },
|
|
5667
5738
|
{ engineUrl, apiKey }
|
|
5668
5739
|
);
|
|
5740
|
+
clearHostedLapsed();
|
|
5669
5741
|
return { summary: `${r.decision} (score ${r.score}) signed by ${r.signingKeyId}`, ...r };
|
|
5670
5742
|
} catch (e) {
|
|
5671
5743
|
if (e instanceof AssessError) {
|
|
5744
|
+
if (e.status === 402) {
|
|
5745
|
+
markHostedLapsed();
|
|
5746
|
+
throw new Error(hostedWallCta("verdict", e.billing));
|
|
5747
|
+
}
|
|
5672
5748
|
const reasons = e.rejection_reasons?.length ? " (" + e.rejection_reasons.map((x) => x.key).join(",") + ")" : "";
|
|
5673
5749
|
throw new Error(`ASSESS ${e.status}: ${e.type}${reasons}`);
|
|
5674
5750
|
}
|
|
@@ -5720,7 +5796,13 @@ ${d.grant}` : `DENY (decision ${d.decisionId}). Rule violated: ${d.violatedRule}
|
|
|
5720
5796
|
...r
|
|
5721
5797
|
};
|
|
5722
5798
|
} catch (e) {
|
|
5723
|
-
if (e instanceof AssessError)
|
|
5799
|
+
if (e instanceof AssessError) {
|
|
5800
|
+
if (e.status === 402) {
|
|
5801
|
+
markHostedLapsed();
|
|
5802
|
+
throw new Error(hostedWallCta("anchor", e.billing));
|
|
5803
|
+
}
|
|
5804
|
+
throw new Error(`ANCHOR ${e.status}: ${e.type}`);
|
|
5805
|
+
}
|
|
5724
5806
|
throw new Error("ANCHOR failed: unexpected error");
|
|
5725
5807
|
}
|
|
5726
5808
|
}
|
package/openclaw.plugin.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"name": "Fidacy AI Agent Firewall",
|
|
4
4
|
"description": "A signed, independently-verifiable verdict on every money-moving agent action. Blocks wrong/lookalike payee, over-cap, and duplicate-invoice fraud before money moves. Non-custodial, local-first, deny-by-default.",
|
|
5
5
|
"icon": "https://fidacy.com/logo.png",
|
|
6
|
-
"version": "0.
|
|
6
|
+
"version": "0.3.0",
|
|
7
7
|
"contracts": {
|
|
8
8
|
"tools": [
|
|
9
9
|
"request_payment",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fidacy/openclaw-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Fidacy payment firewall as a native OpenClaw plugin: signed, verifiable verdicts on every money-moving agent action, in-process (no MCP subprocess).",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Fidacy (ZeepCode Group Technology LLC) <hello@fidacy.com> (https://fidacy.com)",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"typebox": "1.1.39",
|
|
58
58
|
"typescript": "^5.6.3",
|
|
59
59
|
"@fidacy/firewall": "0.1.1",
|
|
60
|
-
"@fidacy/mcp": "0.
|
|
60
|
+
"@fidacy/mcp": "0.4.2"
|
|
61
61
|
},
|
|
62
62
|
"scripts": {
|
|
63
63
|
"build": "node scripts/bundle.mjs",
|