{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://aiwg.io/cockpit/contribution/v1",
  "title": "AIWG Cockpit UI Contribution (#1591)",
  "description": "Declarative extension of the Cockpit UI: screens, actions, and event-hooks. Loaded from apps/cockpit/contrib/ and (future) installed AIWG extensions. An action INJECTS a command into an agentic session (focused, else a new one) — the Cockpit never runs the CLI itself; the agent in the session does. See adr-cockpit-session-control-not-cli-runner.md.",
  "type": "object",
  "required": ["id", "version", "contributes"],
  "additionalProperties": false,
  "properties": {
    "$schema": { "type": "string" },
    "id": { "type": "string", "pattern": "^[a-z0-9][a-z0-9._-]{0,63}$" },
    "version": { "type": "string" },
    "title": { "type": "string" },
    "contributes": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "actions": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["id", "title", "inject"],
            "additionalProperties": false,
            "properties": {
              "id": { "type": "string", "pattern": "^[a-z0-9][a-z0-9._-]{0,63}$" },
              "title": { "type": "string" },
              "icon": { "type": "string" },
              "group": { "type": "string" },
              "inject": {
                "type": "object",
                "required": ["command"],
                "additionalProperties": false,
                "properties": {
                  "command": { "type": "string", "pattern": "^/[a-zA-Z0-9][a-zA-Z0-9._-]*(\\s[^\\r\\n]*)?$", "description": "single slash command injected into an agentic session; newlines are forbidden" },
                  "target": { "type": "string", "enum": ["focused", "new"], "default": "focused", "description": "focused = inject into the attached session, else offer a new one; new = always a fresh session" },
                  "needs_args": { "type": "boolean", "description": "prompt for arguments before injecting" },
                  "args_hint": { "type": "string" }
                }
              }
            }
          }
        },
        "screens": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["id", "title", "source"],
            "additionalProperties": false,
            "properties": {
              "id": { "type": "string", "pattern": "^[a-z0-9][a-z0-9._-]{0,63}$" },
              "title": { "type": "string" },
              "source": { "type": "string", "pattern": "^(cockpit|sandbox)://", "description": "first-party cockpit:// route or third-party sandbox://<contribution-id>/ resource" }
            }
          }
        },
        "workflows": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["id", "title", "steps"],
            "additionalProperties": false,
            "properties": {
              "id": { "type": "string", "pattern": "^[a-z0-9][a-z0-9._-]{0,63}$" },
              "title": { "type": "string" },
              "description": { "type": "string" },
              "steps": {
                "type": "array",
                "minItems": 1,
                "items": {
                  "type": "object",
                  "required": ["action"],
                  "additionalProperties": false,
                  "properties": {
                    "action": { "type": "string", "pattern": "^[a-z0-9][a-z0-9._-]{0,63}$" },
                    "label": { "type": "string" }
                  }
                }
              }
            }
          }
        },
        "hooks": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["on", "action"],
            "additionalProperties": false,
            "properties": {
              "on": { "type": "string", "description": "event name, e.g. session.output, instance.state-changed" },
              "action": { "type": "string", "pattern": "^[a-z0-9][a-z0-9._-]{0,63}$", "description": "id of a contributed action to run" }
            }
          }
        }
      }
    }
  }
}
