feat: Marketing Swarm v2 — templates, SDK, CLI, MCP, and docs#7
feat: Marketing Swarm v2 — templates, SDK, CLI, MCP, and docs#7tonyoconnell wants to merge 8 commits intomainfrom
Conversation
…generator Templates: - swarm-starter: Full commerce stack for agent swarms - PaymentService, PricingTable, TierManager - WalletManager, RevenueTracker, SelfAwareMixin - HoldingsManager for cross-token operations - Memory + LLM integration (ASI1-mini) - consumer-commerce: Multi-token payment processing - FET + USDC support with fiat onramp - Invoice management, delegation flows - Booking, subscription, escrow presets - people.ts: Org chart to agent swarm generator - Transform any org structure into coordinated agents - C-Suite → infrastructure layer - Departments → specialist agents - Teams → service agents - Built-in examples: startup, smb, enterprise, marketing Presets: - 5 C-Suite roles: ceo, cto, cfo, coo, cro - 7 Marketing roles: writer, social, community, analytics, outreach, ads, strategy - 4 Consumer commerce roles: payment-processor, booking-agent, subscription-manager, escrow-service Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
New modules: - payments.ts: Multi-token payment service - FET + USDC support on BSC (testnet/mainnet) - Token registry with known addresses - ERC-20 transfer/balance functions - delegation.ts: Spending delegation (ERC-20 approve/transferFrom) - checkAllowance, spendFromDelegation - createSpendingLimitHandoff for user approval flow Enhanced modules: - handoff.ts: Add fiat onramp links (MoonPay/Transak) - commerce.ts: Add invoice CRUD, active invoice tracking - types.ts: PaymentToken, Invoice, Delegation types - onchain.ts: Multi-token balance queries Exports 26 functions (verified by smoke tests) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
New commands: - marketing: Deploy 7-agent Marketing Team (960 FET) - alliance: Deploy 27-agent ASI Alliance (3,240 FET) - org-template: Generate YAML org chart templates - swarm-from-org: Deploy custom swarms from org charts - wallet: Multi-token balance, send, delegate operations - pay: Direct payments in FET/USDC Enhanced commands: - create: Register marketing/alliance commands - scaffold: Support org-chart generation Options: - --dry-run: Preview without deploying - --output <dir>: Scaffold locally only - --json: Machine-readable output - -y, --yes: Skip confirmation prompts Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
New tools: - multi_token_payment: Send FET/USDC payments - check_spending_limit: Read ERC-20 allowances - create_delegation: Generate delegation handoff links - get_fiat_link: Generate MoonPay/Transak URLs - create_invoice: Create payment invoices - list_invoices: Query invoices by status - get_multi_token_balances: FET + USDC + BNB balances Enhanced tools: - scaffold_swarm: Support org-chart-based generation - check_agent_commerce: Add invoice/delegation tracking - deploy_swarm: Enhanced preset support Total tools: 28 (all verified working) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
New rules: - marketing-swarm.md: 7-role marketing team with pricing/intervals - consumer-payments.md: Multi-token support, delegation, invoices - workflow.md: 8-phase agent lifecycle (NEVER skip Phase 3: Optimize) New skills: - /alliance: Deploy 27-agent ASI Alliance - /welcome: Onboarding flow for new users Updated: - payment-protocol.md: Verified official imports available - uagent-patterns.md: Runtime-verified wallet access patterns - build-agent, build-swarm, deploy: Phase 3 optimization step Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
New documentation: - workflow.md: Complete 8-phase agent lifecycle - marketing-team.md: 7-agent marketing swarm guide - tutorial-marketing-team.md: Step-by-step deployment tutorial - people-to-swarm.md: Org chart to agent transformation - the-agent-economy.md: Economic infrastructure deep dive - playbook.md: Comprehensive agent development playbook - openclaw-implementation.md: OpenCLaw integration guide - stack.md: Technology stack overview - sequence.md: Agent interaction diagrams Updated docs to reference new commands and patterns. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Marketing Team agents (7 fully working examples): - writer.py: Content creation via ASI1-mini - social.py: Twitter/X posting and scheduling - community.py: Telegram group management - analytics.py: Engagement reports - outreach.py: Partnership pitches via Resend - ads.py: Ad copy and A/B testing - strategy.py: Campaign coordination + cross-agent delegation Org chart templates (YAML): - startup.yaml: 2 agents (founders) - smb.yaml: 6 agents (3 C-suite + 3 depts) - enterprise.yaml: 14 agents (5 C-suite + 6 depts + 3 teams) Updated: - CLAUDE.md: Document new commands and workflow - README.md: Marketing and Alliance command docs - smoke-tests: Verify 9 templates, 16 presets Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Remove 17 compiled JavaScript files that were accidentally committed to src/. These files should only exist in dist/ after running npm run build. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
| const toAtestfet = (fet: number): number => Number(BigInt(Math.floor(fet * 100)) * (FET / 100n)); | ||
|
|
||
| /** Default pricing by tier */ | ||
| const DEFAULT_PRICING = { | ||
| "c-suite": 0.02, // FET per query | ||
| department: 0.01, | ||
| team: 0.005, | ||
| }; |
There was a problem hiding this comment.
Bug: The toAtestfet function incorrectly truncates any price less than 0.01 FET to zero due to using Math.floor on the multiplied value before converting to BigInt.
Severity: CRITICAL
Suggested Fix
Modify the toAtestfet function to handle floating-point numbers without premature truncation. The calculation should be performed using BigInt to preserve precision. A potential fix is to multiply the fet value directly by the full FET unit representation (10^18) before converting to BigInt, for example: BigInt(Math.floor(fet * Number(FET))).
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: packages/templates/src/people.ts#L110-L117
Potential issue: The `toAtestfet` function, defined as `Number(BigInt(Math.floor(fet *
100)) * (FET / 100n))`, incorrectly handles prices smaller than 0.01 FET. For example, a
price of `0.005` FET becomes `Math.floor(0.5)`, which evaluates to `0`. This results in
agents intended to have micropayments (e.g., `DEFAULT_PRICING.team = 0.005`) having
their services priced at zero. This is a silent failure that leads to unintended free
services and revenue loss for deployed agents.
Did we get this right? 👍 / 👎 to inform future reviews.
| const abi = [ | ||
| ...ERC20_ABI, | ||
| 'function transfer(address to, uint256 amount) external returns (bool)', | ||
| ]; | ||
| const contract = new ethers.Contract(tokenAddress, abi, wallet); |
There was a problem hiding this comment.
Bug: The transferToken function creates a duplicate ABI entry for the transfer function by spreading ERC20_ABI and then re-declaring it, which will cause a runtime error.
Severity: CRITICAL
Suggested Fix
Remove the redundant transfer function signature from the abi array definition within the transferToken function. The spread ...ERC20_ABI already includes the necessary signature, so the manual addition is not needed.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: packages/sdk/src/payments.ts#L187-L191
Potential issue: In the `transferToken` function, a new ABI is constructed by spreading
the existing `ERC20_ABI` and then manually adding a `transfer` function signature.
However, `ERC20_ABI` already contains this exact signature. This duplication will cause
the `ethers.js` v6 library to throw a runtime error when `new Contract(...)` is called,
as it does not permit duplicate ABI entries. This breaks any functionality that relies
on token transfers, such as the `agentlaunch pay` command and the `multi_token_payment`
tool.
Did we get this right? 👍 / 👎 to inform future reviews.
Hovessian
left a comment
There was a problem hiding this comment.
Code Review: Changes Requested
Critical — Must Fix Before Merge
1. No spending limits or confirmation on MCP payment tools
packages/mcp/src/tools/payments.ts — The multi_token_payment tool can drain a wallet without any authorization gate. Any MCP client can call it. At minimum, add a per-call spending cap or require confirmation for amounts above a threshold.
2. wallet send and pay commands have no confirmation prompt
packages/cli/src/commands/wallet.ts, packages/cli/src/commands/pay.ts — Unlike marketing and alliance which prompt before deploying, these commands transfer tokens immediately. An accidental agentlaunch wallet send USDC 0x... 10000 is irreversible.
3. wallet balances requires WALLET_PRIVATE_KEY for a read-only operation
packages/cli/src/commands/wallet.ts — Should accept --address as an alternative to avoid loading the private key unnecessarily for balance queries.
High Priority
4. Address validation inconsistent across payment flows
packages/sdk/src/payments.ts, packages/sdk/src/delegation.ts, packages/cli/src/commands/wallet.ts, packages/cli/src/commands/pay.ts — handoff.ts has validateEthAddress() but none of the new payment code uses it. All functions accepting Ethereum addresses should validate format.
5. formatEther hardcoded instead of formatUnits(balance, decimals)
packages/sdk/src/payments.ts — Multiple places assume 18 decimals. The PaymentToken type already carries a decimals field — use ethers.formatUnits(balance, token.decimals) and ethers.parseUnits(amount, token.decimals) so adding USDT (6 decimals) doesn't silently break balances.
6. Generated Python template doesn't validate addresses before URL construction
packages/templates/src/templates/swarm-starter.ts — generate_buy_link() and generate_sell_link() in HoldingsManager concatenate token_address directly into URLs. Unlike the TypeScript SDK, no validation prevents URL injection via characters like ? or #.
Medium Priority
7. Parallel deployment waves aren't actually parallel
packages/cli/src/commands/marketing.ts, packages/cli/src/commands/alliance.ts — Waves marked parallel: true still iterate with for...of. Should use Promise.all() for parallel waves.
8. scaffoldSwarm() duplicated verbatim between marketing.ts and alliance.ts
Extract to a shared utility to avoid DRY violation and divergent bug fixes.
9. delegationKey() doesn't include spender
packages/sdk/src/delegation.ts — Multiple delegations from the same owner for the same token symbol silently overwrite each other. Include spender in the compound key.
10. MCP server has no access control distinction
packages/mcp/src/index.ts — All 28 tools are callable by any MCP client with no concept of "dangerous" vs "safe" tools. Consider at least categorizing tools and documenting the risk.
Low Priority (non-blocking)
- No pagination on
listInvoices()/listDelegations() - CLI version hardcoded as
"1.6.0"instead of reading frompackage.json - Invoice status filter accepts any string cast to
InvoiceStatuswithout validation .envparser doesn't handle quoted values
The feature scope is solid and well-structured. Addressing the critical and high items (especially around payment security) will make this production-ready.
🤖 Generated with Claude Code
Summary
Major feature release adding complete marketing swarm infrastructure:
Templates (
packages/templates)SDK (
packages/sdk)CLI (
packages/cli)npx agentlaunch marketing— Deploy 7-agent Marketing Team (960 FET)npx agentlaunch alliance— Deploy 27-agent ASI Alliance (3,240 FET)npx agentlaunch wallet balances/send/delegatenpx agentlaunch pay <address> <amount> --token USDCnpx agentlaunch org-template --size smbnpx agentlaunch swarm-from-org people.yamlMCP (
packages/mcp)multi_token_payment,check_spending_limit,create_delegation,get_fiat_link,create_invoice,list_invoices,get_multi_token_balancesExamples
Rules & Skills
marketing-swarm.md,consumer-payments.md,workflow.md/alliance,/welcomeskillsTest plan
npm run build— All packages compilenpm run test:publish— 5/5 smoke tests pass🤖 Generated with Claude Code