{
  "protocol": 1,
  "transport": "WebSocket opened by the workspace owner A to the agent host B",
  "endpoint": "/api/ai-gateway/v1/workspaces/{workspaceId}/channel",
  "authentication": "Authorization: Bearer <B gateway token with workspaceAccess>; no query credentials or redirects",
  "ready": {
    "type": "ready",
    "protocol": 1
  },
  "call": {
    "type": "call",
    "protocol": 1,
    "id": "<stable UUID>",
    "workspaceId": "<A workspace UUID>",
    "sessionId": "<B session UUID>",
    "intention": "<original launch UUID>",
    "tool": "<tool name>",
    "args": "<tool arguments>"
  },
  "result": {
    "type": "result",
    "id": "<same call UUID>",
    "sessionId": "<same B session UUID>",
    "result": "<JSON tool result, or {error:{code,message}}>"
  },
  "constraints": [
    "Pin one local project identity and launch intention before connecting.",
    "Validate the workspace, session, intention, tool schema and permissions before every operation.",
    "Persist an executing receipt before an effect, and persist its result before acknowledging it. Reconnect with the same IDs; never repeat an uncertain effect.",
    "Do not use the agent’s project label as a local path. The B token cannot authorize A owner APIs."
  ],
  "limits": {
    "channels": 20,
    "channelsPerToken": 4,
    "inFlightCallsPerWorkspace": 4,
    "frameBytes": 2097152
  },
  "tools": [
    {
      "name": "workspace_info",
      "description": "Read the connected project identity, platform and workspace instructions. This project is on the connecting instance. Call this before working.",
      "inputSchema": {
        "type": "object",
        "properties": {},
        "required": [],
        "additionalProperties": false
      },
      "annotations": {
        "readOnlyHint": true,
        "destructiveHint": false,
        "openWorldHint": false
      }
    },
    {
      "name": "workspace_tools",
      "description": "Discover the application, browser, planning and other tools authorized for this conversation on the connecting instance. Returns their exact names and input schemas. Ordinary project sessions may have none.",
      "inputSchema": {
        "type": "object",
        "properties": {},
        "required": [],
        "additionalProperties": false
      },
      "annotations": {
        "readOnlyHint": true,
        "destructiveHint": false,
        "openWorldHint": false
      }
    },
    {
      "name": "workspace_tool",
      "description": "Invoke one tool returned by workspace_tools on the connecting instance. The server keeps the conversation identity and permissions; arguments cannot select another conversation or project.",
      "inputSchema": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "arguments": {
            "type": "object"
          }
        },
        "required": [
          "name",
          "arguments"
        ],
        "additionalProperties": false
      },
      "annotations": {
        "readOnlyHint": false,
        "destructiveHint": false,
        "openWorldHint": false
      }
    },
    {
      "name": "workspace_list",
      "description": "List one directory in the connected project. Paths are relative to its root; use the returned cursor for another page.",
      "inputSchema": {
        "type": "object",
        "properties": {
          "path": {
            "type": "string",
            "minLength": 1,
            "maxLength": 2048
          },
          "offset": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100000
          }
        },
        "required": [],
        "additionalProperties": false
      },
      "annotations": {
        "readOnlyHint": true,
        "destructiveHint": false,
        "openWorldHint": false
      }
    },
    {
      "name": "workspace_read",
      "description": "Read a UTF-8 project file and its SHA-256 revision. Byte offsets/limits page large files; no content is silently shortened. Read AGENTS.md and CLAUDE.md instructions before editing.",
      "inputSchema": {
        "type": "object",
        "properties": {
          "path": {
            "type": "string",
            "minLength": 1,
            "maxLength": 2048
          },
          "offset": {
            "type": "integer",
            "minimum": 0
          },
          "limit": {
            "type": "integer",
            "minimum": 1,
            "maximum": 131072
          }
        },
        "required": [
          "path"
        ],
        "additionalProperties": false
      },
      "annotations": {
        "readOnlyHint": true,
        "destructiveHint": false,
        "openWorldHint": false
      }
    },
    {
      "name": "workspace_image",
      "description": "View an image in the connected workspace, including attached images and generated screenshots. Returns image content; large images are scaled to fit the transport.",
      "inputSchema": {
        "type": "object",
        "properties": {
          "path": {
            "type": "string",
            "minLength": 1,
            "maxLength": 2048
          }
        },
        "required": [
          "path"
        ],
        "additionalProperties": false
      },
      "annotations": {
        "readOnlyHint": true,
        "destructiveHint": false,
        "openWorldHint": false
      }
    },
    {
      "name": "workspace_document",
      "description": "Read one page of a PDF in the connected workspace. Page numbers start at 1; returns the page count and extracted text.",
      "inputSchema": {
        "type": "object",
        "properties": {
          "path": {
            "type": "string",
            "minLength": 1,
            "maxLength": 2048
          },
          "page": {
            "type": "integer",
            "minimum": 1,
            "maximum": 10000
          }
        },
        "required": [
          "path"
        ],
        "additionalProperties": false
      },
      "annotations": {
        "readOnlyHint": true,
        "destructiveHint": false,
        "openWorldHint": false
      }
    },
    {
      "name": "workspace_write",
      "description": "Create or replace a UTF-8 project file on the connecting instance. Supply its last observed SHA-256, or null only when creating a new file. A concurrent change refuses the edit.",
      "inputSchema": {
        "type": "object",
        "properties": {
          "path": {
            "type": "string",
            "minLength": 1,
            "maxLength": 2048
          },
          "content": {
            "type": "string",
            "maxLength": 1048576
          },
          "expectedSha256": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^[a-f0-9]{64}$"
          }
        },
        "required": [
          "path",
          "content",
          "expectedSha256"
        ],
        "additionalProperties": false
      },
      "annotations": {
        "readOnlyHint": false,
        "destructiveHint": true,
        "openWorldHint": false
      }
    },
    {
      "name": "workspace_patch",
      "description": "Replace one exact text occurrence in a project file on the connecting instance. Supply the SHA-256 from workspace_read. Ambiguous or stale edits are refused.",
      "inputSchema": {
        "type": "object",
        "properties": {
          "path": {
            "type": "string",
            "minLength": 1,
            "maxLength": 2048
          },
          "oldText": {
            "type": "string",
            "maxLength": 1048576
          },
          "newText": {
            "type": "string",
            "maxLength": 1048576
          },
          "expectedSha256": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^[a-f0-9]{64}$"
          }
        },
        "required": [
          "path",
          "oldText",
          "newText",
          "expectedSha256"
        ],
        "additionalProperties": false
      },
      "annotations": {
        "readOnlyHint": false,
        "destructiveHint": true,
        "openWorldHint": false
      }
    },
    {
      "name": "workspace_delete",
      "description": "Delete one regular project file on the connecting instance, only if its SHA-256 still matches the observed revision.",
      "inputSchema": {
        "type": "object",
        "properties": {
          "path": {
            "type": "string",
            "minLength": 1,
            "maxLength": 2048
          },
          "expectedSha256": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^[a-f0-9]{64}$"
          }
        },
        "required": [
          "path",
          "expectedSha256"
        ],
        "additionalProperties": false
      },
      "annotations": {
        "readOnlyHint": false,
        "destructiveHint": true,
        "openWorldHint": false
      }
    },
    {
      "name": "workspace_exec",
      "description": "Run a shell command on the connecting instance in its project. Returns an owned command id; read output with workspace_poll. Never rerun an uncertain command without inspecting its effects.",
      "inputSchema": {
        "type": "object",
        "properties": {
          "command": {
            "type": "string",
            "minLength": 1,
            "maxLength": 32768
          },
          "cwd": {
            "type": "string",
            "minLength": 1,
            "maxLength": 2048
          },
          "timeoutMs": {
            "type": "integer",
            "minimum": 1000,
            "maximum": 600000
          }
        },
        "required": [
          "command"
        ],
        "additionalProperties": false
      },
      "annotations": {
        "readOnlyHint": false,
        "destructiveHint": false,
        "openWorldHint": true
      }
    },
    {
      "name": "workspace_poll",
      "description": "Read incremental output and completion status of one command started by this workspace session. This never starts another command.",
      "inputSchema": {
        "type": "object",
        "properties": {
          "commandId": {
            "type": "string",
            "pattern": "^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$"
          },
          "offset": {
            "type": "integer",
            "minimum": 0
          }
        },
        "required": [
          "commandId"
        ],
        "additionalProperties": false
      },
      "annotations": {
        "readOnlyHint": true,
        "destructiveHint": false,
        "openWorldHint": false
      }
    },
    {
      "name": "workspace_input",
      "description": "Send input to one running command on the connecting instance. Use only the command id returned by workspace_exec.",
      "inputSchema": {
        "type": "object",
        "properties": {
          "commandId": {
            "type": "string",
            "pattern": "^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$"
          },
          "text": {
            "type": "string",
            "maxLength": 16384
          }
        },
        "required": [
          "commandId",
          "text"
        ],
        "additionalProperties": false
      },
      "annotations": {
        "readOnlyHint": false,
        "destructiveHint": false,
        "openWorldHint": true
      }
    },
    {
      "name": "workspace_stop",
      "description": "Stop one command owned by this workspace session on the connecting instance.",
      "inputSchema": {
        "type": "object",
        "properties": {
          "commandId": {
            "type": "string",
            "pattern": "^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$"
          }
        },
        "required": [
          "commandId"
        ],
        "additionalProperties": false
      },
      "annotations": {
        "readOnlyHint": true,
        "destructiveHint": false,
        "openWorldHint": false
      }
    },
    {
      "name": "workspace_ask",
      "description": "Ask the owner a concise question in the current conversation and wait for an answer. Do not use this to bypass the selected permission mode.",
      "inputSchema": {
        "type": "object",
        "properties": {
          "question": {
            "type": "string",
            "minLength": 1,
            "maxLength": 4000
          }
        },
        "required": [
          "question"
        ],
        "additionalProperties": false
      },
      "annotations": {
        "readOnlyHint": false,
        "destructiveHint": false,
        "openWorldHint": false
      }
    }
  ]
}
