npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@jpyonchain/aiagent

v0.2.1

Published

JPYON Agent x402 — AI agent JPYC payment infrastructure for Japan

Downloads

471

Readme

@jpyonchain/aiagent

JPYON Agent x402 — AI エージェントが自律的に JPYC(日本円ステーブルコイン)で決済し、企業 API・サービスを購入できるインフラです。

日本発・AI エージェント向け x402 決済基盤。Coinbase / Polygon の Agent 決済に対抗する、JPYC ネイティブなプラットフォーム。


インストール

npm install -g @jpyonchain/aiagent

または SDK として使う場合:

npm install @jpyonchain/aiagent

クイックスタート(CLI)

# ウォレット初期化(初回のみ)
jpyon init

# x402 保護された API を自動決済で叩く
jpyon fetch https://api.example.com/premium

# ウォレットを無効化
jpyon jpyc off

クイックスタート(SDK)

import { createAgent } from "@jpyonchain/aiagent/agent";

// ワンライナーで初期化
const agent = await createAgent({
  relayUrl: "https://jpyon.jp.ai",
  policy: {
    maxPerRequestJpyc: "10",   // 1リクエスト最大 10 JPYC
    maxPerWindowJpyc: "100",   // 1時間最大 100 JPYC
  },
});

// x402 保護された API を自動決済で取得
const res = await agent.fetch("https://api.example.com/premium-data");
const data = await res.json();

// 最安値のサービスを自動選択して取得
const weather = await agent.fetchCheapest(["weather", "forecast"]);

// セッション終了
await agent.shutdown();

仕組み

AI エージェント
  ↓ EIP-3009 署名(ローカル・秘密鍵は外に出ない)
JPYON Server
  ↓ Plan 確認 → gasless relay or 拒否
Polygon Mainnet
  ↓ JPYC V2 transferWithAuthorization
サービス API
  ↓ レスポンス

ガスレス決済: エージェントは MATIC を持たなくてよい。JPYON が MATIC ガス代を代払いします。
サーバー制御: ガスレス配分はサーバーが管理。エージェントが自分で設定変更することはできません。
自動フォールバック: ガスレス枠を超えた場合、エージェントが自動で MATIC 自払いの通常決済に切り替えます。


Plan 制度

| Plan | ガスレス上限 | 月額 | |------|------------|------| | Free | 10回/日 | 無料・自動付与 | | Standard | 100回/日 | 500 JPYC/月 | | Pro | 1,000回/日 | 3,000 JPYC/月 | | Enterprise | 無制限 | お問い合わせ |

# 現在の Plan と残配分を確認
jpyon plan status

# Plan をアップグレード(JPYC で購入・MATIC 不要)
jpyon plan buy standard
jpyon plan buy pro

CLI コマンド一覧

# ウォレット管理
jpyon init                          # 初期化・有効化
jpyon status                        # ウォレット状態 + Plan 情報
jpyon jpyc on                       # ウォレット有効化
jpyon jpyc off                      # ウォレット無効化

# Plan 管理
jpyon plan status                   # 現在の Plan と残配分(サーバー照会)
jpyon plan buy standard             # Standard Plan 購入(500 JPYC)
jpyon plan buy pro                  # Pro Plan 購入(3,000 JPYC)

# 決済
jpyon fetch <url>                   # x402 自動決済付き fetch
jpyon fetch <url> --dry-run         # シミュレーション(送金なし)
jpyon fetch <url> --method POST     # HTTP メソッド指定

# サービス発見
jpyon services list                 # 登録サービス一覧
jpyon services list --capabilities weather,forecast
jpyon services compare weather      # 気象 API 価格比較(安い順)

# 監査
jpyon audit                         # 支払い履歴(直近20件)
jpyon audit --summary               # サマリーのみ

# その他
jpyon version                       # バージョン確認

SDK API リファレンス

createAgent(opts)

const agent = await createAgent({
  relayUrl?: string,        // デフォルト: JPYON_RELAY_URL env var
  storage?: AgentStorage,   // デフォルト: NodeFileStorage (~/.jpyon/agent/)
  policy?: {
    maxPerRequestJpyc?: string,  // デフォルト: "100"
    maxPerWindowJpyc?: string,   // デフォルト: "1000"
    windowMs?: number,           // デフォルト: 3_600_000 (1時間)
    allowedChainIds?: number[],  // デフォルト: [137] (Polygon)
    allowedServiceIds?: string[], // デフォルト: [] (全サービス許可)
    dryRun?: boolean,            // デフォルト: false
    polygonRpcUrl?: string,      // デフォルト: https://polygon-rpc.com
  },
  onBeforePayment?: (ctx) => boolean | Promise<boolean>,
  onPaymentSuccess?: (entry) => void,
  onPaymentFailure?: (entry) => void,
});

agent.fetch(url, init?)

x402 を自動処理する fetch() の drop-in replacement。

const res = await agent.fetch("https://api.example.com/data");

agent.fetchCheapest(capabilities, init?)

サービスレジストリから最安値のサービスを自動選択して fetch。

const res = await agent.fetchCheapest(["weather", "tokyo"]);

agent.getMyPlan()

現在の Plan・ガスレス残配分をサーバーに照会。

const plan = await agent.getMyPlan();
// {
//   planTier: "free",
//   gasless: { dailyLimit: 10, usedToday: 3, remaining: 7 },
//   availablePlans: [...]
// }

agent.buyPlan(tier, treasuryAddress, priceJpyc)

Plan をアップグレード。JPYC を JPYON treasury に送金(MATIC 不要)。

await agent.buyPlan("standard", treasuryAddress, "500000000000000000000");

agent.audit

支払い監査ログ。

agent.audit.summary();       // { totalPayments, totalJpyc, ... }
agent.audit.recent(20);      // 直近20件の AuditEntry[]
agent.audit.getSuccessful(); // 成功した支払いのみ

ストレージ

| 環境 | 推奨ストレージ | 説明 | |------|--------------|------| | ローカル CLI / VPS | NodeFileStorage(デフォルト) | ~/.jpyon/agent/ にファイル保存 | | テスト / 短命エージェント | MemoryStorage | プロセス終了でリセット | | JPYON サーバー内部 | MongoStorage | MongoDB に永続化(サーバー専用) |

import { createAgent, NodeFileStorage, MemoryStorage } from "@jpyonchain/aiagent/agent";

// テスト用
const agent = await createAgent({ storage: new MemoryStorage() });

// カスタムディレクトリ
const agent = await createAgent({ storage: new NodeFileStorage("/custom/path") });

環境変数

| 変数名 | 説明 | |--------|------| | JPYON_RELAY_URL | JPYON リレー URL(デフォルト: https://jpyon.jp.ai) | | ENCRYPTION_KEY | 秘密鍵の暗号化キー(推奨) | | POLYGON_RPC_URL | 通常決済フォールバック用 RPC | | JPYON_DRY_RUN | true でシミュレーションのみ |


企業 API の登録(サービスプロバイダー向け)

JPYON レジストリに API を登録することで、エージェントが自動発見・購入できるようになります。

curl -X POST https://jpyon.jp.ai/api/services/register \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <your-api-key>" \
  -d '{
    "serviceId": "my-weather-api",
    "name": "My Weather API",
    "nameJa": "気象予報 API",
    "endpoint": "https://api.example.com/weather",
    "capabilities": ["weather", "forecast", "japan"],
    "pricing": [{
      "chainId": 137,
      "tokenAddress": "0xE7C3D8C9a439feDe00D2600032D5dB0Be71C3c29",
      "tokenSymbol": "JPYC",
      "amount": "100000000000000000",
      "displayAmount": "0.1 JPYC per request",
      "unit": "per-request"
    }]
  }'

セキュリティ

  • 非カストディアル: 秘密鍵はローカルにのみ保存。JPYON サーバーには送信されない
  • 暗号化: AES-256-GCM(JPYON backend と同一実装)
  • 認証: JWT なし。EIP-191 署名による timestamp challenge でエージェントを識別
  • 予算制限: maxPerRequestJpyc / maxPerWindowJpyc でローカル上限を設定可能

サポート


ライセンス

MIT © AgenticAI jp lab