{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/codai-ro/json-schema/codai-ro-environment-task-schema.json",
  "title": "Agent task",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/codai-ro-projects-environments-api-openapi.yml#/components/schemas/EnvironmentTask",
  "type": "object",
  "required": [
    "id",
    "environment_id",
    "user_id",
    "session_id",
    "prompt",
    "branch",
    "status",
    "result",
    "created_at",
    "started_at",
    "finished_at",
    "output_signature"
  ],
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid"
    },
    "environment_id": {
      "type": "string",
      "format": "uuid"
    },
    "user_id": {
      "type": "string",
      "format": "uuid"
    },
    "session_id": {
      "type": [
        "string",
        "null"
      ],
      "format": "uuid",
      "description": "Conversation session the agent runs in (follow it with the sessions API)."
    },
    "prompt": {
      "type": "string"
    },
    "branch": {
      "type": [
        "string",
        "null"
      ]
    },
    "status": {
      "type": "string",
      "enum": [
        "queued",
        "running",
        "done",
        "failed"
      ],
      "description": "`queued` → `running` (claimed by the relay) → `done` | `failed`."
    },
    "result": {
      "type": "object",
      "description": "Filled when the task finishes; every field may be null.",
      "properties": {
        "diff_stat": {
          "type": [
            "string",
            "null"
          ]
        },
        "commit_sha": {
          "type": [
            "string",
            "null"
          ]
        },
        "branch": {
          "type": [
            "string",
            "null"
          ]
        },
        "preview_url": {
          "type": [
            "string",
            "null"
          ]
        },
        "error": {
          "type": [
            "string",
            "null"
          ]
        }
      }
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    },
    "started_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "finished_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "output_signature": {
      "description": "**Experimental, unaudited (HIDE protocol).** Gateway signature of the finished output, `null` while the\ntask runs or when signing is disabled. Provenance only, never authentication; verify with\n`POST /v1/verify/agent-output`.\n",
      "oneOf": [
        {
          "$ref": "#/$defs/EnvironmentTaskOutputSignature"
        },
        {
          "type": "null"
        }
      ]
    }
  },
  "$defs": {
    "EnvironmentTaskOutputSignature": {
      "type": "object",
      "title": "Agent output signature (experimental)",
      "required": [
        "alg",
        "context",
        "key_id",
        "sig",
        "signed_at"
      ],
      "properties": {
        "alg": {
          "type": "string"
        },
        "context": {
          "type": "string"
        },
        "key_id": {
          "type": "string",
          "description": "16 hex characters identifying the signing key."
        },
        "sig": {
          "type": "string",
          "description": "Base64 hybrid signature."
        },
        "signed_at": {
          "type": "string",
          "format": "date-time"
        }
      }
    }
  }
}