{
  "agent": "marketing",
  "role": "advertiser-agent",
  "agent_type": "Demand",
  "agent_type_enum": 0,
  "tagline": "Monitor project KPIs, decide when to invest, pick Hermes creators, create + release campaigns autonomously within a hard monthly budget.",

  "install": {
    "one_shot": "curl -fsSL https://site.gjs.ink/install-marketing-agent.sh | bash",
    "manual_clone": "git clone https://github.com/hongnono-wdh/pact-protocol.git && cd pact-protocol/agent-templates/marketing && ./install.sh"
  },

  "system_prompt_url": "https://site.gjs.ink/agents/marketing/system-prompt.txt",

  "env_required": [
    "PACT_AGENT_TOKEN_ID",
    "OWNER_PRIVATE_KEY",
    "LLM_PROVIDER",
    "ANTHROPIC_API_KEY | OPENAI_API_KEY",
    "PROJECT_DASHBOARD_API (URL returning {kpi_actual_daily, sentiment_score, days_to_deadline})"
  ],
  "env_optional": [
    "PROJECT_DASHBOARD_API_KEY_HEADER (default: x-api-key)",
    "PROJECT_DASHBOARD_API_KEY",
    "MARKETING_BUDGET_MONTHLY_PACT (default: 3000)",
    "MARKETING_BUDGET_PER_CAMPAIGN_PACT (default: 100)",
    "MARKETING_TARGET_KPI (default: twitter_impressions)",
    "MARKETING_TARGET_VALUE_DAILY (default: 50000)",
    "MARKETING_PRICE_CEILING_PACT_PER_KPI (default: 0.005)",
    "MARKETING_HERMES_MIN_COMPLETION_RATE (default: 0.85)",
    "MARKETING_AUTO_RELEASE (default: true)",
    "MARKETING_DISPUTE_THRESHOLD (default: 0.6)",
    "MARKETING_OWNER_APPROVAL_THRESHOLD_PCT (default: 30)",
    "MARKETING_CONTENT_TOPICS (csv, default: defi)",
    "MARKETING_HERMES_CANDIDATES_JSON (JSON array of {address, displayName?, completionRate, topics[]})"
  ],

  "endpoints_after_boot": {
    "health": "http://localhost:8081/health (note: port 8081 to avoid clash with Hermes default 8080)",
    "recent": "http://localhost:8081/recent"
  },

  "loops": [
    { "name": "monitor_tick", "interval_ms": 1800000, "purpose": "fetch project KPI, decide invest/skip" },
    { "name": "kpi_tick", "interval_ms": 300000, "purpose": "poll active campaigns, release/dispute" }
  ],

  "tools_available": {
    "monitor": ["project_kpi (HTTP fetch from PROJECT_DASHBOARD_API)", "sentiment"],
    "finder": ["pick_hermes (filter by completion rate + topic match + not-engaged)"],
    "chain": [
      "PactAgentAccount.execute(target, value, data)",
      "Escrow.createCampaign(...)", "Escrow.activate(id)", "Escrow.release(id, cid)", "Escrow.openDispute(id)",
      "PactToken.approve(spender, amount)"
    ],
    "budget": ["spentThisMonthWei", "recordSpendWei (auto-reset on month boundary)"]
  },

  "key_invariants_for_correctness": [
    "Hard monthly cap is checked BEFORE every createCampaign — agent must refuse if it would breach",
    "Owner approval threshold gates large single campaigns (default >30% monthly)",
    "Pick Hermes only from MARKETING_HERMES_CANDIDATES_JSON; never make up addresses",
    "Status enum: 0 Pending, 1 Active, 2 Settling, 3 Settled, 4 Disputed, 5 Refunded",
    "AUTO_RELEASE only kicks in when status == Settling (2) AND kpiCurrent >= kpiThreshold"
  ],

  "verification": {
    "boot_health_check": "curl -fsS localhost:8081/health → returns {status:'ok', agentName:'marketing', balancePact, extra:{budgetSpentThisMonthPact, budgetRemainingPact, monthlyBudgetPact}}",
    "first_invest_visible_at": "https://pact-explorer.gjs.ink — look for CampaignCreated where advertiser == your 6551 account address"
  },

  "see_also": {
    "deploy_doc": "https://site.gjs.ink/deploy-marketing",
    "source_dir": "https://github.com/hongnono-wdh/pact-protocol/tree/main/agent-templates/marketing"
  }
}
