@fangorn-network/westmarch 0.0.20-dev → 2026.10.2-2.0-dev
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/README.md +33 -3
- package/docs/app-to-agent.md +117 -60
- package/package.json +10 -5
- package/plugin/scripts/fx.mjs +7 -9
- package/site/dist/assets/{AccountNotFoundScreen-C4njXc69-BOfmiSH1.js → AccountNotFoundScreen-C4njXc69-DyVH4CEz.js} +1 -1
- package/site/dist/assets/{AddFundsSelectionScreen-RAoCn7ej-D_EsIeJu.js → AddFundsSelectionScreen-RAoCn7ej-Dz1--SS9.js} +1 -1
- package/site/dist/assets/{Address-H8kD1d9O-C85sJ79B.js → Address-H8kD1d9O-BdFZmRwI.js} +1 -1
- package/site/dist/assets/{AffirmativeConsentScreen-BG0MJxku-DdEPFOww.js → AffirmativeConsentScreen-BG0MJxku-CxaCAisL.js} +1 -1
- package/site/dist/assets/{AllowlistRejectionScreen-Cae6e1Od-DhVy9iGN.js → AllowlistRejectionScreen-Cae6e1Od-JGk7vndN.js} +1 -1
- package/site/dist/assets/{ApiController-CYdiyu9B.js → ApiController-CTLbMCcH.js} +4 -4
- package/site/dist/assets/{ArrowsRightLeftIcon-cp60yobq.js → ArrowsRightLeftIcon-B8g9adpz.js} +1 -1
- package/site/dist/assets/{AuthenticateWithWalletScreen-CU6hIcFT-8rbYiYYE.js → AuthenticateWithWalletScreen-CU6hIcFT-CXD9_OP8.js} +1 -1
- package/site/dist/assets/{AwaitingEvmToSolBridgingScreen-D0e_sZMS-2pkNfCno.js → AwaitingEvmToSolBridgingScreen-D0e_sZMS-BtJCglvU.js} +1 -1
- package/site/dist/assets/{AwaitingExternalEthereumTransferScreen-ur5HL4R7-7AQt25_k.js → AwaitingExternalEthereumTransferScreen-ur5HL4R7-BgC2TsqH.js} +1 -1
- package/site/dist/assets/{AwaitingPasswordlessCodeScreen-DRHz76mM-BZY30TGs.js → AwaitingPasswordlessCodeScreen-DRHz76mM-B9OzLeEO.js} +1 -1
- package/site/dist/assets/{AwaitingSolToEvmBridgingScreen-CdLRrGD2-BILOOLi_.js → AwaitingSolToEvmBridgingScreen-CdLRrGD2-C7r5snUL.js} +1 -1
- package/site/dist/assets/BridgeNetworkSelectionView-CFGjB2nO-BTV0NRio.js +68 -0
- package/site/dist/assets/{CaptchaScreen-DbpvkIGx-D8eDcAkc.js → CaptchaScreen-DbpvkIGx-7rSZIuM-.js} +1 -1
- package/site/dist/assets/{CheckCircleIcon-NCOQc0Gs.js → CheckCircleIcon-B1l17ioc.js} +1 -1
- package/site/dist/assets/{CheckCircleIcon-BM409mGI.js → CheckCircleIcon-BGSI8nKf.js} +1 -1
- package/site/dist/assets/{Checkbox-D1EDeo41-rHlvsZzP.js → Checkbox-D1EDeo41-BUfq0w99.js} +1 -1
- package/site/dist/assets/{ChevronDownIcon-CW-4MSpE.js → ChevronDownIcon-B6uJvPHu.js} +1 -1
- package/site/dist/assets/{Chip-CZKIKt9K-CutJG010.js → Chip-CZKIKt9K-r9Nk__0-.js} +1 -1
- package/site/dist/assets/{CoinbaseOnrampStatusScreen-BbyCJDXL-DLs9zX-Q.js → CoinbaseOnrampStatusScreen-BbyCJDXL-DWWNHxmR.js} +1 -1
- package/site/dist/assets/{ConnectEmailForm-B-VRE0MN-N9J6T_YL.js → ConnectEmailForm-B-VRE0MN-CRQwS0Xu.js} +1 -1
- package/site/dist/assets/{ConnectLedgerScreen-DWHABGot-h0uYIUi6.js → ConnectLedgerScreen-DWHABGot-CZcCt31O.js} +1 -1
- package/site/dist/assets/{ConnectOnlyLandingScreen-CZYx9Bmp-LeuDMN1E.js → ConnectOnlyLandingScreen-CZYx9Bmp-C5IOf-SQ.js} +1 -1
- package/site/dist/assets/{ConnectOnlyStatusScreen-DCRzjxHx-DaRa59tZ.js → ConnectOnlyStatusScreen-DCRzjxHx-cwg74F3A.js} +1 -1
- package/site/dist/assets/ConnectOrCreateScreen-CUUYUO07-D28oeK6b.js +1 -0
- package/site/dist/assets/{ConnectPhoneForm-Dek5xn4C-BEA4FmhI.js → ConnectPhoneForm-Dek5xn4C-EEdkKeTp.js} +1 -1
- package/site/dist/assets/ConnectWalletView-DqI-PTvX-C2mEzukj.js +74 -0
- package/site/dist/assets/{ConnectionStatusScreen-fUfROm9m-BeWLchcf.js → ConnectionStatusScreen-fUfROm9m-CH_7r8iV.js} +1 -1
- package/site/dist/assets/ConnectionStatusScreen-fUfROm9m-Z33kis0B.js +1 -0
- package/site/dist/assets/{ConnectorUtil-Cq4lWnfe.js → ConnectorUtil-DH4NePk5.js} +1 -1
- package/site/dist/assets/{CopyToClipboard-i_OQSBJr-DujUHNzW.js → CopyToClipboard-i_OQSBJr-_G88JCVR.js} +1 -1
- package/site/dist/assets/{CopyableText-CQapvaMr-DMIdpDaU.js → CopyableText-CQapvaMr-CGGfc_zM.js} +1 -1
- package/site/dist/assets/{CrossAppAuthScreen-CLw7ymZq-Csju14vF.js → CrossAppAuthScreen-CLw7ymZq-C9Okoc0V.js} +1 -1
- package/site/dist/assets/{CustomLandingScreenView-Cm_MBSyX-CBOrbNLo.js → CustomLandingScreenView-Cm_MBSyX-D2l6hdSl.js} +1 -1
- package/site/dist/assets/{DelegatedActionsConsentScreen-DYF2U4y5-BL5hzNUI.js → DelegatedActionsConsentScreen-DYF2U4y5-Dda3KKqS.js} +1 -1
- package/site/dist/assets/{DelegatedActionsRevokeScreen-bPp6Uwyh-fcO51q5H.js → DelegatedActionsRevokeScreen-bPp6Uwyh-DG8kJPt1.js} +1 -1
- package/site/dist/assets/{DepositAddressAddressStepView-4vdkb55L-B3vY888G.js → DepositAddressAddressStepView-4vdkb55L-CcOUfn6f.js} +1 -1
- package/site/dist/assets/{DepositAddressScreen-DBLRs7aI-DmdQaFI2.js → DepositAddressScreen-DBLRs7aI-DeituDNh.js} +1 -1
- package/site/dist/assets/{DepositAddressV3Screen-CDqIEMQw-BoupRyfV.js → DepositAddressV3Screen-CDqIEMQw-FDg6K14-.js} +1 -1
- package/site/dist/assets/{EmailInputForm-Cqo1mda8-B2NG3K5V.js → EmailInputForm-Cqo1mda8-BmbxvPHC.js} +1 -1
- package/site/dist/assets/{EmbeddedWalletConnectingScreen-D4T7DUzs-D_AVgO4s.js → EmbeddedWalletConnectingScreen-D4T7DUzs-B05CQ9rx.js} +1 -1
- package/site/dist/assets/{EmbeddedWalletCreatedScreen-D7WhW5ve-CLsJbPYQ.js → EmbeddedWalletCreatedScreen-D7WhW5ve-Cxd1b9XH.js} +1 -1
- package/site/dist/assets/{EmbeddedWalletKeyExportScreen-CqV4NYQ3-C9sAExzE.js → EmbeddedWalletKeyExportScreen-CqV4NYQ3-CrJy0ViX.js} +1 -1
- package/site/dist/assets/{EmbeddedWalletOnAccountCreateScreen-BoKb3Q2S-DxaWAAKa.js → EmbeddedWalletOnAccountCreateScreen-BoKb3Q2S-Bakaa3zu.js} +1 -1
- package/site/dist/assets/{EmbeddedWalletPasswordUpdateScreen-D3rMlqS7-CxrfLr5q.js → EmbeddedWalletPasswordUpdateScreen-D3rMlqS7-j78vKrcj.js} +1 -1
- package/site/dist/assets/{EmbeddedWalletPasswordUpdateSplashScreen-BPFkWJeE-DHZRGoTN.js → EmbeddedWalletPasswordUpdateSplashScreen-BPFkWJeE-D3dr7W9_.js} +1 -1
- package/site/dist/assets/{EnrollTotp-Dibew4dp-SA2pvNEc.js → EnrollTotp-Dibew4dp-BXbYV8nI.js} +1 -1
- package/site/dist/assets/{EnvelopeIcon-Dh2vSVj4.js → EnvelopeIcon-DjPofnRI.js} +1 -1
- package/site/dist/assets/{ErrorBanner-BcpGRt0h-BKOYTyCi.js → ErrorBanner-BcpGRt0h-BhH6_V-9.js} +1 -1
- package/site/dist/assets/{ErrorMessage-D8VaAP5m-CrZOnUyg.js → ErrorMessage-D8VaAP5m-Bs7uX2a9.js} +1 -1
- package/site/dist/assets/{ErrorScreen-DipdTWzE-c8g8En21.js → ErrorScreen-DipdTWzE-BgPRgnOb.js} +1 -1
- package/site/dist/assets/ErrorScreen-DipdTWzE-CvxXC6pz.js +1 -0
- package/site/dist/assets/{ExclamationCircleIcon-DUA2wMfO.js → ExclamationCircleIcon-BE-WGrut.js} +1 -1
- package/site/dist/assets/{ExclamationTriangleIcon-eZfaqcFq.js → ExclamationTriangleIcon-Ca1Xlc_f.js} +1 -1
- package/site/dist/assets/{FarcasterConnectStatusScreen-51tjUxqq-s_s5M2CZ.js → FarcasterConnectStatusScreen-51tjUxqq-De2JvZdV.js} +1 -1
- package/site/dist/assets/{FarcasterSignerStatusScreen-6x-Uh95G-BHBR4k8H.js → FarcasterSignerStatusScreen-6x-Uh95G-bLp3hXoO.js} +1 -1
- package/site/dist/assets/FiatOnrampScreen-BAhYeiTI-Jr6D6JiZ.js +491 -0
- package/site/dist/assets/{FingerPrintIcon-Dm6kxmg7.js → FingerPrintIcon-DOCbS93y.js} +1 -1
- package/site/dist/assets/{FundSolWalletWithExternalSolanaWallet-WtLwYaOl-B8TRV36j.js → FundSolWalletWithExternalSolanaWallet-WtLwYaOl-A_G5kfa1.js} +1 -1
- package/site/dist/assets/{FundWalletMethodHeader-BWNkokCT-BQdbJ5Bb.js → FundWalletMethodHeader-BWNkokCT-LPv35wkD.js} +1 -1
- package/site/dist/assets/{FundWithBankDepositScreen-DajkHxBD-9rPtyA3d.js → FundWithBankDepositScreen-DajkHxBD-0hfGrfvf.js} +1 -1
- package/site/dist/assets/{FundingEditAmountScreen-CpvpiO4M-GaXigGI9.js → FundingEditAmountScreen-CpvpiO4M-Dz0s_NWR.js} +1 -1
- package/site/dist/assets/{FundingMethodSelectionScreen-Db7vhRlE-UsmtTqv4.js → FundingMethodSelectionScreen-Db7vhRlE-ZGm-3-Io.js} +1 -1
- package/site/dist/assets/{GlobeAltIcon-vqrVV5ho.js → GlobeAltIcon-BBRl2MMn.js} +1 -1
- package/site/dist/assets/{GooglePay-B53WnudL-BX5_WtCx.js → GooglePay-B53WnudL-BGiVpB8y.js} +1 -1
- package/site/dist/assets/{HCaptchaWrapper-CUi9LJsp-D-I8j7NO.js → HCaptchaWrapper-CUi9LJsp-CHdfIeD_.js} +3 -3
- package/site/dist/assets/{InAppBrowserLoginNotPossible-BMR9br1T-BY3j50El.js → InAppBrowserLoginNotPossible-BMR9br1T-Cgoiow3m.js} +1 -1
- package/site/dist/assets/{InfoBanner-Cb3p1z12-DLBl_Ywy.js → InfoBanner-Cb3p1z12-_YqQmRiu.js} +1 -1
- package/site/dist/assets/{InjectedWalletIcon-DLcYOGDj-DLSV_NjP.js → InjectedWalletIcon-DLcYOGDj-tuIrKQHH.js} +1 -1
- package/site/dist/assets/{InstallWalletScreen-DTA8dwLv-CxreyXoD.js → InstallWalletScreen-DTA8dwLv-BMU_wa61.js} +1 -1
- package/site/dist/assets/{JsonTree-BHzNC-ic-DcNcbSoM.js → JsonTree-BHzNC-ic-DcVr0YF0.js} +1 -1
- package/site/dist/assets/{LabelXs-oqZNqbm_-iafrj25N.js → LabelXs-oqZNqbm_-CNprGVQM.js} +1 -1
- package/site/dist/assets/LandingScreen-CGWUoSUG-fH6rsQen.js +1 -0
- package/site/dist/assets/{Layouts-BMRfo5hw-CeCOyCLK.js → Layouts-BMRfo5hw-e-sepi6F.js} +1 -1
- package/site/dist/assets/{Link-BdDilT2T-BEDEdHuS.js → Link-BdDilT2T-BdwlRJch.js} +1 -1
- package/site/dist/assets/{LinkConflictScreen-C3ZEPsgl-ClWoqvEL.js → LinkConflictScreen-C3ZEPsgl-BXKN2Qm5.js} +1 -1
- package/site/dist/assets/LinkEmailScreen-dKo9frwc-Cyn7Q8p1.js +1 -0
- package/site/dist/assets/{LinkPasskeyScreen-zbrl_AI_-D72Gb0LW.js → LinkPasskeyScreen-zbrl_AI_-CWiqnwLM.js} +1 -1
- package/site/dist/assets/LinkPasskeyScreen-zbrl_AI_-YmDevJzf.js +1 -0
- package/site/dist/assets/{LinkPhoneScreen-oIUpfj0w-C0DuD14j.js → LinkPhoneScreen-oIUpfj0w-h7shW-Ay.js} +1 -1
- package/site/dist/assets/{Loader-UAZqxsnw-Cy7hEE2f.js → Loader-UAZqxsnw-DJEVblm1.js} +1 -1
- package/site/dist/assets/{LoadingSkeleton-BMsgO5PV-CiEyS5PZ.js → LoadingSkeleton-BMsgO5PV-D2atjsP5.js} +1 -1
- package/site/dist/assets/{LockClosedIcon-BgY_5v_Z.js → LockClosedIcon-9EFzWK1C.js} +1 -1
- package/site/dist/assets/{LoginFailedScreen-CN0dJV6U-DhUMiJZJ.js → LoginFailedScreen-CN0dJV6U-By3Si77a.js} +1 -1
- package/site/dist/assets/{ManualTransferScreen-CHqcuqbs-tXiZDHmN.js → ManualTransferScreen-CHqcuqbs-BAHPY8rs.js} +1 -1
- package/site/dist/assets/{MfaAuthEnrollmentFlowScreen-Dj7gPTRC-CaW7xeCC.js → MfaAuthEnrollmentFlowScreen-Dj7gPTRC-CLjffFG1.js} +1 -1
- package/site/dist/assets/{MfaAuthVerifyFlowScreen-DbFpyWMy-CeRqvx8k.js → MfaAuthVerifyFlowScreen-DbFpyWMy-BmQg1Y61.js} +1 -1
- package/site/dist/assets/{MfaEnrollmentFlowScreen-DhLnGgnr-BkN1k4lh.js → MfaEnrollmentFlowScreen-DhLnGgnr-DmBtTtlw.js} +1 -1
- package/site/dist/assets/{MfaVerifyFlowScreen-C_XPjMRP-CXSqLVbE.js → MfaVerifyFlowScreen-C_XPjMRP-4a683Bmf.js} +1 -1
- package/site/dist/assets/{ModalFooter-BCuEK_nz-c-khvG4Y.js → ModalFooter-BCuEK_nz-C_71qsaz.js} +1 -1
- package/site/dist/assets/{MoonpayStatusScreen-CzTUtokc-BRFN2eXr.js → MoonpayStatusScreen-CzTUtokc-DEHHcEf8.js} +1 -1
- package/site/dist/assets/{OAuthStatusScreen-ufbOa-da-CeiGcSia.js → OAuthStatusScreen-ufbOa-da-BjAb_WsY.js} +1 -1
- package/site/dist/assets/{OpenLink-CUpJ1mOr-DfAvJRyK.js → OpenLink-CUpJ1mOr-BLWFsPOW.js} +1 -1
- package/site/dist/assets/{PasskeySelectSignupOrLogin-xh2ScC_l-CIf5I7wU.js → PasskeySelectSignupOrLogin-xh2ScC_l-2PJTJxX-.js} +1 -1
- package/site/dist/assets/{PasskeyStatusScreen-Bla8MaOk-CLoL7QC-.js → PasskeyStatusScreen-Bla8MaOk-DCEg761l.js} +1 -1
- package/site/dist/assets/{PasswordRecoveryScreen-awGXZkQk-B9F67IYV.js → PasswordRecoveryScreen-awGXZkQk-8nVjNc8k.js} +1 -1
- package/site/dist/assets/{PhoneIcon-CvIiPwYQ.js → PhoneIcon-CZ47md80.js} +1 -1
- package/site/dist/assets/{PinInput-DbZ0b1i1-CDXZBdQx.js → PinInput-DbZ0b1i1-BrTXu3Km.js} +1 -1
- package/site/dist/assets/{PrivyPluginContext-DA-yS5vO-CtQWBiV2.js → PrivyPluginContext-DA-yS5vO-CY60yubk.js} +1 -1
- package/site/dist/assets/{QrCode-DbnZwlkH-h6Bhoe5U.js → QrCode-DbnZwlkH-CcMrWV5D.js} +2 -2
- package/site/dist/assets/{RecoveryOAuthStatusScreen-CsgtTI2x-D-A5P3PX.js → RecoveryOAuthStatusScreen-CsgtTI2x-DgeDnHOK.js} +1 -1
- package/site/dist/assets/{RecoveryPasswordCreateScreen-Be-qJ-LU-C8lTSeSr.js → RecoveryPasswordCreateScreen-Be-qJ-LU-CvJJwLhK.js} +1 -1
- package/site/dist/assets/{RecoverySelectionScreen-D1iGtpmi-P5P3plkH.js → RecoverySelectionScreen-D1iGtpmi-CADtGtSV.js} +1 -1
- package/site/dist/assets/{SIWXUtil-TUCxa7aA.js → SIWXUtil-Cpiv91-M.js} +1 -1
- package/site/dist/assets/{Screen-D30meWsY-CCeVNuWs.js → Screen-D30meWsY-vEusJ7KX.js} +1 -1
- package/site/dist/assets/{ScreenHeader-CHmc4-Lu-DjyrH7IK.js → ScreenHeader-CHmc4-Lu-BvGTLg53.js} +1 -1
- package/site/dist/assets/{ScreenLayout-OwaQQcxH-CrQM6kvA.js → ScreenLayout-OwaQQcxH-cfOTmyl0.js} +1 -1
- package/site/dist/assets/{SelectSourceAsset-CWFog6gm-D7yTw87h.js → SelectSourceAsset-CWFog6gm-DxYklZYs.js} +1 -1
- package/site/dist/assets/{SetAutomaticRecoveryScreen-BO_OEqAZ-f0iDIGmw.js → SetAutomaticRecoveryScreen-BO_OEqAZ-oeqeo05x.js} +1 -1
- package/site/dist/assets/{SetWalletPasswordForm-DwCTVtAh-kq1zvA7d.js → SetWalletPasswordForm-DwCTVtAh-BxFee9UA.js} +1 -1
- package/site/dist/assets/{ShieldCheckIcon-o6RHYev1.js → ShieldCheckIcon-eFjsosCA.js} +1 -1
- package/site/dist/assets/{SignRequestScreen-BHKv32KR-DDpMYyJ1.js → SignRequestScreen-BHKv32KR-z8ixfIma.js} +1 -1
- package/site/dist/assets/{SolanaWalletConnector-C7Lqk-Wz-DPwhuzcI.js → SolanaWalletConnector-C7Lqk-Wz-Bc_lvdiF.js} +1 -1
- package/site/dist/assets/{StackedContainer-B2vaEl56-eQCM2cmv.js → StackedContainer-B2vaEl56-Do5dXB8-.js} +1 -1
- package/site/dist/assets/{StandardSignAndSendTransactionScreen-CfhIXVtd-BJ-onCjv.js → StandardSignAndSendTransactionScreen-CfhIXVtd-DudetZAc.js} +1 -1
- package/site/dist/assets/{Subtitle-CV-2yKE4-zxWw2m1Q.js → Subtitle-CV-2yKE4-DV0o1av3.js} +1 -1
- package/site/dist/assets/{TelegramAuthScreen-UL9zLfO8-NWlMgNRX.js → TelegramAuthScreen-UL9zLfO8-Bo3sONvf.js} +1 -1
- package/site/dist/assets/{Title-BnzYV3Is-B_JpTatT.js → Title-BnzYV3Is-C3qOPnO_.js} +1 -1
- package/site/dist/assets/{TodoList-DnyULl18-C8Eyy28X.js → TodoList-DnyULl18-BvxvubbF.js} +1 -1
- package/site/dist/assets/{TransactionDetails-e9nesl30-C4MpIHR-.js → TransactionDetails-e9nesl30-WWflkOIi.js} +1 -1
- package/site/dist/assets/{TransactionErrorView-BDBNqA_f-p1T9WVMx.js → TransactionErrorView-BDBNqA_f-CotYKcgf.js} +1 -1
- package/site/dist/assets/{TransferFromWalletScreen-Qvn1Yuno-88IQcRnY.js → TransferFromWalletScreen-Qvn1Yuno-sVFlWqa8.js} +1 -1
- package/site/dist/assets/{TransferOrBridgeLoadingScreen-Dl1I_iIz-1fDAIxAf.js → TransferOrBridgeLoadingScreen-Dl1I_iIz-CV2-mY19.js} +1 -1
- package/site/dist/assets/{TurnstileWrapper-B7sNddys-Jwy1tJtm.js → TurnstileWrapper-B7sNddys-oPbuMTQt.js} +1 -1
- package/site/dist/assets/{UpdateEmailScreen-DVOhPV0H-Jj2DQW8D.js → UpdateEmailScreen-DVOhPV0H-D_mjSpAy.js} +1 -1
- package/site/dist/assets/{UpdatePhoneScreen-CXRswTNZ-DwYIUBqi.js → UpdatePhoneScreen-CXRswTNZ-6RLG0ahv.js} +1 -1
- package/site/dist/assets/{UserLimitReachedScreen-5we2DHn8-D7m70C4b.js → UserLimitReachedScreen-5we2DHn8-CaVN0bti.js} +1 -1
- package/site/dist/assets/{Value-DTgR824E-BRuIGiec.js → Value-DTgR824E-Bp6WGZZm.js} +1 -1
- package/site/dist/assets/{WalletCards-DH1rqayz-Bgp9Fsgs.js → WalletCards-DH1rqayz-D3cOTb9x.js} +1 -1
- package/site/dist/assets/{WalletIcon-gKf0gTw6.js → WalletIcon-DOIZhb2l.js} +1 -1
- package/site/dist/assets/{WalletInfoCard-sq_2wgFg-DpNSAGte.js → WalletInfoCard-sq_2wgFg-bOqfl5MA.js} +1 -1
- package/site/dist/assets/{WalletInterstitialScreen-Sh7LfsAh-DG-RuO-F.js → WalletInterstitialScreen-Sh7LfsAh-DWaVkMCA.js} +1 -1
- package/site/dist/assets/{WalletLink-DK5LB5Ha-DHaL350n.js → WalletLink-DK5LB5Ha-DjUZvqs-.js} +1 -1
- package/site/dist/assets/WalletOverflowButton-bfCnp-9T-B6P7DQXA.js +1 -0
- package/site/dist/assets/{WarningBanner-ZZqCEtZK-2eU4Qo74.js → WarningBanner-ZZqCEtZK-Bc2YKZb7.js} +1 -1
- package/site/dist/assets/__vite-browser-external-NciY4Vu1.js +1 -0
- package/site/dist/assets/{_esm-BdeM6pxJ.js → _esm-BZP3cXTv.js} +1 -1
- package/site/dist/assets/_esm-ZmzBJpEs.js +6 -0
- package/site/dist/assets/{accounts-D96UKWkC.js → accounts-D4AXF17G.js} +1 -1
- package/site/dist/assets/accounts-IkdFx9nq.js +1 -0
- package/site/dist/assets/{baseSepolia-DX-qGsik.js → baseSepolia-Bn1j1Ysw.js} +1 -1
- package/site/dist/assets/{basic-oIwwSyu4.js → basic-Cz1YiCSk.js} +4 -4
- package/site/dist/assets/{ccip-BZvRTL6g.js → ccip-B1J3oTZx.js} +2 -2
- package/site/dist/assets/ccip-Bd7261zy.js +1 -0
- package/site/dist/assets/{ccip-65sIfSPR.js → ccip-D6EHKpjI.js} +1 -1
- package/site/dist/assets/{chain-DM3oH6Px.js → chain-scefkYIH.js} +3 -6
- package/site/dist/assets/check-DHnllI8N.js +1 -0
- package/site/dist/assets/{chevron-down-BSsbXkK-.js → chevron-down-1y-r4bGO.js} +1 -1
- package/site/dist/assets/{circle-alert-DWaeLZNj.js → circle-alert-OwxamXUX.js} +1 -1
- package/site/dist/assets/{circle-check-big-Chb1ivw9.js → circle-check-big-3sZGVC10.js} +1 -1
- package/site/dist/assets/{circle-x-AV9Cet0R.js → circle-x-DQjNUV9J.js} +1 -1
- package/site/dist/assets/client-B-BpRtwY.js +1 -0
- package/site/dist/assets/client-BfIR1FvH.js +9 -0
- package/site/dist/assets/coinbase-DCPC2L_R-YEuIn3jh.js +3 -0
- package/site/dist/assets/{copy-Ckr0AkL6.js → copy-DMOX_yn7.js} +1 -1
- package/site/dist/assets/core-GIEmxmAa.js +12 -0
- package/site/dist/assets/{createLucideIcon-IPW50ckY.js → createLucideIcon-BsERoFTA.js} +1 -1
- package/site/dist/assets/{defineChain-CiuCXUZW.js → defineChain-B-SQDLTG.js} +1 -1
- package/site/dist/assets/{dijkstra-Drfl93V4.js → dijkstra-CY95afk4.js} +1 -1
- package/site/dist/assets/dist-Cp6IXeJd.js +1 -0
- package/site/dist/assets/{dist-Cm7pNAtL.js → dist-CrNxmdZj.js} +1 -1
- package/site/dist/assets/{dist-DnGANz51.js → dist-DYGtf4F0.js} +4 -4
- package/site/dist/assets/embed.worker-Cnl4VGr3.js +1 -0
- package/site/dist/assets/{errors-BQ3N-RVt-BLqjTPNR.js → errors-BQ3N-RVt-CZPAWCgC.js} +1 -1
- package/site/dist/assets/{esm-B5cbIQaz.js → esm-Co94ENUV.js} +17 -17
- package/site/dist/assets/{esm-ByALO6mA.js → esm-bb8SANZh.js} +1 -1
- package/site/dist/assets/{ethers-zTjbodk5-wHhL_BQ1.js → ethers-zTjbodk5-Cs648CnD.js} +1 -1
- package/site/dist/assets/{eventemitter3-CL76jPsW.js → eventemitter3-Dzc_0Uq2.js} +1 -1
- package/site/dist/assets/{external-link-D-uehwM2.js → external-link-BBPG3rG7.js} +1 -1
- package/site/dist/assets/{farcaster-DPlSjvF5-BqTvDXBR.js → farcaster-DPlSjvF5-CzBCmgyL.js} +1 -1
- package/site/dist/assets/{features-DQ0UYy6K.js → features-CuiHbgEJ.js} +1 -1
- package/site/dist/assets/{fingerprint-pattern-D8ytA16Q.js → fingerprint-pattern-CjLtyIxB.js} +1 -1
- package/site/dist/assets/floating-ui.react-DmaCfayr.js +1 -0
- package/site/dist/assets/{floating-ui.react-dom-DKWOL9UG.js → floating-ui.react-dom-CaoMF8mP.js} +1 -1
- package/site/dist/assets/{get-entropy-details-for-user-dHRH5Gpi-Dukf7_kJ.js → get-entropy-details-for-user-dHRH5Gpi-BNiOFXbK.js} +1 -1
- package/site/dist/assets/{getErc20Balance-jXNpFf0N-Bb9WM31M.js → getErc20Balance-jXNpFf0N-q4bV8kQq.js} +1 -1
- package/site/dist/assets/{getErc20TokenInfo-BNTrzLMP-KPrdn04K.js → getErc20TokenInfo-BNTrzLMP-DcnTFrXN.js} +1 -1
- package/site/dist/assets/{guards-BIW-GiMJ-CHfXo8XI.js → guards-BIW-GiMJ-D3tWTQAR.js} +1 -1
- package/site/dist/assets/{hourglass-CPG1HZmf.js → hourglass-D_GfQdJr.js} +1 -1
- package/site/dist/assets/{id-UqEwL2BI-BkKm533U.js → id-UqEwL2BI-CTlvRMA5.js} +1 -1
- package/site/dist/assets/{index-BdEw5wyl-ChSJvPZk.js → index-BdEw5wyl-kLbhqLbv.js} +1 -1
- package/site/dist/assets/index-C2h3EneX.js +8 -0
- package/site/dist/assets/{index-CWARkn2w-Cezl_uBr.js → index-CWARkn2w-DxuckIFn.js} +1 -1
- package/site/dist/assets/{index-DvMddJcd-BatvgC-S.js → index-DvMddJcd-CNBb4VUn.js} +1 -1
- package/site/dist/assets/{index-YiCw0Y_x-CX5i3Z87.js → index-YiCw0Y_x-Czl0tWfF.js} +5 -6
- package/site/dist/assets/{index.es-BmqyoBEM.js → index.es-Crd0TyUS.js} +1 -1
- package/site/dist/assets/index.es-DQbup1WG.js +3 -0
- package/site/dist/assets/{isPaymentRequestAvailable-Bq1cemEn-By6r0dVB.js → isPaymentRequestAvailable-Bq1cemEn-Cjf3l05I.js} +1 -1
- package/site/dist/assets/{jsx-runtime-BbDfbRii.js → jsx-runtime-CndCZlyt.js} +1 -1
- package/site/dist/assets/{landmark-CH6LV6F0.js → landmark-BZPqMFEf.js} +1 -1
- package/site/dist/assets/lib-DGtzi2DK.js +1 -0
- package/site/dist/assets/{localBatchGatewayRequest-3kLrX_c7.js → localBatchGatewayRequest-B71J8sQ9.js} +7 -10
- package/site/dist/assets/{lock-DcskI4Bb.js → lock-DyN_c-ud.js} +1 -1
- package/site/dist/assets/{mail-Bs0r5yOi.js → mail-V_mcPb64.js} +1 -1
- package/site/dist/assets/{modal-context-CwmSeFcv-DruX9J1E.js → modal-context-CwmSeFcv-DPWNJrfK.js} +1 -1
- package/site/dist/assets/{ofetch.CWycOUEr-CHp-crOQ.js → ofetch.CWycOUEr-Duby3iHT.js} +1 -1
- package/site/dist/assets/parseEther-CHS0GNkM.js +1 -0
- package/site/dist/assets/{pkce-DXF0yKjP-ChQhE0st.js → pkce-DXF0yKjP-7_VY-d83.js} +1 -1
- package/site/dist/assets/preload-helper-CRzLMJPS.js +1 -0
- package/site/dist/assets/{privy-context-81KmsBw2-CjWGzyg7.js → privy-context-81KmsBw2-DiR6-Yq8.js} +1 -1
- package/site/dist/assets/{react-DrJ0MmMO.js → react-BfYA1q0G.js} +1 -1
- package/site/dist/assets/react-CK2HRI1t.js +1 -0
- package/site/dist/assets/{react-DQnMl2Xv.js → react-DxGeY8B8.js} +1 -1
- package/site/dist/assets/{react-dom-5dW7aKoP.js → react-dom-BI2Koe4o.js} +1 -1
- package/site/dist/assets/{reservoir-x-nGuZkT-BMX127i6.js → reservoir-x-nGuZkT-BguVFH3D.js} +1 -1
- package/site/dist/assets/roles-BDPDWrwo.js +1 -0
- package/site/dist/assets/rolldown-runtime-Bjp52BOI.js +1 -0
- package/site/dist/assets/secp256k1-BeYL8aZl.js +1 -0
- package/site/dist/assets/{secp256k1-_MleGpqL.js → secp256k1-Bh4MSkhz.js} +1 -1
- package/site/dist/assets/secp256k1-Ci4cqHl0.js +1 -0
- package/site/dist/assets/secp256k1-DsxXqbXv.js +1 -0
- package/site/dist/assets/secp256k1-N9RUmafO.js +1 -0
- package/site/dist/assets/{serializeAuthorizationList-CX8hGL56.js → serializeAuthorizationList-DGMik9Wx.js} +1 -1
- package/site/dist/assets/{serializeSignature-DfxkPnu-.js → serializeSignature-CWKpxoab.js} +1 -1
- package/site/dist/assets/sha2-C6s7zZmb.js +1 -0
- package/site/dist/assets/{shared-DRZUmnL5-xqAUARWo.js → shared-DRZUmnL5-BewE5wK8.js} +1 -1
- package/site/dist/assets/{shared-FM0rljBt--Avg6q2R.js → shared-FM0rljBt-CxLACri_.js} +1 -1
- package/site/dist/assets/shouldProceedtoEmbeddedWalletCreationFlow-B3vyavrh-BkAKsRNi.js +1 -0
- package/site/dist/assets/{simulateTransaction-CfuOrae4-64lWYJAL.js → simulateTransaction-CfuOrae4-PjA_tGjX.js} +1 -1
- package/site/dist/assets/{smartphone-CcEZ-XAy.js → smartphone-3p8nFSTE.js} +1 -1
- package/site/dist/assets/{storage-Ufl800Ne-D0bZBw-H.js → storage-Ufl800Ne-1qCR2JMO.js} +7 -8
- package/site/dist/assets/{stringify-BlDm7tuc.js → stringify-DqUj9VzO.js} +2 -3
- package/site/dist/assets/stripe.esm-DEi2D291.js +2 -0
- package/site/dist/assets/{styles-BsotlekN-CXEB4Ud9.js → styles-BsotlekN-Aq27nZGc.js} +1 -1
- package/site/dist/assets/{styles-Cm9H63WO-Br4QtzUL.js → styles-Cm9H63WO-p_ic_dxE.js} +1 -1
- package/site/dist/assets/{styles-DVyDvTdj-BTABn2K8.js → styles-DVyDvTdj-CjsWqAld.js} +1 -1
- package/site/dist/assets/{styles-hslXy6xG-D-49b1rk.js → styles-hslXy6xG-D5QHIrJU.js} +1 -1
- package/site/dist/assets/{telegram-B-JqnkqZ-RBoY3PLx.js → telegram-B-JqnkqZ-Dqkm4rDn.js} +1 -1
- package/site/dist/assets/{to-ui-error-DWe-qwS3-Cx2bk1kZ.js → to-ui-error-DWe-qwS3-Bi1HUQI9.js} +1 -1
- package/site/dist/assets/toViemAccount-B5iDGq1b-CdFZwv07.js +2 -0
- package/site/dist/assets/transformers.web-BTyOEJ0C.js +40 -0
- package/site/dist/assets/transformers.web-CUZUFjAK.js +49 -0
- package/site/dist/assets/{triangle-alert-CWjYH75H.js → triangle-alert-BG3Qw-Hq.js} +1 -1
- package/site/dist/assets/{twitch-5IOe4sIQ-lDtgk0os.js → twitch-5IOe4sIQ-CaXHFlAu.js} +1 -1
- package/site/dist/assets/{use-headless-crypto-deposit-Yn-QRLB3-LUIVFBSd.js → use-headless-crypto-deposit-Yn-QRLB3-CQqeyhGY.js} +1 -1
- package/site/dist/assets/{use-unlink-wallet-BKK4_5Ur-CC2pq27z.js → use-unlink-wallet-BKK4_5Ur-C0xQN_Lp.js} +1 -1
- package/site/dist/assets/{useActiveWallet-B-yZYGc6-D7Ik-LxJ.js → useActiveWallet-B-yZYGc6-BkK6rFBm.js} +1 -1
- package/site/dist/assets/{useGetSolPrice-x7gfUIHJ-D1hmQfpA.js → useGetSolPrice-x7gfUIHJ-CLVXqv6I.js} +1 -1
- package/site/dist/assets/{useGetTokenPrice-CaoUkb79-ZnbuJ-vP.js → useGetTokenPrice-CaoUkb79-DAXXs3rs.js} +1 -1
- package/site/dist/assets/{useI18n-C-5n_noF-BcqC76yj.js → useI18n-C-5n_noF-CGpkgIVy.js} +1 -1
- package/site/dist/assets/{useWalletBalance-CZnP5f_f-Dw2GIJ4g.js → useWalletBalance-CZnP5f_f-Cfd64m4n.js} +1 -1
- package/site/dist/assets/{useWallets-X1ndvJ_U-DRjz7uYD.js → useWallets-X1ndvJ_U-CAYqg7Za.js} +1 -1
- package/site/dist/assets/{w3m-modal-BeVrBOIf.js → w3m-modal-B4H_uiPH.js} +2 -2
- package/site/dist/assets/{wallet-Bn85Sg2W.js → wallet-BNI12IYk.js} +1 -1
- package/site/dist/assets/wallet-CITSaPlB.js +2 -0
- package/site/dist/assets/{wallet-connect-BvJtUsDt-Y03hhqFN.js → wallet-connect-BvJtUsDt-CVlSNIXP.js} +1 -1
- package/site/dist/assets/{walletconnect-registry-xxG8XLCb-D1SSFvMp.js → walletconnect-registry-xxG8XLCb-BpzpBq5s.js} +1 -1
- package/site/dist/assets/walletconnect-v2-3frQFwbg-CzZ6oybX.js +12 -0
- package/site/dist/assets/{wui-ux-by-reown-D34ILNLS.js → wui-ux-by-reown-XyHdtV1O.js} +1 -1
- package/site/dist/assets/x-gjDrY2rk.js +1 -0
- package/site/dist/index.html +5 -5
- package/site/feed.js +16 -1
- package/site/no-model.js +4 -0
- package/site/worker.js +586 -59
- package/src/agent/agent-card.js +20 -11
- package/src/agent/mcp.js +190 -324
- package/src/agent/view-tools.js +46 -13
- package/src/agent/x402.js +340 -44
- package/src/core/embed.js +51 -52
- package/src/core/embed.worker.js +1 -1
- package/src/core/shard.js +7 -3
- package/src/discover/apps.js +41 -5
- package/src/discover/explore.js +50 -30
- package/src/market/reactions.js +2 -2
- package/src/publish/devnet.js +95 -0
- package/src/publish/init.js +74 -0
- package/src/publish/lint.js +2 -1
- package/src/publish/ship.js +559 -267
- package/src/publish/view-cli.js +14 -10
- package/src/publish/view.js +355 -218
- package/src/taste/taste-doc.js +3 -2
- package/src/taste/taste.js +2 -2
- package/src/taste/vault.js +3 -1
- package/template/README.md +49 -0
- package/template/app.json +27 -0
- package/template/eval/goals.md +7 -0
- package/template/eval/golden.jsonl +0 -0
- package/template/gitignore +3 -0
- package/template/package.json +13 -0
- package/template/wrangler.json +12 -0
- package/site/dist/assets/BridgeNetworkSelectionView-CFGjB2nO-CvsbQcFv.js +0 -68
- package/site/dist/assets/ConnectOrCreateScreen-CUUYUO07-crHzh-TL.js +0 -1
- package/site/dist/assets/ConnectWalletView-DqI-PTvX-CMQIad63.js +0 -74
- package/site/dist/assets/ConnectionStatusScreen-fUfROm9m-wu3a3kw4.js +0 -1
- package/site/dist/assets/ErrorScreen-DipdTWzE-DcxVjMO4.js +0 -1
- package/site/dist/assets/FiatOnrampScreen-BAhYeiTI-BH_sU6EV.js +0 -491
- package/site/dist/assets/LandingScreen-CGWUoSUG-DK1EY-6v.js +0 -1
- package/site/dist/assets/LinkEmailScreen-dKo9frwc-C3v7glH0.js +0 -1
- package/site/dist/assets/LinkPasskeyScreen-zbrl_AI_-DYIl5Kr2.js +0 -1
- package/site/dist/assets/WalletOverflowButton-bfCnp-9T-CUyIJFzt.js +0 -1
- package/site/dist/assets/__vite-browser-external-CitKSmYk.js +0 -1
- package/site/dist/assets/_esm-B26FZg5Y.js +0 -7
- package/site/dist/assets/accounts-DiZ-0VmN.js +0 -1
- package/site/dist/assets/ccip-DA_zG341.js +0 -1
- package/site/dist/assets/check-BPgcwEPP.js +0 -1
- package/site/dist/assets/client-CZG0ndth.js +0 -2
- package/site/dist/assets/client-Dsa7_3V3.js +0 -9
- package/site/dist/assets/coinbase-DCPC2L_R-D3aIgpyd.js +0 -3
- package/site/dist/assets/core-snws5xwv.js +0 -12
- package/site/dist/assets/dist-Dl07uGq1.js +0 -1
- package/site/dist/assets/embed.worker-ugGhEqCV.js +0 -1
- package/site/dist/assets/floating-ui.react-xRkl9O3u.js +0 -1
- package/site/dist/assets/index-1HYFYA-W.js +0 -8
- package/site/dist/assets/index.es-C1v1or--.js +0 -3
- package/site/dist/assets/lib-BsS8z8Lj.js +0 -1
- package/site/dist/assets/parseEther-VjhVo3dd.js +0 -1
- package/site/dist/assets/preload-helper-uBIymjUX.js +0 -1
- package/site/dist/assets/react-DCXkXSrv.js +0 -1
- package/site/dist/assets/roles-32M1l9jI.js +0 -1
- package/site/dist/assets/rolldown-runtime-BcKkbAw3.js +0 -1
- package/site/dist/assets/secp256k1-C4nzcPo-.js +0 -1
- package/site/dist/assets/secp256k1-D92aGNnU.js +0 -1
- package/site/dist/assets/secp256k1-DmbwyFau.js +0 -1
- package/site/dist/assets/secp256k1-xl2og-wO.js +0 -1
- package/site/dist/assets/sha2-BU_QyRTx.js +0 -1
- package/site/dist/assets/shouldProceedtoEmbeddedWalletCreationFlow-B3vyavrh-BK_FBkaE.js +0 -1
- package/site/dist/assets/stripe.esm-CZRDpc-N.js +0 -2
- package/site/dist/assets/toViemAccount-B5iDGq1b-Ba8L7zed.js +0 -2
- package/site/dist/assets/transformers.web-CVP3pJOS.js +0 -40
- package/site/dist/assets/transformers.web-D8W1u_I2.js +0 -49
- package/site/dist/assets/wallet-Bnzeiqed.js +0 -2
- package/site/dist/assets/walletconnect-v2-3frQFwbg-CrtLXofr.js +0 -12
- package/site/dist/assets/x-rlSp9U7W.js +0 -1
package/src/publish/ship.js
CHANGED
|
@@ -1,42 +1,73 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// westmarch-ship: one config, one command, a live Fangorn app.
|
|
2
|
+
// westmarch-ship: one config, one command, a live Fangorn app on the free tier.
|
|
3
3
|
//
|
|
4
4
|
// westmarch-ship app.json [--no-crawl] [--no-deploy] [--dry-run]
|
|
5
5
|
// westmarch-ship app.json --local <out> [--crawl] a view from staged records, no chain (see buildLocal)
|
|
6
|
-
// westmarch-ship app.json --register the app alone: claim,
|
|
6
|
+
// westmarch-ship app.json --register the app alone: claim, empty site, card bound
|
|
7
|
+
// westmarch-ship app.json --devnet [--only …] the whole app on this machine (see devnetShip)
|
|
8
|
+
// westmarch-ship app.json --index the deployed app's indexer, once, here (see indexHere)
|
|
7
9
|
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
+
// The app is one Cloudflare Worker (site/worker.js): its indexer (a cron that runs the
|
|
11
|
+
// embedding lens over everything the app presents, into R2), its view, its MCP endpoint
|
|
12
|
+
// (/mcp) and its site. Nothing is embedded here. Every step checks the chain (or
|
|
13
|
+
// Cloudflare) first and only acts on a difference, so re-running is how you update.
|
|
10
14
|
//
|
|
11
|
-
// 1. claim the app (first run only; the claim block becomes the card's fromBlock)
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
//
|
|
17
|
-
// 7. deploy to Cloudflare Pages
|
|
18
|
-
// 8. register the ERC-8004 agent and bind the card, if the chain points elsewhere
|
|
15
|
+
// 1. claim the app (first run only; the claim block becomes the card's fromBlock).
|
|
16
|
+
// The claimer is the app's first member, so its own updates are accepted.
|
|
17
|
+
// 2. run each source, which crawls and publishes straight into the app
|
|
18
|
+
// 3. the stock page, the card and _headers → .ship/site
|
|
19
|
+
// 4. deploy the Worker: its R2 bucket, Workers AI, the cron, CONFIG (app.json's schema rides in it)
|
|
20
|
+
// 5. register the ERC-8004 agent and bind the card, if the chain points elsewhere
|
|
19
21
|
//
|
|
20
|
-
//
|
|
21
|
-
//
|
|
22
|
-
//
|
|
23
|
-
//
|
|
22
|
+
// The Worker picks up what 2 published on its next cron run (every few minutes),
|
|
23
|
+
// so the view follows the chain with nobody running anything.
|
|
24
|
+
//
|
|
25
|
+
// --register is the fast path, run before there is any data: 1, 3, 4 and 5 binding the card
|
|
26
|
+
// without minting. The mint copies the card's skills into its IPFS registration file and is
|
|
27
|
+
// never redone, so it waits for the first full ship, when the card lists what the app does.
|
|
24
28
|
//
|
|
25
29
|
// Chain writes go through the `fangorn` CLI (its configured wallet signs, and
|
|
26
30
|
// `fangorn wallet` shows which). Reads go through the SDK. State lives in `.ship/` next
|
|
27
|
-
// to app.json: the site, the
|
|
31
|
+
// to app.json: the site, the Worker's config and a small state.json.
|
|
28
32
|
|
|
29
|
-
import { spawnSync } from "node:child_process";
|
|
30
|
-
import { createHash } from "node:crypto";
|
|
33
|
+
import { spawn, spawnSync } from "node:child_process";
|
|
34
|
+
import { createHash, randomBytes } from "node:crypto";
|
|
31
35
|
import { cpSync, existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, rmSync, writeFileSync } from "node:fs";
|
|
32
36
|
import { createRequire } from "node:module";
|
|
33
|
-
import { dirname, join, resolve } from "node:path";
|
|
37
|
+
import { dirname, join, relative, resolve } from "node:path";
|
|
34
38
|
import { homedir } from "node:os";
|
|
35
39
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
36
40
|
|
|
37
41
|
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
38
|
-
|
|
39
|
-
|
|
42
|
+
// USDC per x402 network (CAIP-2): its address and EIP-712 domain, as each contract reports them.
|
|
43
|
+
// They differ: Base Sepolia's is "USDC", Base's "USD Coin", and a payment signed under the wrong
|
|
44
|
+
// one fails at the facilitator.
|
|
45
|
+
const USDC = {
|
|
46
|
+
"eip155:84532": { asset: "0x036CbD53842c5426634e7929541eC2318f3dCF7e", name: "USDC", version: "2" },
|
|
47
|
+
"eip155:8453": { asset: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", name: "USD Coin", version: "2" },
|
|
48
|
+
"eip155:421614": { asset: "0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d", name: "USD Coin", version: "2" },
|
|
49
|
+
"eip155:42161": { asset: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831", name: "USD Coin", version: "2" },
|
|
50
|
+
};
|
|
51
|
+
const X402_NETWORK = { "base-sepolia": "eip155:84532", base: "eip155:8453", "arbitrum-sepolia": "eip155:421614", arbitrum: "eip155:42161" };
|
|
52
|
+
|
|
53
|
+
/** How a sale settles, from `paid` or `private` in app.json: the network (`network`, else the
|
|
54
|
+
* app's own), the token and its EIP-712 domain, the payee (`payTo`, else the owner) and the facilitator. */
|
|
55
|
+
export function settlement(o, { network: own, owner }) {
|
|
56
|
+
const network = o.network ? X402_NETWORK[o.network] ?? o.network : own;
|
|
57
|
+
const usdc = o.asset ? {} : USDC[network];
|
|
58
|
+
if (!usdc) throw new Error(`network ${network}: no default USDC; set asset, tokenName and tokenVersion`);
|
|
59
|
+
const name = o.tokenName ?? usdc.name, version = o.tokenVersion ?? usdc.version;
|
|
60
|
+
if (!name || !version) throw new Error("asset needs tokenName and tokenVersion: its EIP-712 domain");
|
|
61
|
+
return { network, asset: o.asset ?? usdc.asset, name, version, decimals: o.decimals ?? 6, symbol: o.symbol ?? "USDC",
|
|
62
|
+
payTo: o.payTo ?? owner, facilitator: (o.facilitator ?? "https://facilitator.payai.network").replace(/\/$/, "") };
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** "0.01" → "10000": a decimal price in the token's base units. */
|
|
66
|
+
export function units(price, decimals = 6) {
|
|
67
|
+
if (!/^\d+(\.\d+)?$/.test(String(price))) throw new Error(`price must be a decimal like "0.01", got ${price}`);
|
|
68
|
+
const [whole, frac = ""] = String(price).split(".");
|
|
69
|
+
return (BigInt(whole) * 10n ** BigInt(decimals) + BigInt((frac + "0".repeat(decimals)).slice(0, decimals) || "0")).toString();
|
|
70
|
+
}
|
|
40
71
|
const STOCK = join(HERE, "../../site/dist");
|
|
41
72
|
const log = (s) => console.error(`[ship] ${s}`);
|
|
42
73
|
|
|
@@ -44,27 +75,46 @@ const log = (s) => console.error(`[ship] ${s}`);
|
|
|
44
75
|
//
|
|
45
76
|
// {
|
|
46
77
|
// "app": "quorum", "name": "Quorum", "description": "…", "tags": ["civic"],
|
|
47
|
-
// "site": { "project": "quorum",
|
|
78
|
+
// "site": { "project": "quorum", // the Worker's name (and its R2 bucket's: <project>-view)
|
|
79
|
+
// "account": "<cloudflare account id>",
|
|
80
|
+
// "url": "https://quorum.example", // optional: a custom domain routed to the Worker
|
|
81
|
+
// "cron": "*/5 * * * *", // optional: how often the indexer runs
|
|
48
82
|
// "pages": "pages", // optional: the app's own files, copied over the stock page
|
|
49
83
|
// // (pages/intro.html, a fragment, replaces the description on the front page)
|
|
50
84
|
// "nav": [{ "href": "coverage.html", "label": "Coverage" }], // optional: header links to them
|
|
85
|
+
// "examples": ["…"], // optional: questions to start from, on the front page (and a private app's gate)
|
|
51
86
|
// "agent": "app/agent.js" }, // optional: the module whose registerAgent the card lists, when
|
|
52
87
|
// // `pages` replaces the stock index.html with a page of its own
|
|
53
88
|
// "types": { "<tag>": { "description": "…", "role_map": {…}, "presentation": {…} } },
|
|
54
89
|
// "relations": [{ "rel": "…", "from": "<tag>", "to": "<tag>" }],
|
|
55
90
|
// "sources": [{ "namespace": "…", "cwd": "…", "command": ["python", "-m", "…", …] }],
|
|
56
|
-
// "
|
|
57
|
-
//
|
|
91
|
+
// "network": "baseSepolia", // required: the SDK's network name. baseSepolia for a new app; an app
|
|
92
|
+
// // already claimed on arbitrumSepolia keeps it (a different name re-claims it there)
|
|
93
|
+
// "fangorn": "fangorn", // the CLI that signs; e.g. "node ~/fangorn/fangorn/lib/cli/cli.js",
|
|
94
|
+
// // or "env HOME=<dir> node …/cli.js" to sign with <dir>/.fangorn/config.json
|
|
95
|
+
// "paid": { "price": "0.01", "description": "…" } // settles in USDC on the app's network, or "network": "base" / "eip155:8453"…
|
|
58
96
|
// }
|
|
59
97
|
//
|
|
60
|
-
// `paid` sells per-record
|
|
61
|
-
//
|
|
62
|
-
//
|
|
63
|
-
// `
|
|
98
|
+
// `paid` sells per-record keys over x402 v2 (site/worker.js), and the price goes in the card,
|
|
99
|
+
// /openapi.json and /.well-known/x402. The payee is the app owner unless `paid.payTo` says
|
|
100
|
+
// otherwise; the asset is USDC on `paid.network` unless `paid.asset` (with `tokenName` and
|
|
101
|
+
// `tokenVersion`, its EIP-712 domain) does. PAID_SECRET is a Worker secret
|
|
102
|
+
// (`wrangler secret put PAID_SECRET`), the same value the sources encrypt with.
|
|
103
|
+
// The facilitator (PayAI unless `paid.facilitator`) lists POST /paid in its Bazaar on the first
|
|
104
|
+
// sale; each ship says whether it has.
|
|
105
|
+
//
|
|
106
|
+
// "private": { "pass": { "price": "5", "days": 30 }, "call": "0.01", "description": "…" }
|
|
64
107
|
//
|
|
65
|
-
//
|
|
66
|
-
//
|
|
67
|
-
//
|
|
108
|
+
// `private` makes the data itself the product. Each source stages its records (it needs an
|
|
109
|
+
// --output-dir), ship seals every row whole (x402.js's sealRow) and commits them, so IPFS holds
|
|
110
|
+
// only ciphertext; the Worker opens them in its cron with PAID_SECRET (made once in
|
|
111
|
+
// .ship/secret, or $PAID_SECRET, and put to the Worker on every deploy) and serves the view and
|
|
112
|
+
// the MCP tools only with a pass (POST /pass, x402) or one x402 payment per tool call. The card,
|
|
113
|
+
// the catalog and `describe` stay free. Settles like `paid` (network, payTo, asset, facilitator).
|
|
114
|
+
//
|
|
115
|
+
// A source is any command that publishes into the repo `--namespace` names when given
|
|
116
|
+
// `--publish`. It runs with FANGORN_APP_ID set, so it uploads through this app's storage
|
|
117
|
+
// whatever the CLI's saved app is.
|
|
68
118
|
|
|
69
119
|
/** `{field}`, `{field|slug}` and `{field|lower}` from a row; an argv item that is exactly
|
|
70
120
|
* `{args...}` splices the row's own `args` array (for flags only some rows need). */
|
|
@@ -93,20 +143,29 @@ export function loadConfig(path) {
|
|
|
93
143
|
c.sources = expandSources(c.sources ?? [], dirname(resolve(path)));
|
|
94
144
|
for (const k of ["app", "name", "description", "site"]) // types and sources can come after --register
|
|
95
145
|
if (!c[k]) throw new Error(`${path}: missing "${k}"`);
|
|
96
|
-
if (!c.site.project) throw new Error(`${path}: site.project names the Cloudflare
|
|
146
|
+
if (!c.site.project) throw new Error(`${path}: site.project names the Cloudflare Worker`);
|
|
97
147
|
for (const s of c.sources) if (!s.namespace || !Array.isArray(s.command))
|
|
98
148
|
throw new Error(`${path}: each source needs a namespace and a command (an argv array)`);
|
|
99
149
|
return { relations: [], tags: [], types: {}, ...c };
|
|
100
150
|
}
|
|
101
151
|
|
|
102
|
-
/** The
|
|
103
|
-
*
|
|
104
|
-
export function
|
|
105
|
-
const id = (tag) => `type:${tag}`;
|
|
152
|
+
/** The Worker's wrangler config: the stock worker, the site as its assets, its bucket, the AI
|
|
153
|
+
* binding, the cron and CONFIG. `worker` is site/worker.js unless a test points elsewhere. */
|
|
154
|
+
export function wranglerConfig({ name, site, account, cron = "*/5 * * * *", config, url, ipfsGateway, worker = join(HERE, "../../site/worker.js") }) {
|
|
106
155
|
return {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
156
|
+
name, main: worker, compatibility_date: "2025-09-15", compatibility_flags: ["nodejs_compat"],
|
|
157
|
+
...(account ? { account_id: account } : {}),
|
|
158
|
+
assets: { directory: site, binding: "ASSETS" },
|
|
159
|
+
r2_buckets: [{ binding: "VIEW", bucket_name: `${name}-view` }],
|
|
160
|
+
ai: { binding: "AI" },
|
|
161
|
+
triggers: { crons: [cron] },
|
|
162
|
+
// ipfs.io answers a Worker's reads with 429s; the owner's gateway serves the owner's pins.
|
|
163
|
+
// ponytail: a dedicated Pinata gateway serves only its account's pins unless opened up;
|
|
164
|
+
// an app presenting other publishers' repos needs an open gateway here.
|
|
165
|
+
vars: { CONFIG: config, ...(ipfsGateway ? { IPFS_GATEWAY: ipfsGateway } : {}) },
|
|
166
|
+
// The Worker embeds with its AI binding; the in-process model is ~1.5 MB of bundle it never runs.
|
|
167
|
+
alias: { "@huggingface/transformers": join(HERE, "../../site/no-model.js") },
|
|
168
|
+
...(url ? { routes: [{ pattern: new URL(url).hostname, custom_domain: true }] } : {}),
|
|
110
169
|
};
|
|
111
170
|
}
|
|
112
171
|
|
|
@@ -115,25 +174,19 @@ export function schemaGraph(types, relations = []) {
|
|
|
115
174
|
const stable = (v) => Array.isArray(v) ? v.map(stable)
|
|
116
175
|
: v && typeof v === "object" ? Object.fromEntries(Object.keys(v).sort().map((k) => [k, stable(v[k])])) : v;
|
|
117
176
|
|
|
118
|
-
/** Same shape parseSchema returns, so a config and the chain compare directly. */
|
|
119
|
-
const canonical = (types, relations = []) => JSON.stringify(stable({
|
|
120
|
-
types: Object.fromEntries(Object.entries(types).sort(([a], [b]) => a.localeCompare(b))
|
|
121
|
-
.map(([tag, t]) => [tag, { description: t.description ?? "", role_map: t.role_map ?? {}, presentation: t.presentation ?? {} }])),
|
|
122
|
-
relations: [...relations].sort((a, b) => JSON.stringify(a).localeCompare(JSON.stringify(b))),
|
|
123
|
-
}));
|
|
124
|
-
|
|
125
177
|
// ── processes ─────────────────────────────────────────────────────────────────
|
|
126
178
|
|
|
127
179
|
/** `${VAR}` and `${VAR:-default}` from the environment, so one app.json runs on a laptop
|
|
128
180
|
* and in CI (e.g. `"${PYTHON:-python3}"`). */
|
|
129
181
|
export const expandEnv = (s) => s.replace(/\$\{(\w+)(?::-([^}]*))?\}/g, (_, k, d) => process.env[k] ?? d ?? "");
|
|
130
182
|
|
|
131
|
-
function run(cmd, args, { cwd, env, capture = false, dry = false } = {}) {
|
|
183
|
+
function run(cmd, args, { cwd, env, capture = false, dry = false, input } = {}) {
|
|
132
184
|
cmd = expandEnv(cmd); args = args.map(expandEnv);
|
|
133
185
|
log(`$ ${[cmd, ...args].join(" ")}${cwd ? ` (in ${cwd})` : ""}`);
|
|
134
186
|
if (dry) return "";
|
|
135
|
-
|
|
136
|
-
|
|
187
|
+
// `input`: what the command reads on stdin (a secret: never on the command line, never logged).
|
|
188
|
+
const r = spawnSync(cmd, args, { cwd, env: { ...process.env, ...env }, encoding: "utf8", input,
|
|
189
|
+
stdio: [input != null ? "pipe" : capture ? "ignore" : "inherit", capture ? "pipe" : "inherit", "inherit"] });
|
|
137
190
|
if (r.status !== 0) throw new Error(`${cmd} ${args[0]} failed (exit ${r.status})`);
|
|
138
191
|
return r.stdout ?? "";
|
|
139
192
|
}
|
|
@@ -147,6 +200,10 @@ const fangornCli = (app, args, opts = {}) => run(CLI[0], [...CLI.slice(1), "--ap
|
|
|
147
200
|
* and every read says the app is unclaimed. (It happened: a global 2026.08.18-dev CLI
|
|
148
201
|
* claimed and published onto the previous registries.) */
|
|
149
202
|
function assertSameDeployment(cli) {
|
|
203
|
+
// "env HOME=… node cli.js": a CLI with its own config (another wallet); find the script past the env.
|
|
204
|
+
let i = cli[0] === "env" ? 1 : 0;
|
|
205
|
+
while (cli[i]?.includes("=")) i++;
|
|
206
|
+
cli = cli.slice(i);
|
|
150
207
|
const which = (c) => spawnSync("sh", ["-c", `command -v ${c}`], { encoding: "utf8" }).stdout.trim();
|
|
151
208
|
const script = cli.length > 1 && /(^|\/)node$/.test(cli[0]) ? cli[1] : which(cli[0]);
|
|
152
209
|
if (!script) throw new Error(`fangorn CLI not found: ${cli.join(" ")}`);
|
|
@@ -160,12 +217,77 @@ function assertSameDeployment(cli) {
|
|
|
160
217
|
"they talk to different contracts. Point app.json's \"fangorn\" at a matching CLI.");
|
|
161
218
|
}
|
|
162
219
|
|
|
220
|
+
/** The block `appId` was claimed in, or undefined: the AppRegistered log, window by window. */
|
|
221
|
+
export async function claimBlock(chain, FangornConfig, appId) {
|
|
222
|
+
const { parseAbiItem } = await import("viem");
|
|
223
|
+
const from = BigInt(FangornConfig.appRegistryFromBlock), to = await chain.getBlockNumber(), step = BigInt(FangornConfig.logWindow ?? 10000);
|
|
224
|
+
const event = parseAbiItem("event AppRegistered(bytes32 indexed app_id, address indexed owner)");
|
|
225
|
+
for (let a = from; a <= to; a += step) {
|
|
226
|
+
const [claimed] = await chain.getLogs({ address: FangornConfig.appRegistryContractAddress, event, args: { app_id: appId },
|
|
227
|
+
fromBlock: a, toBlock: a + step - 1n < to ? a + step - 1n : to });
|
|
228
|
+
if (claimed) return String(claimed.blockNumber);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/** The template's app.json as `app`'s: its name, its type tag `<app>.item.v1` and the Worker. */
|
|
233
|
+
export const TEMPLATE_APP = "my-app";
|
|
234
|
+
export function nameApp(cfg, app) {
|
|
235
|
+
const from = `${TEMPLATE_APP}.item.v1`, tag = `${app}.item.v1`;
|
|
236
|
+
const types = Object.fromEntries(Object.entries(cfg.types ?? {}).map(([k, t]) =>
|
|
237
|
+
k === from ? [tag, JSON.parse(JSON.stringify(t).replaceAll(from, tag))] : [k, t]));
|
|
238
|
+
return { ...cfg, app, name: cfg.name === TEMPLATE_APP ? app : cfg.name, types,
|
|
239
|
+
site: { ...cfg.site, project: app.replace(/[._]/g, "-") } }; // a Worker name: letters, digits, dashes
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* `westmarch build`: what Workers Builds runs under the deploy button. The site, with a card
|
|
244
|
+
* that names ORIGIN for its own URL (the Worker fills it in), and CONFIG, into the app's own
|
|
245
|
+
* wrangler.json, which `wrangler deploy` then ships with the bucket, AI and cron it declares.
|
|
246
|
+
* No chain writes and no Cloudflare calls: the owner claims the app and registers its agent
|
|
247
|
+
* from fangorn.network. While app.json still names the template's app, the app is the Worker's name.
|
|
248
|
+
*
|
|
249
|
+
* ponytail: free apps only; a paid or private one ships with westmarch-ship, which sets its secret.
|
|
250
|
+
*/
|
|
251
|
+
export async function buildForDeploy(configPath, wranglerPath = join(dirname(resolve(configPath)), "wrangler.json")) {
|
|
252
|
+
const w = JSON.parse(readFileSync(wranglerPath, "utf8"));
|
|
253
|
+
let cfg = loadConfig(configPath);
|
|
254
|
+
if (cfg.app === TEMPLATE_APP) cfg = nameApp(cfg, w.name);
|
|
255
|
+
if (cfg.paid || cfg.private) throw new Error(`${configPath}: a paid or private app ships with westmarch-ship`);
|
|
256
|
+
if (!cfg.network) throw new Error(`${configPath}: "network" is required`);
|
|
257
|
+
if (!w.r2_buckets?.[0]?.bucket_name?.includes(w.name))
|
|
258
|
+
log(`the R2 bucket ${w.r2_buckets?.[0]?.bucket_name} doesn't name the Worker; two apps sharing one overwrite each other's view`);
|
|
259
|
+
|
|
260
|
+
process.env.FANGORN_NETWORK = process.env.CHAIN_NAME = cfg.network;
|
|
261
|
+
const [{ createPublicClient, http }, view, { ORIGIN }] = await Promise.all([import("viem"), import("./view.js"), import("../../site/worker.js")]);
|
|
262
|
+
const FangornConfig = await view.network(cfg.network);
|
|
263
|
+
const fangorn = await view.readOnlyFangorn();
|
|
264
|
+
fangorn.setAppId(cfg.app);
|
|
265
|
+
if (/^0x0+$/.test(await fangorn.getAppRegistry().getAppOwner()))
|
|
266
|
+
throw new Error(`${cfg.app} is unclaimed: claim it at fangorn.network first${/[._]/.test(cfg.app) ? "" : `, or set "app" in app.json to the name you claimed`}`);
|
|
267
|
+
const chain = createPublicClient({ transport: http(FangornConfig.rpcUrl) });
|
|
268
|
+
const fromBlock = cfg.fromBlock != null ? String(cfg.fromBlock) : await claimBlock(chain, FangornConfig, fangorn.getAppId());
|
|
269
|
+
|
|
270
|
+
const base = dirname(resolve(configPath));
|
|
271
|
+
const { site, writeCard } = await buildSite(cfg, base);
|
|
272
|
+
writeCard(ORIGIN, { fromBlock, repos: [] });
|
|
273
|
+
const gateway = process.env.FANGORN_IPFS_GATEWAY;
|
|
274
|
+
w.assets = { ...w.assets, directory: relative(dirname(resolve(wranglerPath)), site) };
|
|
275
|
+
w.vars = { ...w.vars, CONFIG: { app: cfg.app, name: cfg.name, description: cfg.description, fromBlock, network: cfg.network,
|
|
276
|
+
schema: { types: cfg.types, relations: cfg.relations }, repos: [], paid: null, private: null },
|
|
277
|
+
...(gateway ? { IPFS_GATEWAY: gateway } : {}) };
|
|
278
|
+
writeFileSync(wranglerPath, JSON.stringify(w, null, 1) + "\n");
|
|
279
|
+
log(`built ${cfg.app} (fromBlock ${fromBlock}) into ${site}; wrangler deploy ships it`);
|
|
280
|
+
}
|
|
281
|
+
|
|
163
282
|
// ── the steps ─────────────────────────────────────────────────────────────────
|
|
164
283
|
|
|
165
|
-
export async function ship(configPath, { crawl = true, deploy = true, dry = false, replace = false, only = null, register = false
|
|
284
|
+
export async function ship(configPath, { crawl = true, deploy = true, dry = false, replace = false, only = null, register = false } = {}) {
|
|
166
285
|
const cfg = loadConfig(configPath);
|
|
167
|
-
|
|
168
|
-
|
|
286
|
+
// No sources is fine: the app then presents whatever its members commit (repos: [] = all of them).
|
|
287
|
+
if (!register && !Object.keys(cfg.types).length)
|
|
288
|
+
throw new Error(`${configPath}: no types yet, so nothing to build; --register sets up the app alone`);
|
|
289
|
+
// No default: one that changed would claim every app that leaned on it again, elsewhere.
|
|
290
|
+
if (!cfg.network) throw new Error(`${configPath}: "network" is required: "baseSepolia" for a new app, or the network the app was claimed on (before 2026-10-20 the default was "arbitrumSepolia")`);
|
|
169
291
|
CLI = cliArgv(cfg);
|
|
170
292
|
assertSameDeployment(CLI);
|
|
171
293
|
const base = dirname(resolve(configPath));
|
|
@@ -174,23 +296,33 @@ export async function ship(configPath, { crawl = true, deploy = true, dry = fals
|
|
|
174
296
|
mkdirSync(dir, { recursive: true });
|
|
175
297
|
const state = existsSync(statePath) ? JSON.parse(readFileSync(statePath, "utf8")) : {};
|
|
176
298
|
const save = () => !dry && writeFileSync(statePath, JSON.stringify(state, null, 1));
|
|
299
|
+
// A private app's PAID_SECRET: $PAID_SECRET, else made once in .ship/secret. Losing it loses
|
|
300
|
+
// every sealed row, so it is never made again over one that exists.
|
|
301
|
+
const secretPath = join(dir, "secret");
|
|
302
|
+
const secret = () => {
|
|
303
|
+
if (process.env.PAID_SECRET) return process.env.PAID_SECRET;
|
|
304
|
+
if (!existsSync(secretPath)) writeFileSync(secretPath, randomBytes(32).toString("hex"), { mode: 0o600 });
|
|
305
|
+
return readFileSync(secretPath, "utf8").trim();
|
|
306
|
+
};
|
|
177
307
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
env.cacheDir = `${homedir()}/.cache/fangorn-mcp/models`;
|
|
308
|
+
// The SDK's network name: view.js reads with it, and the CLI and the sources spawned below sign on it.
|
|
309
|
+
process.env.FANGORN_NETWORK = process.env.CHAIN_NAME = cfg.network;
|
|
310
|
+
const [{ createPublicClient, http }, view] = await Promise.all([import("viem"), import("./view.js")]);
|
|
311
|
+
const FangornConfig = await view.network(cfg.network);
|
|
183
312
|
const fangorn = await view.readOnlyFangorn();
|
|
184
313
|
fangorn.setAppId(cfg.app);
|
|
185
314
|
const appId = fangorn.getAppId();
|
|
186
315
|
const registry = fangorn.getAppRegistry();
|
|
316
|
+
const cf = cfg.site.account ? { CLOUDFLARE_ACCOUNT_ID: cfg.site.account } : {};
|
|
187
317
|
|
|
188
|
-
// 1. claim
|
|
318
|
+
// 1. claim: pays the subscription (the app sponsors its members' storage) and makes the
|
|
319
|
+
// claimer the app's first member.
|
|
189
320
|
const me = (fangornCli(cfg.app, ["wallet"]).match(/Address:\s+(0x[0-9a-fA-F]{40})/) ?? [])[1]?.toLowerCase();
|
|
190
321
|
if (!me) throw new Error("`fangorn wallet` shows no address; run `fangorn init`");
|
|
191
322
|
let owner = (await registry.getAppOwner()).toLowerCase();
|
|
323
|
+
const chain = createPublicClient({ transport: http(FangornConfig.rpcUrl) });
|
|
192
324
|
if (/^0x0+$/.test(owner)) {
|
|
193
|
-
const block = await
|
|
325
|
+
const block = await chain.getBlockNumber();
|
|
194
326
|
state.fromBlock = String(block);
|
|
195
327
|
log(`${cfg.app} is unclaimed; claiming it for ${me} (fromBlock ${block})`);
|
|
196
328
|
fangornCli(cfg.app, ["app", "claim"], { dry });
|
|
@@ -199,31 +331,12 @@ export async function ship(configPath, { crawl = true, deploy = true, dry = fals
|
|
|
199
331
|
} else if (owner !== me) {
|
|
200
332
|
throw new Error(`${cfg.app} belongs to ${owner}, not this wallet (${me}); pick another name`);
|
|
201
333
|
}
|
|
202
|
-
|
|
334
|
+
// Claimed elsewhere (fangorn.network, the CLI): the view starts at the claim, found once.
|
|
335
|
+
if (state.fromBlock == null && cfg.fromBlock == null) state.fromBlock = await claimBlock(chain, FangornConfig, appId);
|
|
336
|
+
state.fromBlock ??= String(cfg.fromBlock ?? FangornConfig.appRegistryFromBlock);
|
|
203
337
|
log(`app ${cfg.app} = ${appId}, owner ${owner}, fromBlock ${state.fromBlock}`);
|
|
204
338
|
|
|
205
|
-
// 2.
|
|
206
|
-
// Both registries: claiming joins the owner to the app, but commits also need the
|
|
207
|
-
// wallet's global DataRegistry standing, or every push reverts NotRegistered().
|
|
208
|
-
const info = fangornCli(cfg.app, ["app", "info"]);
|
|
209
|
-
if (!/DataRegistry:\s+registered/.test(info) || !/This app:\s+joined/.test(info)) fangornCli(cfg.app, ["register"], { dry });
|
|
210
|
-
|
|
211
|
-
// 3. schema
|
|
212
|
-
let onChain = null;
|
|
213
|
-
if (!register) {
|
|
214
|
-
try { onChain = view.parseSchema((await fangorn.readNamespace(owner, view.SCHEMA_NAMESPACE)).contents); } catch { /* none yet */ }
|
|
215
|
-
if (!onChain || canonical(onChain.types, onChain.relations) !== canonical(cfg.types, cfg.relations)) {
|
|
216
|
-
const sdir = join(dir, "schema");
|
|
217
|
-
mkdirSync(sdir, { recursive: true });
|
|
218
|
-
writeFileSync(join(sdir, "graph.json"), JSON.stringify(schemaGraph(cfg.types, cfg.relations), null, 1));
|
|
219
|
-
log(`schema ${onChain ? "changed" : "is new"}: committing ${Object.keys(cfg.types).join(", ")}`);
|
|
220
|
-
fangornCli(cfg.app, ["repo", "init", view.SCHEMA_NAMESPACE], { cwd: sdir, dry });
|
|
221
|
-
fangornCli(cfg.app, ["commit", "graph.json", "-m", "schema", "--replace"], { cwd: sdir, dry });
|
|
222
|
-
fangornCli(cfg.app, ["push"], { cwd: sdir, dry });
|
|
223
|
-
} else log("schema unchanged");
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
// 4. sources: crawl + publish straight into the app. One source failing (a site that
|
|
339
|
+
// 2. sources: crawl + publish straight into the app. One source failing (a site that
|
|
227
340
|
// blocks us, a feed that is down) keeps its last published data and does not stop the
|
|
228
341
|
// others; the ship still exits non-zero at the end, naming it.
|
|
229
342
|
const failed = [];
|
|
@@ -231,101 +344,75 @@ export async function ship(configPath, { crawl = true, deploy = true, dry = fals
|
|
|
231
344
|
const cwd = s.cwd ? resolve(base, s.cwd.replace(/^~/, homedir())) : base;
|
|
232
345
|
const paidArgs = cfg.paid && s.paid_dir ? ["--paid-dir", resolve(cwd, s.paid_dir)] : [];
|
|
233
346
|
try {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
347
|
+
if (cfg.private) await publishSealed(cfg, base, s, { secret: secret(), dry });
|
|
348
|
+
else run(s.command[0], [...s.command.slice(1), ...paidArgs, ...(replace ? ["--replace"] : []),
|
|
349
|
+
"--publish", "--namespace", s.namespace, "--fangorn-bin", CLI.join(" ")],
|
|
350
|
+
{ cwd, env: { FANGORN_APP_ID: cfg.app }, dry });
|
|
237
351
|
} catch (e) {
|
|
238
352
|
log(`✗ ${s.namespace}: ${e.message}; its last published records stay live`);
|
|
239
353
|
failed.push(s.namespace);
|
|
240
354
|
}
|
|
241
355
|
}
|
|
242
356
|
|
|
243
|
-
//
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
357
|
+
// 3. the page, the card, the headers
|
|
358
|
+
const { site, writeCard } = await buildSite(cfg, base);
|
|
359
|
+
// site.url: the app's own domain, routed to the Worker. Otherwise its workers.dev URL,
|
|
360
|
+
// which is only known once it is deployed: the first deploy learns it and the card follows.
|
|
361
|
+
let url = cfg.site.url?.replace(/\/$/, "") ?? state.url ?? null;
|
|
362
|
+
const repos = [...new Set(cfg.sources.map((s) => s.namespace))];
|
|
363
|
+
// Paid records are in the committed rows already, encrypted (`paid_ct`: AES-256-GCM under
|
|
364
|
+
// HMAC-SHA256(PAID_SECRET, id), see x402.js). The Worker sells keys, never records, so the
|
|
365
|
+
// data a buyer pays for is on IPFS, committed, and in their hands before they pay.
|
|
366
|
+
const terms = (o) => settlement(o, { network: `eip155:${FangornConfig.caip2}`, owner });
|
|
367
|
+
const sale = (u) => {
|
|
368
|
+
if (!cfg.paid) return { paid: null, sale: null };
|
|
369
|
+
const T = terms(cfg.paid), price = units(cfg.paid.price, T.decimals), description = cfg.paid.description ?? "";
|
|
370
|
+
const paid = { url: `${u}/paid/{id}`, price, asset: T.asset, network: T.network, decimals: T.decimals, symbol: T.symbol, description };
|
|
371
|
+
return { paid, sale: { ...T, price, description } };
|
|
372
|
+
};
|
|
373
|
+
const access = (u) => {
|
|
374
|
+
const X = cfg.private;
|
|
375
|
+
if (!X) return { card: null, config: null };
|
|
376
|
+
if (!X.pass?.price || !X.call) throw new Error(`${configPath}: private needs pass.price and call, decimal prices like "5" and "0.01"`);
|
|
377
|
+
const T = terms(X), days = X.pass.days ?? 30, description = X.description ?? "";
|
|
378
|
+
const pass = { price: units(X.pass.price, T.decimals), seconds: Math.round(days * 86400) }, call = units(X.call, T.decimals);
|
|
379
|
+
return { card: { pass_url: `${u}/pass`, pass: pass.price, days, call, network: T.network, asset: T.asset, symbol: T.symbol, decimals: T.decimals, description },
|
|
380
|
+
config: { ...T, pass, call, description } };
|
|
381
|
+
};
|
|
382
|
+
const writeSite = (u) => writeCard(u, { fromBlock: state.fromBlock, repos, paid: sale(u).paid, access: access(u).card });
|
|
383
|
+
writeSite(url ?? `https://${cfg.site.project}.workers.dev`);
|
|
251
384
|
|
|
252
|
-
//
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
let paid = null, sale = null;
|
|
263
|
-
const live = view.liveFields(join(site, "view"));
|
|
264
|
-
if (cfg.paid) {
|
|
265
|
-
const network = cfg.paid.network ?? "arbitrum-sepolia";
|
|
266
|
-
const asset = cfg.paid.asset ?? USDC[network];
|
|
267
|
-
if (!asset) throw new Error(`paid.network ${network}: no default USDC address; set paid.asset`);
|
|
268
|
-
const decimals = cfg.paid.decimals ?? 6;
|
|
269
|
-
const [whole, frac = ""] = String(cfg.paid.price).split(".");
|
|
270
|
-
const price = (BigInt(whole) * 10n ** BigInt(decimals) + BigInt((frac + "0".repeat(decimals)).slice(0, decimals) || "0")).toString();
|
|
271
|
-
paid = { url: `${url}/paid/{id}`, price, asset, network, decimals, symbol: cfg.paid.symbol ?? "USDC", description: cfg.paid.description ?? "" };
|
|
272
|
-
// Only records a live row vouches for (its committed paid_sha256): one left over from
|
|
273
|
-
// an item since removed or re-extracted is not for sale, whatever is still on disk.
|
|
274
|
-
rmSync(join(site, "_paid"), { recursive: true, force: true });
|
|
275
|
-
mkdirSync(join(site, "_paid"), { recursive: true });
|
|
276
|
-
const vouched = new Set(live.map((f) => f.paid_sha256).filter(Boolean));
|
|
277
|
-
let n = 0;
|
|
278
|
-
for (const s of cfg.sources) {
|
|
279
|
-
const d = s.paid_dir && resolve(s.cwd ? resolve(base, s.cwd.replace(/^~/, homedir())) : base, s.paid_dir);
|
|
280
|
-
if (d && existsSync(d)) for (const f of readdirSync(d)) {
|
|
281
|
-
const bytes = readFileSync(join(d, f));
|
|
282
|
-
if (!vouched.has(createHash("sha256").update(bytes).digest("hex"))) continue;
|
|
283
|
-
writeFileSync(join(site, "_paid", f), bytes); n++;
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
sale = { price, network, asset, payTo: cfg.paid.payTo ?? owner, facilitator: cfg.paid.facilitator ?? "https://facilitator.payai.network",
|
|
287
|
-
name: cfg.paid.tokenName ?? "USD Coin", version: cfg.paid.tokenVersion ?? "2", description: paid.description };
|
|
288
|
-
log(`paid: ${n} record(s) at ${cfg.paid.price} ${paid.symbol} on ${network}, to ${sale.payTo}`);
|
|
289
|
-
}
|
|
290
|
-
// The worker: paid records if any, and each record's source document shown in the page.
|
|
291
|
-
// Only the hosts the app's own records link to (their media role) are proxied.
|
|
292
|
-
const media = Object.values(cfg.types).flatMap((t) => [t.role_map?.media ?? []].flat());
|
|
293
|
-
const docHosts = [...new Set(live.flatMap((f) => media.map((m) => f[m])).filter((u) => typeof u === "string" && u.startsWith("https://"))
|
|
294
|
-
.map((u) => { try { return new URL(u).hostname; } catch { return null; } }).filter(Boolean))].sort();
|
|
295
|
-
writeFileSync(join(site, "_worker.js"), readFileSync(join(HERE, "../../site/worker.js"), "utf8")
|
|
296
|
-
.replace(/\/\*CONFIG\*\/[\s\S]*?\/\*END\*\//, JSON.stringify({ docHosts, paid: sale })));
|
|
297
|
-
log(`documents: shown inline from ${docHosts.length} source host(s)`);
|
|
298
|
-
// The card lists the tools the page at `url` registers: the stock page's, or the app's own.
|
|
299
|
-
const { registerAgent } = await import(cfg.site.agent ? pathToFileURL(resolve(base, cfg.site.agent)).href : "../../site/agent.js");
|
|
300
|
-
const agentCard = card.agentCard({
|
|
301
|
-
name: cfg.name, description: cfg.description, url: `${url}/`, version: new Date().toISOString().slice(0, 10),
|
|
302
|
-
tools: await card.captureTools(() => registerAgent({})), tags: cfg.tags,
|
|
303
|
-
fangorn: { app: cfg.app, fromBlock: state.fromBlock, namespaces, views: [`${url}/view`], ...(paid ? { paid } : {}) },
|
|
304
|
-
});
|
|
305
|
-
mkdirSync(join(site, ".well-known"), { recursive: true });
|
|
306
|
-
writeFileSync(join(site, ".well-known/agent-card.json"), JSON.stringify(agentCard, null, 1));
|
|
307
|
-
const immutable = " Cache-Control: public, max-age=31536000, immutable\n";
|
|
308
|
-
const domains = existsSync(join(site, "view/cdn/domains")) ? readdirSync(join(site, "view/cdn/domains")) : [];
|
|
309
|
-
writeFileSync(join(site, "_headers"),
|
|
310
|
-
"/.well-known/agent-card.json\n Access-Control-Allow-Origin: *\n"
|
|
311
|
-
+ "/view/*\n Access-Control-Allow-Origin: *\n"
|
|
312
|
-
+ `/assets/*\n${immutable}`
|
|
313
|
-
// A shard's name is its content hash, so a browser may keep it for good: a change or a
|
|
314
|
-
// retraction writes new names and the manifest stops pointing at the old ones. `private`
|
|
315
|
-
// keeps it out of shared caches, so a retracted record's bytes stop being served the
|
|
316
|
-
// moment the deploy drops the file (see view.js). An hour made readers on a phone fetch
|
|
317
|
-
// the whole catalog again after every hour away.
|
|
318
|
-
+ domains.map((d) => `/view/cdn/domains/${d}/shards/*\n Cache-Control: private, max-age=31536000, immutable\n`).join(""));
|
|
319
|
-
|
|
320
|
-
// 7. deploy
|
|
385
|
+
// 4. the Worker
|
|
386
|
+
const workerConfig = (u) => {
|
|
387
|
+
const path = join(dir, "wrangler.json");
|
|
388
|
+
writeFileSync(path, JSON.stringify(wranglerConfig({
|
|
389
|
+
name: cfg.site.project, site, account: cfg.site.account, cron: cfg.site.cron, url: cfg.site.url, ipfsGateway: view.ipfsGateway(),
|
|
390
|
+
config: { app: cfg.app, name: cfg.name, description: cfg.description, fromBlock: state.fromBlock, network: cfg.network,
|
|
391
|
+
schema: { types: cfg.types, relations: cfg.relations }, repos: register ? [] : repos, paid: sale(u).sale, private: access(u).config },
|
|
392
|
+
}), null, 1));
|
|
393
|
+
return path;
|
|
394
|
+
};
|
|
321
395
|
if (deploy) {
|
|
322
|
-
|
|
323
|
-
|
|
396
|
+
const bucket = `${cfg.site.project}-view`;
|
|
397
|
+
const buckets = run("npx", ["wrangler", "r2", "bucket", "list"], { env: cf, capture: true, dry });
|
|
398
|
+
if (!dry && !buckets.split("\n").some((l) => l.trim() === `name: ${bucket}` || l.includes(` ${bucket}`)))
|
|
399
|
+
run("npx", ["wrangler", "r2", "bucket", "create", bucket], { env: cf });
|
|
400
|
+
const out = run("npx", ["wrangler", "deploy", "--config", workerConfig(url ?? "https://pending.invalid")], { env: cf, capture: true, dry });
|
|
401
|
+
const deployed = (out.match(/https:\/\/[a-z0-9.-]+\.workers\.dev/) ?? [])[0];
|
|
402
|
+
if (!url) {
|
|
403
|
+
if (!deployed && !dry) throw new Error("wrangler deploy printed no workers.dev URL; set site.url");
|
|
404
|
+
url = deployed ?? `https://${cfg.site.project}.workers.dev`;
|
|
405
|
+
// The card and CONFIG name the URL, which the first deploy only now learned.
|
|
406
|
+
writeSite(url);
|
|
407
|
+
run("npx", ["wrangler", "deploy", "--config", workerConfig(url)], { env: cf, capture: true, dry });
|
|
408
|
+
}
|
|
324
409
|
state.url = url;
|
|
325
410
|
save();
|
|
326
|
-
|
|
411
|
+
if (cfg.private) run("npx", ["wrangler", "secret", "put", "PAID_SECRET", "--config", workerConfig(url)], { env: cf, capture: true, dry, input: secret() });
|
|
412
|
+
else if (cfg.paid) log("paid: set the key secret once with `npx wrangler secret put PAID_SECRET --config .ship/wrangler.json`");
|
|
413
|
+
} else workerConfig(url ?? `https://${cfg.site.project}.workers.dev`);
|
|
327
414
|
|
|
328
|
-
//
|
|
415
|
+
// 5. ERC-8004 + the binding
|
|
329
416
|
const cardUrl = `${url}/.well-known/agent-card.json`;
|
|
330
417
|
const bound = await registry.appAgentUri(appId).catch(() => "");
|
|
331
418
|
const mint = () => {
|
|
@@ -347,39 +434,151 @@ export async function ship(configPath, { crawl = true, deploy = true, dry = fals
|
|
|
347
434
|
mint();
|
|
348
435
|
} else if (deploy) log("card already bound");
|
|
349
436
|
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
437
|
+
// A new app has no view until the cron runs, which may be hours off: build the first one now.
|
|
438
|
+
if (deploy && !dry && !register && cfg.sources.length && !await fetch(`${url}/view/cdn/catalog`).then((r) => r.ok, () => false)) {
|
|
439
|
+
log("no view yet: indexing it here rather than waiting for the cron");
|
|
440
|
+
await indexHere(configPath).catch((e) => log(`✗ first index: ${e.message}; the cron will build it`));
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
// The Bazaar: the facilitator lists POST /paid once it settles a sale (and decides to);
|
|
444
|
+
// nothing here can list it sooner, so ship only says where it stands.
|
|
445
|
+
if (deploy && (cfg.paid || cfg.private) && !dry) for (const [route, T] of [["paid", sale(url).sale], ["pass", access(url).config]]) {
|
|
446
|
+
if (!T) continue;
|
|
447
|
+
const listed = await fetch(`${T.facilitator}/discovery/resources?payTo=${T.payTo}`).then((r) => r.json())
|
|
448
|
+
.then((d) => (d.items ?? []).some((i) => i.resource === `${url}/${route}`), () => null);
|
|
449
|
+
log(listed ? `the Bazaar at ${T.facilitator} lists ${url}/${route}`
|
|
450
|
+
: listed === false ? `the Bazaar at ${T.facilitator} does not list ${url}/${route} yet: it is listed on its first sale`
|
|
451
|
+
: `could not read the Bazaar at ${T.facilitator}`);
|
|
353
452
|
}
|
|
354
|
-
|
|
355
|
-
log(`done: ${url} · card ${cardUrl} ·
|
|
453
|
+
|
|
454
|
+
log(`done: ${url} · card ${cardUrl} · MCP ${url}/mcp · the view fills on the Worker's next cron run`);
|
|
356
455
|
if (failed.length) throw new Error(`deployed, but these sources failed and kept their old records: ${failed.join(", ")}`);
|
|
357
|
-
return { url, cardUrl, agentId: state.agentId
|
|
456
|
+
return { url, cardUrl, agentId: state.agentId };
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
/** A private app's source: staged (it needs an --output-dir), every row sealed whole, and committed
|
|
460
|
+
* as a full snapshot. Unchanged rows seal to the same bytes, so the Worker embeds only what changed. */
|
|
461
|
+
async function publishSealed(cfg, base, s, { secret, dry }) {
|
|
462
|
+
const { sealRow } = await import("../agent/x402.js");
|
|
463
|
+
const rows = readStage({ ...cfg, sources: [s] }, base, { crawl: true })[s.namespace];
|
|
464
|
+
const sdir = join(base, ".ship/sealed", s.namespace);
|
|
465
|
+
mkdirSync(sdir, { recursive: true });
|
|
466
|
+
const records = await Promise.all(rows.map(async (r) => ({ id: r.id, type: r.type, payload: await sealRow(secret, r.payload) })));
|
|
467
|
+
writeFileSync(join(sdir, "commit.json"), JSON.stringify({ records }));
|
|
468
|
+
log(`${s.namespace}: ${records.length} rows sealed`);
|
|
469
|
+
try { fangornCli(cfg.app, ["status"], { cwd: sdir, dry }); } catch { fangornCli(cfg.app, ["repo", "init", s.namespace], { cwd: sdir, dry }); }
|
|
470
|
+
fangornCli(cfg.app, ["commit", "commit.json", "-m", `${s.namespace}: ${records.length} rows, sealed`, "--replace"], { cwd: sdir, dry });
|
|
471
|
+
fangornCli(cfg.app, ["push"], { cwd: sdir, dry });
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
/** What x402scan reads (docs/DISCOVERY.md in Merit-Systems/x402scan): /openapi.json with
|
|
475
|
+
* `x-payment-info` on each paid route, and /.well-known/x402 naming them. POST /paid (keys to
|
|
476
|
+
* sealed records) and POST /pass (a private app's pass); not GET /paid/{id}, a template no probe
|
|
477
|
+
* can call. The worker's live 402 is authoritative over both. A private app's tools, paid per
|
|
478
|
+
* call over MCP, are listed in the Bazaar instead: x402scan reads HTTP routes only.
|
|
479
|
+
* ponytail: currency "USD" assumes the asset is USDC, the only default ship knows. */
|
|
480
|
+
export function discovery(cfg, u, paid = null, access = null) {
|
|
481
|
+
const token = paid ?? access;
|
|
482
|
+
const usd = (n) => String(Number(n) / 10 ** (token.decimals ?? 6));
|
|
483
|
+
const ids = { type: "array", items: { type: "string" }, minItems: 1, maxItems: 1000 };
|
|
484
|
+
const sym = token.symbol ?? "USDC";
|
|
485
|
+
const paths = {};
|
|
486
|
+
if (paid) paths["/paid"] = { post: {
|
|
487
|
+
operationId: "buyKeys",
|
|
488
|
+
summary: `Keys to ${cfg.name}'s sealed records, ${usd(paid.price)} ${sym} each`,
|
|
489
|
+
description: `${paid.description ? `${paid.description}. ` : ""}Each record is in the app's rows already, sealed (paid_ct, `
|
|
490
|
+
+ `AES-256-GCM, with paid_sha256 of the plaintext): this sells its key. Find records and their ids with the MCP server at ${u}/mcp; `
|
|
491
|
+
+ `the agent card is ${u}/.well-known/agent-card.json.`,
|
|
492
|
+
requestBody: { required: true, content: { "application/json": { schema: { type: "object", required: ["ids"], properties: { ids } } } } },
|
|
493
|
+
responses: {
|
|
494
|
+
200: { description: "A hex key per id; ids it could not sell are in missing", content: { "application/json": { schema: { type: "object", properties: {
|
|
495
|
+
keys: { type: "object", additionalProperties: { type: "string" } }, missing: ids, receipts: { type: "array", items: { type: "object" } },
|
|
496
|
+
paid: { type: "array", items: { type: "string" } } } } } } },
|
|
497
|
+
402: { description: "Payment required: x402 v2, the PaymentRequired in the PAYMENT-REQUIRED header" },
|
|
498
|
+
},
|
|
499
|
+
"x-payment-info": { protocols: [{ x402: {} }], price: { mode: "dynamic", currency: "USD", min: usd(paid.price), max: usd(BigInt(paid.price) * 1000n) } },
|
|
500
|
+
} };
|
|
501
|
+
if (access) paths["/pass"] = { post: {
|
|
502
|
+
operationId: "buyPass",
|
|
503
|
+
summary: `A ${access.days}-day pass to ${cfg.name}, ${usd(access.pass)} ${sym}`,
|
|
504
|
+
description: `${access.description ? `${access.description}. ` : ""}Every tool of the MCP server at ${u}/mcp (search, get, similar, count, `
|
|
505
|
+
+ `browse) and the view at ${u}/view, for ${access.days} days: send Authorization: Bearer <token>. Without a pass each tool call costs `
|
|
506
|
+
+ `${usd(access.call)} ${sym} over x402's MCP transport.`,
|
|
507
|
+
responses: {
|
|
508
|
+
200: { description: "The pass", content: { "application/json": { schema: { type: "object", properties: {
|
|
509
|
+
token: { type: "string" }, expires: { type: "integer", description: "Unix seconds" }, use: { type: "string" } } } } } },
|
|
510
|
+
402: { description: "Payment required: x402 v2, the PaymentRequired in the PAYMENT-REQUIRED header" },
|
|
511
|
+
},
|
|
512
|
+
"x-payment-info": { protocols: [{ x402: {} }], price: { mode: "fixed", currency: "USD", amount: usd(access.pass) } },
|
|
513
|
+
} };
|
|
514
|
+
const guidance = access
|
|
515
|
+
? `${cfg.name}'s data is private. describe on the MCP server at ${u}/mcp is free. Buy a pass (POST /pass, x402 v2) and send `
|
|
516
|
+
+ `Authorization: Bearer <token> to ${u}/mcp, or pay each tool call over x402's MCP transport (_meta["x402/payment"]).`
|
|
517
|
+
: `Search ${cfg.name} with the MCP server at ${u}/mcp (free). A row with paid_ct is for sale: POST its id to /paid, `
|
|
518
|
+
+ `pay the 402 (x402 v2), and open paid_ct with the key that comes back (AES-256-GCM, nonce first; check paid_sha256).`;
|
|
519
|
+
return {
|
|
520
|
+
openapi: {
|
|
521
|
+
openapi: "3.1.0",
|
|
522
|
+
info: { title: cfg.name, version: new Date().toISOString().slice(0, 10), description: cfg.description, "x-guidance": guidance },
|
|
523
|
+
servers: [{ url: u }],
|
|
524
|
+
paths,
|
|
525
|
+
},
|
|
526
|
+
x402: { version: 1, resources: Object.keys(paths).map((p) => `${u}${p}`) },
|
|
527
|
+
};
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
/** The stock page with the app's own files over it, in .ship/site; `writeCard(url, …)` adds the card for where it is served. */
|
|
531
|
+
export async function buildSite(cfg, base) {
|
|
532
|
+
if (!existsSync(join(STOCK, "index.html"))) throw new Error(`no stock page at ${STOCK}; run \`npx vite build\` in westmarch/site`);
|
|
533
|
+
const site = join(base, ".ship/site");
|
|
534
|
+
rmSync(site, { recursive: true, force: true });
|
|
535
|
+
mkdirSync(site, { recursive: true });
|
|
536
|
+
cpSync(STOCK, site, { recursive: true });
|
|
537
|
+
if (cfg.site.pages) cpSync(resolve(base, cfg.site.pages), site, { recursive: true });
|
|
538
|
+
writeFileSync(join(site, "nav.json"), JSON.stringify(cfg.site.nav ?? []));
|
|
539
|
+
writeFileSync(join(site, "examples.json"), JSON.stringify(cfg.site.examples ?? []));
|
|
540
|
+
// The card lists the tools the page at `url` registers: the stock page's, or the app's own.
|
|
541
|
+
const card = await import("../agent/agent-card.js");
|
|
542
|
+
const { registerAgent } = await import(cfg.site.agent ? pathToFileURL(resolve(base, cfg.site.agent)).href : "../../site/agent.js");
|
|
543
|
+
const tools = await card.captureTools(() => registerAgent({}));
|
|
544
|
+
const config = await (await import("./view.js")).network(cfg.network);
|
|
545
|
+
const writeCard = (u, { fromBlock, repos, paid = null, access = null }) => {
|
|
546
|
+
const agentCard = card.agentCard({
|
|
547
|
+
name: cfg.name, description: cfg.description, url: `${u}/`, version: new Date().toISOString().slice(0, 10), tools, tags: cfg.tags,
|
|
548
|
+
// What is sold, as a skill tagged x402: ERC-8004 registration reads x402Support off the tags.
|
|
549
|
+
skills: [
|
|
550
|
+
...(access ? [{ id: "pass", name: "Pass", tags: [...(cfg.tags ?? []), "x402"],
|
|
551
|
+
description: `A ${access.days}-day pass to every tool and the view (POST ${u}/pass), or one x402 payment per tool call.` }] : []),
|
|
552
|
+
...(paid ? [{ id: "keys", name: "Keys", tags: [...(cfg.tags ?? []), "x402"],
|
|
553
|
+
description: `The keys to sealed records (POST ${u}/paid), per record.` }] : []),
|
|
554
|
+
],
|
|
555
|
+
fangorn: { app: cfg.app, fromBlock, repos, views: [`${u}/view`], mcp: `${u}/mcp`, config, ...(paid ? { paid } : {}), ...(access ? { access } : {}) },
|
|
556
|
+
});
|
|
557
|
+
mkdirSync(join(site, ".well-known"), { recursive: true });
|
|
558
|
+
writeFileSync(join(site, ".well-known/agent-card.json"), JSON.stringify(agentCard, null, 1));
|
|
559
|
+
if (paid || access) {
|
|
560
|
+
const d = discovery(cfg, u, paid, access);
|
|
561
|
+
writeFileSync(join(site, "openapi.json"), JSON.stringify(d.openapi, null, 1));
|
|
562
|
+
writeFileSync(join(site, ".well-known/x402"), JSON.stringify(d.x402, null, 1));
|
|
563
|
+
}
|
|
564
|
+
writeFileSync(join(site, "_headers"), "/.well-known/agent-card.json\n Access-Control-Allow-Origin: *\n"
|
|
565
|
+
+ "/openapi.json\n Access-Control-Allow-Origin: *\n"
|
|
566
|
+
+ "/.well-known/x402\n Access-Control-Allow-Origin: *\n Content-Type: application/json\n"
|
|
567
|
+
+ "/assets/*\n Cache-Control: public, max-age=31536000, immutable\n");
|
|
568
|
+
};
|
|
569
|
+
return { site, writeCard };
|
|
358
570
|
}
|
|
359
571
|
|
|
360
572
|
/**
|
|
361
|
-
*
|
|
362
|
-
*
|
|
363
|
-
* The sources run without --publish, or not at all with crawl=false. Every build is whole
|
|
364
|
-
* (a changed `text` role must reach every row, and publishView re-embeds only new CIDs);
|
|
365
|
-
* `.ship/vectors.ndjson` keeps it cheap, so two recipes over the same data embed only the
|
|
366
|
-
* text that differs.
|
|
573
|
+
* What each source staged in its --output-dir, as records: `{namespace: [{id, type, payload}]}`.
|
|
574
|
+
* The sources run first (without --publish) with crawl=true.
|
|
367
575
|
*
|
|
368
576
|
* ponytail: reads every `volume_<n>_*.json` in a source's --output-dir; the
|
|
369
577
|
* harness publishes only the stems its source declares, so a stale file left by an older
|
|
370
|
-
* shape of a source is
|
|
578
|
+
* shape of a source is read here and not on chain. Clear the stage dir if that bites.
|
|
371
579
|
*/
|
|
372
|
-
export
|
|
373
|
-
const
|
|
374
|
-
const base = dirname(resolve(configPath));
|
|
375
|
-
const [{ env }, view] = await Promise.all([import("@huggingface/transformers"), import("./view.js")]);
|
|
376
|
-
env.cacheDir = `${homedir()}/.cache/fangorn-mcp/models`;
|
|
377
|
-
// Not the app's real id or owner: nothing here is compared with the chain.
|
|
378
|
-
const appId = `0x${createHash("sha256").update(cfg.app).digest("hex")}`, owner = `0x${"10ca1".padStart(40, "0")}`;
|
|
379
|
-
const g = schemaGraph(cfg.types, cfg.relations);
|
|
380
|
-
const chain = { [`${owner}/${view.SCHEMA_NAMESPACE}`]: {
|
|
381
|
-
vertices: g.vertices.map((v) => ({ cid: v.id, schemaId: v.tag, payload: v.payload })),
|
|
382
|
-
edges: g.edges.map((e) => ({ relation: e.rel, sourceCid: e.from, targetCid: e.to })) } };
|
|
580
|
+
export function readStage(cfg, base, { crawl = false, only = null, log: say = log } = {}) {
|
|
581
|
+
const out = {};
|
|
383
582
|
for (const s of cfg.sources.filter((s) => !only || only.includes(s.namespace))) {
|
|
384
583
|
const cwd = s.cwd ? resolve(base, s.cwd.replace(/^~/, homedir())) : base;
|
|
385
584
|
if (crawl) run(s.command[0], s.command.slice(1), { cwd, env: { FANGORN_APP_ID: cfg.app } });
|
|
@@ -387,122 +586,215 @@ export async function buildLocal(configPath, out, { crawl = false, only = null,
|
|
|
387
586
|
if (at < 0) { say(`${s.namespace}: no --output-dir in its command, so nothing staged to read`); continue; }
|
|
388
587
|
const dir = resolve(cwd, expandEnv(s.command[at + 1]));
|
|
389
588
|
const volume = s.command.includes("--volume") ? s.command[s.command.indexOf("--volume") + 1] : "1";
|
|
390
|
-
const
|
|
391
|
-
const
|
|
589
|
+
const records = (out[s.namespace] ??= []);
|
|
590
|
+
const byName = new Map();
|
|
392
591
|
for (const f of existsSync(dir) ? readdirSync(dir).sort() : []) {
|
|
393
592
|
const m = new RegExp(`^volume_${volume}_(.+)\\.json$`).exec(f);
|
|
394
593
|
if (!m || m[1] === "edges") continue;
|
|
395
|
-
// The harness
|
|
396
|
-
// addresses it by the payload's hash, and so does this.
|
|
594
|
+
// The harness stages {name, fields}: the record's id and its payload.
|
|
397
595
|
for (const n of JSON.parse(readFileSync(join(dir, f), "utf8"))) {
|
|
398
|
-
const
|
|
399
|
-
|
|
400
|
-
|
|
596
|
+
const r = { id: n.name, type: n.fields?.entityType ?? m[1][0].toUpperCase() + m[1].slice(1), payload: { ...n.fields } };
|
|
597
|
+
byName.set(n.name, r);
|
|
598
|
+
records.push(r);
|
|
401
599
|
}
|
|
402
600
|
}
|
|
403
|
-
// Edges name
|
|
601
|
+
// Edges name records by the harness's ids: each becomes a reference on its source.
|
|
404
602
|
const edges = join(dir, `volume_${volume}_edges.json`);
|
|
405
603
|
for (const e of existsSync(edges) ? JSON.parse(readFileSync(edges, "utf8")) : [])
|
|
406
|
-
if (
|
|
604
|
+
if (byName.has(e.from) && byName.has(e.to)) byName.get(e.from).payload[e.rel] = { local: e.to };
|
|
407
605
|
}
|
|
408
606
|
// An empty stage is a crawl that did not happen (or a cache that was not restored), not
|
|
409
607
|
// an app with no records; a view of it would grade as a failure for the wrong reason.
|
|
410
|
-
|
|
411
|
-
|
|
608
|
+
if (!Object.values(out).some((rs) => rs.length))
|
|
609
|
+
throw new Error("no staged records under any source's --output-dir: run the sources (--crawl, or a ship) or restore .ship/stage first");
|
|
610
|
+
return out;
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
/**
|
|
614
|
+
* The whole app on this machine (devnet.js): a local chain and IPFS, the app claimed there, what the sources staged published into it, and its Worker under
|
|
615
|
+
* `wrangler dev` with a local R2 and an encoder on localhost (or Workers AI with ai=true).
|
|
616
|
+
* Runs the indexer once, says where everything is, and stays up until interrupted.
|
|
617
|
+
*/
|
|
618
|
+
export async function devnetShip(configPath, { crawl = false, only = null, port = 8787, ai = false } = {}) {
|
|
619
|
+
const cfg = loadConfig(configPath);
|
|
620
|
+
const base = dirname(resolve(configPath));
|
|
621
|
+
const { devnet } = await import("./devnet.js");
|
|
622
|
+
const staged = readStage(cfg, base, { crawl, only });
|
|
623
|
+
const net = await devnet({ log });
|
|
624
|
+
const owner = await net.client(cfg.app);
|
|
625
|
+
await owner.getAppRegistry().registerApp();
|
|
626
|
+
// The claimer publishes the sources, as `fangorn` does in a ship.
|
|
627
|
+
for (const [ns, records] of Object.entries(staged)) {
|
|
628
|
+
if (!records.length) continue;
|
|
629
|
+
await owner.initRepo(ns);
|
|
630
|
+
await owner.uploadBatch(ns, records);
|
|
631
|
+
log(`published ${ns}: ${records.length} records`);
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
const url = `http://127.0.0.1:${port}`;
|
|
635
|
+
const repos = Object.keys(staged);
|
|
636
|
+
const { site, writeCard } = await buildSite(cfg, base);
|
|
637
|
+
writeCard(url, { fromBlock: "0", repos });
|
|
638
|
+
const wcfg = wranglerConfig({ name: cfg.site.project, site, config: { app: cfg.app, name: cfg.name, description: cfg.description,
|
|
639
|
+
fromBlock: "0", schema: { types: cfg.types, relations: cfg.relations }, repos, paid: null, deployment: net.deployment } });
|
|
640
|
+
// Its own R2 and state, apart from a deployed app's.
|
|
641
|
+
wcfg.vars.RPC_URL = net.rpcUrl;
|
|
642
|
+
wcfg.vars.IPFS_GATEWAY = net.gatewayUrl;
|
|
643
|
+
if (!ai) { wcfg.vars.EMBED_URL = await net.encoder(); delete wcfg.ai; } // no binding: wrangler would reach Cloudflare for it
|
|
644
|
+
delete wcfg.routes;
|
|
645
|
+
const wpath = join(base, ".ship/wrangler.devnet.json");
|
|
646
|
+
writeFileSync(wpath, JSON.stringify(wcfg, null, 1));
|
|
647
|
+
rmSync(join(base, ".ship/devnet-state"), { recursive: true, force: true }); // a fresh chain: last run's view is of another one
|
|
648
|
+
const wrangler = spawn("npx", ["wrangler", "dev", "--config", wpath, "--port", String(port), "--ip", "127.0.0.1", "--test-scheduled",
|
|
649
|
+
"--persist-to", join(base, ".ship/devnet-state")], { cwd: join(HERE, "../.."), stdio: ["ignore", "inherit", "inherit"],
|
|
650
|
+
env: { ...process.env, ...(ai && cfg.site.account ? { CLOUDFLARE_ACCOUNT_ID: cfg.site.account } : {}) } });
|
|
651
|
+
net.kids.push(wrangler);
|
|
652
|
+
const up = async () => { for (;;) { if (wrangler.exitCode !== null) throw new Error("wrangler dev exited");
|
|
653
|
+
if (await fetch(url).then((r) => r.ok, () => false)) return; await new Promise((r) => setTimeout(r, 1000)); } };
|
|
654
|
+
await up();
|
|
655
|
+
log(`indexing (the cron, once): ${repos.length} repos`);
|
|
656
|
+
await fetch(`${url}/__scheduled?cron=${encodeURIComponent(wcfg.triggers.crons[0])}`);
|
|
657
|
+
const want = Object.values(staged).filter((rs) => rs.length).length;
|
|
658
|
+
let catalog = null;
|
|
659
|
+
while ((catalog?.domains?.length ?? 0) < want) {
|
|
660
|
+
if (wrangler.exitCode !== null) throw new Error("wrangler dev exited");
|
|
661
|
+
await new Promise((r) => setTimeout(r, 5000));
|
|
662
|
+
catalog = await fetch(`${url}/view/cdn/catalog`).then((r) => r.ok ? r.json() : null, () => null);
|
|
663
|
+
}
|
|
664
|
+
log(`done: ${catalog?.domains?.length ?? 0} domains, ${(catalog?.domains ?? []).reduce((n, d) => n + d.count, 0)} rows`);
|
|
665
|
+
log(`site ${url} · MCP ${url}/mcp · view ${url}/view · reindex: curl '${url}/__scheduled' · Ctrl-C stops it all`);
|
|
666
|
+
log(`grade it: npx westmarch-eval ${url}/view --golden eval/golden.jsonl`);
|
|
667
|
+
await new Promise((r) => wrangler.on("exit", r));
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
/**
|
|
671
|
+
* The deployed app's indexer, run once on this machine: its Worker under `wrangler dev` with
|
|
672
|
+
* the app's own R2 bucket and Workers AI (remote bindings), its CONFIG, and for a private app
|
|
673
|
+
* its PAID_SECRET (in .ship/.dev.vars for the run, then removed). The first view right after a
|
|
674
|
+
* deploy, without waiting for the cron; and a catalog too big for one cron run's limits, since
|
|
675
|
+
* nothing here is capped. Writes the same view the cron would.
|
|
676
|
+
* ponytail: Workers AI still embeds; an encoder on this machine (EMBED_URL) would record another
|
|
677
|
+
* embedder, and the deployed Worker's queries would not match it.
|
|
678
|
+
*/
|
|
679
|
+
export async function indexHere(configPath, { port = 8791 } = {}) {
|
|
680
|
+
const cfg = loadConfig(configPath);
|
|
681
|
+
const base = dirname(resolve(configPath)), dir = join(base, ".ship");
|
|
682
|
+
if (!existsSync(join(dir, "wrangler.json"))) throw new Error(`${dir}/wrangler.json: ship the app first`);
|
|
683
|
+
const w = JSON.parse(readFileSync(join(dir, "wrangler.json"), "utf8"));
|
|
684
|
+
w.r2_buckets = w.r2_buckets.map((b) => ({ ...b, remote: true }));
|
|
685
|
+
w.ai = { ...w.ai, remote: true };
|
|
686
|
+
delete w.routes;
|
|
687
|
+
const wpath = join(dir, "wrangler.index.json"), vars = join(dir, ".dev.vars");
|
|
688
|
+
writeFileSync(wpath, JSON.stringify(w, null, 1));
|
|
689
|
+
const secret = process.env.PAID_SECRET ?? (existsSync(join(dir, "secret")) ? readFileSync(join(dir, "secret"), "utf8").trim() : null);
|
|
690
|
+
if (cfg.private && !secret) throw new Error("a private app's rows open only with its PAID_SECRET: none in $PAID_SECRET or .ship/secret");
|
|
691
|
+
if (secret) writeFileSync(vars, `PAID_SECRET=${secret}\n`, { mode: 0o600 });
|
|
692
|
+
const url = `http://127.0.0.1:${port}`, start = Math.floor(Date.now() / 1000);
|
|
693
|
+
const wrangler = spawn("npx", ["wrangler", "dev", "--config", wpath, "--port", String(port), "--ip", "127.0.0.1", "--test-scheduled"],
|
|
694
|
+
{ cwd: join(HERE, "../.."), stdio: ["ignore", "inherit", "inherit"],
|
|
695
|
+
env: { ...process.env, ...(cfg.site.account ? { CLOUDFLARE_ACCOUNT_ID: cfg.site.account } : {}) } });
|
|
696
|
+
try {
|
|
697
|
+
for (;;) {
|
|
698
|
+
if (wrangler.exitCode !== null) throw new Error("wrangler dev exited");
|
|
699
|
+
if (await fetch(`${url}/.well-known/agent-card.json`).then((r) => r.ok, () => false)) break;
|
|
700
|
+
await new Promise((ok) => setTimeout(ok, 1000));
|
|
701
|
+
}
|
|
702
|
+
log(`indexing ${cfg.app} here, into ${w.r2_buckets[0].bucket_name}`);
|
|
703
|
+
await fetch(`${url}/__scheduled?cron=${encodeURIComponent(w.triggers.crons[0])}`);
|
|
704
|
+
let catalog = null;
|
|
705
|
+
while (!(catalog?.generated_at >= start)) {
|
|
706
|
+
if (wrangler.exitCode !== null) throw new Error("wrangler dev exited");
|
|
707
|
+
await new Promise((ok) => setTimeout(ok, 5000));
|
|
708
|
+
catalog = await fetch(`${url}/view/cdn/catalog`).then((r) => (r.ok ? r.json() : null), () => null);
|
|
709
|
+
}
|
|
710
|
+
log(`indexed: ${catalog.domains.length} domain(s), ${catalog.domains.reduce((n, d) => n + d.count, 0)} rows`);
|
|
711
|
+
return catalog;
|
|
712
|
+
} finally {
|
|
713
|
+
wrangler.kill();
|
|
714
|
+
rmSync(vars, { force: true });
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
/**
|
|
719
|
+
* A view from what the sources staged, with app.json's schema, touching no chain and no
|
|
720
|
+
* site: what a recipe change would ship, built so it can be graded first (westmarch-eval).
|
|
721
|
+
* The sources run without --publish, or not at all with crawl=false. Every build is whole
|
|
722
|
+
* (a changed `text` role must reach every row, and publishView re-embeds only new CIDs);
|
|
723
|
+
* `.ship/vectors.ndjson` keeps it cheap, so two recipes over the same data embed only the
|
|
724
|
+
* text that differs.
|
|
725
|
+
*/
|
|
726
|
+
export async function buildLocal(configPath, out, { crawl = false, only = null, log: say = log } = {}) {
|
|
727
|
+
const cfg = loadConfig(configPath);
|
|
728
|
+
const base = dirname(resolve(configPath));
|
|
729
|
+
const [{ env }, view] = await Promise.all([import("@huggingface/transformers"), import("./view.js")]);
|
|
730
|
+
env.cacheDir = `${homedir()}/.cache/fangorn-mcp/models`;
|
|
731
|
+
// Not the app's real id or owner: nothing here is compared with the chain.
|
|
732
|
+
const appId = `0x${createHash("sha256").update(cfg.app).digest("hex")}`, owner = `0x${"10ca1".padStart(40, "0")}`;
|
|
733
|
+
const chain = {};
|
|
734
|
+
// Storage addresses a record by its content, and so does this.
|
|
735
|
+
for (const [ns, records] of Object.entries(readStage(cfg, base, { crawl, only, log: say })))
|
|
736
|
+
chain[`${owner}/${ns}`] = { records: records.map((r) => ({ ...r, cid: createHash("sha256").update(JSON.stringify(stable(r.payload))).digest("hex") })) };
|
|
412
737
|
rmSync(out, { recursive: true, force: true });
|
|
413
738
|
mkdirSync(join(base, ".ship"), { recursive: true });
|
|
414
739
|
const embed = view.cachedEmbed(join(base, ".ship/vectors.ndjson"));
|
|
415
|
-
const
|
|
740
|
+
const repos = [...new Set(cfg.sources.map((s) => s.namespace))].filter((n) => !only || only.includes(n));
|
|
416
741
|
const report = await view.publishView({ fangorn: view.localFangorn(chain, { appId, owner }), app: cfg.app,
|
|
417
|
-
|
|
742
|
+
schema: { types: cfg.types, relations: cfg.relations }, repos, out, embed, log: say });
|
|
418
743
|
const rows = Object.values(report).reduce((n, r) => n + r.added, 0);
|
|
419
744
|
say(`local view: ${out} · ${rows} records, ${embed.misses} embedded, ${rows - embed.misses} from the vector cache`);
|
|
420
745
|
return report;
|
|
421
746
|
}
|
|
422
747
|
|
|
423
|
-
/** Copy a deployed view (catalog, manifests, shards) to `dir`, so the next publish appends. */
|
|
424
|
-
async function mirrorView(base, dir) {
|
|
425
|
-
const get = async (p) => { const r = await fetch(`${base}/${p}`); if (!r.ok) throw new Error(`${base}/${p}: HTTP ${r.status}`); return r; };
|
|
426
|
-
let catalog;
|
|
427
|
-
try { catalog = await (await get("cdn/catalog")).json(); } catch (e) { log(`no deployed view to start from (${e.message})`); return; }
|
|
428
|
-
const { createHash } = await import("node:crypto");
|
|
429
|
-
let files = 0;
|
|
430
|
-
for (const d of catalog.domains ?? []) {
|
|
431
|
-
const m = await (await get(`cdn/domains/${d.name}/manifest`)).json();
|
|
432
|
-
mkdirSync(join(dir, "cdn/domains", d.name, "shards"), { recursive: true });
|
|
433
|
-
writeFileSync(join(dir, "cdn/domains", d.name, "manifest"), JSON.stringify(m, null, 1));
|
|
434
|
-
for (const s of m.shards ?? []) {
|
|
435
|
-
const buf = Buffer.from(await (await get(`cdn/domains/${d.name}/shards/${s.file}`)).arrayBuffer());
|
|
436
|
-
if (s.sha256 && createHash("sha256").update(buf).digest("hex") !== s.sha256) throw new Error(`${s.file} does not match its manifest`);
|
|
437
|
-
writeFileSync(join(dir, "cdn/domains", d.name, "shards", s.file), buf);
|
|
438
|
-
files++;
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
writeFileSync(join(dir, "cdn/catalog"), JSON.stringify(catalog, null, 1));
|
|
442
|
-
log(`started from the deployed view: ${catalog.domains?.length ?? 0} domain(s), ${files} shard(s)`);
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
/** The project's pages.dev URL, creating the project on first use. Pages appends a
|
|
446
|
-
* suffix when the name is taken elsewhere, so the URL is read back, never assumed. */
|
|
447
|
-
function pagesUrl(cfg) {
|
|
448
|
-
const env = cfg.site.account ? { CLOUDFLARE_ACCOUNT_ID: cfg.site.account } : {};
|
|
449
|
-
const find = () => {
|
|
450
|
-
const out = run("npx", ["wrangler", "pages", "project", "list"], { env, capture: true });
|
|
451
|
-
const row = out.split("\n").find((l) => l.split("│")[1]?.trim() === cfg.site.project);
|
|
452
|
-
const host = row?.match(/([a-z0-9-]+\.pages\.dev)/)?.[1];
|
|
453
|
-
return host ? `https://${host}` : null;
|
|
454
|
-
};
|
|
455
|
-
let url = find();
|
|
456
|
-
if (!url) {
|
|
457
|
-
run("npx", ["wrangler", "pages", "project", "create", cfg.site.project, "--production-branch", "main"], { env });
|
|
458
|
-
url = find();
|
|
459
|
-
}
|
|
460
|
-
if (!url) throw new Error(`could not read the pages.dev URL of project ${cfg.site.project}`);
|
|
461
|
-
return url;
|
|
462
|
-
}
|
|
463
|
-
|
|
464
748
|
// ── cli ───────────────────────────────────────────────────────────────────────
|
|
465
749
|
if (process.argv[1]?.endsWith("ship.js") || process.argv[1]?.endsWith("westmarch-ship")) {
|
|
466
750
|
if (process.argv[2] === "--selfcheck") {
|
|
467
|
-
// The schema as committed, read back the way the chain returns it, must compare
|
|
468
|
-
// equal to the config, or every run re-commits an unchanged schema.
|
|
469
|
-
const { parseSchema } = await import("./view.js");
|
|
470
|
-
const types = { "t.v1": { description: "d", role_map: { title: "name", text: ["body"] }, presentation: { externalUrl: { "t.v1": "{url}" } } },
|
|
471
|
-
"u.v1": { description: "e", role_map: { title: "label" } } };
|
|
472
|
-
const relations = [{ rel: "cites", from: "t.v1", to: "u.v1" }];
|
|
473
|
-
const g = schemaGraph(types, relations);
|
|
474
|
-
// Keys reversed at every depth, as a canonical (sorted) encoding hands them back.
|
|
475
|
-
const reverse = (v) => Array.isArray(v) ? v.map(reverse)
|
|
476
|
-
: v && typeof v === "object" ? Object.fromEntries(Object.keys(v).reverse().map((k) => [k, reverse(v[k])])) : v;
|
|
477
|
-
const readBack = parseSchema({
|
|
478
|
-
vertices: g.vertices.map((v) => ({ cid: `cid-${v.id}`, schemaId: v.tag, payload: reverse(v.payload) })),
|
|
479
|
-
edges: g.edges.map((e) => ({ relation: e.rel, sourceCid: `cid-${e.from}`, targetCid: `cid-${e.to}` })),
|
|
480
|
-
});
|
|
481
|
-
if (canonical(readBack.types, readBack.relations) !== canonical(types, relations)) throw new Error("schema does not round-trip");
|
|
482
|
-
if (canonical(readBack.types, readBack.relations) === canonical({ ...types, "v.v1": {} }, relations)) throw new Error("a new type must count as a change");
|
|
483
751
|
const row = { city: "Wisconsin Rapids", state: "WI", site: "https://x", args: ["--archive-page", "/569/A"] };
|
|
484
752
|
const cmd = fill(["py", "--site", "{site}", "--city", "{city}", "{args...}", "--ns", "us-{state|lower}-{city|slug}"], row);
|
|
485
753
|
if (JSON.stringify(cmd) !== JSON.stringify(["py", "--site", "https://x", "--city", "Wisconsin Rapids", "--archive-page", "/569/A", "--ns", "us-wi-wisconsin-rapids"]))
|
|
486
754
|
throw new Error(`template fill: ${JSON.stringify(cmd)}`);
|
|
487
|
-
|
|
755
|
+
const w = wranglerConfig({ name: "quorum", site: "/s", config: { app: "quorum" }, url: "https://quorum.example" });
|
|
756
|
+
if (w.r2_buckets[0].bucket_name !== "quorum-view" || !w.ai || !w.triggers.crons.length || w.routes[0].pattern !== "quorum.example"
|
|
757
|
+
|| !w.compatibility_flags.includes("nodejs_compat") || !existsSync(w.main) || !existsSync(w.alias["@huggingface/transformers"]))
|
|
758
|
+
throw new Error(`wrangler config: ${JSON.stringify(w)}`);
|
|
759
|
+
const d = discovery({ name: "Q", description: "q" }, "https://q.example", { price: "10000", decimals: 6, symbol: "USDC" });
|
|
760
|
+
const op = d.openapi.paths["/paid"].post;
|
|
761
|
+
if (op["x-payment-info"].price.min !== "0.01" || op["x-payment-info"].price.max !== "10" || !op.responses[402] || d.x402.resources[0] !== "https://q.example/paid")
|
|
762
|
+
throw new Error(`discovery: ${JSON.stringify(d)}`);
|
|
763
|
+
const dp = discovery({ name: "Q", description: "q" }, "https://q.example", null, { pass: "5000000", days: 30, call: "10000", decimals: 6 });
|
|
764
|
+
if (dp.openapi.paths["/pass"].post["x-payment-info"].price.amount !== "5" || dp.x402.resources.join() !== "https://q.example/pass" || dp.openapi.paths["/paid"])
|
|
765
|
+
throw new Error(`private discovery: ${JSON.stringify(dp.x402)}`);
|
|
766
|
+
if (units("0.01") !== "10000" || units("5") !== "5000000" || units("1.5", 2) !== "150") throw new Error("units");
|
|
767
|
+
if (USDC["eip155:84532"].name !== "USDC" || USDC["eip155:8453"].name !== "USD Coin") throw new Error("USDC's EIP-712 name differs on Base Sepolia and Base");
|
|
768
|
+
console.log("ship.js self-check ok — a source template fills per row, the Worker config binds its bucket, AI and cron, and the paid route is priced per id in /openapi.json and named in /.well-known/x402");
|
|
488
769
|
process.exit(0);
|
|
489
770
|
}
|
|
490
771
|
const [path, ...flags] = process.argv.slice(2);
|
|
491
772
|
if (!path || flags.includes("--help")) {
|
|
492
|
-
console.error("usage: westmarch-ship app.json [--no-crawl] [--no-deploy] [--dry-run] [--replace] [--
|
|
493
|
-
" westmarch-ship app.json --register [--dry-run] (claim,
|
|
494
|
-
" westmarch-ship app.json --local <out> [--crawl] [--only ns1,ns2] (no chain, no deploy)"
|
|
773
|
+
console.error("usage: westmarch-ship app.json [--no-crawl] [--no-deploy] [--dry-run] [--replace] [--only ns1,ns2]\n" +
|
|
774
|
+
" westmarch-ship app.json --register [--dry-run] (claim, empty site, card bound: no data)\n" +
|
|
775
|
+
" westmarch-ship app.json --local <out> [--crawl] [--only ns1,ns2] (no chain, no deploy)\n" +
|
|
776
|
+
" westmarch-ship app.json --index (the deployed app's indexer, once, on this machine)\n" +
|
|
777
|
+
" westmarch-ship app.json --devnet [--crawl] [--only ns1,ns2] [--port 8787] [--ai] (the whole app on this machine)");
|
|
495
778
|
process.exit(path ? 0 : 2);
|
|
496
779
|
}
|
|
497
780
|
const only = flags.includes("--only") ? flags[flags.indexOf("--only") + 1].split(",") : null;
|
|
781
|
+
if (flags.includes("--devnet")) {
|
|
782
|
+
await devnetShip(path, { crawl: flags.includes("--crawl"), only, ai: flags.includes("--ai"),
|
|
783
|
+
port: flags.includes("--port") ? Number(flags[flags.indexOf("--port") + 1]) : 8787 })
|
|
784
|
+
.catch((e) => { console.error(`[ship] ✗ ${e.message}`); process.exit(1); });
|
|
785
|
+
process.exit(0);
|
|
786
|
+
}
|
|
787
|
+
if (flags.includes("--index")) {
|
|
788
|
+
await indexHere(path).catch((e) => { console.error(`[ship] ✗ ${e.message}`); process.exit(1); });
|
|
789
|
+
process.exit(0);
|
|
790
|
+
}
|
|
498
791
|
if (flags.includes("--local")) {
|
|
499
792
|
await buildLocal(path, resolve(flags[flags.indexOf("--local") + 1]), { crawl: flags.includes("--crawl"), only })
|
|
500
793
|
.catch((e) => { console.error(`[ship] ✗ ${e.message}`); process.exit(1); });
|
|
501
794
|
process.exit(0);
|
|
502
795
|
}
|
|
503
796
|
await ship(path, { crawl: !flags.includes("--no-crawl"), deploy: !flags.includes("--no-deploy"), dry: flags.includes("--dry-run"),
|
|
504
|
-
replace: flags.includes("--replace"), register: flags.includes("--register"),
|
|
505
|
-
only })
|
|
797
|
+
replace: flags.includes("--replace"), register: flags.includes("--register"), only })
|
|
506
798
|
.catch((e) => { console.error(`[ship] ✗ ${e.message}`); process.exit(1); });
|
|
507
799
|
process.exit(0); // a CUDA embedder keeps the process alive (and can abort in its teardown)
|
|
508
800
|
}
|