{
  "$id": "https://raw.githubusercontent.com/MeterApp/skillhook/main/schema/skillhook.schema.json",
  "title": "skillhook.json",
  "description": "Server configuration for skillhook (https://github.com/MeterApp/skillhook).",
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "$schema": {
      "type": "string"
    },
    "port": {
      "default": 8787,
      "type": "integer",
      "minimum": 1,
      "maximum": 65535
    },
    "host": {
      "default": "127.0.0.1",
      "type": "string"
    },
    "public_url": {
      "type": "string",
      "format": "uri"
    },
    "trust_proxy": {
      "default": true,
      "type": "boolean"
    },
    "defaults": {
      "default": {},
      "type": "object",
      "properties": {
        "runner": {
          "default": "claude",
          "type": "string",
          "enum": [
            "claude",
            "codex",
            "shell"
          ]
        },
        "model": {
          "type": "string"
        },
        "effort": {
          "type": "string"
        },
        "timeout_seconds": {
          "default": 900,
          "type": "integer",
          "exclusiveMinimum": 0,
          "maximum": 9007199254740991
        },
        "cwd": {
          "type": "string"
        },
        "fallback": {
          "type": "object",
          "properties": {
            "runners": {
              "minItems": 1,
              "type": "array",
              "items": {
                "anyOf": [
                  {
                    "type": "string",
                    "enum": [
                      "claude",
                      "codex",
                      "shell"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "runner": {
                        "type": "string",
                        "enum": [
                          "claude",
                          "codex",
                          "shell"
                        ]
                      },
                      "model": {
                        "type": "string"
                      },
                      "effort": {
                        "type": "string"
                      },
                      "account": {
                        "type": "string",
                        "minLength": 1
                      }
                    },
                    "required": [
                      "runner"
                    ],
                    "additionalProperties": false
                  }
                ]
              }
            },
            "on": {
              "type": "array",
              "items": {
                "type": "string",
                "enum": [
                  "not_ready",
                  "auth",
                  "usage_limit",
                  "rate_limit",
                  "crash"
                ]
              }
            }
          },
          "required": [
            "runners"
          ],
          "additionalProperties": false
        },
        "accounts": {
          "type": "object",
          "properties": {
            "claude": {
              "anyOf": [
                {
                  "type": "string",
                  "pattern": "^[a-z0-9][a-z0-9_-]{0,39}$"
                },
                {
                  "minItems": 1,
                  "maxItems": 20,
                  "type": "array",
                  "items": {
                    "type": "string",
                    "pattern": "^[a-z0-9][a-z0-9_-]{0,39}$"
                  }
                }
              ]
            },
            "codex": {
              "anyOf": [
                {
                  "type": "string",
                  "pattern": "^[a-z0-9][a-z0-9_-]{0,39}$"
                },
                {
                  "minItems": 1,
                  "maxItems": 20,
                  "type": "array",
                  "items": {
                    "type": "string",
                    "pattern": "^[a-z0-9][a-z0-9_-]{0,39}$"
                  }
                }
              ]
            }
          },
          "additionalProperties": false
        }
      },
      "additionalProperties": false
    },
    "accounts": {
      "default": {},
      "type": "object",
      "propertyNames": {
        "type": "string",
        "pattern": "^[a-z0-9][a-z0-9_-]{0,39}$"
      },
      "additionalProperties": {
        "type": "object",
        "properties": {
          "runner": {
            "type": "string",
            "enum": [
              "claude",
              "codex"
            ]
          },
          "kind": {
            "default": "login",
            "type": "string",
            "enum": [
              "login",
              "token",
              "api_key"
            ]
          },
          "dir": {
            "type": "string",
            "minLength": 1
          },
          "share_from": {
            "type": "string",
            "minLength": 1
          },
          "secret_env": {
            "type": "string",
            "pattern": "^[A-Z_][A-Z0-9_]*$"
          },
          "label": {
            "type": "string",
            "maxLength": 200
          },
          "disabled": {
            "default": false,
            "type": "boolean"
          }
        },
        "required": [
          "runner"
        ],
        "additionalProperties": false
      }
    },
    "account_policy": {
      "default": {},
      "type": "object",
      "properties": {
        "strategy": {
          "default": "balanced",
          "type": "string",
          "enum": [
            "ordered",
            "balanced"
          ]
        },
        "usage_avoid_percent": {
          "default": 90,
          "type": "integer",
          "minimum": 1,
          "maximum": 100
        },
        "failover": {
          "default": true,
          "type": "boolean"
        },
        "limited_cooldown_minutes": {
          "default": 60,
          "type": "integer",
          "minimum": 1,
          "maximum": 10080
        },
        "usage_poll_minutes": {
          "default": 0,
          "type": "integer",
          "minimum": 0,
          "maximum": 1440
        },
        "usage_warn_percent": {
          "default": 85,
          "type": "integer",
          "minimum": 1,
          "maximum": 100
        },
        "notify": {
          "default": "none",
          "type": "string",
          "enum": [
            "none",
            "desktop"
          ]
        }
      },
      "additionalProperties": false
    },
    "concurrency": {
      "default": 2,
      "type": "integer",
      "minimum": 1,
      "maximum": 9007199254740991
    },
    "max_body_bytes": {
      "default": 1048576,
      "type": "integer",
      "exclusiveMinimum": 0,
      "maximum": 9007199254740991
    },
    "max_wait_seconds": {
      "default": 120,
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991
    },
    "rate_limit": {
      "default": {},
      "type": "object",
      "properties": {
        "requests_per_minute": {
          "default": 120,
          "type": "integer",
          "exclusiveMinimum": 0,
          "maximum": 9007199254740991
        },
        "auth_failures_per_minute": {
          "default": 10,
          "type": "integer",
          "exclusiveMinimum": 0,
          "maximum": 9007199254740991
        }
      },
      "additionalProperties": false
    },
    "runners": {
      "default": {},
      "type": "object",
      "properties": {
        "claude": {
          "default": {},
          "type": "object",
          "properties": {
            "command": {
              "default": "claude",
              "anyOf": [
                {
                  "type": "string",
                  "minLength": 1
                },
                {
                  "minItems": 1,
                  "type": "array",
                  "items": {
                    "type": "string",
                    "minLength": 1
                  }
                }
              ]
            },
            "permission_mode": {
              "default": "bypassPermissions",
              "type": "string",
              "enum": [
                "acceptEdits",
                "auto",
                "bypassPermissions",
                "manual",
                "dontAsk",
                "plan"
              ]
            },
            "args": {
              "default": [],
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "auth": {
              "default": "auto",
              "type": "string",
              "enum": [
                "auto",
                "api_key",
                "login"
              ]
            }
          },
          "additionalProperties": false
        },
        "codex": {
          "default": {},
          "type": "object",
          "properties": {
            "command": {
              "default": "codex",
              "anyOf": [
                {
                  "type": "string",
                  "minLength": 1
                },
                {
                  "minItems": 1,
                  "type": "array",
                  "items": {
                    "type": "string",
                    "minLength": 1
                  }
                }
              ]
            },
            "sandbox": {
              "default": "workspace-write",
              "type": "string",
              "enum": [
                "read-only",
                "workspace-write",
                "danger-full-access"
              ]
            },
            "network_access": {
              "default": true,
              "type": "boolean"
            },
            "approval_policy": {
              "default": "never",
              "type": "string"
            },
            "args": {
              "default": [],
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          },
          "additionalProperties": false
        }
      },
      "additionalProperties": false
    },
    "jobs": {
      "default": {},
      "type": "object",
      "properties": {
        "max_jobs": {
          "default": 1000,
          "type": "integer",
          "exclusiveMinimum": 0,
          "maximum": 9007199254740991
        },
        "dedupe_window_seconds": {
          "default": 86400,
          "type": "integer",
          "exclusiveMinimum": 0,
          "maximum": 9007199254740991
        },
        "dedupe_in_flight": {
          "default": true,
          "type": "boolean"
        },
        "inline_payload_max_bytes": {
          "default": 200000,
          "type": "integer",
          "exclusiveMinimum": 0,
          "maximum": 9007199254740991
        }
      },
      "additionalProperties": false
    },
    "deliveries": {
      "default": {},
      "type": "object",
      "properties": {
        "max": {
          "default": 2000,
          "type": "integer",
          "exclusiveMinimum": 0,
          "maximum": 9007199254740991
        },
        "store_bodies": {
          "default": true,
          "type": "boolean"
        },
        "body_max_bytes": {
          "default": 65536,
          "type": "integer",
          "exclusiveMinimum": 0,
          "maximum": 9007199254740991
        }
      },
      "additionalProperties": false
    },
    "health": {
      "default": {},
      "type": "object",
      "properties": {
        "cache_seconds": {
          "default": 60,
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "probe_timeout_seconds": {
          "default": 20,
          "type": "integer",
          "exclusiveMinimum": 0,
          "maximum": 9007199254740991
        },
        "readiness_cache_seconds": {
          "default": 60,
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        }
      },
      "additionalProperties": false
    },
    "env_passthrough": {
      "default": [],
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "projects": {
      "default": [],
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1
      }
    },
    "project_refresh": {
      "default": [],
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1
      }
    },
    "cloud": {
      "default": {},
      "type": "object",
      "properties": {
        "enabled": {
          "default": false,
          "type": "boolean"
        },
        "url": {
          "default": "https://skillhook.dev",
          "type": "string",
          "format": "uri"
        },
        "machine_id": {
          "type": "string",
          "maxLength": 200
        },
        "mode": {
          "default": "observe",
          "type": "string",
          "enum": [
            "observe",
            "control"
          ]
        },
        "allow_commands": {
          "default": [],
          "type": "array",
          "items": {
            "type": "string",
            "maxLength": 100
          }
        },
        "deny_commands": {
          "default": [],
          "type": "array",
          "items": {
            "type": "string",
            "maxLength": 100
          }
        },
        "upload_payloads": {
          "default": true,
          "type": "boolean"
        },
        "public_env": {
          "default": [],
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "upload_artifacts": {
          "default": true,
          "type": "boolean"
        },
        "ingress": {
          "default": true,
          "type": "boolean"
        },
        "upload_definitions": {
          "default": true,
          "type": "boolean"
        },
        "managed_skills": {
          "default": false,
          "type": "boolean"
        },
        "require_fresh_definitions": {
          "default": false,
          "type": "boolean"
        },
        "snapshot_interval_seconds": {
          "default": 60,
          "type": "integer",
          "minimum": 10,
          "maximum": 86400
        },
        "health_interval_seconds": {
          "default": 600,
          "type": "integer",
          "minimum": 60,
          "maximum": 86400
        },
        "outbox_max_events": {
          "default": 5000,
          "type": "integer",
          "minimum": 100,
          "maximum": 100000
        }
      },
      "additionalProperties": false
    },
    "log_level": {
      "default": "info",
      "type": "string",
      "enum": [
        "debug",
        "info",
        "warn",
        "error"
      ]
    },
    "update_check": {
      "default": true,
      "type": "boolean"
    },
    "auto_update": {
      "default": true,
      "type": "boolean"
    }
  },
  "additionalProperties": false
}
