Buckets:
Polygon Agent CLI
Team Standards
Fetch and apply the Polygon Apps Team standards:
Repository Structure
This is a pnpm workspace monorepo. The primary package is:
packages/polygon-agent-cli/— CLI tool for on-chain agent operations on Polygon
Wallets use the OMS (Open Money Stack) V3 embedded-wallet model (@polygonlabs/oms-wallet,
OMSWallet): the CLI authenticates via browser login with Google or email (wallet login) and
holds the credential on disk.
Static assets: ABI JSON in contracts/ is published with the CLI package (it is in
package.json files).
Skills: one skill, Open Money Agent, in skills/open-money-agent/. SKILL.md is the index every agent reads
(kept under 12 KB): check the CLI is installed, run wallet status first, then route
the request to references/<topic>.md, loaded only for that task. Each reference opens with a
title and a **When to use:** line; only the index has frontmatter. src/lib/skills.test.ts
(CLI package) enforces this, and that every reference is linked from the index. The CLI bundles
the folder (scripts/build.mjs), workspace init installs it with its references, and
skills show <topic> prints a reference (old skill names map to topics). The agentconnect site
serves the index at /skill.md (the URL assistants are given), /SKILL.md, /setup.md, /open-money-agent/SKILL.md and every older skill URL, and
the references at /references/ too (vite.config.ts). Also distributed via npx skills add
and the plugins, not via npm on its own.
Plugins: the repo is a plugin marketplace for Claude Code (.claude-plugin/marketplace.json),
Codex (.codex-plugin/plugin.json, .agents/plugins/marketplace.json) and Cursor
(.cursor-plugin/marketplace.json). Each points at plugins/open-money-agent/, whose skills and
assets are symlinks to the root folders, so a skill edit needs no plugin change. The manifests
carry no version, so installs update with each commit. Check with claude plugin validate ..
ChatGPT has its own package, plugins/open-money-agent-chatgpt/: the read-only MCP server and no
skills (ChatGPT plugins may not move funds). It has a version, bumped for each upload; how to
build and submit it is in docs/CHATGPT_PLUGIN.md.
Development
- Dev environment requires Node 24+ (
.nvmrc). The published CLI supports Node 22+. tsx packages/polygon-agent-cli/src/index.tsruns the CLI directly from source (tsx handles.js→.tsremapping for workspace packages).pnpm run buildcompiles TypeScript todist/(targeting es2023 for Node 22 compat).- The CLI uses yargs with the
CommandModulebuilder/handler pattern.
Key Directories
packages/polygon-agent-cli/src/commands/— yargs command modulespackages/polygon-agent-cli/src/lib/— shared utilities (storage, oms-client, oms-tx, oms-storage, tx-dispatch, token-directory, ethauth)packages/polygon-agent-cli/src/types.d.ts— ambient declarations for untyped dependencies
Wallet auth (OMS V3)
agent wallet login(bare) connects the agent wallet in session mode: the owner signs in once to approve a limited allowance (--allowance,--days,--chains) for this install's own key, and the sign-in is revoked. The CLI picks the method automatically: the browser login page (a detached background waiter drives it;wallet login --waitcollects the result) or a code emailed to the owner and pasted into chat (--email <email>forces it;POLYGON_AGENT_SIGNIN=email|browseroverrides the pick). Allowance, withdraw and access changes are owner requests that use the same picker.agent wallet login --owner: the full owner session. Opens the agentconnect login page (POLYGON_AGENT_LOGIN_UI, defaulthttps://agentconnect.polygon.technology), where the user chooses Google or email; works whether the browser is local or remote.--localfalls back to the older loopback flow (raw Google URL + localhost callback; browser must be on this machine).--remoteis deprecated now that the default flow already works remotely. Relay base URL isPOLYGON_AGENT_OIDC_RELAYor--relay-url(defaulthttps://oidc-relay.polygon.technology). Other flags:--name <n>(default "main"),--no-fund,--force. Session persists1 week under `/.polygon-agent/oms//`.- No setup step is required: the CLI ships a default
OMS_PUBLISHABLE_KEY, andwallet loginauto-provisions a Builder project + access key on first login, saving it to~/.polygon-agent/builder.json.OMS_PUBLISHABLE_KEY(env) andsetup --oms-publishable-keyremain as advanced overrides for developers pointing at their own OMS project; plainsetupremains for manual or--forcere-provisioning. lib/tx-dispatch.tsrunTxis the single tx primitive (wrapsrunOmsTx). All commands submit through it.
Site sign-in and MCP (agentconnect)
- Site sign-in: the dashboard's own sign-in (email code or Google) runs in the worker (
/api/session/*, reusingworker/owner-signin.ts) and sets an HttpOnlyagentconnect_sessioncookie (worker/owner-session.ts, HMAC withAGENT_CERT_SECRET, 30 days). Requests that change something with the cookie must carry this site'sOrigin. Opening/signed in shows that wallet's dashboard: the wallet of the method signed in with (OMS gives each sign-in method its own wallet). - The CLI's dashboard links use
POLYGON_AGENT_CREDENTIALS_URL(default: the login page's site), so sign-in and the dashboard can run on different deployments. - Saved details (the shipping address, agent sign-in with
at1tokens) and cards and buying (AgentCard vault,agent buy, approvals, the auto-pay limit, the per-wallet payment lock) are built on thecardsbranch, not on staging. Staging's wrangler migrationv4deleted theWalletLockDurable Object class, so bringing it back takes a new migration tag. - MCP: the worker serves a remote MCP server at
/mcp(worker/mcp.ts, stateless JSON-RPC) behind@cloudflare/workers-oauth-provider(/authorize,/oauth/token,/oauth/register,/.well-known/*;OAUTH_KVbinding)./authorizehands off to the SPA's/connectpage, where the owner signs in by email code or Google (skipped when already signed in on the site), then sees a consent screen (what the agent can do) and allows or denies (/api/connect/decide; deny returnsaccess_denied). Settings lists connected agents (/api/agents, the provider's grants; owner session cookie only) with Disconnect (revokeGrant). the worker does that OMS sign-in itself (worker/owner-signin.ts, state sealed in KV for 10 minutes) because the OMS project only accepts browser calls from the production origin. Its one tool,get_wallet, covers the address and balances; moving funds stays in the CLI. - MCP client profiles (
worker/profiles.ts): each connection gets a profile when the owner allows it, from its OAuth client id viaMCP_CLIENT_PROFILES(JSON, client id to profile; unlisted clients and older connections arestandard), kept in the grant'sprops. A profile is a tool allowlist, checked ontools/listandtools/call.standardandmuse(Muse takes no money movement) currently allow the same tool,get_wallet. A platform's client is registered at/oauth/registerwith its redirect URIs, and the returned client id goes inMCP_CLIENT_PROFILES. - Local MCP:
npx wrangler@4 dev --env staging --port 8787 --local-upstream localhost:8787(secrets in the gitignored.dev.vars.staging). - Worker secrets are GitHub environment secrets, uploaded by the deploy workflow with
wrangler deploy --secrets-file:AGENT_CERT_SECRET(session cookie HMAC),CREDENTIALS_KEY(seals sign-ins in progress),INDEXER_ACCESS_KEY(fromVITE_INDEXER_ACCESS_KEY). TheOAUTH_KVnamespace has no id inwrangler.toml; wrangler creates it on the first deploy.
Xet Storage Details
- Size:
- 7.96 kB
- Xet hash:
- bff17ce2cfc315a6c80dcabc42d1abc8dc046ec6c656a49f30a3994c7cca328d
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.