@fidacy/openclaw-plugin 0.1.11 → 0.1.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 (2) hide show
  1. package/dist/index.js +43 -9
  2. 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.11" : "dev";
4693
+ var CLIENT_VERSION = true ? "0.1.13" : "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({ type, ts: (/* @__PURE__ */ new Date()).toISOString(), client_version: CLIENT_VERSION, shell: currentShell, ...result ? { result } : {} });
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: buildMandate(),
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
- dev.setMandate(buildMandate());
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.11" : "dev";
4870
+ var CLIENT_VERSION2 = true ? "0.1.13" : "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");
@@ -4903,6 +4934,9 @@ function decisionNudge(status, violatedRule, upgradeToolName) {
4903
4934
  if (status === "DENY" && nudgeOnce("first_deny")) {
4904
4935
  return `Fidacy just blocked this for you \u2014 for server-signed, anchored proof of every block (free account, local history migrates), call the ${upgradeToolName} tool.`;
4905
4936
  }
4937
+ if (count === 25 && nudgeOnce("proof_teaser")) {
4938
+ return `Your local chain now holds ${count} decisions only you can read. Anchor them and anyone can verify at fidacy.com/verify, no account needed on their side. Call the ${upgradeToolName} tool (free) to make your history portable.`;
4939
+ }
4906
4940
  if (count === 10 && nudgeOnce("milestone_10")) {
4907
4941
  return `That's 10 actions gated on this install. For a signed, Bitcoin-anchored history of all of them (free account), call the ${upgradeToolName} tool.`;
4908
4942
  }
@@ -4999,7 +5033,7 @@ async function postOnce(fetchImpl, url, headers, payload, timeoutMs) {
4999
5033
  body: payload,
5000
5034
  signal: controller.signal
5001
5035
  });
5002
- } catch (err) {
5036
+ } catch {
5003
5037
  const aborted = controller.signal.aborted;
5004
5038
  throw new AssessError({ type: aborted ? "timeout" : "network_error", status: 0 });
5005
5039
  } finally {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fidacy/openclaw-plugin",
3
- "version": "0.1.11",
3
+ "version": "0.1.13",
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",