@fidacy/openclaw-plugin 0.1.11 → 0.1.12
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 +40 -9
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4570,6 +4570,9 @@ var FileAuditStore = class {
|
|
|
4570
4570
|
const digest = sha256(stableStringify({ decisionId: decision.decisionId, status: decision.status, request: decision.request, violatedRule: decision.violatedRule ?? null }));
|
|
4571
4571
|
const hash = sha256(`${prevHash}|${digest}|${seq}|${ts}`);
|
|
4572
4572
|
const record2 = { seq, decisionId: decision.decisionId, status: decision.status, subject: decision.subject, digest, prevHash, hash, ts };
|
|
4573
|
+
if (typeof decision.request?.purpose === "string" && decision.request.purpose.trim()) {
|
|
4574
|
+
record2.purpose = decision.request.purpose.slice(0, 500);
|
|
4575
|
+
}
|
|
4573
4576
|
if (decision.status === "ALLOW") {
|
|
4574
4577
|
const req = decision.request;
|
|
4575
4578
|
if (typeof req?.amount === "number" && Number.isFinite(req.amount))
|
|
@@ -4687,7 +4690,25 @@ function resolveMandateRules(cfg) {
|
|
|
4687
4690
|
}
|
|
4688
4691
|
|
|
4689
4692
|
// ../mcp/src/telemetry.ts
|
|
4690
|
-
var CLIENT_VERSION = true ? "0.1.
|
|
4693
|
+
var CLIENT_VERSION = true ? "0.1.12" : "dev";
|
|
4694
|
+
function bandOf(amount) {
|
|
4695
|
+
if (typeof amount !== "number" || !Number.isFinite(amount) || amount <= 0) return void 0;
|
|
4696
|
+
if (amount < 10) return "lt10";
|
|
4697
|
+
if (amount < 100) return "10_99";
|
|
4698
|
+
if (amount < 1e3) return "100_999";
|
|
4699
|
+
if (amount < 1e4) return "1k_10k";
|
|
4700
|
+
if (amount < 1e5) return "10k_100k";
|
|
4701
|
+
return "gte100k";
|
|
4702
|
+
}
|
|
4703
|
+
function capRatioOf(amount, perTxMax) {
|
|
4704
|
+
if (typeof amount !== "number" || typeof perTxMax !== "number") return void 0;
|
|
4705
|
+
if (!Number.isFinite(amount) || !Number.isFinite(perTxMax) || perTxMax <= 0 || amount <= perTxMax) return void 0;
|
|
4706
|
+
const r = amount / perTxMax;
|
|
4707
|
+
if (r < 2) return "1_2x";
|
|
4708
|
+
if (r < 5) return "2_5x";
|
|
4709
|
+
if (r < 10) return "5_10x";
|
|
4710
|
+
return "gt10x";
|
|
4711
|
+
}
|
|
4691
4712
|
var currentShell = "mcp";
|
|
4692
4713
|
function setTelemetryShell(shell) {
|
|
4693
4714
|
currentShell = shell;
|
|
@@ -4720,9 +4741,17 @@ function resultOf(status, violatedRule) {
|
|
|
4720
4741
|
if (r.startsWith("non_positive_amount") || r.startsWith("invalid_")) return "deny_invalid";
|
|
4721
4742
|
return "deny_scope";
|
|
4722
4743
|
}
|
|
4723
|
-
function record(type, result) {
|
|
4744
|
+
function record(type, result, band, capRatio) {
|
|
4724
4745
|
if (!telemetryEnabled()) return;
|
|
4725
|
-
buffer.push({
|
|
4746
|
+
buffer.push({
|
|
4747
|
+
type,
|
|
4748
|
+
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4749
|
+
client_version: CLIENT_VERSION,
|
|
4750
|
+
shell: currentShell,
|
|
4751
|
+
...result ? { result } : {},
|
|
4752
|
+
...band ? { band } : {},
|
|
4753
|
+
...capRatio ? { cap_ratio: capRatio } : {}
|
|
4754
|
+
});
|
|
4726
4755
|
if (!flushTimer) {
|
|
4727
4756
|
flushTimer = setTimeout(() => {
|
|
4728
4757
|
void flush();
|
|
@@ -4732,7 +4761,7 @@ function record(type, result) {
|
|
|
4732
4761
|
}
|
|
4733
4762
|
var recordInstall = () => record("install");
|
|
4734
4763
|
var recordAgentActive = () => record("agent_active");
|
|
4735
|
-
var recordDecision = (status, violatedRule) => record("decision", resultOf(status, violatedRule));
|
|
4764
|
+
var recordDecision = (status, violatedRule, amount, perTxMax) => record("decision", resultOf(status, violatedRule), bandOf(amount), capRatioOf(amount, perTxMax));
|
|
4736
4765
|
var recordUpgradeIntent = () => record("upgrade_intent");
|
|
4737
4766
|
async function flush() {
|
|
4738
4767
|
if (flushTimer) {
|
|
@@ -4795,10 +4824,11 @@ function makeCore() {
|
|
|
4795
4824
|
if (!url || !key) throw new Error("FIDACY_MODE=http requires FIDACY_API_URL and FIDACY_API_KEY");
|
|
4796
4825
|
return new HttpFidacyCore(url, key, process.env.FIDACY_PUBLIC_KEY_PEM ?? "");
|
|
4797
4826
|
}
|
|
4827
|
+
let activeMandate = buildMandate();
|
|
4798
4828
|
const dev = new DevFidacyCore({
|
|
4799
|
-
mandate:
|
|
4829
|
+
mandate: activeMandate,
|
|
4800
4830
|
auditLogPath: auditLogPath(),
|
|
4801
|
-
onDecision: (d) => recordDecision(d.status, d.violatedRule)
|
|
4831
|
+
onDecision: (d) => recordDecision(d.status, d.violatedRule, d.request?.amount, activeMandate?.allow?.perTxMax)
|
|
4802
4832
|
});
|
|
4803
4833
|
const mtimeOf = () => statSync(configPath(), { throwIfNoEntry: false })?.mtimeMs ?? 0;
|
|
4804
4834
|
let seenMtime = mtimeOf();
|
|
@@ -4806,7 +4836,8 @@ function makeCore() {
|
|
|
4806
4836
|
const m = mtimeOf();
|
|
4807
4837
|
if (m !== seenMtime) {
|
|
4808
4838
|
seenMtime = m;
|
|
4809
|
-
|
|
4839
|
+
activeMandate = buildMandate();
|
|
4840
|
+
dev.setMandate(activeMandate);
|
|
4810
4841
|
}
|
|
4811
4842
|
};
|
|
4812
4843
|
return {
|
|
@@ -4836,7 +4867,7 @@ function requestUpgrade() {
|
|
|
4836
4867
|
}
|
|
4837
4868
|
|
|
4838
4869
|
// ../mcp/src/provision.ts
|
|
4839
|
-
var CLIENT_VERSION2 = true ? "0.1.
|
|
4870
|
+
var CLIENT_VERSION2 = true ? "0.1.12" : "dev";
|
|
4840
4871
|
function provisionEnabled() {
|
|
4841
4872
|
const v = (process.env.FIDACY_DISABLE_PROVISION ?? "").trim().toLowerCase();
|
|
4842
4873
|
return !(v === "1" || v === "true" || v === "yes");
|
|
@@ -4999,7 +5030,7 @@ async function postOnce(fetchImpl, url, headers, payload, timeoutMs) {
|
|
|
4999
5030
|
body: payload,
|
|
5000
5031
|
signal: controller.signal
|
|
5001
5032
|
});
|
|
5002
|
-
} catch
|
|
5033
|
+
} catch {
|
|
5003
5034
|
const aborted = controller.signal.aborted;
|
|
5004
5035
|
throw new AssessError({ type: aborted ? "timeout" : "network_error", status: 0 });
|
|
5005
5036
|
} finally {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fidacy/openclaw-plugin",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.12",
|
|
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
|
"homepage": "https://fidacy.com",
|