# Cannabis and tomato support diagnosis.
# An unhealthy tomato result names one cause (spider mites and leaf miners count as pests).
# Every response has a species_name field, null when no species is detected.
arazzo: 1.0.1
info:
  title: PlantLab Agent Workflow
  summary: Diagnose an image and submit feedback with the original request_id.
  version: 1.0.0
sourceDescriptions:
  - name: plantlabPublicApi
    url: /openapi.yaml
    type: openapi
workflows:
  - workflowId: diagnoseAndFeedback
    summary: Diagnose an uploaded image and optionally submit feedback.
    description: >
      This workflow describes the canonical PlantLab agent flow: upload an image,
      inspect the result, and later submit user feedback referencing the original
      request_id.
    inputs:
      type: object
      properties:
        apiKey:
          type: string
        image:
          type: string
        isAccurate:
          type: boolean
      required:
        - apiKey
        - image
    steps:
      - stepId: diagnose
        operationPath: '{$sourceDescriptions.plantlabPublicApi.url}#/paths/~1diagnose/post'
        parameters:
          - name: X-API-Key
            in: header
            value: $inputs.apiKey
        requestBody:
          contentType: multipart/form-data
          payload:
            image: $inputs.image
        successCriteria:
          - condition: $statusCode == 200
        outputs:
          requestId: $response.body.request_id
          response: $response.body
        onSuccess:
          - name: feedbackWhenProvided
            type: goto
            stepId: submitFeedback
            criteria:
              - condition: $inputs.isAccurate != null
          - name: returnDiagnosis
            type: end
      - stepId: submitFeedback
        operationPath: '{$sourceDescriptions.plantlabPublicApi.url}#/paths/~1feedback/post'
        parameters:
          - name: X-API-Key
            in: header
            value: $inputs.apiKey
        requestBody:
          contentType: application/json
          payload:
            request_id: $steps.diagnose.outputs.requestId
            is_accurate: $inputs.isAccurate
        successCriteria:
          - condition: $statusCode == 201
