Skip to content

[#842] Register tab: Link AI Writer + Register New Agent#847

Merged
realproject7 merged 4 commits intomainfrom
task/842-register-link-ai-writer
Apr 5, 2026
Merged

[#842] Register tab: Link AI Writer + Register New Agent#847
realproject7 merged 4 commits intomainfrom
task/842-register-link-ai-writer

Conversation

@realproject7
Copy link
Copy Markdown
Owner

Summary

  • Split Register tab into two sections: "Link AI Writer (PlotLink OWS App)" and "Register New AI Agent"
  • Added POST /api/user/verify-ows-binding — verifies OWS binding signature via verifyMessage (ecrecover)
  • Link AI Writer flow: paste OWS wallet + binding signature → verify → register on ERC-8004 (human as owner) → bind OWS wallet via setAgentWallet
  • Existing direct registration preserved below with "or" separator
  • Version bumped to 0.1.14

Test plan

  • Register tab shows two sections with "or" separator
  • Link AI Writer: valid OWS wallet + signature verifies and triggers on-chain registration
  • Link AI Writer: invalid signature shows error
  • Link AI Writer: success state shows agent ID and tx links
  • Direct Registration: existing flow still works unchanged
  • POST /api/user/verify-ows-binding returns { valid: true } for valid signatures
  • POST /api/user/verify-ows-binding returns { valid: false } for invalid/mismatched signatures

Fixes #842

🤖 Generated with Claude Code

Add "Link AI Writer (PlotLink OWS App)" section at top of Register tab
with OWS wallet binding verification flow. User pastes OWS wallet address
and binding signature, verified via ecrecover, then registers on ERC-8004
with human wallet as owner and OWS wallet bound via setAgentWallet.

Add POST /api/user/verify-ows-binding endpoint that validates binding
signatures using viem verifyMessage.

Keep existing direct registration flow below as "Register New AI Agent"
section for developers. Bump to v0.1.14.

Fixes #842

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 5, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
plotlink Ignored Ignored Apr 5, 2026 6:10am

Request Review

Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: REQUEST CHANGES

Summary

The existing direct-registration flow is preserved, but the new OWS-link path has a blocking wallet-binding bug and then reports success even after that bind step fails.

Findings

  • [high] The new flow signs AgentWalletSet with the connected owner wallet, not with the OWS wallet being bound. In this file, the link flow calls signTypedDataAsync directly from the owner context before setAgentWallet (src/components/AgentRegister.tsx:138-150), while the existing direct-registration flow in the same component requires switching to the agent wallet to produce that signature first (src/components/AgentRegister.tsx:351-385). The SDK helper documents the same contract expectation: the agent wallet signs, the owner submits (packages/cli/src/sdk/client.ts:475-533). As written, the bind transaction will fail and the OWS wallet never gets attached to the registered agent.
    • File: src/components/AgentRegister.tsx:138
    • Suggestion: reuse the existing two-wallet binding pattern here: obtain the EIP-712 signature from the OWS wallet, then submit setAgentWallet from the owner wallet.
  • [high] The component persists and renders the link as successful before wallet binding succeeds. It writes agentWallet into /api/user/agent-register immediately after register() (src/components/AgentRegister.tsx:117-129), and the success branch renders whenever linkedAgentId exists even if walletBound is still false (src/components/AgentRegister.tsx:175-199). Because finally resets bindingWallet to false, any bind failure falls into the success UI and hides the error.
    • File: src/components/AgentRegister.tsx:117
    • Suggestion: only persist agent_wallet and show the success state after setAgentWallet has confirmed; otherwise keep the error/form state visible.

Decision

Request changes. In the current implementation, the happy path can register the human-owned agent but fail to bind the OWS wallet, while still telling the user that linking succeeded.

setAgentWallet requires the agent (OWS) wallet to sign EIP-712 data,
but the OWS wallet is on the user's local machine and cannot sign via
RainbowKit. Remove the bind step — register on-chain with human as
owner, persist OWS wallet to DB for display. On-chain wallet binding
can be done from the OWS app side in a future ticket.

Also fix success state to only show after both on-chain registration
and DB persist complete, preventing false success on partial failure.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: REQUEST CHANGES

Summary

The latest push fixes the premature-success problem, but it removes the on-chain owner+agent wallet binding instead of implementing it. That means the PR still does not satisfy issue #842.

Findings

  • [high] The Link AI Writer flow no longer binds the OWS wallet as the agent wallet on ERC-8004. The updated implementation explicitly stops at register() and only stores the OWS wallet in the DB for display (src/components/AgentRegister.tsx:114-127). Issue #842 requires "ERC-8004 registration with separate owner + agent wallet" and the task list specifically says to proceed with the human wallet as owner and the OWS wallet as agent wallet after signature verification. With the current code, the chain state still has only the owner wallet attached, so the required linked-wallet registration is not actually completed.
    • File: src/components/AgentRegister.tsx:114
    • Suggestion: keep the issue open and implement the missing on-chain bind in this ticket, or explicitly rescope the issue/PR before approval. As written, this PR claims to fix #842 but leaves the required owner/agent split unfinished.

Decision

Request changes. The PR still misses a stated acceptance criterion from #842 even though the UI/DB behavior is cleaner now.

After registration, show wallet bind step: user goes to OWS app,
enters Agent ID, generates EIP-712 AgentWalletSet signature, then
pastes signature + deadline on PlotLink to call setAgentWallet.
This completes the on-chain owner/agent wallet split.

The EIP-712 signature must come from the OWS (agent) wallet, not
the browser wallet, so a round-trip to the OWS app is required.
Companion endpoint added to plotlink-ows in a separate PR.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: REQUEST CHANGES

Summary

The owner/agent-wallet split is now wired end-to-end, but the registration step still persists agent_wallet before setAgentWallet succeeds. In the current app, that makes the OWS wallet look like a registered agent wallet even if the on-chain bind never happens.

Findings

  • [high] The new flow writes agent_wallet during registration, before the wallet-bind transaction.
    • File: src/components/AgentRegister.tsx:125
    • Suggestion: keep the OWS wallet out of /api/user/agent-register and only write agent_wallet after setAgentWallet confirms, or store it in a separate pending field.
  • [high] The app's DB-first writer detection treats any row with agent_wallet= and non-null agent_id as an agent immediately.
    • File: lib/contracts/erc8004.ts:195
    • Suggestion: same fix as above; otherwise an unbound OWS wallet can be misclassified as registered.

Decision

Requesting changes because the current flow can still behave as if the AI writer is linked before the ERC-8004 wallet bind is complete.

Don't write agent_wallet to DB during initial registration — only
write it after the on-chain setAgentWallet tx confirms. Prevents
misclassifying an unbound OWS wallet as a linked agent.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: APPROVE

Summary

The follow-up commit resolves the remaining correctness issue in the Link AI Writer flow. agent_wallet is no longer persisted during initial registration, so the app no longer risks treating an unbound OWS wallet as fully linked before setAgentWallet succeeds.

Findings

  • None.

Decision

Approving. The separate owner/agent-wallet flow is now implemented without the premature DB classification bug from the prior revision.

@realproject7 realproject7 merged commit 52e2c84 into main Apr 5, 2026
5 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.

[#841] Register tab: Link AI Writer + Register New Agent sections

2 participants