{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/omnara-com/json-schema/omnara-com-worktree-descriptor-schema.json",
  "title": "WorktreeDescriptor",
  "description": "Serialized worktree entity returned to API clients.",
  "x-generated": "2026-11-19",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/omnara-com-openapi.json#/components/schemas/WorktreeDescriptor",
  "properties": {
    "id": {
      "type": "string",
      "title": "Id",
      "description": "Unique worktree identifier"
    },
    "workspace_id": {
      "type": "string",
      "title": "Workspace Id",
      "description": "Parent workspace identifier"
    },
    "name": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Name",
      "description": "Worktree name (null for the main worktree)"
    },
    "is_main": {
      "type": "boolean",
      "title": "Is Main",
      "description": "Whether this is the main/default worktree for the workspace"
    },
    "path": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Path",
      "description": "Filesystem path for the worktree on the machine"
    },
    "worktree_type": {
      "anyOf": [
        {
          "type": "string",
          "enum": [
            "LOCAL",
            "REMOTE"
          ]
        },
        {
          "type": "null"
        }
      ],
      "title": "Worktree Type",
      "description": "Type of worktree: LOCAL (user machine) or REMOTE (sandbox)"
    },
    "user_machine_path": {
      "anyOf": [
        {
          "$ref": "#/$defs/shared__schemas__worktree__UserMachinePathDescriptor"
        },
        {
          "type": "null"
        }
      ],
      "description": "Machine+path link when worktree_type is LOCAL"
    },
    "managed_machine_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Managed Machine Id",
      "description": "Managed machine ID if worktree_type is REMOTE"
    },
    "last_heartbeat_at": {
      "anyOf": [
        {
          "type": "string",
          "format": "date-time"
        },
        {
          "type": "null"
        }
      ],
      "title": "Last Heartbeat At",
      "description": "Most recent liveness heartbeat received from the sandbox container (REMOTE only)."
    },
    "last_synced_checkpoint_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Last Synced Checkpoint Id",
      "description": "ID of the last checkpoint that was successfully synced to cloud storage. This may differ from current_checkpoint_id if a recent checkpoint failed to sync."
    },
    "checkpoint_restore_pending": {
      "type": "boolean",
      "title": "Checkpoint Restore Pending",
      "description": "Whether a checkpoint needs to be restored on next local session start",
      "default": false
    },
    "current_checkpoint_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Current Checkpoint Id",
      "description": "Identifier of the current checkpoint for this worktree"
    },
    "checkpoint_metadata": {
      "anyOf": [
        {
          "additionalProperties": true,
          "type": "object"
        },
        {
          "type": "null"
        }
      ],
      "title": "Checkpoint Metadata",
      "description": "Metadata associated with the current checkpoint (e.g., commit info)"
    },
    "created_at": {
      "type": "string",
      "format": "date-time",
      "title": "Created At",
      "description": "Timestamp when the worktree was created"
    },
    "updated_at": {
      "type": "string",
      "format": "date-time",
      "title": "Updated At",
      "description": "Timestamp when the worktree was last updated"
    }
  },
  "additionalProperties": false,
  "type": "object",
  "required": [
    "id",
    "workspace_id",
    "is_main",
    "created_at",
    "updated_at"
  ],
  "$defs": {
    "shared__schemas__worktree__UserMachinePathDescriptor": {
      "properties": {
        "id": {
          "type": "string",
          "title": "Id"
        },
        "machine_id": {
          "type": "string",
          "title": "Machine Id"
        },
        "local_path": {
          "type": "string",
          "title": "Local Path"
        }
      },
      "type": "object",
      "required": [
        "id",
        "machine_id",
        "local_path"
      ],
      "title": "UserMachinePathDescriptor",
      "description": "Machine path information associated with a LOCAL worktree."
    }
  }
}