feat: SETUP_AGENT - unified agent setup with create and connect modes#76
Merged
pcarranzav merged 12 commits intomainfrom Apr 10, 2026
Merged
feat: SETUP_AGENT - unified agent setup with create and connect modes#76pcarranzav merged 12 commits intomainfrom
pcarranzav merged 12 commits intomainfrom
Conversation
Add the ability to connect an agent key to an existing agent account instead of creating a new one. This enables the primary use case where a user creates an agent in the dashboard, then sets it up via CLI. - New `ConnectAgentKeyApprovalRequest` type in types.ts - New `requestConnectAgentKey()` method on ApprovalClient - New `--agent <address>` option on `ampersend setup start` - `setup finish` works unchanged (same resolved payload shape) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
--name is for agent name (create flow), --key-name is for the key name (connect flow with --agent). Avoids confusing dual semantics. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add key_name field to CreateAgentApprovalRequest type - Pass key_name through approval client for create flow - --key-name now works for both create and connect flows - Update SKILL.md with connect-to-existing docs, key naming explanation, and per-flow option tables Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- CLI setup start now outputs verificationCode (6-digit code derived from keccak256 of the key address) for both create and connect flows - SKILL.md updated to instruct agents to show the verification code to the user alongside the approval URL Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Consolidate the separate CONNECT_AGENT_KEY flow into a unified SETUP_AGENT approach. Instead of a separate requestConnectAgentKey() method, requestAgentCreation() now accepts optional agent_address and connect_to_existing fields. - Add agent_address, connect_to_existing, key_name to CreateAgentApprovalRequest - Remove ConnectAgentKeyApprovalRequest (if present) - Remove requestConnectAgentKey() (if present) - CLI: --agent, --connect-to-existing, --key-name all go through requestAgentCreation() - SKILL.md: updated with new connect options Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
423347c to
2001d88
Compare
…te ConnectAgentKeyApprovalRequest Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
9539cab to
96c055a
Compare
Collaborator
matiasedgeandnode
left a comment
There was a problem hiding this comment.
I would suggest you consider the following:
TL;DR: Replace --connect-to-existing with --mode <create|connect> (default: create). Add cross-flag validation. Add tests for the new flags.
Why: The three new flags (--agent, --connect-to-existing, --key-name) have no mutual exclusion validation, so contradictory combinations like --agent 0x... --connect-to-existing or --name "foo" --connect-to-existing silently pass through. A --mode flag makes intent explicit and validation trivial.
Design:
- --mode create (default): current behavior. --agent is invalid.
- --mode connect: connects a key to an existing agent. --agent is optional (omit = user picks in dashboard). --name and spend config flags (--daily-limit, etc.) are invalid since the agent already exists.
- --key-name is valid in both modes.
- --connect-to-existing flag goes away entirely — it's just --mode connect without --agent.
Validation to add (in executeSetupStart, before the API call):
- --mode connect + --name → error
- --mode connect + any spend config flag → error
- --mode create + --agent → error
Other:
- Group related flags in CreateAgentApprovalRequest by mode.
- Add tests for: connect mode with/without --agent, invalid address, --key-name passthrough, and the three validation errors above. The existing test infra (mockRequestAgentCreation,
ExitError pattern) makes this straightforward. - Update SKILL.md examples to use --mode connect instead of --connect-to-existing.
Add `mode: "create" | "connect" | "connect_choose"` field to CreateAgentApprovalRequest, replacing the implicit `connect_to_existing` boolean. CLI resolves mode from flags before sending. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add --mode <create|connect> CLI flag (default: create) - Cross-flag validation: --name and spend flags rejected in connect mode, --agent rejected in create mode - Add tests for connect mode, connect_choose, key-name passthrough, and all three validation error cases - Update SKILL.md examples Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
8793808 to
822d510
Compare
matiasedgeandnode
approved these changes
Apr 10, 2026
Collaborator
matiasedgeandnode
left a comment
There was a problem hiding this comment.
lgtm - nits:
- requestAgentCreation naming — method + JSDoc still say "create" but now handles connect flows too. Consider requestAgentApproval.
- Missing test: invalid --agent address — the INVALID_ADDRESS error path (setup.ts:66-69) has no test coverage.
- Missing test: --auto-topup alone in connect mode — existing test triggers rejection via dailyLimit with autoTopup: false. No test that autoTopup: true alone is rejected.
- key_name uses Schema.optional(NullOr(String)) but null is never sent — CLI does options.keyName ?? undefined. Could simplify to Schema.optional(String) to match agent_address / mode pattern.
- Payload building in approval.ts — four sequential if (x !== undefined) blocks. Works, but fragile as fields grow.
- Rename requestAgentCreation -> requestAgentApproval and CreateAgentApprovalRequest -> AgentApprovalRequest to reflect that the method now handles both create and connect flows - Simplify key_name schema: Schema.optional(String) instead of Schema.optional(NullOr(String)) since null is never sent - Replace sequential if-blocks with Object.fromEntries filter pattern - Add tests: invalid --agent address, --auto-topup alone in connect mode Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Consolidate agent setup into a single flow. Instead of separate
requestAgentCreation()andrequestConnectAgentKey()methods,requestAgentCreation()now accepts optional fields to control the mode:agent_address→ connect key to specific existing agentconnect_to_existing→ connect mode, user picks agent in dashboardChanges
CreateAgentApprovalRequest: added optionalagent_address,connect_to_existing,key_namefieldsConnectAgentKeyApprovalRequestandrequestConnectAgentKey()requestAgentCreation()passes throughagent_address,connect_to_existing,key_namewhen presentsetup start: new--agent <address>,--connect-to-existing,--key-name <name>flagsverificationCode(6-digit keccak256-derived) for MITM preventionCLI usage
Test plan
setup start --namesetup start --agent 0x...setup start --connect-to-existing🤖 Generated with Claude Code