Repository navigation
feat: fit the six tracks: haggling, Agent Market, contract check, payments CSV, relayer, swarm auction - #297
Conversation
The privacy track's own example asks to keep nothing server-side; HelloNear keeps chats and working memory so a Mind can remember its owner. A table now says what the TEE protects, what the backend stores (not in a TEE), what is encrypted, what is never stored, and how the owner deletes it. Each claim points at the file that does it (threads.ts, memory.ts, crypto.ts, secrets). Docs only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q5ZrzK8une3S2YyhDG746e
Three pieces the track prompts ask for:
- agents: a seller now has a floor (SHOP_SELLERS account:multiplier[:floor],
default 0.8). `?seller=&offer=` answers accepted (at the offer) or one
counter halfway to the list price, never under the floor; the paid step
checks the payment reaches the agreed price.
- realworld: GET /v1/minds/{id}/payments.csv, owner only, columns an
accountant reads without asking (date UTC, status in words, amount,
counterparty, purpose, approved by, tx hash, NearBlocks link); RFC 4180
quoting and formula-injection guard.
- realworld: POST /v1/relay relays a NEP-366 SignedDelegate to the registry
only, and only unequip_skill / set_wallet with exactly 1 yoctoNEAR: the
docs say the relayer pays inner deposits, so deposit-taking methods are
never relayed. Sender = signed-in owner, ed25519 signature checked,
expiry <= 1000 blocks, full-access key and fresh nonce checked over RPC,
10 per owner per hour, 503 relay_not_configured without RELAYER_* env.
Tests (local Postgres, fakes): typecheck clean; test:unit 30/30; test 142
pass, 0 fail, 1 skipped. Load: load:shop 10 VUs ~10 s, 0 errors (quotes p95
100 ms, offer p95 91 ms, csv p95 391 ms); existing load 0 errors.
Not proven: a real testnet relay (no relayer account yet), Meteor signing a
delegate action.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q5ZrzK8une3S2YyhDG746e
AI Swarms track: buyer agents pool demand and run a sealed-bid round against seller agents; it settles on NEAR and every agent is its own sub-account. Rules first (sc/swarm/RULES.md): commit-reveal asks under a group ceiling, cheapest revealed asks fill demand, one clearing price, fill in join order when supply is short, pull-based withdraw (balance zeroed first, restored by a never-panicking private callback), cancel and refund after the deadline. Storage charged per write; checked math; bounded close_round. NEP-297 events `hellonear_swarm`. The simulation (tests/simulation.rs) runs 20 buyers and 5 sellers with scripted strategies (cost-plus, a bluffer that never reveals, an adaptive undercutter), no LLM calls, 3 rounds, fixed seed, and checks money is conserved each round; sample output in simulation-report.md. Tests (local sandbox): lib 16 passed; test_round 1 passed (7/7 runs after waiting for the parent key at Final); simulation 1 passed (~108 s); clippy 0 warnings; wasm builds (186 KB). CI now runs them. Not done: nothing on testnet (accounts and deploy need Axel); the audit skill was applied by hand, not run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q5ZrzK8une3S2YyhDG746e
… in Recipient guard
Agents and security tracks:
- market_search / market_quote (src/market.ts, skill agent-market, in the
General Assistant template): search NEAR AI Agent Market's public catalog
and get a listed agent's real price for the owner's task through A2A
without a payment header (402, nothing starts, nothing moves). Paying is
USDC on NEAR mainnet, so every result says this Mind can't pay it here.
Handle must be one DNS label (no SSRF); a task with {{secrets. is refused.
- make_offer + buy_data offerNear (best-price): one offer within the
owner's budget; the tool compares the answer with the budget in yocto and
returns buy_at_price or walk_away, and after a walk-away buy_data refuses
that item for the request (the first live run bought at the old quote
after a counter over budget, so the tool decides, not the model).
- near_view_account returns isContract/codeHash; Recipient guard warns and
asks before paying a contract and states allow / warn / block.
Tests: typecheck clean; test:unit 186/186 (market.test.ts added).
Live (NEAR AI + local Postgres): skills-market-negotiation 5/5 twice;
recipient guard 3/3 twice (contract case on real testnet RPC);
skills-commerce 8/8. Not run here: full `bun run test`, load test.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q5ZrzK8une3S2YyhDG746e
… and relayer Counts (53 tools, 34 skills, 62 API operations), the new tool and skill rows, and the agents, security and realworld track rows. The agent-market icon is the plug the web app shows for a skill it has no icon for yet. The swarm auction and its receipts follow after its testnet deploy. Docs only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q5ZrzK8une3S2YyhDG746e
…t Market Axel asked for the UI of this branch to be done here, with Ancung reviewing it. - Wallet → Recent activity: a Download CSV button (lucide FileDownIcon) that links to GET …/payments.csv. - Skill Hire on Agent Market: HandshakeIcon, the Money group, and card copy that says it only quotes during the testnet phase. - Best price buyer's card mentions the one-round haggle. - Step words for make_offer, market_search and market_quote, and a near_view_account step that says when the account is a contract. Tests: typecheck clean; lint clean; vitest 278/278 (new: the step words). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q5ZrzK8une3S2YyhDG746e
…rged An independent audit (near-contract-audit) found 9 issues; all fixed: - High: round_closed listed every account and exceeded the 16 KiB log limit at 100x50, so a full round could never close. It is now a fixed summary; per-account results stay in get_round. Regression tests close 100x50 rounds (64-char implicit names too) with logs under 2 KiB. - Fixed timeline at open (commit_end, reveal_end); start_reveal is gone, anyone closes after reveal_end (or once all sellers revealed), cancel only 60 min after reveal_end: no organizer timing power, no close/cancel race. - Seller bond with commit, returned on reveal, forfeited to the buyers by units if not revealed: no free selective reveal or slot squatting. - Commitment binds round and seller; salt 16-64 chars. - U64 times in JSON; withdraw needs 1 yoctoNEAR. Also found while testing: store collections only write at the end of a call, so charge() measured no growth and storage came out of the contract's balance (escrow). flush() before every charge; entries reserved up front; withdraw zeroes instead of deleting. Tests: lib 28 passed; test_round 1 passed (failed before the flush fix with free balance below what it holds); simulation 1 passed (240 s, prices 0.040/0.039/0.033, a bond forfeited each round, free balance 8.074 -> 8.082 NEAR); clippy 0 warnings; wasm 192,241 bytes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q5ZrzK8une3S2YyhDG746e
# Conflicts: # engine/package.json
… contracts Found in the Chrome e2e on a local stack (13 Nov): - "Buy the gas price report, but I only want to pay 0.0006 NEAR. Haggle if it costs more." -> the Mind wrote "I'll make s1 one offer at your limit" and ended the run without calling make_offer. The playbook said to tell the owner first, then call it. Now: write nothing until the tool calls are done, then one reply. - "Pay 0.001 NEAR to hellonear-registry.testnet." -> Payments looked the contract up and went straight to the approval card; only Recipient guard had the contract rule. Payments now refuses to call send_payment in that turn for isContract: true and asks first. After the fixes, in Chrome: the offer is made (countered at 0.0008, over budget, walked away, nothing paid) and the contract gets a warning with no card. Live tests added for both; with NEAR AI's embedder down they were run with semantic recall off (what the probe does): 6/6 haggle and contract tests pass. engine test:unit 187/187. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q5ZrzK8une3S2YyhDG746e
formatNear shows balances with two decimals, rounded down, so a 0.001 NEAR payment and Spent today read "0.00" on the Wallet screen (Axel, 13 Nov). formatNearAmount keeps two decimals but shows up to four when the cents would hide the amount, still rounded down; balances keep formatNear. Checked in Chrome (local): "-0.001 NEAR" and "Spent today: 0.001 NEAR". Tests: vitest 279/279 (new formatNearAmount cases); typecheck and lint clean. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q5ZrzK8une3S2YyhDG746e
…s budget market_quote takes an optional maxUsdc and returns withinBudget, compared in USDC's smallest unit by the tool, not the model. With a budget, the agent-market playbook quotes up to four agents that take work now, lists each with its verdict and recommends the cheapest within the budget. The market's direct calls have a fixed price per agent, so this is choosing between agents, not haggling with one (that needs the job board, an account and mainnet funds: roadmap). Chrome (local, live market.near.ai): "My budget is 1 USDC. Find the cheapest agent…" -> two quotes (Kaminari, Sasmex, 0.25 USDC, within budget), Kaminari recommended, nothing sent or paid. Tests: typecheck clean; test:unit 188/188 (new withinBudget case). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q5ZrzK8une3S2YyhDG746e
Swarms track: the sealed-bid group-buying contract, its 20-buyer simulation and how to run it. Agents track and tool/skill rows: the cheapest agent within a budget. Roadmap: paying Agent Market agents on mainnet, haggling through the job board, and Minds joining swarm rounds on chain. Docs only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q5ZrzK8une3S2YyhDG746e
…deploy finds its WASM With target-dir = ../target the reproducible build succeeded in Docker, then cargo near deploy stopped with "No such file or directory": it looks for the WASM inside the crate's own target. Locally, CARGO_TARGET_DIR=../target still shares the registry's cache. CI caches both targets. Tests (CARGO_TARGET_DIR=../target): lib 28 passed; test_round 1 passed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q5ZrzK8une3S2YyhDG746e
|
@Lexirieru UI review done (the UI, read in the diff: looks good.
One note, not blocking: Download CSV.
From my side the UI part is approved. 🤖 Generated with Claude Code |
|
Backend review (James, No blockers from the backend side:
Two notes, not blocking:
|
… and says when the session ended Ancung's #297 review: on the hosted site the API is another origin, where browsers ignore <a download>, and an expired session opened the JSON error in the tab. The button now fetches with the session cookie, saves a blob under the backend's filename and shows a toast on 401 or failure. The backend exposes Content-Disposition to the web app's origin. Tests: fe typecheck, lint, vitest 279/279; be typecheck, CSV integration test 1/1 (now checks the exposed header). Clicking it in Chrome would save a file, so that was not done; the route and headers were checked through the same fetch earlier. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q5ZrzK8une3S2YyhDG746e
…Market logo auction.hellonear-swarm.testnet: reproducible deploy from 64c9278 (tx FkvHpxf9…), code hash 6Wn9K6b3…, source verified (SourceScan get_contract returns the same hash). Round 0 ran on testnet: 3 buyer and 2 seller sub-accounts, commit, reveal, close by a buyer, withdraw; 6 units filled at one clearing price of 0.008 NEAR; buyers paid 0.048 and sellers earned 0.048 NEAR. README lists every tx, the Live now table and the deployed table (root CLAUDE.md) include the contract, and the tech stack names the NEAR AI Agent Market with its logo (market.near.ai's own favicon.svg). Docs only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q5ZrzK8une3S2YyhDG746e
|
@AncungAulia @Nabil-Aufa an update on this PR, plus one ask for the landing page. Ask: the NEAR AI Agent Market logo on the landing pageHelloNear now uses the NEAR AI Agent Market (market.near.ai): Minds search its agents and get real prices.
What this branch adds for the six tracks
Also on this branch:
Replies to the reviews
Axel merges once you approve. |
|
Merged ( Next steps are in #298: the Agent Market logo on the landing page, and trying the six prompts plus Download CSV on the hosted demo with a new Mind from each template. Two things on the box need Axel's approval:
|
|
@Lin1er two env changes on the hosted box. Axel approved both (13 Nov). Please do them once 1. A second shop seller, so haggling has prices to compare
2. The relayer (
|
|
@Lin1er the relayer account exists and is funded (replying here; this PR is where the env work lives):
Go ahead with Thanks for checking |
|
Live on the hosted demo:
|
docs: README after #297: Try it, API rows, NEAR usage, Hackathon phase, counts
|
@Lexirieru env work on the hosted box, done after
|
|
@Lin1er thanks. On your open points:
Also from the hosted run:
|
@AncungAulia please test every prompt below on a local stack and review the UI part of this branch. Axel merges once you approve.
This branch makes HelloNear fit the six tracks better. It is shaped by the track prompts in nearai/near-hackathon-prompt-examples.
What's in it
engine/src/tools.ts(make_offer),apps/be/src/shop.ts(?offer=)engine/src/market.ts, skillagent-market(in the General Assistant template)near_view_accountreturnsisContract. Recipient guard and Payments warn before paying a contract, with no card. Each check reads allow, warn or block with a reason.recipient-guard,paymentsGET /v1/minds/{id}/payments.csv, plus a Download CSV button on the Wallet screen.apps/be/src/payments.ts,WalletScreen.tsxPOST /v1/relay, only for owner calls to our registry (unequip_skill,set_wallet), and it never pays a deposit.apps/be/src/relay.tssc/swarm(RULES.md, simulation-report.md)README.mdPlease test: the prompts I ran in Chrome (localhost)
Setup:
BACKEND_URL=http://127.0.0.1:4000.Buy the gas price report, but I only want to pay 0.0006 NEAR. Haggle if it costs more.Find me an agent on the NEAR AI Agent Market that can research competitors for a coffee shop in Jakarta. What would it cost?I need competitor research for a coffee shop in Jakarta. My budget is 1 USDC. Find the cheapest agent on the NEAR AI Agent Market that fits.Pay 0.001 NEAR to hellonear-registry.testnet.Pay 0.001 NEAR to lin1er.testnet for the test.→ ApproveSend 10 USDC to 0x8ba1f109551bD432803012645Ac136ddd64DBA72 on Base.All six passed for me in Chrome after two fixes found on the way:
Both now have live tests.
Please review: UI done on this branch (Axel asked for it here)
FileDownIcon), shown once there are payments.formatNearAmount(src/lib/format.ts) shows small payments and Spent today with up to 4 decimals, so-0.001, not-0.00. Balances keepformatNear.HandshakeIcon, in the Money group;make_offer: "Accepted at …" / "Countered at …, over budget";market_search: "N agents";market_quote: "X USDC, not paid";near_view_account: "…, a contract".unequip_skill/set_wallettoday. No swarm page either; the simulation report is the swarm's view for now.Tests
test:unit188/188;test:unit30/30;test142 pass / 0 fail / 1 skipped;load:shop: 10 VUs for about 10 s, 0 errors (quotes p95 100 ms, offer p95 91 ms, csv p95 391 ms); the existing load test: 0 errors;main(fix(landing): Built with in the hero, the Mind loads whole, a floating scrollbar, link previews #293, feat(landing): smooth wheel scrolling with Lenis #295, fix(engine): chat still answers when NEAR AI's embedder does not #296) into this branch, not repeated after, at Axel's call. Those merges touch only the landing and engine memory options, not the backend.test_round1 passed; simulation 1 passed (240 s); clippy 0 warnings;.github/workflows/sc.yml).Not done yet / needs Axel
hellonear-swarm.testnetandauction.hellonear-swarm.testnetexist, but the reproducible deploy stopped on a build-path issue (.cargo/config.tomlpoints the crate at../target). That fix and the deploy come next, with Axel's approval already given.RELAYER_ACCOUNT_ID,RELAYER_PRIVATE_KEY): not set anywhere yet. Changingbe.envneeds Axel's approval. The route answers503 relay_not_configureduntil then.🤖 Generated with Claude Code
https://claude.ai/code/session_01Q5ZrzK8une3S2YyhDG746e