@fidacy/mcp 0.1.18 → 0.1.20

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/core.js CHANGED
@@ -442,7 +442,25 @@ function resolveMandateRules(cfg) {
442
442
  }
443
443
 
444
444
  // src/telemetry.ts
445
- var CLIENT_VERSION = true ? "0.1.18" : "dev";
445
+ var CLIENT_VERSION = true ? "0.1.20" : "dev";
446
+ function bandOf(amount) {
447
+ if (typeof amount !== "number" || !Number.isFinite(amount) || amount <= 0) return void 0;
448
+ if (amount < 10) return "lt10";
449
+ if (amount < 100) return "10_99";
450
+ if (amount < 1e3) return "100_999";
451
+ if (amount < 1e4) return "1k_10k";
452
+ if (amount < 1e5) return "10k_100k";
453
+ return "gte100k";
454
+ }
455
+ function capRatioOf(amount, perTxMax) {
456
+ if (typeof amount !== "number" || typeof perTxMax !== "number") return void 0;
457
+ if (!Number.isFinite(amount) || !Number.isFinite(perTxMax) || perTxMax <= 0 || amount <= perTxMax) return void 0;
458
+ const r = amount / perTxMax;
459
+ if (r < 2) return "1_2x";
460
+ if (r < 5) return "2_5x";
461
+ if (r < 10) return "5_10x";
462
+ return "gt10x";
463
+ }
446
464
  var currentShell = "mcp";
447
465
  function telemetryEnabled() {
448
466
  const v = (process.env.FIDACY_DISABLE_TELEMETRY ?? "").trim().toLowerCase();
@@ -472,9 +490,17 @@ function resultOf(status, violatedRule) {
472
490
  if (r.startsWith("non_positive_amount") || r.startsWith("invalid_")) return "deny_invalid";
473
491
  return "deny_scope";
474
492
  }
475
- function record(type, result) {
493
+ function record(type, result, band, capRatio) {
476
494
  if (!telemetryEnabled()) return;
477
- buffer.push({ type, ts: (/* @__PURE__ */ new Date()).toISOString(), client_version: CLIENT_VERSION, shell: currentShell, ...result ? { result } : {} });
495
+ buffer.push({
496
+ type,
497
+ ts: (/* @__PURE__ */ new Date()).toISOString(),
498
+ client_version: CLIENT_VERSION,
499
+ shell: currentShell,
500
+ ...result ? { result } : {},
501
+ ...band ? { band } : {},
502
+ ...capRatio ? { cap_ratio: capRatio } : {}
503
+ });
478
504
  if (!flushTimer) {
479
505
  flushTimer = setTimeout(() => {
480
506
  void flush();
@@ -482,7 +508,7 @@ function record(type, result) {
482
508
  if (typeof flushTimer.unref === "function") flushTimer.unref();
483
509
  }
484
510
  }
485
- var recordDecision = (status, violatedRule) => record("decision", resultOf(status, violatedRule));
511
+ var recordDecision = (status, violatedRule, amount, perTxMax) => record("decision", resultOf(status, violatedRule), bandOf(amount), capRatioOf(amount, perTxMax));
486
512
  async function flush() {
487
513
  if (flushTimer) {
488
514
  clearTimeout(flushTimer);
@@ -544,10 +570,11 @@ function makeCore() {
544
570
  if (!url || !key) throw new Error("FIDACY_MODE=http requires FIDACY_API_URL and FIDACY_API_KEY");
545
571
  return new HttpFidacyCore(url, key, process.env.FIDACY_PUBLIC_KEY_PEM ?? "");
546
572
  }
573
+ let activeMandate = buildMandate();
547
574
  const dev = new DevFidacyCore({
548
- mandate: buildMandate(),
575
+ mandate: activeMandate,
549
576
  auditLogPath: auditLogPath(),
550
- onDecision: (d) => recordDecision(d.status, d.violatedRule)
577
+ onDecision: (d) => recordDecision(d.status, d.violatedRule, d.request?.amount, activeMandate?.allow?.perTxMax)
551
578
  });
552
579
  const mtimeOf = () => statSync(configPath(), { throwIfNoEntry: false })?.mtimeMs ?? 0;
553
580
  let seenMtime = mtimeOf();
@@ -555,7 +582,8 @@ function makeCore() {
555
582
  const m = mtimeOf();
556
583
  if (m !== seenMtime) {
557
584
  seenMtime = m;
558
- dev.setMandate(buildMandate());
585
+ activeMandate = buildMandate();
586
+ dev.setMandate(activeMandate);
559
587
  }
560
588
  };
561
589
  return {
package/dist/index.js CHANGED
@@ -471,7 +471,25 @@ function resolveMandateRules(cfg) {
471
471
  }
472
472
 
473
473
  // src/telemetry.ts
474
- var CLIENT_VERSION = true ? "0.1.18" : "dev";
474
+ var CLIENT_VERSION = true ? "0.1.20" : "dev";
475
+ function bandOf(amount) {
476
+ if (typeof amount !== "number" || !Number.isFinite(amount) || amount <= 0) return void 0;
477
+ if (amount < 10) return "lt10";
478
+ if (amount < 100) return "10_99";
479
+ if (amount < 1e3) return "100_999";
480
+ if (amount < 1e4) return "1k_10k";
481
+ if (amount < 1e5) return "10k_100k";
482
+ return "gte100k";
483
+ }
484
+ function capRatioOf(amount, perTxMax) {
485
+ if (typeof amount !== "number" || typeof perTxMax !== "number") return void 0;
486
+ if (!Number.isFinite(amount) || !Number.isFinite(perTxMax) || perTxMax <= 0 || amount <= perTxMax) return void 0;
487
+ const r = amount / perTxMax;
488
+ if (r < 2) return "1_2x";
489
+ if (r < 5) return "2_5x";
490
+ if (r < 10) return "5_10x";
491
+ return "gt10x";
492
+ }
475
493
  var currentShell = "mcp";
476
494
  function telemetryEnabled() {
477
495
  const v = (process.env.FIDACY_DISABLE_TELEMETRY ?? "").trim().toLowerCase();
@@ -501,9 +519,17 @@ function resultOf(status, violatedRule) {
501
519
  if (r.startsWith("non_positive_amount") || r.startsWith("invalid_")) return "deny_invalid";
502
520
  return "deny_scope";
503
521
  }
504
- function record(type, result) {
522
+ function record(type, result, band, capRatio) {
505
523
  if (!telemetryEnabled()) return;
506
- buffer.push({ type, ts: (/* @__PURE__ */ new Date()).toISOString(), client_version: CLIENT_VERSION, shell: currentShell, ...result ? { result } : {} });
524
+ buffer.push({
525
+ type,
526
+ ts: (/* @__PURE__ */ new Date()).toISOString(),
527
+ client_version: CLIENT_VERSION,
528
+ shell: currentShell,
529
+ ...result ? { result } : {},
530
+ ...band ? { band } : {},
531
+ ...capRatio ? { cap_ratio: capRatio } : {}
532
+ });
507
533
  if (!flushTimer) {
508
534
  flushTimer = setTimeout(() => {
509
535
  void flush();
@@ -513,7 +539,7 @@ function record(type, result) {
513
539
  }
514
540
  var recordInstall = () => record("install");
515
541
  var recordAgentActive = () => record("agent_active");
516
- var recordDecision = (status, violatedRule) => record("decision", resultOf(status, violatedRule));
542
+ var recordDecision = (status, violatedRule, amount, perTxMax) => record("decision", resultOf(status, violatedRule), bandOf(amount), capRatioOf(amount, perTxMax));
517
543
  var recordUpgradeIntent = () => record("upgrade_intent");
518
544
  async function flush() {
519
545
  if (flushTimer) {
@@ -576,10 +602,11 @@ function makeCore() {
576
602
  if (!url || !key) throw new Error("FIDACY_MODE=http requires FIDACY_API_URL and FIDACY_API_KEY");
577
603
  return new HttpFidacyCore(url, key, process.env.FIDACY_PUBLIC_KEY_PEM ?? "");
578
604
  }
605
+ let activeMandate = buildMandate();
579
606
  const dev = new DevFidacyCore({
580
- mandate: buildMandate(),
607
+ mandate: activeMandate,
581
608
  auditLogPath: auditLogPath(),
582
- onDecision: (d) => recordDecision(d.status, d.violatedRule)
609
+ onDecision: (d) => recordDecision(d.status, d.violatedRule, d.request?.amount, activeMandate?.allow?.perTxMax)
583
610
  });
584
611
  const mtimeOf = () => statSync(configPath(), { throwIfNoEntry: false })?.mtimeMs ?? 0;
585
612
  let seenMtime = mtimeOf();
@@ -587,7 +614,8 @@ function makeCore() {
587
614
  const m = mtimeOf();
588
615
  if (m !== seenMtime) {
589
616
  seenMtime = m;
590
- dev.setMandate(buildMandate());
617
+ activeMandate = buildMandate();
618
+ dev.setMandate(activeMandate);
591
619
  }
592
620
  };
593
621
  return {
@@ -786,7 +814,7 @@ async function findArtifacts(sha2562, cfg) {
786
814
  }
787
815
 
788
816
  // src/provision.ts
789
- var CLIENT_VERSION2 = true ? "0.1.18" : "dev";
817
+ var CLIENT_VERSION2 = true ? "0.1.20" : "dev";
790
818
  function provisionEnabled() {
791
819
  const v = (process.env.FIDACY_DISABLE_PROVISION ?? "").trim().toLowerCase();
792
820
  return !(v === "1" || v === "true" || v === "yes");
@@ -870,6 +898,9 @@ function decisionNudge(status, violatedRule, upgradeToolName) {
870
898
  if (status === "DENY" && nudgeOnce("first_deny")) {
871
899
  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.`;
872
900
  }
901
+ if (count === 25 && nudgeOnce("proof_teaser")) {
902
+ 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.`;
903
+ }
873
904
  if (count === 10 && nudgeOnce("milestone_10")) {
874
905
  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.`;
875
906
  }
@@ -886,7 +917,7 @@ function weekOneBootNudge(upgradeToolName) {
886
917
  var state = ensureState();
887
918
  var core = makeCore();
888
919
  var subject = process.env.FIDACY_SUBJECT ?? "agent:demo";
889
- var SERVER_VERSION = true ? "0.1.18" : "dev";
920
+ var SERVER_VERSION = true ? "0.1.20" : "dev";
890
921
  var server = new McpServer({ name: "fidacy", version: SERVER_VERSION });
891
922
  server.registerTool(
892
923
  "request_payment",
package/dist/lib.js CHANGED
@@ -594,7 +594,25 @@ function resolveMandateRules(cfg) {
594
594
  }
595
595
 
596
596
  // src/telemetry.ts
597
- var CLIENT_VERSION = true ? "0.1.18" : "dev";
597
+ var CLIENT_VERSION = true ? "0.1.20" : "dev";
598
+ function bandOf(amount) {
599
+ if (typeof amount !== "number" || !Number.isFinite(amount) || amount <= 0) return void 0;
600
+ if (amount < 10) return "lt10";
601
+ if (amount < 100) return "10_99";
602
+ if (amount < 1e3) return "100_999";
603
+ if (amount < 1e4) return "1k_10k";
604
+ if (amount < 1e5) return "10k_100k";
605
+ return "gte100k";
606
+ }
607
+ function capRatioOf(amount, perTxMax) {
608
+ if (typeof amount !== "number" || typeof perTxMax !== "number") return void 0;
609
+ if (!Number.isFinite(amount) || !Number.isFinite(perTxMax) || perTxMax <= 0 || amount <= perTxMax) return void 0;
610
+ const r = amount / perTxMax;
611
+ if (r < 2) return "1_2x";
612
+ if (r < 5) return "2_5x";
613
+ if (r < 10) return "5_10x";
614
+ return "gt10x";
615
+ }
598
616
  var currentShell = "mcp";
599
617
  function setTelemetryShell(shell) {
600
618
  currentShell = shell;
@@ -627,9 +645,17 @@ function resultOf(status, violatedRule) {
627
645
  if (r.startsWith("non_positive_amount") || r.startsWith("invalid_")) return "deny_invalid";
628
646
  return "deny_scope";
629
647
  }
630
- function record(type, result) {
648
+ function record(type, result, band, capRatio) {
631
649
  if (!telemetryEnabled()) return;
632
- buffer.push({ type, ts: (/* @__PURE__ */ new Date()).toISOString(), client_version: CLIENT_VERSION, shell: currentShell, ...result ? { result } : {} });
650
+ buffer.push({
651
+ type,
652
+ ts: (/* @__PURE__ */ new Date()).toISOString(),
653
+ client_version: CLIENT_VERSION,
654
+ shell: currentShell,
655
+ ...result ? { result } : {},
656
+ ...band ? { band } : {},
657
+ ...capRatio ? { cap_ratio: capRatio } : {}
658
+ });
633
659
  if (!flushTimer) {
634
660
  flushTimer = setTimeout(() => {
635
661
  void flush();
@@ -639,7 +665,7 @@ function record(type, result) {
639
665
  }
640
666
  var recordInstall = () => record("install");
641
667
  var recordAgentActive = () => record("agent_active");
642
- var recordDecision = (status, violatedRule) => record("decision", resultOf(status, violatedRule));
668
+ var recordDecision = (status, violatedRule, amount, perTxMax) => record("decision", resultOf(status, violatedRule), bandOf(amount), capRatioOf(amount, perTxMax));
643
669
  var recordUpgradeIntent = () => record("upgrade_intent");
644
670
  async function flush() {
645
671
  if (flushTimer) {
@@ -702,10 +728,11 @@ function makeCore() {
702
728
  if (!url || !key) throw new Error("FIDACY_MODE=http requires FIDACY_API_URL and FIDACY_API_KEY");
703
729
  return new HttpFidacyCore(url, key, process.env.FIDACY_PUBLIC_KEY_PEM ?? "");
704
730
  }
731
+ let activeMandate = buildMandate();
705
732
  const dev = new DevFidacyCore({
706
- mandate: buildMandate(),
733
+ mandate: activeMandate,
707
734
  auditLogPath: auditLogPath(),
708
- onDecision: (d) => recordDecision(d.status, d.violatedRule)
735
+ onDecision: (d) => recordDecision(d.status, d.violatedRule, d.request?.amount, activeMandate?.allow?.perTxMax)
709
736
  });
710
737
  const mtimeOf = () => statSync(configPath(), { throwIfNoEntry: false })?.mtimeMs ?? 0;
711
738
  let seenMtime = mtimeOf();
@@ -713,7 +740,8 @@ function makeCore() {
713
740
  const m = mtimeOf();
714
741
  if (m !== seenMtime) {
715
742
  seenMtime = m;
716
- dev.setMandate(buildMandate());
743
+ activeMandate = buildMandate();
744
+ dev.setMandate(activeMandate);
717
745
  }
718
746
  };
719
747
  return {
@@ -743,7 +771,7 @@ function requestUpgrade() {
743
771
  }
744
772
 
745
773
  // src/provision.ts
746
- var CLIENT_VERSION2 = true ? "0.1.18" : "dev";
774
+ var CLIENT_VERSION2 = true ? "0.1.20" : "dev";
747
775
  function provisionEnabled() {
748
776
  const v = (process.env.FIDACY_DISABLE_PROVISION ?? "").trim().toLowerCase();
749
777
  return !(v === "1" || v === "true" || v === "yes");
@@ -815,6 +843,9 @@ function decisionNudge(status, violatedRule, upgradeToolName) {
815
843
  if (status === "DENY" && nudgeOnce("first_deny")) {
816
844
  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.`;
817
845
  }
846
+ if (count === 25 && nudgeOnce("proof_teaser")) {
847
+ 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.`;
848
+ }
818
849
  if (count === 10 && nudgeOnce("milestone_10")) {
819
850
  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.`;
820
851
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fidacy/mcp",
3
- "version": "0.1.18",
3
+ "version": "0.1.20",
4
4
  "description": "Fidacy action firewall for AI agents. Mandate-gated payment authorization as an MCP server.",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://fidacy.com",