Skip to content

studio-agent: connect your own NEAR AI account, wallet sign-in or pasted key - #267

Merged
petersalomonsen merged 4 commits into
masterfrom
nearai-own-account
Nov 8, 2026
Merged

petersalomonsen merged 4 commits into
masterfrom
nearai-own-account

Conversation

@petersalomonsen

@petersalomonsen petersalomonsen commented Nov 8, 2026 •

Copy link
Copy Markdown
Owner

Users can now run the studio agent on their own NEAR AI account, from a new NEAR AI account button in the agent panel. Requests go straight from the browser to NEAR AI, because its CORS settings now allow our site. The existing proxy and session pass stay as they are.

What's new

  • Account page (nearai-connect.html): opens from the panel button or /nearai connect, on its own page because the app's COOP header breaks wallet popups.
    • Wallet sign-in: creates a key with a chosen spending limit and a 90-day expiry, then revokes the session. A session can't call inference, so a key is required.
    • Pasted key: for accounts not tied to a wallet. It's checked before saving.
  • Chat messages: out-of-credits and rejected-key errors offer Manage account and Try again, and keep the typed message. With no AI connected, the chat offers the account page.

Keys stay in localStorage and never reach the OPFS repo.

Bugs fixed

  • A user's key was ignored on the deployed site: the default base URL put it in proxy mode, so /nearai <key> silently used our key.
  • The session pass was attached to direct NEAR AI requests.
  • A 402 on the user's own account cleared the pass and offered to sell one.
  • /pay kept COOP in production, because Pages redirects /pay.html to /pay and only the .html URL was exempt. This could break popup wallets. It's outside the panel work, so drop it if you'd rather ship it separately.

Testing

Passing

  • CI, including the full Playwright suite.
  • Wallet sign-in with NEAR Mobile on the pages.dev preview and on localhost, with a funded account: connected, and real agent turns ran. Signing in twice no longer hits the duplicate key name.
  • Pasted real key on localhost: bad key refused, then a real turn with no proxy requests.

Not tested

  • Popup wallets such as Meteor.
  • The /pay COOP header fix hasn't been checked on a deployment.

Seen once, unexplained

  • Two local browser test timeouts, at least one in the waitForAppReady boot wait. They passed on rerun and in CI.

Risks

  • Wallet sign-in may break without notice: /v1/auth/near isn't in NEAR AI's API spec, and key management is marked as moving to cloud-platform, which doesn't allow our site today. Pasted keys don't use key management, though their check call is also marked as moving, and they're saved even if that check can't answer.
  • New users need credits: a new wallet account gets a 402 until it's funded.
  • Disconnect is local: it removes the key from the browser, and the key itself stays active until deleted at cloud.near.ai or until it expires.

Related, not in this PR

Our proxy serves users on our key, and the repo has no End User Agreement, which NEAR AI's terms require (§6.1(b), §7.7).

🤖 Generated with Claude Code

…ted key

The agent can now run on the user's own credits and talk to NEAR AI directly
from the browser. A wallet sign-in only yields a session and inference accepts
API keys only, so the session creates one capped, expiring key and is revoked.

Fixes found on the way:
- a user key on the deployed site was ignored and routed through the proxy
- the session pass was attached to requests going directly to NEAR AI
- a 402 on the user's own account cleared the pass and offered to sell one
- /pay kept COOP in production, because Pages redirects /pay.html to /pay

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

Deploying webassemblymusic with  Cloudflare Pages  Cloudflare Pages

Latest commit: a6228dc
Status: ✅  Deploy successful!
Preview URL: https://1f6a13f0.webassemblymusic.pages.dev
Branch Preview URL: https://nearai-own-account.webassemblymusic.pages.dev

View logs

petersalomonsen and others added 3 commits November 8, 2026 12:22
NEAR AI answers 409 to a second key with the same name in a workspace, so a
fixed name broke every sign-in after the first. That included reconnecting in
the same browser, since the old key is only deleted after the new one exists.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Offering a sign-in to someone already connected read as if they were not. They
stay available behind "Use a different account".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@petersalomonsen
petersalomonsen merged commit de18c8b into master Nov 8, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant