{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://docs.nylorun.com/schemas/runtime-manifest/v1.json",
  "title": "Nylorun runtime manifest 1",
  "type": "object",
  "properties": {
    "$schema": {
      "type": "string"
    },
    "kind": {
      "type": "string",
      "enum": [
        "virtual",
        "pod",
        "none"
      ]
    },
    "image": {
      "type": "string",
      "minLength": 1
    },
    "resources": {
      "type": "object",
      "properties": {
        "cpus": {
          "type": "integer",
          "minimum": 1,
          "maximum": 9007199254740991
        },
        "memory": {
          "type": "string"
        }
      },
      "additionalProperties": false
    },
    "storage": {
      "type": "string"
    },
    "network": {
      "type": "object",
      "properties": {
        "allowedHosts": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "additionalProperties": false
    },
    "lifecycle": {
      "type": "object",
      "properties": {
        "idle": {
          "type": "string"
        },
        "deleteAfter": {
          "type": "string"
        }
      },
      "additionalProperties": false
    },
    "setup": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "command": {
            "type": "string",
            "minLength": 1
          },
          "cwd": {
            "type": "string",
            "minLength": 1,
            "maxLength": 1024
          },
          "timeout": {
            "type": "string"
          }
        },
        "required": [
          "command"
        ],
        "additionalProperties": false
      }
    },
    "files": {
      "type": "array",
      "items": {
        "anyOf": [
          {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "artifactId": {
                    "type": "string"
                  },
                  "version": {
                    "type": "integer",
                    "exclusiveMinimum": 0,
                    "maximum": 9007199254740991
                  },
                  "path": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 1024
                  }
                },
                "required": [
                  "artifactId",
                  "version",
                  "path"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "path": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 1024
                  },
                  "files": {
                    "type": "object",
                    "propertyNames": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 1024
                    },
                    "additionalProperties": {
                      "type": "string"
                    }
                  }
                },
                "required": [
                  "path",
                  "files"
                ],
                "additionalProperties": false
              }
            ]
          },
          {
            "type": "object",
            "properties": {
              "path": {
                "type": "string",
                "minLength": 1
              },
              "from": {
                "type": "string",
                "minLength": 1
              }
            },
            "required": [
              "path",
              "from"
            ],
            "additionalProperties": false
          }
        ]
      }
    },
    "limits": {
      "type": "object",
      "properties": {
        "artifacts": {
          "type": "object",
          "properties": {
            "fileBytes": {
              "type": "integer",
              "exclusiveMinimum": 0,
              "maximum": 9007199254740991
            },
            "totalBytes": {
              "type": "integer",
              "exclusiveMinimum": 0,
              "maximum": 9007199254740991
            }
          },
          "additionalProperties": false
        },
        "skills": {
          "type": "object",
          "properties": {
            "totalBytes": {
              "type": "integer",
              "exclusiveMinimum": 0,
              "maximum": 9007199254740991
            }
          },
          "additionalProperties": false
        },
        "disk": {
          "type": "object",
          "properties": {
            "versionBytes": {
              "type": "integer",
              "exclusiveMinimum": 0,
              "maximum": 9007199254740991
            },
            "versionEntries": {
              "type": "integer",
              "exclusiveMinimum": 0,
              "maximum": 9007199254740991
            }
          },
          "additionalProperties": false
        }
      },
      "additionalProperties": false
    },
    "secrets": {
      "type": "object",
      "propertyNames": {
        "type": "string"
      },
      "additionalProperties": {
        "oneOf": [
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "const": "environment_secret"
              },
              "allowedHosts": {
                "minItems": 1,
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "inject": {
                "type": "object",
                "properties": {
                  "header": {
                    "type": "string",
                    "pattern": "^[!#$%&'*+.^_`|~0-9A-Za-z-]+$"
                  },
                  "format": {
                    "type": "string",
                    "minLength": 1
                  }
                },
                "required": [
                  "header",
                  "format"
                ],
                "additionalProperties": false
              },
              "required": {
                "type": "boolean"
              },
              "description": {
                "type": "string"
              }
            },
            "required": [
              "type",
              "allowedHosts"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "const": "environment_variable"
              },
              "required": {
                "type": "boolean"
              },
              "description": {
                "type": "string"
              }
            },
            "required": [
              "type"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "const": "bearer"
              },
              "url": {
                "type": "string",
                "minLength": 1
              },
              "via": {
                "type": "string"
              },
              "identity": {
                "type": "object",
                "properties": {
                  "header": {
                    "type": "string",
                    "pattern": "^[!#$%&'*+.^_`|~0-9A-Za-z-]+$"
                  }
                },
                "required": [
                  "header"
                ],
                "additionalProperties": false
              },
              "required": {
                "type": "boolean"
              },
              "description": {
                "type": "string"
              }
            },
            "required": [
              "type",
              "url"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "const": "headers"
              },
              "url": {
                "type": "string",
                "minLength": 1
              },
              "via": {
                "type": "string"
              },
              "identity": {
                "type": "object",
                "properties": {
                  "header": {
                    "type": "string",
                    "pattern": "^[!#$%&'*+.^_`|~0-9A-Za-z-]+$"
                  }
                },
                "required": [
                  "header"
                ],
                "additionalProperties": false
              },
              "required": {
                "type": "boolean"
              },
              "description": {
                "type": "string"
              }
            },
            "required": [
              "type",
              "url"
            ],
            "additionalProperties": false
          }
        ]
      }
    },
    "triggers": {
      "description": "What starts the Agent's turns with no client connected, by trigger id (D74)",
      "type": "object",
      "propertyNames": {
        "type": "string",
        "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$",
        "description": "A trigger's id, such as `hourly-check`"
      },
      "additionalProperties": {
        "$ref": "#/$defs/Trigger"
      }
    },
    "selfWake": {
      "description": "Offer the agent schedule_wake: it books its session's next turn itself (D77)",
      "type": "boolean"
    }
  },
  "required": [
    "kind"
  ],
  "additionalProperties": false,
  "$defs": {
    "Trigger": {
      "type": "object",
      "properties": {
        "schedule": {
          "type": "string",
          "pattern": "^\\S+(\\s+\\S+){4}$"
        },
        "timezone": {
          "type": "string",
          "minLength": 1
        },
        "at": {
          "type": "string",
          "format": "date-time",
          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
        },
        "webhook": {
          "type": "string",
          "enum": [
            "standard-webhooks"
          ]
        },
        "session": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        },
        "prompt": {
          "type": "string",
          "minLength": 1
        }
      },
      "required": [
        "session",
        "prompt"
      ],
      "additionalProperties": false
    }
  }
}
