{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://example.invalid/pi-crew.schema.json",
  "title": "pi-crew config",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "asyncByDefault": {
      "type": "boolean",
      "description": "Run team workflows in detached async mode by default when the tool call omits async."
    },
    "executeWorkers": {
      "type": "boolean",
      "description": "Allow real child Pi workers. Defaults to true; set false or use PI_CREW_EXECUTE_WORKERS=0/PI_TEAMS_EXECUTE_WORKERS=0 to force scaffold mode."
    },
    "notifierIntervalMs": {
      "type": "number",
      "minimum": 1000,
      "description": "Polling interval for async completion notifications."
    },
    "requireCleanWorktreeLeader": {
      "type": "boolean",
      "description": "Require a clean leader git repository before provisioning worktrees."
    },
    "autonomous": {
      "type": "object",
      "additionalProperties": false,
      "description": "Autonomous team routing policy injected into the agent system prompt.",
      "properties": {
        "profile": { "type": "string", "enum": ["manual", "suggested", "assisted", "aggressive"] },
        "enabled": { "type": "boolean" },
        "injectPolicy": { "type": "boolean" },
        "preferAsyncForLongTasks": { "type": "boolean" },
        "allowWorktreeSuggestion": { "type": "boolean" },
        "magicKeywords": {
          "type": "object",
          "additionalProperties": {
            "type": "array",
            "items": { "type": "string" }
          }
        }
      }
    },
    "limits": {
      "type": "object",
      "additionalProperties": false,
      "description": "Runtime safety limits for crew workers and policy decisions.",
      "properties": {
        "maxConcurrentWorkers": { "type": "integer", "minimum": 1 },
        "allowUnboundedConcurrency": { "type": "boolean" },
        "maxTaskDepth": { "type": "integer", "minimum": 1 },
        "maxChildrenPerTask": { "type": "integer", "minimum": 1 },
        "maxRunMinutes": { "type": "integer", "minimum": 1 },
        "maxRetriesPerTask": { "type": "integer", "minimum": 1 },
        "maxTasksPerRun": { "type": "integer", "minimum": 1 },
        "heartbeatStaleMs": { "type": "integer", "minimum": 1 }
      }
    },
    "runtime": {
      "type": "object",
      "additionalProperties": false,
      "description": "Crew runtime selection and live-agent behavior knobs.",
      "properties": {
        "mode": { "type": "string", "enum": ["auto", "scaffold", "child-process", "live-session"] },
        "preferLiveSession": { "type": "boolean" },
        "allowChildProcessFallback": { "type": "boolean" },
        "maxTurns": { "type": "integer", "minimum": 1 },
        "graceTurns": { "type": "integer", "minimum": 1 },
        "inheritContext": { "type": "boolean" },
        "promptMode": { "type": "string", "enum": ["replace", "append"] },
        "groupJoin": { "type": "string", "enum": ["off", "group", "smart"] },
        "groupJoinAckTimeoutMs": { "type": "integer", "minimum": 1 },
        "requirePlanApproval": { "type": "boolean" },
        "completionMutationGuard": { "type": "string", "enum": ["off", "warn", "fail"] },
        "effectivenessGuard": { "type": "string", "enum": ["off", "warn", "block", "fail"] }
      }
    },
    "control": {
      "type": "object",
      "additionalProperties": false,
      "description": "Agent control-plane settings for attention/stale activity detection.",
      "properties": {
        "enabled": { "type": "boolean" },
        "needsAttentionAfterMs": { "type": "integer", "minimum": 1 }
      }
    },
    "worktree": {
      "type": "object",
      "additionalProperties": false,
      "description": "Worktree setup hooks and dependency-linking options.",
      "properties": {
        "setupHook": { "type": "string", "minLength": 1 },
        "setupHookTimeoutMs": { "type": "integer", "minimum": 1 },
        "linkNodeModules": { "type": "boolean" }
      }
    },
    "agents": {
      "type": "object",
      "additionalProperties": false,
      "description": "Builtin agent override settings.",
      "properties": {
        "disableBuiltins": { "type": "boolean" },
        "overrides": {
          "type": "object",
          "additionalProperties": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "disabled": { "type": "boolean" },
              "model": { "oneOf": [{ "type": "string", "minLength": 1 }, { "const": false }] },
              "fallbackModels": { "oneOf": [{ "type": "array", "items": { "type": "string", "minLength": 1 } }, { "const": false }] },
              "thinking": { "oneOf": [{ "type": "string", "minLength": 1 }, { "const": false }] },
              "tools": { "type": "array", "items": { "type": "string", "minLength": 1 } }
            }
          }
        }
      }
    },
    "ui": {
      "type": "object",
      "additionalProperties": false,
      "description": "Pi UI settings for the crew widget, dashboard, and optional powerbar segments.",
      "properties": {
        "widgetPlacement": { "type": "string", "enum": ["aboveEditor", "belowEditor"] },
        "widgetMaxLines": { "type": "integer", "minimum": 1, "maximum": 50 },
        "powerbar": { "type": "boolean" },
        "dashboardPlacement": { "type": "string", "enum": ["center", "right"], "default": "right", "description": "Place /team-dashboard as a centered overlay or right-side panel." },
        "dashboardWidth": { "type": "integer", "minimum": 32, "maximum": 120, "default": 56 },
        "dashboardLiveRefreshMs": { "type": "integer", "minimum": 250, "maximum": 60000, "default": 1000 },
        "autoOpenDashboard": { "type": "boolean", "default": false, "description": "Opt in to automatically opening the live right sidebar for foreground runs when UI is available. Disabled by default because Pi overlays are modal in some terminals." },
        "autoOpenDashboardForForegroundRuns": { "type": "boolean", "default": true },
        "showModel": { "type": "boolean", "default": true, "description": "Show worker model attempts in dashboard agent rows." },
        "showTokens": { "type": "boolean", "description": "Show token usage in dashboard agent rows." },
        "showTools": { "type": "boolean", "description": "Show tool activity in dashboard agent rows." },
        "transcriptTailBytes": { "type": "integer", "minimum": 1024, "maximum": 52428800, "default": 262144, "description": "Maximum transcript bytes to parse by default; use viewer hotkey f to load full content." },
        "mascotStyle": { "type": "string", "enum": ["cat", "armin"] },
        "mascotEffect": { "type": "string", "enum": ["random", "none", "typewriter", "scanline", "rain", "fade", "crt", "glitch", "dissolve"] }
      }
    },
    "tools": {
      "type": "object",
      "additionalProperties": false,
      "description": "Public tool registration and foreground result behavior.",
      "properties": {
        "enableClaudeStyleAliases": { "type": "boolean", "default": true },
        "enableSteer": { "type": "boolean", "default": true },
        "terminateOnForeground": { "type": "boolean", "default": false, "description": "Opt in to returning terminate:true from foreground Agent/crew_agent calls after the child result is available." }
      }
    },
    "telemetry": {
      "type": "object",
      "additionalProperties": false,
      "description": "Pi-crew telemetry event controls.",
      "properties": {
        "enabled": { "type": "boolean", "default": true }
      }
    },
    "notifications": {
      "type": "object",
      "additionalProperties": false,
      "description": "Operator notification routing, quiet-hours, batching, and JSONL sink settings.",
      "properties": {
        "enabled": { "type": "boolean", "default": true },
        "severityFilter": { "type": "array", "items": { "type": "string", "enum": ["info", "warning", "error", "critical"] }, "default": ["warning", "error", "critical"] },
        "dedupWindowMs": { "type": "integer", "minimum": 1000, "default": 30000 },
        "batchWindowMs": { "type": "integer", "minimum": 0, "default": 0 },
        "quietHours": { "type": "string", "pattern": "^\\d{2}:\\d{2}-\\d{2}:\\d{2}$", "description": "Local HH:MM-HH:MM quiet-hours range; supports cross-day ranges such as 22:00-07:00." },
        "sinkRetentionDays": { "type": "integer", "minimum": 1, "maximum": 90, "default": 7 }
      }
    },
    "observability": {
      "type": "object",
      "additionalProperties": false,
      "description": "Metric registry, heartbeat watcher, and metric file sink settings.",
      "properties": {
        "enabled": { "type": "boolean", "default": true },
        "pollIntervalMs": { "type": "integer", "minimum": 1000, "maximum": 60000, "default": 5000 },
        "metricRetentionDays": { "type": "integer", "minimum": 1, "maximum": 365, "default": 7 }
      }
    },
    "reliability": {
      "type": "object",
      "additionalProperties": false,
      "description": "Opt-in reliability controls for retry, recovery, and deadletter handling.",
      "properties": {
        "autoRetry": { "type": "boolean", "default": false },
        "autoRecover": { "type": "boolean", "default": false },
        "deadletterThreshold": { "type": "integer", "minimum": 1, "default": 3 },
        "retryPolicy": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "maxAttempts": { "type": "integer", "minimum": 1, "maximum": 10, "default": 3 },
            "backoffMs": { "type": "integer", "minimum": 100, "maximum": 60000, "default": 1000 },
            "jitterRatio": { "type": "number", "minimum": 0, "maximum": 1, "default": 0.3 },
            "exponentialFactor": { "type": "number", "minimum": 1, "maximum": 5, "default": 2 },
            "retryableErrors": { "type": "array", "items": { "type": "string", "minLength": 1 } }
          }
        }
      }
    },
    "otlp": {
      "type": "object",
      "additionalProperties": false,
      "description": "Optional OpenTelemetry metric export. Disabled by default.",
      "properties": {
        "enabled": { "type": "boolean", "default": false },
        "endpoint": { "type": "string", "minLength": 1 },
        "headers": { "type": "object", "additionalProperties": { "type": "string" } },
        "intervalMs": { "type": "integer", "minimum": 5000, "default": 60000 }
      }
    }
  }
}
