{
  "$ref": "#/definitions/PortablePlaybook",
  "definitions": {
    "PortablePlaybook": {
      "type": "object",
      "properties": {
        "schemaVersion": {
          "type": "number",
          "const": 2
        },
        "definition": {
          "anyOf": [
            {
              "type": "object",
              "properties": {
                "schemaVersion": {
                  "type": "number",
                  "const": 1
                },
                "runtime": {
                  "type": "object",
                  "properties": {
                    "targets": {
                      "type": "array",
                      "items": {
                        "type": "string",
                        "enum": [
                          "gabriel",
                          "openai-sdk",
                          "openai-hosted",
                          "claude-managed",
                          "google-adk"
                        ]
                      },
                      "minItems": 1,
                      "maxItems": 5,
                      "default": [
                        "gabriel"
                      ]
                    },
                    "agent": {
                      "type": "object",
                      "properties": {
                        "instructions": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 12000
                        },
                        "models": {
                          "type": "object",
                          "additionalProperties": {
                            "type": "string",
                            "maxLength": 160,
                            "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$"
                          },
                          "propertyNames": {
                            "enum": [
                              "gabriel",
                              "openai-sdk",
                              "openai-hosted",
                              "claude-managed",
                              "google-adk"
                            ]
                          }
                        },
                        "role": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 160
                        }
                      },
                      "required": [
                        "instructions",
                        "models",
                        "role"
                      ],
                      "additionalProperties": false
                    },
                    "input": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "const": "object"
                        }
                      },
                      "required": [
                        "type"
                      ],
                      "additionalProperties": true
                    },
                    "output": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "const": "object"
                        }
                      },
                      "required": [
                        "type"
                      ],
                      "additionalProperties": true
                    },
                    "skills": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "maxLength": 160,
                            "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$"
                          },
                          "source": {
                            "anyOf": [
                              {
                                "type": "object",
                                "properties": {
                                  "kind": {
                                    "type": "string",
                                    "const": "github"
                                  },
                                  "owner": {
                                    "type": "string",
                                    "pattern": "^[a-zA-Z0-9-]{1,39}$"
                                  },
                                  "repository": {
                                    "type": "string",
                                    "pattern": "^[a-zA-Z0-9_][a-zA-Z0-9_.-]{0,99}$"
                                  },
                                  "commit": {
                                    "type": "string",
                                    "pattern": "^[0-9a-f]{40}$"
                                  },
                                  "path": {
                                    "type": "string",
                                    "maxLength": 200,
                                    "pattern": "^[a-zA-Z0-9_][a-zA-Z0-9_.-]*(?:\\/[a-zA-Z0-9_][a-zA-Z0-9_.-]*)*$"
                                  }
                                },
                                "required": [
                                  "kind",
                                  "owner",
                                  "repository",
                                  "commit",
                                  "path"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "kind": {
                                    "type": "string",
                                    "const": "npm"
                                  },
                                  "package": {
                                    "type": "object",
                                    "properties": {
                                      "registry": {
                                        "type": "string",
                                        "maxLength": 300,
                                        "format": "uri",
                                        "default": "https://registry.npmjs.org/"
                                      },
                                      "name": {
                                        "type": "string",
                                        "maxLength": 214,
                                        "pattern": "^@[a-z0-9][a-z0-9._-]*\\/[a-z0-9][a-z0-9._-]*$"
                                      },
                                      "version": {
                                        "type": "string",
                                        "maxLength": 100,
                                        "pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*)?$"
                                      },
                                      "integrity": {
                                        "type": "string",
                                        "pattern": "^sha512-[A-Za-z0-9+/]{86}==$"
                                      }
                                    },
                                    "required": [
                                      "name",
                                      "version",
                                      "integrity"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "path": {
                                    "type": "string",
                                    "maxLength": 200,
                                    "pattern": "^[a-zA-Z0-9_][a-zA-Z0-9_.-]*(?:\\/[a-zA-Z0-9_][a-zA-Z0-9_.-]*)*$"
                                  }
                                },
                                "required": [
                                  "kind",
                                  "package"
                                ],
                                "additionalProperties": false
                              }
                            ]
                          },
                          "digest": {
                            "type": "string",
                            "pattern": "^[a-f0-9]{64}$"
                          }
                        },
                        "required": [
                          "id",
                          "source",
                          "digest"
                        ],
                        "additionalProperties": false
                      },
                      "maxItems": 8,
                      "default": []
                    },
                    "scripts": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "maxLength": 160,
                            "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$"
                          },
                          "skill": {
                            "type": "string",
                            "maxLength": 160,
                            "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$"
                          },
                          "path": {
                            "type": "string",
                            "maxLength": 200,
                            "pattern": "^[a-zA-Z0-9_][a-zA-Z0-9_.-]*(?:\\/[a-zA-Z0-9_][a-zA-Z0-9_.-]*)*$"
                          },
                          "interpreter": {
                            "type": "string",
                            "enum": [
                              "node",
                              "python"
                            ]
                          },
                          "event": {
                            "type": "string",
                            "enum": [
                              "BeforeTask",
                              "AfterTask",
                              "tool"
                            ]
                          },
                          "input": {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "const": "object"
                              }
                            },
                            "required": [
                              "type"
                            ],
                            "additionalProperties": true
                          },
                          "output": {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "const": "object"
                              }
                            },
                            "required": [
                              "type"
                            ],
                            "additionalProperties": true
                          },
                          "timeoutSeconds": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 120,
                            "default": 30
                          }
                        },
                        "required": [
                          "id",
                          "path",
                          "interpreter",
                          "event",
                          "input",
                          "output"
                        ],
                        "additionalProperties": false
                      },
                      "maxItems": 20,
                      "default": []
                    },
                    "tools": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "maxLength": 160,
                            "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$"
                          },
                          "requirement": {
                            "type": "string",
                            "maxLength": 160,
                            "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$"
                          },
                          "operation": {
                            "type": "string",
                            "maxLength": 160,
                            "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$"
                          },
                          "effect": {
                            "type": "string",
                            "enum": [
                              "read",
                              "write",
                              "process"
                            ]
                          },
                          "input": {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "const": "object"
                              }
                            },
                            "required": [
                              "type"
                            ],
                            "additionalProperties": true
                          },
                          "output": {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "const": "object"
                              }
                            },
                            "required": [
                              "type"
                            ],
                            "additionalProperties": true
                          }
                        },
                        "required": [
                          "id",
                          "requirement",
                          "operation",
                          "effect",
                          "input",
                          "output"
                        ],
                        "additionalProperties": false
                      },
                      "maxItems": 30,
                      "default": []
                    },
                    "delegation": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "maxLength": 160,
                            "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$"
                          },
                          "playbook": {
                            "type": "string",
                            "maxLength": 160,
                            "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$"
                          },
                          "mode": {
                            "type": "string",
                            "enum": [
                              "tool",
                              "handoff"
                            ]
                          },
                          "fields": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "maxLength": 160,
                              "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$"
                            },
                            "maxItems": 30,
                            "default": []
                          }
                        },
                        "required": [
                          "id",
                          "playbook",
                          "mode"
                        ],
                        "additionalProperties": false
                      },
                      "maxItems": 20,
                      "default": []
                    },
                    "execution": {
                      "type": "object",
                      "properties": {
                        "profile": {
                          "type": "string",
                          "enum": [
                            "text",
                            "sandbox",
                            "realtime"
                          ]
                        },
                        "voice": {
                          "type": "string",
                          "enum": [
                            "native",
                            "transcribed"
                          ]
                        },
                        "retainTranscript": {
                          "type": "boolean",
                          "default": false
                        }
                      },
                      "required": [
                        "profile"
                      ],
                      "additionalProperties": false,
                      "default": {
                        "profile": "text"
                      }
                    },
                    "guardrails": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "phase": {
                            "type": "string",
                            "enum": [
                              "input",
                              "beforeTool",
                              "output"
                            ]
                          },
                          "tool": {
                            "type": "string",
                            "maxLength": 160,
                            "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$"
                          },
                          "schema": {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "const": "object"
                              }
                            },
                            "required": [
                              "type"
                            ],
                            "additionalProperties": true
                          }
                        },
                        "required": [
                          "phase",
                          "schema"
                        ],
                        "additionalProperties": false
                      },
                      "maxItems": 20,
                      "default": []
                    },
                    "approvals": {
                      "type": "object",
                      "properties": {
                        "protectedEffects": {
                          "type": "string",
                          "const": "rehearse-and-approve"
                        }
                      },
                      "required": [
                        "protectedEffects"
                      ],
                      "additionalProperties": false,
                      "default": {
                        "protectedEffects": "rehearse-and-approve"
                      }
                    },
                    "session": {
                      "type": "string",
                      "enum": [
                        "run",
                        "conversation"
                      ],
                      "default": "run"
                    },
                    "tracing": {
                      "type": "string",
                      "const": "metadata",
                      "default": "metadata"
                    }
                  },
                  "required": [
                    "agent",
                    "input",
                    "output"
                  ],
                  "additionalProperties": false
                },
                "key": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 160,
                  "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._:-]*$"
                },
                "name": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 160
                },
                "revision": {
                  "type": "integer",
                  "exclusiveMinimum": 0
                },
                "inputs": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "key": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 160,
                        "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._:-]*$"
                      },
                      "label": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 160
                      },
                      "required": {
                        "type": "boolean"
                      }
                    },
                    "required": [
                      "key",
                      "label",
                      "required"
                    ],
                    "additionalProperties": false
                  },
                  "maxItems": 50,
                  "default": []
                },
                "requirements": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 160,
                        "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._:-]*$"
                      },
                      "label": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 120
                      },
                      "context": {
                        "type": "string",
                        "enum": [
                          "personal",
                          "app"
                        ]
                      },
                      "providers": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 160,
                          "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._:-]*$"
                        },
                        "minItems": 1,
                        "maxItems": 100
                      },
                      "operations": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 160,
                          "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._:-]*$"
                        },
                        "minItems": 1,
                        "maxItems": 50
                      },
                      "optional": {
                        "type": "boolean",
                        "default": false
                      },
                      "appId": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 160,
                        "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._:-]*$"
                      }
                    },
                    "required": [
                      "id",
                      "label",
                      "context",
                      "providers",
                      "operations"
                    ],
                    "additionalProperties": false
                  },
                  "maxItems": 30,
                  "default": []
                },
                "outputFields": {
                  "type": "array",
                  "items": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 160,
                    "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._:-]*$"
                  },
                  "maxItems": 100,
                  "default": []
                },
                "kind": {
                  "type": "string",
                  "const": "structured"
                },
                "steps": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 160,
                        "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._:-]*$"
                      },
                      "title": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 160
                      },
                      "instruction": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 12000
                      },
                      "dependsOn": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 160,
                          "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._:-]*$"
                        },
                        "maxItems": 32,
                        "default": []
                      },
                      "type": {
                        "type": "string",
                        "enum": [
                          "reason",
                          "connector_operation",
                          "playbook",
                          "wait_until"
                        ]
                      },
                      "operation": {
                        "type": "object",
                        "properties": {
                          "requirementId": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 160,
                            "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._:-]*$"
                          },
                          "operationId": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 160,
                            "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._:-]*$"
                          },
                          "values": {
                            "type": "object",
                            "additionalProperties": {
                              "type": "string",
                              "maxLength": 1000
                            },
                            "default": {}
                          },
                          "effect": {
                            "type": "string",
                            "enum": [
                              "read",
                              "write",
                              "process"
                            ]
                          },
                          "safety": {
                            "type": "string",
                            "enum": [
                              "member_briefing",
                              "consented_meeting"
                            ]
                          },
                          "remoteId": {
                            "type": "string",
                            "maxLength": 1000
                          },
                          "expectedRevision": {
                            "type": "string",
                            "maxLength": 1000
                          },
                          "completion": {
                            "type": "object",
                            "properties": {
                              "operationId": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 160,
                                "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._:-]*$"
                              },
                              "values": {
                                "type": "object",
                                "additionalProperties": {
                                  "type": "string",
                                  "maxLength": 1000
                                },
                                "default": {}
                              },
                              "statePath": {
                                "type": "string",
                                "maxLength": 1000
                              },
                              "success": {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                },
                                "minItems": 1
                              },
                              "failure": {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                },
                                "default": []
                              },
                              "intervalSeconds": {
                                "type": "integer",
                                "minimum": 15,
                                "maximum": 3600,
                                "default": 60
                              },
                              "deadlineSeconds": {
                                "type": "integer",
                                "minimum": 30,
                                "maximum": 604800
                              }
                            },
                            "required": [
                              "operationId",
                              "statePath",
                              "success",
                              "deadlineSeconds"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "requirementId",
                          "operationId",
                          "effect"
                        ],
                        "additionalProperties": false
                      },
                      "playbookKey": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 160,
                        "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._:-]*$"
                      },
                      "inputMappings": {
                        "type": "object",
                        "additionalProperties": {
                          "type": "string",
                          "maxLength": 1000
                        },
                        "default": {}
                      },
                      "outputFields": {
                        "type": "object",
                        "additionalProperties": {
                          "type": "string",
                          "maxLength": 1000
                        },
                        "default": {}
                      },
                      "waitUntil": {
                        "type": "string",
                        "maxLength": 1000
                      },
                      "requiresApproval": {
                        "type": "boolean",
                        "default": false
                      },
                      "publication": {
                        "type": "object",
                        "properties": {
                          "target": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 160,
                            "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._:-]*$"
                          },
                          "fields": {
                            "type": "object",
                            "additionalProperties": {
                              "type": "string",
                              "maxLength": 1000
                            }
                          },
                          "recordId": {
                            "type": "string",
                            "maxLength": 1000
                          },
                          "expectedUpdatedAt": {
                            "type": "string",
                            "maxLength": 1000
                          }
                        },
                        "required": [
                          "target",
                          "fields"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "required": [
                      "id",
                      "title",
                      "instruction",
                      "type"
                    ],
                    "additionalProperties": false
                  },
                  "minItems": 1,
                  "maxItems": 32
                }
              },
              "required": [
                "schemaVersion",
                "key",
                "name",
                "revision",
                "kind",
                "steps",
                "runtime"
              ],
              "additionalProperties": false
            },
            {
              "type": "object",
              "properties": {
                "schemaVersion": {
                  "type": "number",
                  "const": 1
                },
                "runtime": {
                  "type": "object",
                  "properties": {
                    "targets": {
                      "type": "array",
                      "items": {
                        "type": "string",
                        "enum": [
                          "gabriel",
                          "openai-sdk",
                          "openai-hosted",
                          "claude-managed",
                          "google-adk"
                        ]
                      },
                      "minItems": 1,
                      "maxItems": 5,
                      "default": [
                        "gabriel"
                      ]
                    },
                    "agent": {
                      "type": "object",
                      "properties": {
                        "instructions": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 12000
                        },
                        "models": {
                          "type": "object",
                          "additionalProperties": {
                            "type": "string",
                            "maxLength": 160,
                            "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$"
                          },
                          "propertyNames": {
                            "enum": [
                              "gabriel",
                              "openai-sdk",
                              "openai-hosted",
                              "claude-managed",
                              "google-adk"
                            ]
                          }
                        },
                        "role": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 160
                        }
                      },
                      "required": [
                        "instructions",
                        "models",
                        "role"
                      ],
                      "additionalProperties": false
                    },
                    "input": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "const": "object"
                        }
                      },
                      "required": [
                        "type"
                      ],
                      "additionalProperties": true
                    },
                    "output": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "const": "object"
                        }
                      },
                      "required": [
                        "type"
                      ],
                      "additionalProperties": true
                    },
                    "skills": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "maxLength": 160,
                            "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$"
                          },
                          "source": {
                            "anyOf": [
                              {
                                "type": "object",
                                "properties": {
                                  "kind": {
                                    "type": "string",
                                    "const": "github"
                                  },
                                  "owner": {
                                    "type": "string",
                                    "pattern": "^[a-zA-Z0-9-]{1,39}$"
                                  },
                                  "repository": {
                                    "type": "string",
                                    "pattern": "^[a-zA-Z0-9_][a-zA-Z0-9_.-]{0,99}$"
                                  },
                                  "commit": {
                                    "type": "string",
                                    "pattern": "^[0-9a-f]{40}$"
                                  },
                                  "path": {
                                    "type": "string",
                                    "maxLength": 200,
                                    "pattern": "^[a-zA-Z0-9_][a-zA-Z0-9_.-]*(?:\\/[a-zA-Z0-9_][a-zA-Z0-9_.-]*)*$"
                                  }
                                },
                                "required": [
                                  "kind",
                                  "owner",
                                  "repository",
                                  "commit",
                                  "path"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "object",
                                "properties": {
                                  "kind": {
                                    "type": "string",
                                    "const": "npm"
                                  },
                                  "package": {
                                    "type": "object",
                                    "properties": {
                                      "registry": {
                                        "type": "string",
                                        "maxLength": 300,
                                        "format": "uri",
                                        "default": "https://registry.npmjs.org/"
                                      },
                                      "name": {
                                        "type": "string",
                                        "maxLength": 214,
                                        "pattern": "^@[a-z0-9][a-z0-9._-]*\\/[a-z0-9][a-z0-9._-]*$"
                                      },
                                      "version": {
                                        "type": "string",
                                        "maxLength": 100,
                                        "pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*)?$"
                                      },
                                      "integrity": {
                                        "type": "string",
                                        "pattern": "^sha512-[A-Za-z0-9+/]{86}==$"
                                      }
                                    },
                                    "required": [
                                      "name",
                                      "version",
                                      "integrity"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "path": {
                                    "type": "string",
                                    "maxLength": 200,
                                    "pattern": "^[a-zA-Z0-9_][a-zA-Z0-9_.-]*(?:\\/[a-zA-Z0-9_][a-zA-Z0-9_.-]*)*$"
                                  }
                                },
                                "required": [
                                  "kind",
                                  "package"
                                ],
                                "additionalProperties": false
                              }
                            ]
                          },
                          "digest": {
                            "type": "string",
                            "pattern": "^[a-f0-9]{64}$"
                          }
                        },
                        "required": [
                          "id",
                          "source",
                          "digest"
                        ],
                        "additionalProperties": false
                      },
                      "maxItems": 8,
                      "default": []
                    },
                    "scripts": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "maxLength": 160,
                            "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$"
                          },
                          "skill": {
                            "type": "string",
                            "maxLength": 160,
                            "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$"
                          },
                          "path": {
                            "type": "string",
                            "maxLength": 200,
                            "pattern": "^[a-zA-Z0-9_][a-zA-Z0-9_.-]*(?:\\/[a-zA-Z0-9_][a-zA-Z0-9_.-]*)*$"
                          },
                          "interpreter": {
                            "type": "string",
                            "enum": [
                              "node",
                              "python"
                            ]
                          },
                          "event": {
                            "type": "string",
                            "enum": [
                              "BeforeTask",
                              "AfterTask",
                              "tool"
                            ]
                          },
                          "input": {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "const": "object"
                              }
                            },
                            "required": [
                              "type"
                            ],
                            "additionalProperties": true
                          },
                          "output": {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "const": "object"
                              }
                            },
                            "required": [
                              "type"
                            ],
                            "additionalProperties": true
                          },
                          "timeoutSeconds": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 120,
                            "default": 30
                          }
                        },
                        "required": [
                          "id",
                          "path",
                          "interpreter",
                          "event",
                          "input",
                          "output"
                        ],
                        "additionalProperties": false
                      },
                      "maxItems": 20,
                      "default": []
                    },
                    "tools": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "maxLength": 160,
                            "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$"
                          },
                          "requirement": {
                            "type": "string",
                            "maxLength": 160,
                            "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$"
                          },
                          "operation": {
                            "type": "string",
                            "maxLength": 160,
                            "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$"
                          },
                          "effect": {
                            "type": "string",
                            "enum": [
                              "read",
                              "write",
                              "process"
                            ]
                          },
                          "input": {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "const": "object"
                              }
                            },
                            "required": [
                              "type"
                            ],
                            "additionalProperties": true
                          },
                          "output": {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "const": "object"
                              }
                            },
                            "required": [
                              "type"
                            ],
                            "additionalProperties": true
                          }
                        },
                        "required": [
                          "id",
                          "requirement",
                          "operation",
                          "effect",
                          "input",
                          "output"
                        ],
                        "additionalProperties": false
                      },
                      "maxItems": 30,
                      "default": []
                    },
                    "delegation": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "maxLength": 160,
                            "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$"
                          },
                          "playbook": {
                            "type": "string",
                            "maxLength": 160,
                            "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$"
                          },
                          "mode": {
                            "type": "string",
                            "enum": [
                              "tool",
                              "handoff"
                            ]
                          },
                          "fields": {
                            "type": "array",
                            "items": {
                              "type": "string",
                              "maxLength": 160,
                              "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$"
                            },
                            "maxItems": 30,
                            "default": []
                          }
                        },
                        "required": [
                          "id",
                          "playbook",
                          "mode"
                        ],
                        "additionalProperties": false
                      },
                      "maxItems": 20,
                      "default": []
                    },
                    "execution": {
                      "type": "object",
                      "properties": {
                        "profile": {
                          "type": "string",
                          "enum": [
                            "text",
                            "sandbox",
                            "realtime"
                          ]
                        },
                        "voice": {
                          "type": "string",
                          "enum": [
                            "native",
                            "transcribed"
                          ]
                        },
                        "retainTranscript": {
                          "type": "boolean",
                          "default": false
                        }
                      },
                      "required": [
                        "profile"
                      ],
                      "additionalProperties": false,
                      "default": {
                        "profile": "text"
                      }
                    },
                    "guardrails": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "phase": {
                            "type": "string",
                            "enum": [
                              "input",
                              "beforeTool",
                              "output"
                            ]
                          },
                          "tool": {
                            "type": "string",
                            "maxLength": 160,
                            "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]*$"
                          },
                          "schema": {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "const": "object"
                              }
                            },
                            "required": [
                              "type"
                            ],
                            "additionalProperties": true
                          }
                        },
                        "required": [
                          "phase",
                          "schema"
                        ],
                        "additionalProperties": false
                      },
                      "maxItems": 20,
                      "default": []
                    },
                    "approvals": {
                      "type": "object",
                      "properties": {
                        "protectedEffects": {
                          "type": "string",
                          "const": "rehearse-and-approve"
                        }
                      },
                      "required": [
                        "protectedEffects"
                      ],
                      "additionalProperties": false,
                      "default": {
                        "protectedEffects": "rehearse-and-approve"
                      }
                    },
                    "session": {
                      "type": "string",
                      "enum": [
                        "run",
                        "conversation"
                      ],
                      "default": "run"
                    },
                    "tracing": {
                      "type": "string",
                      "const": "metadata",
                      "default": "metadata"
                    }
                  },
                  "required": [
                    "agent",
                    "input",
                    "output"
                  ],
                  "additionalProperties": false
                },
                "key": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 160,
                  "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._:-]*$"
                },
                "name": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 160
                },
                "revision": {
                  "type": "integer",
                  "exclusiveMinimum": 0
                },
                "inputs": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "key": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 160,
                        "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._:-]*$"
                      },
                      "label": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 160
                      },
                      "required": {
                        "type": "boolean"
                      }
                    },
                    "required": [
                      "key",
                      "label",
                      "required"
                    ],
                    "additionalProperties": false
                  },
                  "maxItems": 50,
                  "default": []
                },
                "requirements": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 160,
                        "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._:-]*$"
                      },
                      "label": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 120
                      },
                      "context": {
                        "type": "string",
                        "enum": [
                          "personal",
                          "app"
                        ]
                      },
                      "providers": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 160,
                          "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._:-]*$"
                        },
                        "minItems": 1,
                        "maxItems": 100
                      },
                      "operations": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 160,
                          "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._:-]*$"
                        },
                        "minItems": 1,
                        "maxItems": 50
                      },
                      "optional": {
                        "type": "boolean",
                        "default": false
                      },
                      "appId": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 160,
                        "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._:-]*$"
                      }
                    },
                    "required": [
                      "id",
                      "label",
                      "context",
                      "providers",
                      "operations"
                    ],
                    "additionalProperties": false
                  },
                  "maxItems": 30,
                  "default": []
                },
                "outputFields": {
                  "type": "array",
                  "items": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 160,
                    "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._:-]*$"
                  },
                  "maxItems": 100,
                  "default": []
                },
                "kind": {
                  "type": "string",
                  "const": "goal"
                },
                "objective": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 12000
                },
                "completionCriteria": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 12000
                },
                "allowedSkills": {
                  "type": "array",
                  "maxItems": 0
                },
                "limits": {
                  "type": "object",
                  "properties": {
                    "maxDepth": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 3,
                      "default": 3
                    },
                    "maxAgents": {
                      "type": "integer",
                      "minimum": 1,
                      "maximum": 12,
                      "default": 12
                    },
                    "maxTasks": {
                      "type": "integer",
                      "minimum": 1,
                      "maximum": 32,
                      "default": 32
                    },
                    "maxConcurrentAgents": {
                      "type": "integer",
                      "minimum": 1,
                      "maximum": 4,
                      "default": 4
                    },
                    "activeMinutes": {
                      "type": "integer",
                      "minimum": 1,
                      "maximum": 60,
                      "default": 60
                    },
                    "elapsedDays": {
                      "type": "integer",
                      "minimum": 1,
                      "maximum": 7,
                      "default": 7
                    }
                  },
                  "additionalProperties": false,
                  "default": {}
                },
                "allowedPlaybooks": {
                  "type": "array",
                  "items": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 160,
                    "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._:-]*$"
                  },
                  "maxItems": 30,
                  "default": []
                }
              },
              "required": [
                "schemaVersion",
                "key",
                "name",
                "revision",
                "kind",
                "objective",
                "completionCriteria",
                "runtime"
              ],
              "additionalProperties": false
            }
          ]
        },
        "skill": {
          "type": "string",
          "maxLength": 71,
          "pattern": "^skills\\/[a-z0-9]+(?:-[a-z0-9]+)*$"
        }
      },
      "required": [
        "schemaVersion",
        "definition"
      ],
      "additionalProperties": false
    }
  },
  "$schema": "http://json-schema.org/draft-07/schema#"
}
