{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://weverlabs.com/schemas/tokenops-result-package.schema.json",
  "title": "TokenOps Result Package",
  "description": "Schema for delivery-ready TokenOps output after settlement receipt, paid agent usage, usage receipt, result contract, callback payload, and delivery evidence are reviewed.",
  "type": "object",
  "required": [
    "package_type",
    "operating_tool",
    "evidence_status",
    "evidence_score",
    "executive_summary",
    "recommended_next_actions"
  ],
  "additionalProperties": true,
  "properties": {
    "package_type": {
      "type": "string",
      "const": "tokenops_result_package"
    },
    "operating_tool": {
      "type": "string",
      "const": "tokenops"
    },
    "evidence_status": {
      "type": "string",
      "enum": [
        "sufficient",
        "partial",
        "insufficient",
        "unknown"
      ]
    },
    "evidence_score": {
      "type": "integer",
      "minimum": 0,
      "maximum": 100
    },
    "work_order_id": {
      "type": "string"
    },
    "agent_task_run_id": {
      "type": "string"
    },
    "settlement_reference": {
      "type": "string"
    },
    "payment_request": {
      "type": "object",
      "additionalProperties": true,
      "properties": {
        "reference": {
          "type": "string"
        },
        "provider": {
          "type": "string"
        },
        "status": {
          "type": "string"
        }
      }
    },
    "usage_receipt": {
      "type": "object",
      "additionalProperties": true,
      "properties": {
        "reference": {
          "type": "string"
        },
        "credits_debited": {
          "type": "number"
        },
        "remaining_credits": {
          "type": "number"
        }
      }
    },
    "received_inputs": {
      "type": "integer",
      "minimum": 0
    },
    "uploaded_files": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": true,
        "properties": {
          "filename": {
            "type": "string"
          },
          "purpose": {
            "type": "string"
          }
        }
      }
    },
    "result_contract": {
      "type": "object",
      "additionalProperties": true
    },
    "callback_delivery": {
      "type": "object",
      "additionalProperties": true
    },
    "executive_summary": {
      "type": "string"
    },
    "work_performed": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "findings": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "open_items": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "recommended_next_actions": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "client_deliverable": {
      "type": "string"
    },
    "receipt_ledger_entry": {
      "$ref": "https://weverlabs.com/schemas/tokenops-usage-receipt.schema.json"
    },
    "callback_payload": {
      "$ref": "https://weverlabs.com/schemas/agent-callback-payload.schema.json"
    },
    "agent_task_run": {
      "$ref": "https://weverlabs.com/schemas/agent-task-run.schema.json"
    },
    "agent_result_attestation": {
      "$ref": "https://weverlabs.com/schemas/agent-result-attestation.schema.json"
    },
    "agent_task_ledger_url": {
      "type": "string",
      "format": "uri"
    },
    "result_attestation_url": {
      "type": "string",
      "format": "uri"
    },
    "handshake_id": {
      "type": "string",
      "description": "Optional upstream agent handshake ID."
    },
    "preflight_id": {
      "type": "string",
      "description": "Optional upstream preflight check ID."
    },
    "contract_id": {
      "type": "string",
      "description": "Optional upstream run contract ID."
    },
    "run_contract_url": {
      "type": "string",
      "format": "uri",
      "description": "Optional URL for the run contract object."
    },
    "agent_result_contract": {
      "$ref": "https://weverlabs.com/schemas/agent-result-contract-v2.schema.json"
    },
    "agent_result_contract_url": {
      "type": "string",
      "format": "uri"
    },
    "settlement_receipt": {
      "$ref": "https://weverlabs.com/schemas/agent-settlement-receipt.schema.json"
    },
    "settlement_receipt_url": {
      "type": "string",
      "format": "uri"
    },
    "usage_receipt_url": {
      "type": "string",
      "format": "uri"
    },
    "os_support_matrix_url": {
      "type": "string",
      "format": "uri"
    },
    "rail_binding_url": {
      "type": "string",
      "format": "uri"
    },
    "runtime_execution_plan_url": {
      "type": "string",
      "format": "uri"
    }
  }
}
