{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/farmdash/json-schema/farmdash-agent-session-schema.json",
  "title": "AgentSession",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/farmdash-autopilot-api-openapi.yml#/components/schemas/AgentSession",
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "agentAddress": {
      "type": "string"
    },
    "status": {
      "type": "string",
      "enum": [
        "active",
        "paused",
        "halted",
        "expired"
      ]
    },
    "delegation": {
      "$ref": "#/$defs/DelegationRecord"
    },
    "autopilot": {
      "$ref": "#/$defs/AutopilotConfig"
    },
    "activePositions": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/TrackedPosition"
      }
    },
    "sessionPnl": {
      "type": "number"
    },
    "peakEquity": {
      "type": "number"
    },
    "tradeCount": {
      "type": "integer"
    },
    "lastHeartbeat": {
      "type": "string",
      "format": "date-time"
    },
    "createdAt": {
      "type": "string",
      "format": "date-time"
    },
    "expiresAt": {
      "type": "string",
      "format": "date-time"
    },
    "agentMeta": {
      "$ref": "#/$defs/AgentMeta"
    }
  },
  "$defs": {
    "AgentMeta": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string"
        },
        "version": {
          "type": "string"
        },
        "framework": {
          "type": "string"
        },
        "capabilities": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    },
    "AutopilotConfig": {
      "type": "object",
      "properties": {
        "strategies": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "funding_arb",
              "momentum",
              "mean_reversion",
              "portfolio_rebalance",
              "full_auto"
            ]
          }
        },
        "assets": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "maxEquityPct": {
          "type": "number"
        },
        "rebalanceIntervalMin": {
          "type": "integer"
        },
        "autoCompound": {
          "type": "boolean"
        },
        "riskPreference": {
          "type": "string",
          "enum": [
            "conservative",
            "balanced",
            "aggressive"
          ]
        },
        "riskSentinel": {
          "$ref": "#/$defs/RiskSentinelConfig"
        },
        "executionAlpha": {
          "$ref": "#/$defs/ExecutionAlphaConfig"
        }
      }
    },
    "DelegationRecord": {
      "type": "object",
      "properties": {
        "ownerAddress": {
          "type": "string"
        },
        "apiWalletAddress": {
          "type": "string"
        },
        "verified": {
          "type": "boolean"
        },
        "verifiedAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        }
      }
    },
    "ExecutionAlphaConfig": {
      "type": "object",
      "properties": {
        "mevSafetyMode": {
          "$ref": "#/$defs/SwapSafetyMode"
        },
        "maxQuoteDecayBps": {
          "type": "number"
        },
        "maxGasUsdPerAction": {
          "type": "number"
        },
        "requirePositiveNetEdge": {
          "type": "boolean"
        },
        "minNetEdgeUsd": {
          "type": "number"
        }
      }
    },
    "RiskSentinelConfig": {
      "type": "object",
      "properties": {
        "minHealthFactor": {
          "type": "number"
        },
        "minLiquidationBufferPct": {
          "type": "number"
        },
        "maxStablecoinDepegPct": {
          "type": "number"
        }
      }
    },
    "SwapSafetyMode": {
      "type": "string",
      "enum": [
        "strict",
        "balanced"
      ]
    },
    "TrackedPosition": {
      "type": "object",
      "properties": {
        "coin": {
          "type": "string"
        },
        "side": {
          "type": "string",
          "enum": [
            "long",
            "short"
          ]
        },
        "entryPrice": {
          "type": "number"
        },
        "size": {
          "type": "number"
        },
        "leverage": {
          "type": "number"
        },
        "stopLoss": {
          "type": [
            "number",
            "null"
          ]
        },
        "takeProfit": {
          "type": [
            "number",
            "null"
          ]
        },
        "openedAt": {
          "type": "string",
          "format": "date-time"
        },
        "strategy": {
          "type": "string"
        },
        "unrealizedPnl": {
          "type": "number"
        }
      }
    }
  }
}