@capxul/mcp 2.0.0 → 2.0.2

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/main.mjs +751 -82
  2. package/package.json +3 -3
package/dist/main.mjs CHANGED
@@ -7,7 +7,7 @@ import { createHash, randomBytes } from "node:crypto";
7
7
  import { createServer } from "node:http";
8
8
  import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
9
9
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
10
- import { concat, concatHex, createPublicClient, createWalletClient, custom, decodeAbiParameters, decodeFunctionData, decodeFunctionResult, encodeAbiParameters, encodeFunctionData, encodePacked, formatUnits, getAddress, getContractAddress, hashMessage, hashTypedData, hexToBigInt, http, isAddress, isHex, keccak256, pad, padHex, parseUnits, recoverAddress, size, slice, stringToHex, toBytes, toEventSelector, toFunctionSelector, toHex, zeroAddress } from "viem";
10
+ import { concat, concatHex, createPublicClient, createWalletClient, custom, decodeAbiParameters, decodeFunctionData, decodeFunctionResult, encodeAbiParameters, encodeFunctionData, encodePacked, formatUnits, getAddress, getContractAddress, hashMessage, hashTypedData, hexToBigInt, http, isAddress, isHex, keccak256, pad, padHex, parseUnits, recoverAddress, size, slice, stringToHex, toBytes, toEventSelector, toFunctionSelector, toFunctionSignature, toHex, zeroAddress } from "viem";
11
11
  import { z } from "zod";
12
12
  import { Cause, Context, Data, Deferred, Effect, Exit, Fiber, Layer, Queue, Ref, Result, Schema, SchemaGetter, SchemaIssue, SchemaParser, Scope, Struct, Tracer } from "effect";
13
13
  import { privateKeyToAccount, toAccount } from "viem/accounts";
@@ -240,7 +240,7 @@ function normalizeEmail(email) {
240
240
  }
241
241
  //#endregion
242
242
  //#region package.json
243
- var version$2 = "2.0.0";
243
+ var version$2 = "2.0.2";
244
244
  //#endregion
245
245
  //#region ../../packages/errors/src/errors.ts
246
246
  const CAPXUL_ERROR_CODES = [
@@ -1271,6 +1271,12 @@ const EXEC_TRANSACTION_WITH_ROLE = "zodiac.roles.execTransactionWithRole";
1271
1271
  const ASSIGN_ROLES = "zodiac.roles.assignRoles";
1272
1272
  const SCOPE_TARGET = "zodiac.roles.scopeTarget";
1273
1273
  const OWNER_ROLE_LABEL = "Owner";
1274
+ const FOUNDER_BUDGET_ROLE_LABEL = "Founder Budget";
1275
+ const FOUNDER_BUDGET_LIMIT = {
1276
+ currency: "USD",
1277
+ value: "1000000000000",
1278
+ decimals: 6
1279
+ };
1274
1280
  function usd(value) {
1275
1281
  return {
1276
1282
  currency: "USD",
@@ -1310,6 +1316,13 @@ function soloOrgRoleTemplate() {
1310
1316
  label: "Owner",
1311
1317
  canManageMembers: true,
1312
1318
  canManageRoles: true
1319
+ }, {
1320
+ label: FOUNDER_BUDGET_ROLE_LABEL,
1321
+ spend: {
1322
+ perTx: FOUNDER_BUDGET_LIMIT,
1323
+ perDay: FOUNDER_BUDGET_LIMIT,
1324
+ toRecipients: "anyone"
1325
+ }
1313
1326
  }];
1314
1327
  }
1315
1328
  function startupOrgRoleTemplate() {
@@ -1376,6 +1389,632 @@ function compileOrgRoleDefinitions(definitions) {
1376
1389
  }
1377
1390
  };
1378
1391
  }
1392
+ //#endregion
1393
+ //#region ../../packages/config/src/capxul-payments-v2.ts
1394
+ /** The exact compiled CapxulPaymentsV2 ABI. */
1395
+ const CAPXUL_PAYMENTS_V2_ABI = [
1396
+ {
1397
+ type: "function",
1398
+ name: "cancel",
1399
+ inputs: [{
1400
+ name: "commitmentId",
1401
+ type: "uint256",
1402
+ internalType: "uint256"
1403
+ }, {
1404
+ name: "documentHash",
1405
+ type: "bytes32",
1406
+ internalType: "bytes32"
1407
+ }],
1408
+ outputs: [],
1409
+ stateMutability: "nonpayable"
1410
+ },
1411
+ {
1412
+ type: "function",
1413
+ name: "claim",
1414
+ inputs: [{
1415
+ name: "commitmentId",
1416
+ type: "uint256",
1417
+ internalType: "uint256"
1418
+ }],
1419
+ outputs: [],
1420
+ stateMutability: "nonpayable"
1421
+ },
1422
+ {
1423
+ type: "function",
1424
+ name: "claimableAmount",
1425
+ inputs: [{
1426
+ name: "commitmentId",
1427
+ type: "uint256",
1428
+ internalType: "uint256"
1429
+ }],
1430
+ outputs: [{
1431
+ name: "",
1432
+ type: "uint256",
1433
+ internalType: "uint256"
1434
+ }],
1435
+ stateMutability: "view"
1436
+ },
1437
+ {
1438
+ type: "function",
1439
+ name: "commitments",
1440
+ inputs: [{
1441
+ name: "",
1442
+ type: "uint256",
1443
+ internalType: "uint256"
1444
+ }],
1445
+ outputs: [
1446
+ {
1447
+ name: "settlementId",
1448
+ type: "bytes32",
1449
+ internalType: "bytes32"
1450
+ },
1451
+ {
1452
+ name: "creator",
1453
+ type: "address",
1454
+ internalType: "address"
1455
+ },
1456
+ {
1457
+ name: "recipient",
1458
+ type: "address",
1459
+ internalType: "address"
1460
+ },
1461
+ {
1462
+ name: "token",
1463
+ type: "address",
1464
+ internalType: "address"
1465
+ },
1466
+ {
1467
+ name: "totalAmount",
1468
+ type: "uint256",
1469
+ internalType: "uint256"
1470
+ },
1471
+ {
1472
+ name: "claimed",
1473
+ type: "uint256",
1474
+ internalType: "uint256"
1475
+ },
1476
+ {
1477
+ name: "startTime",
1478
+ type: "uint48",
1479
+ internalType: "uint48"
1480
+ },
1481
+ {
1482
+ name: "cliffTime",
1483
+ type: "uint48",
1484
+ internalType: "uint48"
1485
+ },
1486
+ {
1487
+ name: "endTime",
1488
+ type: "uint48",
1489
+ internalType: "uint48"
1490
+ },
1491
+ {
1492
+ name: "kind",
1493
+ type: "uint16",
1494
+ internalType: "uint16"
1495
+ },
1496
+ {
1497
+ name: "documentHash",
1498
+ type: "bytes32",
1499
+ internalType: "bytes32"
1500
+ },
1501
+ {
1502
+ name: "cancelled",
1503
+ type: "bool",
1504
+ internalType: "bool"
1505
+ }
1506
+ ],
1507
+ stateMutability: "view"
1508
+ },
1509
+ {
1510
+ type: "function",
1511
+ name: "createCommitment",
1512
+ inputs: [{
1513
+ name: "input",
1514
+ type: "tuple",
1515
+ internalType: "struct CapxulPaymentsV2.CommitmentInput",
1516
+ components: [
1517
+ {
1518
+ name: "settlementId",
1519
+ type: "bytes32",
1520
+ internalType: "bytes32"
1521
+ },
1522
+ {
1523
+ name: "recipient",
1524
+ type: "address",
1525
+ internalType: "address"
1526
+ },
1527
+ {
1528
+ name: "token",
1529
+ type: "address",
1530
+ internalType: "address"
1531
+ },
1532
+ {
1533
+ name: "totalAmount",
1534
+ type: "uint256",
1535
+ internalType: "uint256"
1536
+ },
1537
+ {
1538
+ name: "startTime",
1539
+ type: "uint48",
1540
+ internalType: "uint48"
1541
+ },
1542
+ {
1543
+ name: "cliffTime",
1544
+ type: "uint48",
1545
+ internalType: "uint48"
1546
+ },
1547
+ {
1548
+ name: "endTime",
1549
+ type: "uint48",
1550
+ internalType: "uint48"
1551
+ },
1552
+ {
1553
+ name: "kind",
1554
+ type: "uint16",
1555
+ internalType: "uint16"
1556
+ },
1557
+ {
1558
+ name: "documentHash",
1559
+ type: "bytes32",
1560
+ internalType: "bytes32"
1561
+ }
1562
+ ]
1563
+ }],
1564
+ outputs: [{
1565
+ name: "commitmentId",
1566
+ type: "uint256",
1567
+ internalType: "uint256"
1568
+ }],
1569
+ stateMutability: "nonpayable"
1570
+ },
1571
+ {
1572
+ type: "function",
1573
+ name: "nextCommitmentId",
1574
+ inputs: [],
1575
+ outputs: [{
1576
+ name: "",
1577
+ type: "uint256",
1578
+ internalType: "uint256"
1579
+ }],
1580
+ stateMutability: "view"
1581
+ },
1582
+ {
1583
+ type: "function",
1584
+ name: "redirect",
1585
+ inputs: [
1586
+ {
1587
+ name: "commitmentId",
1588
+ type: "uint256",
1589
+ internalType: "uint256"
1590
+ },
1591
+ {
1592
+ name: "recipient",
1593
+ type: "address",
1594
+ internalType: "address"
1595
+ },
1596
+ {
1597
+ name: "documentHash",
1598
+ type: "bytes32",
1599
+ internalType: "bytes32"
1600
+ }
1601
+ ],
1602
+ outputs: [],
1603
+ stateMutability: "nonpayable"
1604
+ },
1605
+ {
1606
+ type: "function",
1607
+ name: "send",
1608
+ inputs: [{
1609
+ name: "item",
1610
+ type: "tuple",
1611
+ internalType: "struct CapxulPaymentsV2.PaymentItem",
1612
+ components: [
1613
+ {
1614
+ name: "settlementId",
1615
+ type: "bytes32",
1616
+ internalType: "bytes32"
1617
+ },
1618
+ {
1619
+ name: "recipient",
1620
+ type: "address",
1621
+ internalType: "address"
1622
+ },
1623
+ {
1624
+ name: "token",
1625
+ type: "address",
1626
+ internalType: "address"
1627
+ },
1628
+ {
1629
+ name: "amount",
1630
+ type: "uint256",
1631
+ internalType: "uint256"
1632
+ },
1633
+ {
1634
+ name: "kind",
1635
+ type: "uint16",
1636
+ internalType: "uint16"
1637
+ },
1638
+ {
1639
+ name: "documentHash",
1640
+ type: "bytes32",
1641
+ internalType: "bytes32"
1642
+ }
1643
+ ]
1644
+ }],
1645
+ outputs: [],
1646
+ stateMutability: "nonpayable"
1647
+ },
1648
+ {
1649
+ type: "function",
1650
+ name: "sendBatch",
1651
+ inputs: [{
1652
+ name: "items",
1653
+ type: "tuple[]",
1654
+ internalType: "struct CapxulPaymentsV2.PaymentItem[]",
1655
+ components: [
1656
+ {
1657
+ name: "settlementId",
1658
+ type: "bytes32",
1659
+ internalType: "bytes32"
1660
+ },
1661
+ {
1662
+ name: "recipient",
1663
+ type: "address",
1664
+ internalType: "address"
1665
+ },
1666
+ {
1667
+ name: "token",
1668
+ type: "address",
1669
+ internalType: "address"
1670
+ },
1671
+ {
1672
+ name: "amount",
1673
+ type: "uint256",
1674
+ internalType: "uint256"
1675
+ },
1676
+ {
1677
+ name: "kind",
1678
+ type: "uint16",
1679
+ internalType: "uint16"
1680
+ },
1681
+ {
1682
+ name: "documentHash",
1683
+ type: "bytes32",
1684
+ internalType: "bytes32"
1685
+ }
1686
+ ]
1687
+ }],
1688
+ outputs: [],
1689
+ stateMutability: "nonpayable"
1690
+ },
1691
+ {
1692
+ type: "function",
1693
+ name: "vestedAmount",
1694
+ inputs: [{
1695
+ name: "commitmentId",
1696
+ type: "uint256",
1697
+ internalType: "uint256"
1698
+ }],
1699
+ outputs: [{
1700
+ name: "",
1701
+ type: "uint256",
1702
+ internalType: "uint256"
1703
+ }],
1704
+ stateMutability: "view"
1705
+ },
1706
+ {
1707
+ type: "event",
1708
+ name: "CommitmentCancelled",
1709
+ inputs: [
1710
+ {
1711
+ name: "commitmentId",
1712
+ type: "uint256",
1713
+ indexed: true,
1714
+ internalType: "uint256"
1715
+ },
1716
+ {
1717
+ name: "settlementId",
1718
+ type: "bytes32",
1719
+ indexed: true,
1720
+ internalType: "bytes32"
1721
+ },
1722
+ {
1723
+ name: "creator",
1724
+ type: "address",
1725
+ indexed: true,
1726
+ internalType: "address"
1727
+ },
1728
+ {
1729
+ name: "vestedUnclaimed",
1730
+ type: "uint256",
1731
+ indexed: false,
1732
+ internalType: "uint256"
1733
+ },
1734
+ {
1735
+ name: "unvestedReturned",
1736
+ type: "uint256",
1737
+ indexed: false,
1738
+ internalType: "uint256"
1739
+ },
1740
+ {
1741
+ name: "documentHash",
1742
+ type: "bytes32",
1743
+ indexed: false,
1744
+ internalType: "bytes32"
1745
+ }
1746
+ ],
1747
+ anonymous: false
1748
+ },
1749
+ {
1750
+ type: "event",
1751
+ name: "CommitmentCreated",
1752
+ inputs: [
1753
+ {
1754
+ name: "commitmentId",
1755
+ type: "uint256",
1756
+ indexed: true,
1757
+ internalType: "uint256"
1758
+ },
1759
+ {
1760
+ name: "settlementId",
1761
+ type: "bytes32",
1762
+ indexed: true,
1763
+ internalType: "bytes32"
1764
+ },
1765
+ {
1766
+ name: "creator",
1767
+ type: "address",
1768
+ indexed: true,
1769
+ internalType: "address"
1770
+ },
1771
+ {
1772
+ name: "recipient",
1773
+ type: "address",
1774
+ indexed: false,
1775
+ internalType: "address"
1776
+ },
1777
+ {
1778
+ name: "token",
1779
+ type: "address",
1780
+ indexed: false,
1781
+ internalType: "address"
1782
+ },
1783
+ {
1784
+ name: "totalAmount",
1785
+ type: "uint256",
1786
+ indexed: false,
1787
+ internalType: "uint256"
1788
+ },
1789
+ {
1790
+ name: "startTime",
1791
+ type: "uint48",
1792
+ indexed: false,
1793
+ internalType: "uint48"
1794
+ },
1795
+ {
1796
+ name: "cliffTime",
1797
+ type: "uint48",
1798
+ indexed: false,
1799
+ internalType: "uint48"
1800
+ },
1801
+ {
1802
+ name: "endTime",
1803
+ type: "uint48",
1804
+ indexed: false,
1805
+ internalType: "uint48"
1806
+ },
1807
+ {
1808
+ name: "kind",
1809
+ type: "uint16",
1810
+ indexed: false,
1811
+ internalType: "uint16"
1812
+ },
1813
+ {
1814
+ name: "documentHash",
1815
+ type: "bytes32",
1816
+ indexed: false,
1817
+ internalType: "bytes32"
1818
+ }
1819
+ ],
1820
+ anonymous: false
1821
+ },
1822
+ {
1823
+ type: "event",
1824
+ name: "CommitmentRedirected",
1825
+ inputs: [
1826
+ {
1827
+ name: "commitmentId",
1828
+ type: "uint256",
1829
+ indexed: true,
1830
+ internalType: "uint256"
1831
+ },
1832
+ {
1833
+ name: "settlementId",
1834
+ type: "bytes32",
1835
+ indexed: true,
1836
+ internalType: "bytes32"
1837
+ },
1838
+ {
1839
+ name: "oldRecipient",
1840
+ type: "address",
1841
+ indexed: true,
1842
+ internalType: "address"
1843
+ },
1844
+ {
1845
+ name: "newRecipient",
1846
+ type: "address",
1847
+ indexed: false,
1848
+ internalType: "address"
1849
+ },
1850
+ {
1851
+ name: "documentHash",
1852
+ type: "bytes32",
1853
+ indexed: false,
1854
+ internalType: "bytes32"
1855
+ }
1856
+ ],
1857
+ anonymous: false
1858
+ },
1859
+ {
1860
+ type: "event",
1861
+ name: "FundsClaimed",
1862
+ inputs: [
1863
+ {
1864
+ name: "commitmentId",
1865
+ type: "uint256",
1866
+ indexed: true,
1867
+ internalType: "uint256"
1868
+ },
1869
+ {
1870
+ name: "settlementId",
1871
+ type: "bytes32",
1872
+ indexed: true,
1873
+ internalType: "bytes32"
1874
+ },
1875
+ {
1876
+ name: "recipient",
1877
+ type: "address",
1878
+ indexed: true,
1879
+ internalType: "address"
1880
+ },
1881
+ {
1882
+ name: "amount",
1883
+ type: "uint256",
1884
+ indexed: false,
1885
+ internalType: "uint256"
1886
+ },
1887
+ {
1888
+ name: "documentHash",
1889
+ type: "bytes32",
1890
+ indexed: false,
1891
+ internalType: "bytes32"
1892
+ }
1893
+ ],
1894
+ anonymous: false
1895
+ },
1896
+ {
1897
+ type: "event",
1898
+ name: "PaymentSent",
1899
+ inputs: [
1900
+ {
1901
+ name: "settlementId",
1902
+ type: "bytes32",
1903
+ indexed: true,
1904
+ internalType: "bytes32"
1905
+ },
1906
+ {
1907
+ name: "sender",
1908
+ type: "address",
1909
+ indexed: true,
1910
+ internalType: "address"
1911
+ },
1912
+ {
1913
+ name: "recipient",
1914
+ type: "address",
1915
+ indexed: true,
1916
+ internalType: "address"
1917
+ },
1918
+ {
1919
+ name: "token",
1920
+ type: "address",
1921
+ indexed: false,
1922
+ internalType: "address"
1923
+ },
1924
+ {
1925
+ name: "amount",
1926
+ type: "uint256",
1927
+ indexed: false,
1928
+ internalType: "uint256"
1929
+ },
1930
+ {
1931
+ name: "kind",
1932
+ type: "uint16",
1933
+ indexed: false,
1934
+ internalType: "uint16"
1935
+ },
1936
+ {
1937
+ name: "documentHash",
1938
+ type: "bytes32",
1939
+ indexed: false,
1940
+ internalType: "bytes32"
1941
+ }
1942
+ ],
1943
+ anonymous: false
1944
+ },
1945
+ {
1946
+ type: "error",
1947
+ name: "AlreadyCancelled",
1948
+ inputs: []
1949
+ },
1950
+ {
1951
+ type: "error",
1952
+ name: "AlreadyClaimed",
1953
+ inputs: []
1954
+ },
1955
+ {
1956
+ type: "error",
1957
+ name: "DocumentHashMismatch",
1958
+ inputs: [{
1959
+ name: "expected",
1960
+ type: "bytes32",
1961
+ internalType: "bytes32"
1962
+ }, {
1963
+ name: "supplied",
1964
+ type: "bytes32",
1965
+ internalType: "bytes32"
1966
+ }]
1967
+ },
1968
+ {
1969
+ type: "error",
1970
+ name: "InvalidTimeParams",
1971
+ inputs: []
1972
+ },
1973
+ {
1974
+ type: "error",
1975
+ name: "NotCreator",
1976
+ inputs: []
1977
+ },
1978
+ {
1979
+ type: "error",
1980
+ name: "NotRecipient",
1981
+ inputs: []
1982
+ },
1983
+ {
1984
+ type: "error",
1985
+ name: "NothingToClaim",
1986
+ inputs: []
1987
+ },
1988
+ {
1989
+ type: "error",
1990
+ name: "SettlementIdConsumed",
1991
+ inputs: [{
1992
+ name: "settlementId",
1993
+ type: "bytes32",
1994
+ internalType: "bytes32"
1995
+ }]
1996
+ },
1997
+ {
1998
+ type: "error",
1999
+ name: "ZeroAddress",
2000
+ inputs: []
2001
+ },
2002
+ {
2003
+ type: "error",
2004
+ name: "ZeroAmount",
2005
+ inputs: []
2006
+ },
2007
+ {
2008
+ type: "error",
2009
+ name: "ZeroDocumentHash",
2010
+ inputs: []
2011
+ },
2012
+ {
2013
+ type: "error",
2014
+ name: "ZeroSettlementId",
2015
+ inputs: []
2016
+ }
2017
+ ];
1379
2018
  padHex(stringToHex("FM_DAILY"), {
1380
2019
  size: 32,
1381
2020
  dir: "right"
@@ -1387,6 +2026,16 @@ padHex(concat([MULTI_SEND_CALL_ONLY, "0x8d80ff0a"]), {
1387
2026
  dir: "right",
1388
2027
  size: 32
1389
2028
  });
2029
+ function paymentsV2Signature(name) {
2030
+ const item = CAPXUL_PAYMENTS_V2_ABI.find((candidate) => candidate.type === "function" && candidate.name === name);
2031
+ if (item === void 0) throw new Error(`CapxulPaymentsV2 ABI has no ${name} function`);
2032
+ return toFunctionSignature(item);
2033
+ }
2034
+ paymentsV2Signature("send");
2035
+ paymentsV2Signature("sendBatch");
2036
+ paymentsV2Signature("createCommitment");
2037
+ paymentsV2Signature("cancel");
2038
+ paymentsV2Signature("redirect");
1390
2039
  new Map([
1391
2040
  ["assignRoles(address,bytes32[],bool[])", "AssignRoles(address,bytes32[],bool[])"],
1392
2041
  ["allowTarget(bytes32,address,uint8)", "AllowTarget(bytes32,address,uint8)"],
@@ -6201,6 +6850,7 @@ async function runPortEffect(effect, controls, operation = "port", runPromise =
6201
6850
  }
6202
6851
  /** Map machine-internal failure state onto the public SDK error vocabulary. */
6203
6852
  function publicIdentityFailure(failure) {
6853
+ if (failure.error !== void 0) return failure.error;
6204
6854
  return new CapxulError(failure.code === "WORK_DIED" ? "UNKNOWN" : failure.code, failure.message, {
6205
6855
  ...failure.mode === void 0 ? {} : { details: { failure_mode: failure.mode } },
6206
6856
  layer: "identity"
@@ -6721,6 +7371,25 @@ const actorScopeContract = {
6721
7371
  inboxDecline: makeFunctionReference(CAPXUL_FUNCTIONS["financialOps/requestsInbox"].decline)
6722
7372
  };
6723
7373
  //#endregion
7374
+ //#region ../../packages/sdk/src/domain/money/from-wei.ts
7375
+ /**
7376
+ * Lift an on-chain integer (e.g. USDX 6-decimal) into consumer `Money`.
7377
+ * Canon `account-balance-model.md` §10 — internal at the SDK boundary only.
7378
+ */
7379
+ function fromWei(rawBalance, decimals, currency) {
7380
+ if (!Number.isInteger(decimals) || decimals < 0) throw new Error(`fromWei: decimals must be a non-negative integer, got ${String(decimals)}`);
7381
+ const normalized = rawBalance.trim();
7382
+ if (!/^\d+$/.test(normalized)) {
7383
+ const truncated = normalized.length > 80 ? `${normalized.slice(0, 80)}…` : normalized;
7384
+ throw new Error(`fromWei: rawBalance must be a base-10 integer string, got ${truncated}`);
7385
+ }
7386
+ return {
7387
+ currency: toCurrencyCode(currency),
7388
+ value: formatUnits(BigInt(normalized), decimals),
7389
+ decimals
7390
+ };
7391
+ }
7392
+ //#endregion
6724
7393
  //#region ../../packages/sdk/src/surface/contacts.ts
6725
7394
  function makeActorRelationshipMethods(deps) {
6726
7395
  const domain = deps.actor.kind === "account" ? "account" : "org";
@@ -6799,11 +7468,16 @@ function makeActorRelationshipMethods(deps) {
6799
7468
  },
6800
7469
  inbox: {
6801
7470
  list: (options) => mapOk$1(awaitableConvex(options?.signal, "inbox.list", () => convexCall.query(fns.inboxList, { actor })), (items) => items.map(mapInboxItem)),
6802
- approve: (input, options) => mapOk$1(awaitableConvex(options?.signal, "inbox.approve", () => convexCall.mutation(fns.inboxApprove, {
6803
- actor,
6804
- paymentRequestId: input.requestId,
6805
- ...input.timing === void 0 ? {} : { timing: input.timing }
6806
- })), mapApprovedInboxPayment),
7471
+ approve: async (input, options) => {
7472
+ const result = await awaitableConvex(options?.signal, "inbox.approve", () => convexCall.mutation(fns.inboxApprove, {
7473
+ actor,
7474
+ paymentRequestId: input.requestId,
7475
+ ...input.timing === void 0 ? {} : { timing: input.timing },
7476
+ ...input.permissionId === void 0 ? {} : { permissionId: input.permissionId }
7477
+ }));
7478
+ if (!result.ok) return result;
7479
+ return mapApprovedInboxPayment(result.value, input);
7480
+ },
6807
7481
  decline: (requestId, options) => mapOk$1(awaitableConvex(options?.signal, "inbox.decline", () => convexCall.mutation(fns.inboxDecline, {
6808
7482
  actor,
6809
7483
  paymentRequestId: requestId
@@ -6918,50 +7592,45 @@ function mapInboxItem(item) {
6918
7592
  status: mapInboxStatus(item.status)
6919
7593
  };
6920
7594
  }
6921
- function mapApprovedInboxPayment(item) {
6922
- if (item.settledPayment !== void 0) return normalizePaymentTiming$1(item.settledPayment);
6923
- const zero = {
6924
- ...item.amount,
6925
- value: "0"
6926
- };
6927
- const status = item.settledPaymentStatus ?? (item.status === "paid" ? "settled" : "pending");
6928
- const timing = item.settledPaymentTiming ?? { kind: "instant" };
6929
- return {
6930
- id: item.settledPaymentId ?? `payment_${item.id}`,
6931
- status,
6932
- amount: item.amount,
6933
- paymentType: "invoice",
6934
- recipient: paymentRecipientFromRef(item.issuer),
6935
- documents: [],
6936
- timing,
6937
- released: status === "settled" ? item.amount : zero,
6938
- availableToClaim: zero,
6939
- createdAt: item.createdAt ?? 0,
6940
- updatedAt: item.updatedAt ?? item.createdAt ?? 0
7595
+ function mapApprovedInboxPayment(command, input) {
7596
+ const item = command.items[0];
7597
+ if (item === void 0 || item.operation !== "send" && item.operation !== "create_commitment") return {
7598
+ ok: false,
7599
+ error: Errors.providerError("convex", "inbox.approve", "reply has no payment birth item")
6941
7600
  };
6942
- }
6943
- function paymentRecipientFromRef(ref) {
6944
- switch (ref.kind) {
6945
- case "handle": return {
6946
- kind: "handle",
6947
- label: ref.handle
6948
- };
6949
- case "email": return {
6950
- kind: "email",
6951
- label: ref.email
6952
- };
6953
- case "orgHandle": return {
6954
- kind: "org",
6955
- label: ref.orgHandle
7601
+ try {
7602
+ const amount = fromWei(item.operation === "send" ? item.rawAmount : item.totalAmount, 6, "USD");
7603
+ const zero = {
7604
+ ...amount,
7605
+ value: "0"
6956
7606
  };
6957
- case "capxulUserId": return {
6958
- kind: "capxulUserId",
6959
- label: ref.capxulUserId
7607
+ const timing = input.timing ?? { kind: "instant" };
7608
+ return {
7609
+ ok: true,
7610
+ value: {
7611
+ id: item.paymentId,
7612
+ status: timing.kind === "instant" ? "pending" : timing.kind === "scheduled" ? "scheduled" : "streaming",
7613
+ amount,
7614
+ paymentType: "invoice",
7615
+ recipient: {
7616
+ kind: "external_address",
7617
+ label: item.recipientSafe
7618
+ },
7619
+ documents: [{
7620
+ documentHash: item.documentHash,
7621
+ kind: "invoice"
7622
+ }],
7623
+ timing,
7624
+ released: zero,
7625
+ availableToClaim: zero,
7626
+ createdAt: 0,
7627
+ updatedAt: 0
7628
+ }
6960
7629
  };
6961
- case "payeeId": return {
6962
- kind: "payee",
6963
- label: ref.payeeId,
6964
- payeeId: ref.payeeId
7630
+ } catch (cause) {
7631
+ return {
7632
+ ok: false,
7633
+ error: Errors.providerError("convex", "inbox.approve", cause)
6965
7634
  };
6966
7635
  }
6967
7636
  }
@@ -6989,13 +7658,6 @@ function mapInboxStatus(status) {
6989
7658
  default: return "open";
6990
7659
  }
6991
7660
  }
6992
- function normalizePaymentTiming$1(payment) {
6993
- const { release: _release, ...rest } = payment;
6994
- return {
6995
- ...rest,
6996
- timing: payment.timing ?? payment.release ?? { kind: "instant" }
6997
- };
6998
- }
6999
7661
  function normalizeRefForBackend$1(ref, field) {
7000
7662
  try {
7001
7663
  if (typeof ref === "string") throw Errors.invalidInput(field, "recipient must be a typed Ref variant");
@@ -7138,7 +7800,7 @@ function makeAccountMethods(deps) {
7138
7800
  const state = result._tag === "Failure" ? deps.actor.snapshot() : result.success;
7139
7801
  if (result._tag === "Failure" && state.phase === "authenticated" && state.account.at === "failed" && state.account.failure.code === result.failure.reason) return {
7140
7802
  ok: false,
7141
- error: state.account.step === "deploy" && state.account.failure.code === "PROVIDER_ERROR" ? Errors.providerError("signer", "getAddress", state.account.failure.message) : publicIdentityFailure(state.account.failure)
7803
+ error: publicIdentityFailure(state.account.failure)
7142
7804
  };
7143
7805
  if (result._tag === "Failure") return {
7144
7806
  ok: false,
@@ -7150,7 +7812,7 @@ function makeAccountMethods(deps) {
7150
7812
  };
7151
7813
  if (state.phase === "authenticated" && state.account.at === "failed") return {
7152
7814
  ok: false,
7153
- error: state.account.step === "deploy" && state.account.failure.code === "PROVIDER_ERROR" ? Errors.providerError("signer", "getAddress", state.account.failure.message) : publicIdentityFailure(state.account.failure)
7815
+ error: publicIdentityFailure(state.account.failure)
7154
7816
  };
7155
7817
  return {
7156
7818
  ok: true,
@@ -7504,7 +8166,7 @@ async function recoverRawDigestSigner(input) {
7504
8166
  }
7505
8167
  //#endregion
7506
8168
  //#region ../../packages/sdk/package.json
7507
- var version = "2.0.0";
8169
+ var version = "2.0.2";
7508
8170
  //#endregion
7509
8171
  //#region ../../packages/observability/src/engineering.ts
7510
8172
  const SAFE_TRACED_HEADER_NAMES = [
@@ -11723,25 +12385,6 @@ function accountReadErrorFromCapxul(operation, error, cause = error) {
11723
12385
  }
11724
12386
  var AccountReadPortTag = class extends Context.Service()("@capxul/sdk/ports/AccountReadPort") {};
11725
12387
  //#endregion
11726
- //#region ../../packages/sdk/src/domain/money/from-wei.ts
11727
- /**
11728
- * Lift an on-chain integer (e.g. USDX 6-decimal) into consumer `Money`.
11729
- * Canon `account-balance-model.md` §10 — internal at the SDK boundary only.
11730
- */
11731
- function fromWei(rawBalance, decimals, currency) {
11732
- if (!Number.isInteger(decimals) || decimals < 0) throw new Error(`fromWei: decimals must be a non-negative integer, got ${String(decimals)}`);
11733
- const normalized = rawBalance.trim();
11734
- if (!/^\d+$/.test(normalized)) {
11735
- const truncated = normalized.length > 80 ? `${normalized.slice(0, 80)}…` : normalized;
11736
- throw new Error(`fromWei: rawBalance must be a base-10 integer string, got ${truncated}`);
11737
- }
11738
- return {
11739
- currency: toCurrencyCode(currency),
11740
- value: formatUnits(BigInt(normalized), decimals),
11741
- decimals
11742
- };
11743
- }
11744
- //#endregion
11745
12388
  //#region ../../packages/sdk/src/adapters/account-read/ConvexAccountAdapter.ts
11746
12389
  const DEFAULT_FUNCTIONS$3 = {
11747
12390
  readBalance: makeFunctionReference(CAPXUL_FUNCTIONS["account/actions"].readBalance),
@@ -12544,7 +13187,20 @@ const OrganizationCreationFailedProps = Schema.Struct({
12544
13187
  attempt_number: AttemptNumberSchema,
12545
13188
  stage: OnboardingStageSchema,
12546
13189
  error_code: Schema.String,
12547
- retryable: Schema.Boolean
13190
+ retryable: Schema.Boolean,
13191
+ failure_reason: Schema.optional(Schema.Literals([
13192
+ "deterministic_address_mismatch",
13193
+ "receipt_provider_unavailable",
13194
+ "receipt_mismatch",
13195
+ "block_provider_unavailable",
13196
+ "authority_event_mismatch",
13197
+ "allowance_timestamp_mismatch",
13198
+ "receipt_identity_unavailable",
13199
+ "receipt_identity_mismatch",
13200
+ "contract_code_unavailable",
13201
+ "contract_state_mismatch",
13202
+ "permission_projection_mismatch"
13203
+ ]))
12548
13204
  });
12549
13205
  const OnboardingIntentSchema = Schema.Literals(["personal", "organization"]);
12550
13206
  const OnboardingIntentSelectedProps = Schema.Struct({
@@ -35976,7 +36632,8 @@ const failureOf = (error) => {
35976
36632
  return {
35977
36633
  code: error.code,
35978
36634
  message: error.message,
35979
- ...typeof mode === "string" ? { mode } : {}
36635
+ ...typeof mode === "string" ? { mode } : {},
36636
+ error
35980
36637
  };
35981
36638
  }
35982
36639
  if (typeof error === "object" && error !== null && "publicError" in error) return failureOf(error.publicError);
@@ -36004,7 +36661,7 @@ const modelSession = (session) => ({
36004
36661
  });
36005
36662
  const claimAccount = (input, authUserId, signer) => call("smart-account.claim", Effect.tryPromise({
36006
36663
  try: () => signer.getAddress(),
36007
- catch: () => new CapxulError("PROVIDER_ERROR", "Provider error: signer getAddress")
36664
+ catch: (cause) => cause instanceof CapxulError ? cause : Errors.providerError("openfort", "getAddress", cause, { failure_mode: "unknown" })
36008
36665
  }).pipe(Effect.flatMap((signerAddress) => input.ports.smartAccount.claim({
36009
36666
  authUserId: toAuthUserId(authUserId),
36010
36667
  chainId: toChainId(input.chainId),
@@ -41787,6 +42444,14 @@ const EVIDENCE_RPC_METHODS = new Set([
41787
42444
  "eth_getLogs",
41788
42445
  "eth_getTransactionReceipt"
41789
42446
  ]);
42447
+ const BUNDLER_RPC_METHODS = new Set([
42448
+ "eth_sendUserOperation",
42449
+ "eth_estimateUserOperationGas",
42450
+ "eth_getUserOperationReceipt",
42451
+ "eth_getUserOperationByHash",
42452
+ "pm_getPaymasterStubData",
42453
+ "pm_getPaymasterData"
42454
+ ]);
41790
42455
  function rethrowProvider(method) {
41791
42456
  return (e) => {
41792
42457
  throw Errors.providerError("alchemy", method, e);
@@ -41845,7 +42510,9 @@ var DefinitiveAlchemyJsonRpcRejection = class extends Error {
41845
42510
  }
41846
42511
  };
41847
42512
  async function alchemyRpc(chainId, method, params, timeoutMs, externalSignal) {
41848
- const url = (chainId === 84532 && EVIDENCE_RPC_METHODS.has(method) ? optionalEnv("BASE_SEPOLIA_EVIDENCE_RPC_URL") : void 0)?.replace(/\/+$/u, "") ?? alchemyUrl(chainId);
42513
+ const bundlerUrl = chainId === 84532 && BUNDLER_RPC_METHODS.has(method) ? optionalEnv("BASE_SEPOLIA_BUNDLER_RPC_URL") : void 0;
42514
+ const evidenceUrl = chainId === 84532 && EVIDENCE_RPC_METHODS.has(method) ? optionalEnv("BASE_SEPOLIA_EVIDENCE_RPC_URL") : void 0;
42515
+ const url = bundlerUrl?.replace(/\/+$/u, "") ?? evidenceUrl?.replace(/\/+$/u, "") ?? alchemyUrl(chainId);
41849
42516
  const timeoutSignal = timeoutMs === void 0 ? void 0 : AbortSignal.timeout(timeoutMs);
41850
42517
  const signal = externalSignal === void 0 ? timeoutSignal : timeoutSignal === void 0 ? externalSignal : AbortSignal.any([externalSignal, timeoutSignal]);
41851
42518
  const res = await fetch(url, {
@@ -41906,14 +42573,16 @@ function parseReceiptLogs(raw) {
41906
42573
  async function fetchUserOperationReceipt(args) {
41907
42574
  const raw = await alchemyRpc(args.chainId, "eth_getUserOperationReceipt", [args.userOpHash]);
41908
42575
  if (raw === null) return null;
41909
- if (typeof raw !== "object" || typeof raw.userOpHash !== "string" || typeof raw.sender !== "string" || typeof raw.success !== "boolean" || typeof raw.receipt !== "object" || typeof raw.receipt.blockNumber !== "string" || typeof raw.receipt.transactionHash !== "string") throw Errors.providerError("alchemy", "eth_getUserOperationReceipt", `unexpected shape: ${JSON.stringify(raw)}`);
42576
+ if (typeof raw !== "object" || typeof raw.userOpHash !== "string" || typeof raw.sender !== "string" || typeof raw.success !== "boolean" || typeof raw.receipt !== "object" || typeof raw.receipt.blockNumber !== "string" || typeof raw.receipt.blockHash !== "string" || typeof raw.receipt.transactionHash !== "string" || typeof raw.receipt.transactionIndex !== "string") throw Errors.providerError("alchemy", "eth_getUserOperationReceipt", `unexpected shape: ${JSON.stringify(raw)}`);
41910
42577
  return {
41911
42578
  userOpHash: providerBytes32(raw.userOpHash, "eth_getUserOperationReceipt", "userOpHash"),
41912
42579
  sender: providerAddress(raw.sender, "eth_getUserOperationReceipt", "sender"),
41913
42580
  success: raw.success,
41914
42581
  receipt: {
41915
42582
  blockNumber: hexToSafeInteger(raw.receipt.blockNumber, "eth_getUserOperationReceipt"),
42583
+ blockHash: providerBytes32(raw.receipt.blockHash, "eth_getUserOperationReceipt", "blockHash"),
41916
42584
  transactionHash: providerBytes32(raw.receipt.transactionHash, "eth_getUserOperationReceipt", "transactionHash"),
42585
+ transactionIndex: hexToSafeInteger(raw.receipt.transactionIndex, "eth_getUserOperationReceipt"),
41917
42586
  logs: parseReceiptLogs(raw.logs)
41918
42587
  }
41919
42588
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capxul/mcp",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "private": false,
5
5
  "description": "Capxul MCP server for auth, Account readiness, identity, Organizations, relationships, requests, destinations, and testnet funding over Streamable HTTP.",
6
6
  "keywords": [
@@ -47,9 +47,9 @@
47
47
  "typescript": "npm:@typescript/typescript6@6.0.2",
48
48
  "vite": "npm:@voidzero-dev/vite-plus-core@0.1.23",
49
49
  "vite-plus": "0.1.23",
50
- "@capxul/backend": "0.1.6",
50
+ "@capxul/backend": "0.1.8",
51
51
  "@capxul/config": "0.1.1",
52
- "@capxul/sdk": "2.0.0",
52
+ "@capxul/sdk": "2.0.2",
53
53
  "@capxul/types": "0.1.0",
54
54
  "@capxul/typescript-config": "0.0.0",
55
55
  "@capxul/wire": "0.1.0"