{
  "$schema": "https://json-schema.org/draft/2019-09/schema",
  "title": "CopilotApi",
  "description": "Describes all JSON-RPC methods exposed by the Copilot CLI server. SDK codegen tools consume this to produce typed client wrappers.",
  "server": {
    "ping": {
      "rpcMethod": "ping",
      "params": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string",
            "description": "Optional message to echo back"
          }
        },
        "additionalProperties": false
      },
      "result": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string",
            "description": "Echoed message (or default greeting)"
          },
          "timestamp": {
            "type": "number",
            "description": "Server timestamp in milliseconds"
          },
          "protocolVersion": {
            "type": "number",
            "description": "Server protocol version number"
          }
        },
        "required": [
          "message",
          "timestamp",
          "protocolVersion"
        ],
        "additionalProperties": false
      }
    },
    "models": {
      "list": {
        "rpcMethod": "models.list",
        "params": null,
        "result": {
          "type": "object",
          "properties": {
            "models": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "description": "Model identifier (e.g., \"claude-sonnet-4.5\")"
                  },
                  "name": {
                    "type": "string",
                    "description": "Display name"
                  },
                  "capabilities": {
                    "type": "object",
                    "properties": {
                      "supports": {
                        "type": "object",
                        "properties": {
                          "vision": {
                            "type": "boolean",
                            "description": "Whether this model supports vision/image input"
                          },
                          "reasoningEffort": {
                            "type": "boolean",
                            "description": "Whether this model supports reasoning effort configuration"
                          }
                        },
                        "additionalProperties": false,
                        "description": "Feature flags indicating what the model supports"
                      },
                      "limits": {
                        "type": "object",
                        "properties": {
                          "max_prompt_tokens": {
                            "type": "number",
                            "description": "Maximum number of prompt/input tokens"
                          },
                          "max_output_tokens": {
                            "type": "number",
                            "description": "Maximum number of output/completion tokens"
                          },
                          "max_context_window_tokens": {
                            "type": "number",
                            "description": "Maximum total context window size in tokens"
                          }
                        },
                        "required": [
                          "max_context_window_tokens"
                        ],
                        "additionalProperties": false,
                        "description": "Token limits for prompts, outputs, and context window"
                      }
                    },
                    "required": [
                      "supports",
                      "limits"
                    ],
                    "additionalProperties": false,
                    "description": "Model capabilities and limits"
                  },
                  "policy": {
                    "type": "object",
                    "properties": {
                      "state": {
                        "type": "string",
                        "description": "Current policy state for this model"
                      },
                      "terms": {
                        "type": "string",
                        "description": "Usage terms or conditions for this model"
                      }
                    },
                    "required": [
                      "state",
                      "terms"
                    ],
                    "additionalProperties": false,
                    "description": "Policy state (if applicable)"
                  },
                  "billing": {
                    "type": "object",
                    "properties": {
                      "multiplier": {
                        "type": "number",
                        "description": "Billing cost multiplier relative to the base rate"
                      }
                    },
                    "required": [
                      "multiplier"
                    ],
                    "additionalProperties": false,
                    "description": "Billing information"
                  },
                  "supportedReasoningEfforts": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Supported reasoning effort levels (only present if model supports reasoning effort)"
                  },
                  "defaultReasoningEffort": {
                    "type": "string",
                    "description": "Default reasoning effort level (only present if model supports reasoning effort)"
                  }
                },
                "required": [
                  "id",
                  "name",
                  "capabilities"
                ],
                "additionalProperties": false
              },
              "description": "List of available models with full metadata"
            }
          },
          "required": [
            "models"
          ],
          "additionalProperties": false
        }
      }
    },
    "tools": {
      "list": {
        "rpcMethod": "tools.list",
        "params": {
          "type": "object",
          "properties": {
            "model": {
              "type": "string",
              "description": "Optional model ID — when provided, the returned tool list reflects model-specific overrides"
            }
          },
          "additionalProperties": false
        },
        "result": {
          "type": "object",
          "properties": {
            "tools": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "Tool identifier (e.g., \"bash\", \"grep\", \"str_replace_editor\")"
                  },
                  "namespacedName": {
                    "type": "string",
                    "description": "Optional namespaced name for declarative filtering (e.g., \"playwright/navigate\" for MCP tools)"
                  },
                  "description": {
                    "type": "string",
                    "description": "Description of what the tool does"
                  },
                  "parameters": {
                    "type": "object",
                    "additionalProperties": {},
                    "description": "JSON Schema for the tool's input parameters"
                  },
                  "instructions": {
                    "type": "string",
                    "description": "Optional instructions for how to use this tool effectively"
                  }
                },
                "required": [
                  "name",
                  "description"
                ],
                "additionalProperties": false
              },
              "description": "List of available built-in tools with metadata"
            }
          },
          "required": [
            "tools"
          ],
          "additionalProperties": false
        }
      }
    },
    "account": {
      "getQuota": {
        "rpcMethod": "account.getQuota",
        "params": null,
        "result": {
          "type": "object",
          "properties": {
            "quotaSnapshots": {
              "type": "object",
              "additionalProperties": {
                "type": "object",
                "properties": {
                  "entitlementRequests": {
                    "type": "number",
                    "description": "Number of requests included in the entitlement"
                  },
                  "usedRequests": {
                    "type": "number",
                    "description": "Number of requests used so far this period"
                  },
                  "remainingPercentage": {
                    "type": "number",
                    "description": "Percentage of entitlement remaining"
                  },
                  "overage": {
                    "type": "number",
                    "description": "Number of overage requests made this period"
                  },
                  "overageAllowedWithExhaustedQuota": {
                    "type": "boolean",
                    "description": "Whether pay-per-request usage is allowed when quota is exhausted"
                  },
                  "resetDate": {
                    "type": "string",
                    "description": "Date when the quota resets (ISO 8601)"
                  }
                },
                "required": [
                  "entitlementRequests",
                  "usedRequests",
                  "remainingPercentage",
                  "overage",
                  "overageAllowedWithExhaustedQuota"
                ],
                "additionalProperties": false
              },
              "description": "Quota snapshots keyed by type (e.g., chat, completions, premium_interactions)"
            }
          },
          "required": [
            "quotaSnapshots"
          ],
          "additionalProperties": false
        }
      }
    }
  },
  "session": {
    "model": {
      "getCurrent": {
        "rpcMethod": "session.model.getCurrent",
        "params": {
          "type": "object",
          "properties": {
            "sessionId": {
              "type": "string",
              "description": "Target session identifier"
            }
          },
          "required": [
            "sessionId"
          ],
          "additionalProperties": false
        },
        "result": {
          "type": "object",
          "properties": {
            "modelId": {
              "type": "string",
              "description": "Currently active model identifier"
            }
          },
          "additionalProperties": false
        }
      },
      "switchTo": {
        "rpcMethod": "session.model.switchTo",
        "params": {
          "type": "object",
          "properties": {
            "sessionId": {
              "type": "string",
              "description": "Target session identifier"
            },
            "modelId": {
              "type": "string",
              "description": "Model identifier to switch to"
            },
            "reasoningEffort": {
              "type": "string",
              "description": "Reasoning effort level to use for the model"
            }
          },
          "required": [
            "sessionId",
            "modelId"
          ],
          "additionalProperties": false
        },
        "result": {
          "type": "object",
          "properties": {
            "modelId": {
              "type": "string",
              "description": "Currently active model identifier after the switch"
            }
          },
          "additionalProperties": false
        }
      }
    },
    "mode": {
      "get": {
        "rpcMethod": "session.mode.get",
        "params": {
          "type": "object",
          "properties": {
            "sessionId": {
              "type": "string",
              "description": "Target session identifier"
            }
          },
          "required": [
            "sessionId"
          ],
          "additionalProperties": false
        },
        "result": {
          "type": "object",
          "properties": {
            "mode": {
              "type": "string",
              "enum": [
                "interactive",
                "plan",
                "autopilot"
              ],
              "description": "The current agent mode."
            }
          },
          "required": [
            "mode"
          ],
          "additionalProperties": false
        }
      },
      "set": {
        "rpcMethod": "session.mode.set",
        "params": {
          "type": "object",
          "properties": {
            "sessionId": {
              "type": "string",
              "description": "Target session identifier"
            },
            "mode": {
              "type": "string",
              "enum": [
                "interactive",
                "plan",
                "autopilot"
              ],
              "description": "The mode to switch to. Valid values: \"interactive\", \"plan\", \"autopilot\"."
            }
          },
          "required": [
            "sessionId",
            "mode"
          ],
          "additionalProperties": false
        },
        "result": {
          "type": "object",
          "properties": {
            "mode": {
              "type": "string",
              "enum": [
                "interactive",
                "plan",
                "autopilot"
              ],
              "description": "The agent mode after switching."
            }
          },
          "required": [
            "mode"
          ],
          "additionalProperties": false
        }
      }
    },
    "plan": {
      "read": {
        "rpcMethod": "session.plan.read",
        "params": {
          "type": "object",
          "properties": {
            "sessionId": {
              "type": "string",
              "description": "Target session identifier"
            }
          },
          "required": [
            "sessionId"
          ],
          "additionalProperties": false
        },
        "result": {
          "type": "object",
          "properties": {
            "exists": {
              "type": "boolean",
              "description": "Whether the plan file exists in the workspace"
            },
            "content": {
              "type": [
                "string",
                "null"
              ],
              "description": "The content of the plan file, or null if it does not exist"
            },
            "path": {
              "type": [
                "string",
                "null"
              ],
              "description": "Absolute file path of the plan file, or null if workspace is not enabled"
            }
          },
          "required": [
            "exists",
            "content",
            "path"
          ],
          "additionalProperties": false
        }
      },
      "update": {
        "rpcMethod": "session.plan.update",
        "params": {
          "type": "object",
          "properties": {
            "sessionId": {
              "type": "string",
              "description": "Target session identifier"
            },
            "content": {
              "type": "string",
              "description": "The new content for the plan file"
            }
          },
          "required": [
            "sessionId",
            "content"
          ],
          "additionalProperties": false
        },
        "result": {
          "type": "object",
          "properties": {},
          "additionalProperties": false
        }
      },
      "delete": {
        "rpcMethod": "session.plan.delete",
        "params": {
          "type": "object",
          "properties": {
            "sessionId": {
              "type": "string",
              "description": "Target session identifier"
            }
          },
          "required": [
            "sessionId"
          ],
          "additionalProperties": false
        },
        "result": {
          "type": "object",
          "properties": {},
          "additionalProperties": false
        }
      }
    },
    "workspace": {
      "listFiles": {
        "rpcMethod": "session.workspace.listFiles",
        "params": {
          "type": "object",
          "properties": {
            "sessionId": {
              "type": "string",
              "description": "Target session identifier"
            }
          },
          "required": [
            "sessionId"
          ],
          "additionalProperties": false
        },
        "result": {
          "type": "object",
          "properties": {
            "files": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "description": "Relative file paths in the workspace files directory"
            }
          },
          "required": [
            "files"
          ],
          "additionalProperties": false
        }
      },
      "readFile": {
        "rpcMethod": "session.workspace.readFile",
        "params": {
          "type": "object",
          "properties": {
            "sessionId": {
              "type": "string",
              "description": "Target session identifier"
            },
            "path": {
              "type": "string",
              "description": "Relative path within the workspace files directory"
            }
          },
          "required": [
            "sessionId",
            "path"
          ],
          "additionalProperties": false
        },
        "result": {
          "type": "object",
          "properties": {
            "content": {
              "type": "string",
              "description": "File content as a UTF-8 string"
            }
          },
          "required": [
            "content"
          ],
          "additionalProperties": false
        }
      },
      "createFile": {
        "rpcMethod": "session.workspace.createFile",
        "params": {
          "type": "object",
          "properties": {
            "sessionId": {
              "type": "string",
              "description": "Target session identifier"
            },
            "path": {
              "type": "string",
              "description": "Relative path within the workspace files directory"
            },
            "content": {
              "type": "string",
              "description": "File content to write as a UTF-8 string"
            }
          },
          "required": [
            "sessionId",
            "path",
            "content"
          ],
          "additionalProperties": false
        },
        "result": {
          "type": "object",
          "properties": {},
          "additionalProperties": false
        }
      }
    },
    "fleet": {
      "start": {
        "rpcMethod": "session.fleet.start",
        "params": {
          "type": "object",
          "properties": {
            "sessionId": {
              "type": "string",
              "description": "Target session identifier"
            },
            "prompt": {
              "type": "string",
              "description": "Optional user prompt to combine with fleet instructions"
            }
          },
          "additionalProperties": false,
          "required": [
            "sessionId"
          ]
        },
        "result": {
          "type": "object",
          "properties": {
            "started": {
              "type": "boolean",
              "description": "Whether fleet mode was successfully activated"
            }
          },
          "required": [
            "started"
          ],
          "additionalProperties": false
        },
        "stability": "experimental"
      }
    },
    "agent": {
      "list": {
        "rpcMethod": "session.agent.list",
        "params": {
          "type": "object",
          "properties": {
            "sessionId": {
              "type": "string",
              "description": "Target session identifier"
            }
          },
          "required": [
            "sessionId"
          ],
          "additionalProperties": false
        },
        "result": {
          "type": "object",
          "properties": {
            "agents": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "Unique identifier of the custom agent"
                  },
                  "displayName": {
                    "type": "string",
                    "description": "Human-readable display name"
                  },
                  "description": {
                    "type": "string",
                    "description": "Description of the agent's purpose"
                  }
                },
                "required": [
                  "name",
                  "displayName",
                  "description"
                ],
                "additionalProperties": false
              },
              "description": "Available custom agents"
            }
          },
          "required": [
            "agents"
          ],
          "additionalProperties": false
        },
        "stability": "experimental"
      },
      "getCurrent": {
        "rpcMethod": "session.agent.getCurrent",
        "params": {
          "type": "object",
          "properties": {
            "sessionId": {
              "type": "string",
              "description": "Target session identifier"
            }
          },
          "required": [
            "sessionId"
          ],
          "additionalProperties": false
        },
        "result": {
          "type": "object",
          "properties": {
            "agent": {
              "anyOf": [
                {
                  "type": "object",
                  "properties": {
                    "name": {
                      "type": "string",
                      "description": "Unique identifier of the custom agent"
                    },
                    "displayName": {
                      "type": "string",
                      "description": "Human-readable display name"
                    },
                    "description": {
                      "type": "string",
                      "description": "Description of the agent's purpose"
                    }
                  },
                  "required": [
                    "name",
                    "displayName",
                    "description"
                  ],
                  "additionalProperties": false
                },
                {
                  "type": "null"
                }
              ],
              "description": "Currently selected custom agent, or null if using the default agent"
            }
          },
          "required": [
            "agent"
          ],
          "additionalProperties": false
        },
        "stability": "experimental"
      },
      "select": {
        "rpcMethod": "session.agent.select",
        "params": {
          "type": "object",
          "properties": {
            "sessionId": {
              "type": "string",
              "description": "Target session identifier"
            },
            "name": {
              "type": "string",
              "description": "Name of the custom agent to select"
            }
          },
          "required": [
            "sessionId",
            "name"
          ],
          "additionalProperties": false
        },
        "result": {
          "type": "object",
          "properties": {
            "agent": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string",
                  "description": "Unique identifier of the custom agent"
                },
                "displayName": {
                  "type": "string",
                  "description": "Human-readable display name"
                },
                "description": {
                  "type": "string",
                  "description": "Description of the agent's purpose"
                }
              },
              "required": [
                "name",
                "displayName",
                "description"
              ],
              "additionalProperties": false,
              "description": "The newly selected custom agent"
            }
          },
          "required": [
            "agent"
          ],
          "additionalProperties": false
        },
        "stability": "experimental"
      },
      "deselect": {
        "rpcMethod": "session.agent.deselect",
        "params": {
          "type": "object",
          "properties": {
            "sessionId": {
              "type": "string",
              "description": "Target session identifier"
            }
          },
          "required": [
            "sessionId"
          ],
          "additionalProperties": false
        },
        "result": {
          "type": "object",
          "properties": {},
          "additionalProperties": false
        },
        "stability": "experimental"
      }
    },
    "compaction": {
      "compact": {
        "rpcMethod": "session.compaction.compact",
        "params": {
          "type": "object",
          "properties": {
            "sessionId": {
              "type": "string",
              "description": "Target session identifier"
            }
          },
          "required": [
            "sessionId"
          ],
          "additionalProperties": false
        },
        "result": {
          "type": "object",
          "properties": {
            "success": {
              "type": "boolean",
              "description": "Whether compaction completed successfully"
            },
            "tokensRemoved": {
              "type": "number",
              "description": "Number of tokens freed by compaction"
            },
            "messagesRemoved": {
              "type": "number",
              "description": "Number of messages removed during compaction"
            }
          },
          "required": [
            "success",
            "tokensRemoved",
            "messagesRemoved"
          ],
          "additionalProperties": false
        },
        "stability": "experimental"
      }
    },
    "tools": {
      "handlePendingToolCall": {
        "rpcMethod": "session.tools.handlePendingToolCall",
        "params": {
          "type": "object",
          "properties": {
            "sessionId": {
              "type": "string",
              "description": "Target session identifier"
            },
            "requestId": {
              "type": "string"
            },
            "result": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "object",
                  "properties": {
                    "textResultForLlm": {
                      "type": "string"
                    },
                    "resultType": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    },
                    "toolTelemetry": {
                      "type": "object",
                      "additionalProperties": {}
                    }
                  },
                  "required": [
                    "textResultForLlm"
                  ],
                  "additionalProperties": false
                }
              ]
            },
            "error": {
              "type": "string"
            }
          },
          "required": [
            "sessionId",
            "requestId"
          ],
          "additionalProperties": false
        },
        "result": {
          "type": "object",
          "properties": {
            "success": {
              "type": "boolean",
              "description": "Whether the tool call result was handled successfully"
            }
          },
          "required": [
            "success"
          ],
          "additionalProperties": false
        }
      }
    },
    "permissions": {
      "handlePendingPermissionRequest": {
        "rpcMethod": "session.permissions.handlePendingPermissionRequest",
        "params": {
          "type": "object",
          "properties": {
            "sessionId": {
              "type": "string",
              "description": "Target session identifier"
            },
            "requestId": {
              "type": "string"
            },
            "result": {
              "anyOf": [
                {
                  "type": "object",
                  "properties": {
                    "kind": {
                      "type": "string",
                      "const": "approved"
                    }
                  },
                  "required": [
                    "kind"
                  ],
                  "additionalProperties": false
                },
                {
                  "type": "object",
                  "properties": {
                    "kind": {
                      "type": "string",
                      "const": "denied-by-rules"
                    },
                    "rules": {
                      "type": "array",
                      "items": {}
                    }
                  },
                  "required": [
                    "kind",
                    "rules"
                  ],
                  "additionalProperties": false
                },
                {
                  "type": "object",
                  "properties": {
                    "kind": {
                      "type": "string",
                      "const": "denied-no-approval-rule-and-could-not-request-from-user"
                    }
                  },
                  "required": [
                    "kind"
                  ],
                  "additionalProperties": false
                },
                {
                  "type": "object",
                  "properties": {
                    "kind": {
                      "type": "string",
                      "const": "denied-interactively-by-user"
                    },
                    "feedback": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "kind"
                  ],
                  "additionalProperties": false
                },
                {
                  "type": "object",
                  "properties": {
                    "kind": {
                      "type": "string",
                      "const": "denied-by-content-exclusion-policy"
                    },
                    "path": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "kind",
                    "path",
                    "message"
                  ],
                  "additionalProperties": false
                }
              ]
            }
          },
          "required": [
            "sessionId",
            "requestId",
            "result"
          ],
          "additionalProperties": false
        },
        "result": {
          "type": "object",
          "properties": {
            "success": {
              "type": "boolean",
              "description": "Whether the permission request was handled successfully"
            }
          },
          "required": [
            "success"
          ],
          "additionalProperties": false
        }
      }
    },
    "log": {
      "rpcMethod": "session.log",
      "params": {
        "type": "object",
        "properties": {
          "sessionId": {
            "type": "string",
            "description": "Target session identifier"
          },
          "message": {
            "type": "string",
            "description": "Human-readable message"
          },
          "level": {
            "type": "string",
            "enum": [
              "info",
              "warning",
              "error"
            ],
            "description": "Log severity level. Determines how the message is displayed in the timeline. Defaults to \"info\"."
          },
          "ephemeral": {
            "type": "boolean",
            "description": "When true, the message is transient and not persisted to the session event log on disk"
          }
        },
        "required": [
          "sessionId",
          "message"
        ],
        "additionalProperties": false
      },
      "result": {
        "type": "object",
        "properties": {
          "eventId": {
            "type": "string",
            "format": "uuid",
            "description": "The unique identifier of the emitted session event"
          }
        },
        "required": [
          "eventId"
        ],
        "additionalProperties": false
      }
    },
    "shell": {
      "exec": {
        "rpcMethod": "session.shell.exec",
        "params": {
          "type": "object",
          "properties": {
            "sessionId": {
              "type": "string",
              "description": "Target session identifier"
            },
            "command": {
              "type": "string",
              "description": "Shell command to execute"
            },
            "cwd": {
              "type": "string",
              "description": "Working directory (defaults to session working directory)"
            },
            "timeout": {
              "type": "number",
              "description": "Timeout in milliseconds (default: 30000)"
            }
          },
          "required": [
            "sessionId",
            "command"
          ],
          "additionalProperties": false
        },
        "result": {
          "type": "object",
          "properties": {
            "processId": {
              "type": "string",
              "description": "Unique identifier for tracking streamed output"
            }
          },
          "required": [
            "processId"
          ],
          "additionalProperties": false
        }
      },
      "kill": {
        "rpcMethod": "session.shell.kill",
        "params": {
          "type": "object",
          "properties": {
            "sessionId": {
              "type": "string",
              "description": "Target session identifier"
            },
            "processId": {
              "type": "string",
              "description": "Process identifier returned by shell.exec"
            },
            "signal": {
              "type": "string",
              "enum": [
                "SIGTERM",
                "SIGKILL",
                "SIGINT"
              ],
              "description": "Signal to send (default: SIGTERM)"
            }
          },
          "required": [
            "sessionId",
            "processId"
          ],
          "additionalProperties": false
        },
        "result": {
          "type": "object",
          "properties": {
            "killed": {
              "type": "boolean",
              "description": "Whether the signal was sent successfully"
            }
          },
          "required": [
            "killed"
          ],
          "additionalProperties": false
        }
      }
    }
  }
}
